Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2787,13 +2787,7 @@ |
2788 | 2788 | $wgEnableJS2system = false; |
2789 | 2789 | |
2790 | 2790 | /* |
2791 | | - * boolean; if relative file paths can be used (in addition to the autoload |
2792 | | - * js classes listed in: $wgJSAutoloadClasses) |
2793 | | - */ |
2794 | | -$wgEnableScriptLoaderJsFile = false; |
2795 | | - |
2796 | | -/* |
2797 | | - * boolean; if we should minify the output. (note if you send ?debug=true in |
| 2791 | + * boolean; if we should minify the output. (note if you send ?debug=true in |
2798 | 2792 | * the page request it will automatically not group and not minify) |
2799 | 2793 | */ |
2800 | 2794 | $wgEnableScriptMinify = true; |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -554,29 +554,32 @@ |
555 | 555 | _this.doLoad([ |
556 | 556 | 'window.jQuery' |
557 | 557 | ], function() { |
558 | | - _global['$j'] = jQuery.noConflict(); |
559 | | - |
560 | | - //setup our global settings using the (jQuery helper) |
561 | | - $j.extend( mwConfig, mwConfigOptions); |
562 | | - |
563 | | - // Set up the skin path |
564 | | - _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' +mwConfig['jui_skin'] + '/'; |
565 | | - _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/images/'; |
566 | | - _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg'; |
567 | | - |
568 | | - // Make sure the skin/style sheets are always available: |
569 | | - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
570 | | - loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/styles.css' ); |
571 | | - |
572 | | - // Set up AJAX to not send dynamic URLs for loading scripts (we control that with |
573 | | - // the scriptLoader) |
574 | | - $j.ajaxSetup({ |
575 | | - cache: true |
576 | | - }); |
577 | | - |
578 | | - js_log( 'jQuery loaded into $j' ); |
579 | | - // Set up mvEmbed jQuery bindings: |
580 | | - mv_jqueryBindings(); |
| 558 | + //only do the $j setup once: |
| 559 | + if(!_global['$j']){ |
| 560 | + _global['$j'] = jQuery.noConflict(); |
| 561 | + |
| 562 | + //setup our global settings using the (jQuery helper) |
| 563 | + $j.extend( mwConfig, mwConfigOptions); |
| 564 | + |
| 565 | + // Set up the skin path |
| 566 | + _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' +mwConfig['jui_skin'] + '/'; |
| 567 | + _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/images/'; |
| 568 | + _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg'; |
| 569 | + |
| 570 | + // Make sure the skin/style sheets are always available: |
| 571 | + loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
| 572 | + loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/styles.css' ); |
| 573 | + |
| 574 | + // Set up AJAX to not send dynamic URLs for loading scripts (we control that with |
| 575 | + // the scriptLoader) |
| 576 | + $j.ajaxSetup({ |
| 577 | + cache: true |
| 578 | + }); |
| 579 | + |
| 580 | + js_log( 'jQuery loaded into $j' ); |
| 581 | + // Set up mvEmbed jQuery bindings: |
| 582 | + mv_jqueryBindings(); |
| 583 | + } |
581 | 584 | // Run the callback |
582 | 585 | if( callback ) { |
583 | 586 | callback(); |
Index: trunk/phase3/js2/mwEmbed/jsScriptLoader.php |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | var $jsvarurl = false; // whether we should include generated JS (special class '-') |
24 | 24 | var $doProcReqFlag = true; |
25 | 25 | |
26 | | - //@@todo fix: will break down if someone does }); in their msg text |
| 26 | + //@@todo fix: will break down if someone does }) in their msg text |
27 | 27 | const loadGMregEx = '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU'; |
28 | 28 | |
29 | 29 | function doScriptLoader() { |
30 | | - global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgEnableScriptLoaderJsFile, $IP, |
| 30 | + global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $IP, |
31 | 31 | $wgEnableScriptMinify, $wgUseFileCache; |
32 | 32 | |
33 | 33 | // Process the request |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | */ |
170 | 170 | function procRequestVars() { |
171 | 171 | global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, |
172 | | - $wgJSAutoloadLocalClasses, $wgStyleVersion, $wgEnableScriptLoaderJsFile; |
| 172 | + $wgJSAutoloadLocalClasses, $wgStyleVersion; |
173 | 173 | |
174 | 174 | // Set debug flag |
175 | 175 | if ( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) || ( isset( $wgEnableScriptDebug ) && $wgEnableScriptDebug == true ) ) { |
— | — | @@ -194,11 +194,27 @@ |
195 | 195 | // Clean the class list and populate jsFileList |
196 | 196 | foreach ( $reqClassList as $reqClass ) { |
197 | 197 | if ( trim( $reqClass ) != '' ) { |
198 | | - // Check for special case '-' class for user-generated JS |
199 | 198 | if ( substr( $reqClass, 0, 3 ) == 'WT:' ) { |
200 | | - $this->jsFileList[$reqClass] = true; |
201 | | - $this->rKey .= $reqClass; |
202 | | - $this->jsvarurl = true; |
| 199 | + $doAddWT = false; |
| 200 | + // Check for special case '-' class for user-generated JS |
| 201 | + if( substr( $reqClass, 3, 1) == '-'){ |
| 202 | + $doAddWT = true; |
| 203 | + }else{ |
| 204 | + if( strtolower( substr( $reqClass, -3) ) == '.js'){ |
| 205 | + //make sure its a valid wikipage before doing processing |
| 206 | + $t = Title::newFromDBkey( substr( $reqClass, 3) ); |
| 207 | + if( $t->exists() |
| 208 | + && $t->getNamespace == NS_MEDIAWIKI |
| 209 | + && $t->getNamespace == NS_USER){ |
| 210 | + $doAddWT = true; |
| 211 | + } |
| 212 | + } |
| 213 | + } |
| 214 | + if( $doAddWT ){ |
| 215 | + $this->jsFileList[$reqClass] = true; |
| 216 | + $this->rKey .= $reqClass; |
| 217 | + $this->jsvarurl = true; |
| 218 | + } |
203 | 219 | continue; |
204 | 220 | } |
205 | 221 | |
— | — | @@ -215,29 +231,7 @@ |
216 | 232 | } |
217 | 233 | } |
218 | 234 | |
219 | | - // Check for requested files, if enabled |
220 | | - if ( $wgEnableScriptLoaderJsFile ) { |
221 | | - if ( isset( $_GET['files'] ) ) { |
222 | | - $reqFileList = explode( ',', isset( $_GET['files'] ) ); |
223 | | - // Clean the file list and populate jsFileList |
224 | | - foreach ( $reqFileList as $reqFile ) { |
225 | | - // No jumping dirs |
226 | | - $reqFile = str_replace( '../', '', $reqFile ); |
227 | | - // Only allow alphanumeric underscores periods and ending with .js |
228 | | - $reqFile = ereg_replace( "[^A-Za-z0-9_\-\/\.]", '', $reqFile ); |
229 | | - if ( substr( $reqFile, - 3 ) == '.js' ) { |
230 | | - // Don't add it twice: |
231 | | - if ( !in_array( $reqFile, $jsFileList ) ) { |
232 | | - $this->jsFileList[] = $IP . $reqFile; |
233 | | - $this->rKey .= $reqFile; |
234 | | - } |
235 | | - } else { |
236 | | - $this->error_msg .= 'Not valid requested JavaScript file' . "\n"; |
237 | | - } |
238 | | - } |
239 | | - } |
240 | | - } |
241 | | - |
| 235 | + |
242 | 236 | // Add the language code to the rKey: |
243 | 237 | $this->rKey .= '_' . $wgContLanguageCode; |
244 | 238 | |
— | — | @@ -311,8 +305,6 @@ |
312 | 306 | // Return the updated loadGM JSON with updated msgs: |
313 | 307 | return 'loadGM( ' . FormatJson::encode( $jmsg ) . ')'; |
314 | 308 | } else { |
315 | | - print_r($jvar); |
316 | | - |
317 | 309 | // Could not parse JSON return error: (maybe a alert?) |
318 | 310 | //we just make a note in the code, visitors will get the fallback language, |
319 | 311 | //developers will read the js source when its not behaving as expected. |