Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <? |
3 | 3 | /** |
4 | | - * Global functions and constants for Metavid MediaWiki. |
5 | | - * |
| 4 | + * Global functions and constants for Metavid MediaWiki. |
| 5 | + * |
6 | 6 | * All Metavid Wiki code is Released Under the GPL2 |
7 | 7 | * for more info visit http://metavid.org/wiki/Code |
8 | | - * |
| 8 | + * |
9 | 9 | */ |
10 | 10 | define( 'MV_VERSION', '1.0r47961' ); |
11 | 11 | |
— | — | @@ -13,9 +13,9 @@ |
14 | 14 | /** |
15 | 15 | * Switch on Metavid MediaWiki. This function must be called in LocalSettings.php |
16 | 16 | * its separated out to allow for overwriting semantic wiki hooks and functions |
17 | | - * if semantic wiki is enabled for this wiki. |
| 17 | + * if semantic wiki is enabled for this wiki. |
18 | 18 | */ |
19 | | - |
| 19 | + |
20 | 20 | // add language: |
21 | 21 | $wgExtensionMessagesFiles['MetavidWiki'] = $mvgIP . '/languages/MV_Messages.php'; |
22 | 22 | require_once( $mvgIP . '/languages/MV_Language.php' ); |
— | — | @@ -29,150 +29,150 @@ |
30 | 30 | $wgSpecialPages['Search'] = 'MV_SpecialSearch'; |
31 | 31 | $wgAutoloadClasses['MV_SpecialSearch'] = dirname( __FILE__ ) . '/specials/MV_SpecialMediaSearch.php'; |
32 | 32 | |
| 33 | +/**********************************************/ |
| 34 | +/***** register autoLoad javascript Classes: */ |
| 35 | +/**********************************************/ |
| 36 | +$mv_jspath = 'extensions/MetavidWiki/skins/'; |
| 37 | + |
| 38 | +$wgJSAutoloadClasses['mv_allpages'] = $mv_jspath . 'mv_allpages.js'; |
| 39 | +$wgJSAutoloadClasses['mv_search'] = $mv_jspath . 'mv_search.js'; |
| 40 | +$wgJSAutoloadClasses['mv_stream'] = $mv_jspath . 'mv_stream.js'; |
| 41 | + |
| 42 | + |
33 | 43 | function enableMetavid() { |
34 | 44 | global $wgExtensionFunctions, $smwgNamespacesWithSemanticLinks; |
35 | 45 | $wgExtensionFunctions[] = 'mvSetupExtension'; |
36 | | - // add in metavid namespace to semanticLinks array: |
| 46 | + // add in metavid namespace to semanticLinks array: |
37 | 47 | $smwgNamespacesWithSemanticLinks[MV_NS_STREAM] = true; |
38 | 48 | $smwgNamespacesWithSemanticLinks[MV_NS_STREAM_TALK] = false; |
39 | 49 | $smwgNamespacesWithSemanticLinks[MV_NS_SEQUENCE] = true; |
40 | 50 | $smwgNamespacesWithSemanticLinks[MV_NS_SEQUENCE_TALK] = false; |
41 | 51 | $smwgNamespacesWithSemanticLinks[MV_NS_MVD] = true; |
42 | 52 | $smwgNamespacesWithSemanticLinks[MV_NS_MVD_TALK] = false; |
43 | | - |
| 53 | + |
44 | 54 | return true; |
45 | 55 | } |
46 | 56 | function mvSetupExtension() { |
47 | 57 | global $mvVersion, $mvNamespace, $mvgIP, $wgHooks, $wgExtensionCredits, $mvMasterStore, |
48 | 58 | $wgParser, $mvArticlePath, $mvgScriptPath, $wgServer, $wgExtensionFunctions, $markerList,$wgVersion, |
49 | | - $wgAjaxExportList, $mvEnableAutoComplete, $mvEnableJSMVDrewrite, |
| 59 | + $wgAjaxExportList, $mvEnableAutoComplete, $mvEnableJSMVDrewrite, |
50 | 60 | $wgAutoloadClasses, $wgSpecialPages, $wgMediaHandlers, $wgJSAutoloadClasses, |
51 | 61 | $wgAPIModules; |
52 | | - |
53 | 62 | |
| 63 | + |
54 | 64 | mvfInitMessages(); |
55 | | - //add the ALL page header |
| 65 | + //add the ALL page header |
56 | 66 | mvfAutoAllPageHeader(); |
57 | | - |
| 67 | + |
58 | 68 | /******************************** |
59 | | - * Ajax Hooks |
| 69 | + * Ajax Hooks |
60 | 70 | *********************************/ |
61 | 71 | $wgAjaxExportList[] = 'mv_auto_complete_all'; |
62 | 72 | $wgAjaxExportList[] = 'mv_auto_complete_person'; |
63 | | - |
64 | | - |
| 73 | + |
| 74 | + |
65 | 75 | $wgAjaxExportList[] = 'mv_auto_complete_stream_name'; |
66 | 76 | $wgAjaxExportList[] = 'mv_helpers_auto_complete'; |
67 | | - |
| 77 | + |
68 | 78 | $wgAjaxExportList[] = 'mv_disp_mvd'; |
69 | | - |
| 79 | + |
70 | 80 | $wgAjaxExportList[] = 'mv_add_disp'; |
71 | 81 | $wgAjaxExportList[] = 'mv_remove_mvd'; |
72 | 82 | $wgAjaxExportList[] = 'mv_disp_remove_mvd'; |
73 | | - |
| 83 | + |
74 | 84 | $wgAjaxExportList[] = 'mv_edit_disp'; |
75 | 85 | $wgAjaxExportList[] = 'mv_edit_preview'; |
76 | | - $wgAjaxExportList[] = 'mv_edit_submit'; |
77 | | - |
| 86 | + $wgAjaxExportList[] = 'mv_edit_submit'; |
| 87 | + |
78 | 88 | //$wgAjaxExportList[] = 'mv_history_disp'; |
79 | 89 | $wgAjaxExportList[] = 'mv_adjust_disp'; |
80 | 90 | $wgAjaxExportList[] = 'mv_adjust_submit'; |
81 | | - |
| 91 | + |
82 | 92 | //sequence interface exported functions |
83 | 93 | $wgAjaxExportList[] = 'mv_edit_sequence_submit'; |
84 | 94 | $wgAjaxExportList[] = 'mv_seqtool_disp'; |
85 | 95 | $wgAjaxExportList[] = 'mv_seqtool_clipboard'; |
86 | | - |
87 | | - |
88 | | - // search interface exported functions: |
| 96 | + |
| 97 | + |
| 98 | + // search interface exported functions: |
89 | 99 | $wgAjaxExportList[] = 'mv_expand_wt'; |
90 | 100 | $wgAjaxExportList[] = 'mv_pl_wt'; |
91 | 101 | $wgAjaxExportList[] = 'mv_submit_remove'; |
92 | 102 | $wgAjaxExportList[] = 'mv_tool_disp'; |
93 | 103 | $wgAjaxExportList[] = 'mv_date_obj'; |
94 | | - |
95 | | - |
96 | | - // media serving |
| 104 | + |
| 105 | + |
| 106 | + // media serving |
97 | 107 | $wgAjaxExportList[] = 'mv_frame_server'; |
98 | | - |
99 | | - /**********************************************/ |
100 | | - /***** register autoLoad javascript Classes: */ |
101 | | - /**********************************************/ |
102 | | - $mv_jspath = $mvgIP . '/skins/'; |
103 | | - |
104 | | - $wgJSAutoloadClasses['mv_allpages'] = $mv_jspath . 'mv_allpages.js'; |
105 | | - $wgJSAutoloadClasses['mv_search'] = $mv_jspath . 'mv_search.js'; |
106 | | - $wgJSAutoloadClasses['mv_stream'] = $mv_jspath . 'mv_stream.js'; |
107 | 108 | |
108 | | - |
109 | | - |
| 109 | + |
110 | 110 | /**********************************************/ |
111 | 111 | /***** register autoLoad Classes: *****/ |
112 | 112 | /**********************************************/ |
113 | | - // setup autoload classes: |
| 113 | + // setup autoload classes: |
114 | 114 | $wgAutoloadClasses['MV_Overlay'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_Overlay.php'; |
115 | 115 | $wgAutoloadClasses['MV_Component'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_Component.php'; |
116 | | - |
| 116 | + |
117 | 117 | $wgAutoloadClasses['MV_MetavidInterface'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_MetavidInterface.php'; |
118 | | - |
| 118 | + |
119 | 119 | $wgAutoloadClasses['MV_SequencePlayer'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_SequencePlayer.php'; |
120 | 120 | $wgAutoloadClasses['MV_SequenceTools'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_SequenceTools.php'; |
121 | 121 | $wgAutoloadClasses['MV_EditSequencePage'] = dirname( __FILE__ ) . '/MV_EditSequencePage.php'; |
122 | | - |
| 122 | + |
123 | 123 | $wgAutoloadClasses['MV_VideoPlayer'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_VideoPlayer.php'; |
124 | 124 | $wgAutoloadClasses['MV_Tools'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_Tools.php'; |
125 | 125 | $wgAutoloadClasses['MV_Navigator'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_Navigator.php'; |
126 | 126 | $wgAutoloadClasses['MV_EditPageAjax'] = dirname( __FILE__ ) . '/MV_MetavidInterface/MV_EditPageAjax.php'; |
127 | | - |
| 127 | + |
128 | 128 | $wgAutoloadClasses['MV_CategoryPage'] = dirname( __FILE__ ) . '/articlepages/MV_CategoryPage.php'; |
129 | 129 | $wgAutoloadClasses['MV_SequencePage'] = dirname( __FILE__ ) . '/articlepages/MV_SequencePage.php'; |
130 | 130 | $wgAutoloadClasses['MV_StreamPage'] = dirname( __FILE__ ) . '/articlepages/MV_StreamPage.php'; |
131 | 131 | $wgAutoloadClasses['MV_EditDataPage'] = $wgAutoloadClasses['MV_DataPage'] = dirname( __FILE__ ) . '/articlepages/MV_DataPage.php'; |
132 | 132 | $wgAutoloadClasses['MV_EditStreamPage'] = dirname( __FILE__ ) . '/MV_EditStreamPage.php'; |
133 | | - |
134 | | - |
| 133 | + |
| 134 | + |
135 | 135 | $wgAutoloadClasses['MV_Title'] = dirname( __FILE__ ) . '/MV_Title.php'; |
136 | 136 | $wgAutoloadClasses['MV_Index'] = dirname( __FILE__ ) . '/MV_Index.php'; |
137 | 137 | $wgAutoloadClasses['MV_ImageGallery'] = dirname( __FILE__ ) . '/MV_ImageGallery.php'; |
138 | 138 | $wgAutoloadClasses['MV_Image'] = dirname( __FILE__ ) . '/MV_Image.php'; |
139 | 139 | $wgAutoloadClasses['MV_Stream'] = dirname( __FILE__ ) . '/MV_Stream.php'; |
140 | | - $wgAutoloadClasses['MV_StreamFile'] = dirname( __FILE__ ) . '/MV_StreamFile.php'; |
141 | | - |
| 140 | + $wgAutoloadClasses['MV_StreamFile'] = dirname( __FILE__ ) . '/MV_StreamFile.php'; |
| 141 | + |
142 | 142 | $wgAutoloadClasses['MV_StreamImage'] = dirname( __FILE__ ) . '/MV_StreamImage.php'; |
143 | 143 | $wgAutoloadClasses['MV_ParserCache'] = dirname( __FILE__ ) . '/MV_ParserCache.php'; |
144 | 144 | $wgAutoloadClasses['MV_MagicWords'] = dirname( __FILE__ ) . '/MV_MagicWords.php'; |
145 | | - |
| 145 | + |
146 | 146 | /**********************************************/ |
147 | 147 | /***** register special pages hooks *****/ |
148 | 148 | /**********************************************/ |
149 | 149 | $wgAutoloadClasses['MV_SpecialCRUDStream'] = dirname( __FILE__ ) . '/specials/MV_SpecialCRUDStream.php'; |
150 | 150 | $wgSpecialPages['Mv_Add_Stream'] = array( 'MV_SpecialCRUDStream' ); |
151 | | - |
| 151 | + |
152 | 152 | $wgAutoloadClasses['MV_SpecialListStreams'] = dirname( __FILE__ ) . '/specials/MV_SpecialListStreams.php'; |
153 | | - $wgSpecialPages['Mv_List_Streams'] = array( 'MV_SpecialListStreams' ); |
154 | | - |
| 153 | + $wgSpecialPages['Mv_List_Streams'] = array( 'MV_SpecialListStreams' ); |
| 154 | + |
155 | 155 | /* special export views */ |
156 | 156 | $wgAutoloadClasses['MV_SpecialExport'] = dirname( __FILE__ ) . '/specials/MV_SpecialExport.php'; |
157 | | - |
| 157 | + |
158 | 158 | $wgAutoloadClasses['MvVideoFeed'] = dirname( __FILE__ ) . '/specials/MV_SpecialExport.php'; |
159 | 159 | $wgAutoloadClasses['MvExportStream'] = dirname( __FILE__ ) . '/specials/MV_SpecialExport.php'; |
160 | 160 | $wgAutoloadClasses['MvExportSequence'] = dirname( __FILE__ ) . '/specials/MV_SpecialExport.php'; |
161 | 161 | $wgAutoloadClasses['MvExportSearch'] = dirname( __FILE__ ) . '/specials/MV_SpecialExport.php'; |
162 | 162 | $wgAutoloadClasses['MvExportAsk'] = dirname( __FILE__ ) . '/specials/MV_SpecialExport.php'; |
163 | | - |
| 163 | + |
164 | 164 | $wgSpecialPages['MvVideoFeed'] = array( 'MvVideoFeed' ); |
165 | 165 | $wgSpecialPages['MvExportStream'] = array( 'MvExportStream' ); |
166 | 166 | $wgSpecialPages['MvExportSequence'] = array( 'MvExportSequence' ); |
167 | 167 | $wgSpecialPages['MvExportSearch'] = array( 'MvExportSearch' ); |
168 | 168 | $wgSpecialPages['MvExportAsk'] = array( 'MvExportAsk' ); |
169 | | - |
| 169 | + |
170 | 170 | $wgAutoloadClasses['MV_SpecialMediaSearch'] = dirname( __FILE__ ) . '/specials/MV_SpecialMediaSearch.php'; |
171 | 171 | $wgSpecialPages['Mv_List_Streams'] = array( 'MV_SpecialListStreams' ); |
172 | | - |
| 172 | + |
173 | 173 | $wgAutoloadClasses['MediaSearch'] = dirname( __FILE__ ) . '/specials/MV_SpecialMediaSearch.php'; |
174 | 174 | $wgSpecialPages['MediaSearch'] = array( 'MediaSearch' ); |
175 | 175 | $wgSpecialPages['MV_SpecialSearch'] = array( 'MV_SpecialSearch' ); |
176 | | - |
| 176 | + |
177 | 177 | $wgAutoloadClasses['MVAdmin'] = dirname( __FILE__ ) . '/specials/MV_SpecialMVAdmin.php'; |
178 | 178 | $wgSpecialPages['MVAdmin'] = array( 'MVAdmin' ); |
179 | 179 | // require_once( dirname(__FILE__) . '/specials/MV_SpecialCRUDStream.php'); |
— | — | @@ -188,20 +188,20 @@ |
189 | 189 | // $wgHooks['ArticleSave'][] = 'mvSaveHook'; |
190 | 190 | $wgHooks['ArticleSaveComplete'][] = 'mvSaveHook'; |
191 | 191 | $wgHooks['ArticleDelete'][] = 'mvDeleteHook'; |
192 | | - $wgHooks['ArticleFromTitle'][] = 'mvDoMvPage'; |
| 192 | + $wgHooks['ArticleFromTitle'][] = 'mvDoMvPage'; |
193 | 193 | $wgHooks['TitleMoveComplete'][] = 'mvMoveHook'; |
194 | 194 | $wgHooks['LinkEnd'][] = 'mvLinkEnd'; |
195 | 195 | $wgHooks['LinkBegin'][] = 'mvLinkBegin'; |
196 | | - |
| 196 | + |
197 | 197 | $wgHooks['MakeGlobalVariablesScript'][] = 'mvGlobalJSVariables'; |
198 | | - |
| 198 | + |
199 | 199 | //our move function handles calling SMW hook |
200 | 200 | foreach($wgHooks['TitleMoveComplete'] as $k=>$f){ |
201 | 201 | if($f=='smwfMoveHook'){ |
202 | 202 | unset($wgHooks['TitleMoveComplete'][$k]); |
203 | 203 | } |
204 | 204 | } |
205 | | - |
| 205 | + |
206 | 206 | if (version_compare($wgVersion,'1.13','>')) { |
207 | 207 | $wgHooks['SkinTemplateToolboxEnd'][] = 'mvAddToolBoxLinks'; // introduced only in 1.13 |
208 | 208 | } else { |
— | — | @@ -209,7 +209,7 @@ |
210 | 210 | } |
211 | 211 | |
212 | 212 | |
213 | | - // @@NOTE this hook is not avaliable by default in medaiwiki |
| 213 | + // @@NOTE this hook is not avaliable by default in medaiwiki |
214 | 214 | // to use this hook you should add this function to moveTo() |
215 | 215 | // right after the local check in Title.php: |
216 | 216 | /* |
— | — | @@ -219,24 +219,24 @@ |
220 | 220 | } |
221 | 221 | */ |
222 | 222 | $wgHooks['TitleisValidMove'][] = 'mvisValidMoveOperation'; |
223 | | - |
| 223 | + |
224 | 224 | $wgHooks['ParserAfterTidy'][] = 'mvParserAfterTidy'; |
225 | | - |
| 225 | + |
226 | 226 | $wgHooks['CustomEditor'][] = 'mvCustomEditor'; |
227 | 227 | $wgParser->setHook( SEQUENCE_TAG, 'mvSeqTag' ); |
228 | 228 | |
229 | 229 | $wgParser->setFunctionHook( 'mvData', 'mvMagicParserFunction_Render' ); |
230 | | - |
231 | | - |
| 230 | + |
| 231 | + |
232 | 232 | /* |
233 | 233 | * OggHandler extension overrides |
234 | 234 | * if the OggHandler is included remap the object for compatibility with metavid |
235 | 235 | * MV_OggHandler.php handles all the re-mapping |
236 | 236 | */ |
237 | | - if(isset($wgMediaHandlers['application/ogg'])){ |
| 237 | + if(isset($wgMediaHandlers['application/ogg'])){ |
238 | 238 | if($wgMediaHandlers['application/ogg'] == 'OggHandler'){ |
239 | 239 | $wgAutoloadClasses['mvOggHandler'] = dirname( __FILE__ ) . '/MV_OggHandler.php'; |
240 | | - $wgMediaHandlers['application/ogg']='mvOggHandler'; |
| 240 | + $wgMediaHandlers['application/ogg']='mvOggHandler'; |
241 | 241 | $wgParserOutputHooks['OggHandler'] = array( 'mvOggHandler', 'outputHook' ); |
242 | 242 | foreach($wgHooks['LanguageGetMagic'] as & $hook_function){ |
243 | 243 | if($hook_function=='OggHandler::registerMagicWords'){ |
— | — | @@ -253,15 +253,15 @@ |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | | - |
| 257 | + |
258 | 258 | /************************************ |
259 | | - * API extension (this may be integrated into semantic wiki at some point) |
| 259 | + * API extension (this may be integrated into semantic wiki at some point) |
260 | 260 | **************************************/ |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - // $wgHooks['BeforePageDisplay'][] = 'mvDoSpecialPage'; |
| 261 | + |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + // $wgHooks['BeforePageDisplay'][] = 'mvDoSpecialPage'; |
266 | 266 | // $wgHooks['ArticleViewHeader'][] = 'mvArticleViewOpts'; |
267 | 267 | /**********************************************/ |
268 | 268 | /***** credits (see "Special:Version") *****/ |
— | — | @@ -279,13 +279,13 @@ |
280 | 280 | # Define a setup function |
281 | 281 | # Add a hook to initialize the magic word |
282 | 282 | $wgHooks['LanguageGetMagic'][] = 'mvMagicParserFunction_Magic'; |
283 | | - |
| 283 | + |
284 | 284 | function mvMagicParserFunction_Magic( &$magicWords, $langCode ) { |
285 | 285 | $magicWords['mvData'] = array( 0, 'mvData' ); |
286 | 286 | $magicWords['mvEmbed'] = array( 0, 'mvEmbed' ); |
287 | 287 | return true; |
288 | 288 | } |
289 | | - |
| 289 | + |
290 | 290 | function mvMagicParserFunction_Render( &$parser ) { |
291 | 291 | // gennerate arg_list array without parser param |
292 | 292 | $arg_list = array_slice( func_get_args(), 1 ); |
— | — | @@ -297,25 +297,28 @@ |
298 | 298 | /***** Header modifications *****/ |
299 | 299 | /**********************************************/ |
300 | 300 | /** |
301 | | - * header script to be added to all pages: |
| 301 | + * header script to be added to all pages: |
302 | 302 | * enables linkback and autocomplete for search |
303 | 303 | */ |
304 | 304 | function mvfAutoAllPageHeader() { |
305 | | - global $mvgScriptPath, $wgJsMimeType, $wgOut, $mvExtraHeader, $wgTitle, $mvgJSDebug, $wgEnableScriptLoader, $wgRequest;; |
| 305 | + global $mvgScriptPath, $wgJsMimeType, $wgOut, $mvExtraHeader, $wgTitle; |
| 306 | + global $mvgJSDebug, $wgEnableScriptLoader, $wgRequest, $wgEnableJS2system; |
| 307 | + |
306 | 308 | $mvgScriptPath = htmlspecialchars( $mvgScriptPath ); |
307 | | - $wgJsMimeType = htmlspecialchars( $wgJsMimeType ) ; |
308 | | - //set the unquie request value |
309 | | - if( $mvgJSDebug ){ |
| 309 | + $wgJsMimeType = htmlspecialchars( $wgJsMimeType ) ; |
| 310 | + //set the unquie request value |
| 311 | + if( $mvgJSDebug ){ |
310 | 312 | $unique_req_param = time(); |
311 | 313 | }else{ |
312 | 314 | //@@todo should read form svn version file info |
313 | 315 | $unique_req_param = MV_VERSION; |
314 | 316 | } |
315 | | - |
316 | | - $wgOut->addScriptFile( "{$mvgScriptPath}/skins/mv_allpages.js" ); |
317 | | - $wgOut->addScriptFile( "{$mvgScriptPath}/skins/mv_search.js" ); |
318 | | - |
319 | | - |
| 317 | + if( $wgEnableJS2system ){ |
| 318 | + $wgOut->addScriptClass( "mv_allpages" ); |
| 319 | + $wgOut->addScriptClass( "mv_search" ); |
| 320 | + } |
| 321 | + |
| 322 | + |
320 | 323 | $mvCssUrl = $mvgScriptPath . '/skins/mv_custom.css'; |
321 | 324 | $wgOut->addLink( array( |
322 | 325 | 'rel' => 'stylesheet', |
— | — | @@ -323,13 +326,13 @@ |
324 | 327 | 'media' => 'all', |
325 | 328 | 'href' => $mvCssUrl |
326 | 329 | ) ); |
327 | | - |
| 330 | + |
328 | 331 | $wgOut->addScript( $mvExtraHeader ); |
329 | 332 | } |
330 | 333 | function mvAddPerNamespaceJS( &$title ){ |
331 | 334 | global $mvgScriptPath, $wgJsMimeType, $wgOut; |
332 | 335 | if( $title->getNamespace() == MV_NS_STREAM ) |
333 | | - $wgOut->addScriptFile( "{$mvgScriptPath}/skins/mv_stream.js" ); |
| 336 | + $wgOut->addScriptFile( "{$mvgScriptPath}/skins/mv_stream.js" ); |
334 | 337 | } |
335 | 338 | function mvAddGlobalJSVariables( $values ){ |
336 | 339 | global $mvGlobalJSVariables; |
— | — | @@ -337,9 +340,9 @@ |
338 | 341 | } |
339 | 342 | function mvGlobalJSVariables( $vars ){ |
340 | 343 | global $mvGlobalJSVariables; |
341 | | - $vars = array_merge($vars, $mvGlobalJSVariables); |
| 344 | + $vars = array_merge($vars, $mvGlobalJSVariables); |
342 | 345 | return true; |
343 | | -} |
| 346 | +} |
344 | 347 | /** |
345 | 348 | * Init the additional namepsaces used by Metavid MediaWiki. The |
346 | 349 | * parameter denotes the least unused even namespace ID that is |
— | — | @@ -348,7 +351,7 @@ |
349 | 352 | function mvInitNamespaces() { |
350 | 353 | global $mvNamespaceIndex, $wgExtraNamespaces, $wgNamespacesWithSubpages, $wgLanguageCode, $mvgContLang, |
351 | 354 | $mvLastNamespaceIndex; |
352 | | - |
| 355 | + |
353 | 356 | if ( !isset( $mvNamespaceIndex ) ) { |
354 | 357 | $mvNamespaceIndex = 100; |
355 | 358 | } |
— | — | @@ -360,15 +363,15 @@ |
361 | 364 | define( 'MV_NS_SEQUENCE_TALK', $mvNamespaceIndex + 3 ); |
362 | 365 | define( 'MV_NS_MVD', $mvNamespaceIndex + 4 ); |
363 | 366 | define( 'MV_NS_MVD_TALK', $mvNamespaceIndex + 5 ); |
364 | | - |
| 367 | + |
365 | 368 | mvfInitContentLanguage( $wgLanguageCode ); |
366 | | - |
| 369 | + |
367 | 370 | // print_r($mvgContLang); |
368 | 371 | // print_r($mvgContLang->getNamespaces()); |
369 | 372 | // Register namespace identifiers |
370 | 373 | if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); } |
371 | 374 | $wgExtraNamespaces = $wgExtraNamespaces + $mvgContLang->getNamespaces(); |
372 | | - // update the mvLastNamespaceIndex for however many name spaces are established above: |
| 375 | + // update the mvLastNamespaceIndex for however many name spaces are established above: |
373 | 376 | $mvLastNamespaceIndex = $mvNamespaceIndex + 6; |
374 | 377 | } |
375 | 378 | |
— | — | @@ -463,13 +466,13 @@ |
464 | 467 | function mvOutputJSON( & $data ) { |
465 | 468 | $fname = 'Mv_output_json_data'; |
466 | 469 | wfProfileIn( $fname ); |
467 | | - |
| 470 | + |
468 | 471 | global $wgRequest; |
469 | 472 | |
470 | 473 | // get callback index and wrap function: |
471 | 474 | $callback_index = $wgRequest->getVal( 'cb_inx' ); |
472 | 475 | $wrap_function = $wgRequest->getVal( 'cb' ); |
473 | | - |
| 476 | + |
474 | 477 | header( 'Content-Type: text/javascript' ); |
475 | 478 | if($callback_index!='' && $wrap_function!=''){ |
476 | 479 | $output = htmlspecialchars( $wrap_function ) . '(' . PhpArrayToJsObject_Recurse( |
— | — | @@ -479,7 +482,7 @@ |
480 | 483 | ) |
481 | 484 | ) . ');'; |
482 | 485 | }else{ |
483 | | - //just produce a results var: |
| 486 | + //just produce a results var: |
484 | 487 | $output = php2jsObj( array('pay_load'=>$data) ); |
485 | 488 | } |
486 | 489 | wfProfileOut( $fname ); |
— | — | @@ -538,21 +541,21 @@ |
539 | 542 | * Check if time is NTP based: hh:mm:ss.ms(fraction of a second) |
540 | 543 | */ |
541 | 544 | function mvIsNtpTime( $time ) { |
542 | | - // could alternatively do preg match: (too strict) |
| 545 | + // could alternatively do preg match: (too strict) |
543 | 546 | // preg_match('/[0-9]+:[0-9][0-9]:[0-9][0-9]/', $this->start_time, $matches); |
544 | | - // if(count($matches)==0) |
| 547 | + // if(count($matches)==0) |
545 | 548 | $tp = split( ':', $time ); |
546 | 549 | if ( count( $tp ) >= 4 || count( $tp ) <= 2 )return false; |
547 | 550 | list( $hours, $min, $sec ) = $tp; |
548 | | - // min/sec should be no larger than 60 |
| 551 | + // min/sec should be no larger than 60 |
549 | 552 | if ( $min >= 60 || $sec >= 60 )return false; |
550 | | - // @@TODO min & hour should not be a floating point number |
| 553 | + // @@TODO min & hour should not be a floating point number |
551 | 554 | if ( is_numeric( $hours ) && is_numeric( $min ) && is_numeric( $sec ) ) |
552 | 555 | return true; |
553 | 556 | return false; |
554 | 557 | } |
555 | 558 | /* |
556 | | - * simple array increment (supports up two 2 dim deep) |
| 559 | + * simple array increment (supports up two 2 dim deep) |
557 | 560 | * should be a cleaner way to write this... hmm... |
558 | 561 | */ |
559 | 562 | function assoc_array_increment( &$ary ) { |
— | — | @@ -577,16 +580,16 @@ |
578 | 581 | break; |
579 | 582 | } |
580 | 583 | } |
581 | | - |
| 584 | + |
582 | 585 | /* |
583 | | - * takes ntp time of format hh:mm:ss and converts to seconds |
| 586 | + * takes ntp time of format hh:mm:ss and converts to seconds |
584 | 587 | */ |
585 | 588 | function npt2seconds( $str_time ) { |
586 | | - $time_ary = explode( ':', $str_time ); |
| 589 | + $time_ary = explode( ':', $str_time ); |
587 | 590 | $hours = $min = $sec = 0; |
588 | 591 | if ( count( $time_ary ) == 3 ) { |
589 | 592 | $hours = (int) $time_ary[0]; |
590 | | - $min = (int) $time_ary[1]; |
| 593 | + $min = (int) $time_ary[1]; |
591 | 594 | $sec = (float) $time_ary[2]; |
592 | 595 | } else if ( count( $time_ary ) == 2 ) { |
593 | 596 | $min = (int) $time_ary[0]; |
— | — | @@ -615,19 +618,19 @@ |
616 | 619 | $o=''; |
617 | 620 | if( $dur['days']!=0){ |
618 | 621 | $msg = ($singular)?'mv_days_singular':'mv_days'; |
619 | | - $o.= wfMsg($msg, intval( $dur['days']) ); |
| 622 | + $o.= wfMsg($msg, intval( $dur['days']) ); |
620 | 623 | } |
621 | 624 | if( $dur['hours'] != 0 ){ |
622 | 625 | $msg = ($singular)?'mv_hours_singular':'mv_hours'; |
623 | 626 | $o.= wfMsg($msg, intval( $dur['hours']) ); |
624 | | - } |
| 627 | + } |
625 | 628 | if( $dur['minutes'] != 0 ){ |
626 | 629 | $msg = ($singular)?'mv_minutes_singular':'mv_minutes'; |
627 | 630 | $o.=($o!='')?' ':''; |
628 | 631 | $o.= wfMsg($msg, intval( $dur['minutes']) ); |
629 | | - } |
| 632 | + } |
630 | 633 | if( ( $short == false || $o == '' ) && $dur['seconds'] ){ |
631 | | - $msg = ($singular)?'mv_seconds_singular':'mv_seconds'; |
| 634 | + $msg = ($singular)?'mv_seconds_singular':'mv_seconds'; |
632 | 635 | $o.=($o!='')?' ':''; |
633 | 636 | $o.= wfMsg($msg, intval( $dur['seconds']) ); |
634 | 637 | } |
— | — | @@ -675,10 +678,10 @@ |
676 | 679 | */ |
677 | 680 | function mvOutputSpecialPage( $title, & $page ) { |
678 | 681 | global $wgOut, $wgTitle; |
679 | | - |
| 682 | + |
680 | 683 | // $wgTitle = SpecialPage::getTitleFor($title); |
681 | 684 | $wgTitle->mNamespace = NS_SPECIAL; |
682 | | - |
| 685 | + |
683 | 686 | $wgOut->setPageTitle( $title ); |
684 | 687 | $wgOut->setHTMLTitle( $title ); |
685 | 688 | $wgOut->setArticleRelated( false ); |
— | — | @@ -686,9 +689,9 @@ |
687 | 690 | |
688 | 691 | $wgOut->addHTML( $page ); |
689 | 692 | $wgOut->returnToMain( false ); |
690 | | - |
| 693 | + |
691 | 694 | $wgOut->output(); |
692 | | - |
| 695 | + |
693 | 696 | exit(); |
694 | 697 | } |
695 | 698 | function mvDoMetavidStreamPage( &$title, &$article ) { |
— | — | @@ -696,14 +699,14 @@ |
697 | 700 | if ( $mvTitle->doesStreamExist() ) { |
698 | 701 | // @@TODO check if we have /name corresponding to a view or |
699 | 702 | // /ss:ss:ss or /ss:ss:ss/ee:ee:ee corresponding to a time request |
700 | | - // force metavid to be special |
| 703 | + // force metavid to be special |
701 | 704 | // (@@todo clean up skin.php to enable better tab controls) |
702 | 705 | // $title->mNamespace= NS_SPECIAL; |
703 | 706 | |
704 | | - // add a hit to the digest if enabled: |
| 707 | + // add a hit to the digest if enabled: |
705 | 708 | // @@todo (maybe in the future use javascript to confirm they acutally "watched" the clip) |
706 | 709 | global $mvEnableClipViewDigest, $wgRequest; |
707 | | - // don't log views without end times (default stream view) |
| 710 | + // don't log views without end times (default stream view) |
708 | 711 | if ( $mvEnableClipViewDigest && $mvTitle->end_time != null && $wgRequest->getVal( 'tl' ) != '1' ) { |
709 | 712 | $dbw =& wfGetDB( DB_WRITE ); |
710 | 713 | $dbw->insert( 'mv_clipview_digest', array( |
— | — | @@ -727,18 +730,18 @@ |
728 | 731 | 'start_time' => $start_time, |
729 | 732 | 'end_time' => $end_time |
730 | 733 | ) ); |
731 | | - // print $dbw->lastQuery(); |
732 | | - // also update the mvd_page if directly requested: |
| 734 | + // print $dbw->lastQuery(); |
| 735 | + // also update the mvd_page if directly requested: |
733 | 736 | $dbw->update( 'mv_mvd_index', array( '`view_count`=`view_count`+1' ), |
734 | 737 | array( 'stream_id' => $mvTitle->getStreamId(), |
735 | 738 | 'start_time' => $mvTitle->getStartTimeSeconds(), |
736 | 739 | 'end_time' => $mvTitle->getEndTimeSeconds() |
737 | 740 | ) ); |
738 | | - // print $dbw->lastQuery(); |
| 741 | + // print $dbw->lastQuery(); |
739 | 742 | } |
740 | | - // @@todo check if the requested title is already just the stream name: |
| 743 | + // @@todo check if the requested title is already just the stream name: |
741 | 744 | $streamTitle = Title::newFromText( $mvTitle->getStreamName(), MV_NS_STREAM ); |
742 | | - // print " new title: " . $streamTitle . "\n"; |
| 745 | + // print " new title: " . $streamTitle . "\n"; |
743 | 746 | $article = new MV_StreamPage( $streamTitle, $mvTitle ); |
744 | 747 | } else { |
745 | 748 | mvMissingStreamPage( $mvTitle->stream_name ); |
— | — | @@ -750,22 +753,22 @@ |
751 | 754 | * @@todo cache this function |
752 | 755 | */ |
753 | 756 | function mvGetMVStream( $stream_init ) { |
754 | | - global $MVStreams; |
| 757 | + global $MVStreams; |
755 | 758 | // wfDebug('mv get stream: ' .$stream_name . "\n"); |
756 | 759 | if ( is_object( $stream_init ) ) { |
757 | 760 | $stream_init = get_object_vars( $stream_init ); |
758 | 761 | } else if ( is_string( $stream_init ) ) { |
759 | | - // if a string is passed in assume its the stream name: |
| 762 | + // if a string is passed in assume its the stream name: |
760 | 763 | $stream_init = array( 'name' => $stream_init ); |
761 | 764 | } |
762 | 765 | if ( isset( $stream_init['name'] ) ) { |
763 | 766 | $stream_name = $stream_init['name']; |
764 | 767 | } else if ( isset( $stream_init['id'] ) ) { |
765 | 768 | $stream_name = MV_Stream::getStreamNameFromId( $stream_init['id'] ); |
766 | | - } else { |
| 769 | + } else { |
767 | 770 | die('missing stream id or name'. $stream_init); |
768 | 771 | } |
769 | | - // @@todo cache in memcache) |
| 772 | + // @@todo cache in memcache) |
770 | 773 | if ( !isset( $MVStreams[$stream_name] ) ) { |
771 | 774 | $MVStreams[$stream_name] = new MV_Stream( $stream_init ); |
772 | 775 | $MVStreams[$stream_name]->db_load_stream(); |
— | — | @@ -774,7 +777,7 @@ |
775 | 778 | } |
776 | 779 | |
777 | 780 | function mvGetMVTitle() { |
778 | | - |
| 781 | + |
779 | 782 | } |
780 | 783 | function mv_get_person_img( $person_name ) { |
781 | 784 | $imgTitle = Title::makeTitle( NS_IMAGE, $person_name . '.jpg' ); |
— | — | @@ -784,7 +787,7 @@ |
785 | 788 | $img = wfLocalFile( $imgTitle ); |
786 | 789 | } |
787 | 790 | } else { |
788 | | - // @@todo add Missing person.jpg to install scripts |
| 791 | + // @@todo add Missing person.jpg to install scripts |
789 | 792 | $imgTitle = Title::makeTitle( NS_IMAGE, MV_MISSING_PERSON_IMG ); |
790 | 793 | $img = wfFindFile( $imgTitle ); |
791 | 794 | if ( !$img ) { |