29 $plugins->attachHook('render_wikiformat_pre', 'cortado_process($text);'); |
29 $plugins->attachHook('render_wikiformat_pre', 'cortado_process($text);'); |
30 |
30 |
31 function cortado_process(&$text) |
31 function cortado_process(&$text) |
32 { |
32 { |
33 global $db, $session, $paths, $template, $plugins; // Common objects |
33 global $db, $session, $paths, $template, $plugins; // Common objects |
|
34 global $lang; |
34 |
35 |
35 $match_count = preg_match_all('#\[\[:' . preg_quote($paths->nslist['File']) . '([^]]+?\.ogg)(\|video)?\]\]#is', $text, $matches); |
36 $match_count = preg_match_all('#\[\[:' . preg_quote($paths->nslist['File']) . '([^]]+?\.ogg)(\|video)?\]\]#is', $text, $matches); |
36 if ( $match_count < 1 ) |
37 if ( $match_count < 1 ) |
37 // No media tags - might as well just abort here. |
38 // No media tags - might as well just abort here. |
38 return false; |
39 return false; |
55 <param name="keepAspect" value="true"/> |
56 <param name="keepAspect" value="true"/> |
56 <param name="video" value="<!-- BEGIN video -->true<!-- BEGINELSE video -->false<!-- END video -->"/> |
57 <param name="video" value="<!-- BEGIN video -->true<!-- BEGINELSE video -->false<!-- END video -->"/> |
57 <param name="audio" value="true"/> |
58 <param name="audio" value="true"/> |
58 <param name="bufferSize" value="200"/> |
59 <param name="bufferSize" value="200"/> |
59 <param name="autoPlay" value="false"/> |
60 <param name="autoPlay" value="false"/> |
|
61 {lang:cortado_err_no_java} |
60 </applet> |
62 </applet> |
61 <div class="cortado-controls"> |
63 <div class="cortado-controls"> |
62 <a href="#" onclick="document.applets['cortado_{UUID}'].doPlay(); return false;">Play</a> | |
64 <a href="#" onclick="document.applets['cortado_{UUID}'].doPlay(); return false;">{lang:cortado_btn_play}</a> | |
63 <a href="#" onclick="document.applets['cortado_{UUID}'].doPause(); return false;">Pause</a> | |
65 <a href="#" onclick="document.applets['cortado_{UUID}'].doPause(); return false;">{lang:cortado_btn_pause}</a> | |
64 <a href="#" onclick="document.applets['cortado_{UUID}'].doStop(); return false;">Stop</a> |
66 <a href="#" onclick="document.applets['cortado_{UUID}'].doStop(); return false;">{lang:cortado_btn_stop}</a> |
65 </div> |
67 </div> |
66 </div> |
68 </div> |
67 |
69 |
68 <!-- End embedded player: {FILENAME} --> |
70 <!-- End embedded player: {FILENAME} --> |
69 |
71 |
85 // Verify permissions |
87 // Verify permissions |
86 $acl = $session->fetch_page_acl($filename, 'File'); |
88 $acl = $session->fetch_page_acl($filename, 'File'); |
87 if ( !$acl->get_permissions('read') ) |
89 if ( !$acl->get_permissions('read') ) |
88 { |
90 { |
89 // No permission to read this file |
91 // No permission to read this file |
90 $text = str_replace_once($entire_match, "<span class=\"cortado-error\">Access denied to file {$filename} - not embedding media player applet.</span>", $text); |
92 $text = str_replace_once($entire_match, "<span class=\"cortado-error\">" . $lang->get('cortado_err_access_denied', array('filename' => $filename)) . "</span>", $text); |
91 continue; |
93 continue; |
92 } |
94 } |
93 |
95 |
94 // We should be good, set up the parser |
96 // We should be good, set up the parser |
95 $parser->assign_vars(array( |
97 $parser->assign_vars(array( |
108 $applet_parsed = $parser->run(); |
110 $applet_parsed = $parser->run(); |
109 |
111 |
110 $text = str_replace_once($entire_match, $applet_parsed, $text); |
112 $text = str_replace_once($entire_match, $applet_parsed, $text); |
111 } |
113 } |
112 } |
114 } |
|
115 |
|
116 /**!language** |
|
117 |
|
118 The following text up to the closing comment tag is JSON language data. |
|
119 It is not PHP code but your editor or IDE may highlight it as such. This |
|
120 data is imported when the plugin is loaded for the first time; it provides |
|
121 the strings displayed by this plugin's interface. |
|
122 |
|
123 You should copy and paste this block when you create your own plugins so |
|
124 that these comments and the basic structure of the language data is |
|
125 preserved. All language data is in the same format as the Enano core |
|
126 language files in the /language/* directories. See the Enano Localization |
|
127 Guide and Enano API Documentation for further information on the format of |
|
128 language files. |
|
129 |
|
130 The exception in plugin language file format is that multiple languages |
|
131 may be specified in the language block. This should be done by way of making |
|
132 the top-level elements each a JSON language object, with elements named |
|
133 according to the ISO-639-1 language they are representing. The path should be: |
|
134 |
|
135 root => language ID => categories array, strings object => category \ |
|
136 objects => strings |
|
137 |
|
138 All text leading up to first curly brace is stripped by the parser; using |
|
139 a code tag makes jEdit and other editors do automatic indentation and |
|
140 syntax highlighting on the language data. The use of the code tag is not |
|
141 necessary; it is only included as a tool for development. |
|
142 |
|
143 <code> |
|
144 { |
|
145 // english |
|
146 eng: { |
|
147 categories: [ 'meta', 'cortado' ], |
|
148 strings: { |
|
149 meta: { |
|
150 cortado: 'Cortado plugin' |
|
151 }, |
|
152 cortado: { |
|
153 err_no_java: 'Your browser doesn\'t have a Java plugin. You can get Java from <a href="http://java.com/">java.com</a>.', |
|
154 err_access_denied: 'Access to file "%filename%" is denied, so the media player can\'t be loaded here.', |
|
155 btn_play: 'Play', |
|
156 btn_pause: 'Pause', |
|
157 btn_stop: 'Stop' |
|
158 } |
|
159 } |
|
160 } |
|
161 } |
|
162 </code> |
|
163 |
|
164 **!*/ |