Index: trunk/extensions/JS2Support/ScriptLoaderOutputPage.php |
— | — | @@ -246,23 +246,23 @@ |
247 | 247 | // If script-loader enabled check if we can add the script via script-loader |
248 | 248 | if( $this->isScriptGroupingEnabled() ) { |
249 | 249 | global $wgStylePath, $wgScript; |
250 | | - |
251 | | - // Append style path if a relative path |
| 250 | + |
| 251 | + // Append style path if a relative path |
252 | 252 | if( substr( $style, 0, 1 ) == '/' ){ |
253 | 253 | // already absolute path don't modify path |
254 | | - |
| 254 | + |
255 | 255 | } else if ( |
256 | 256 | substr( $style, 0, 5 ) == 'http:' || |
257 | 257 | substr( $style, 0, 6 ) == 'https:' ) { |
258 | | - |
259 | | - // Remote css can't group: |
| 258 | + |
| 259 | + // Remote css can't group: |
260 | 260 | $this->styles[ $style ] = $options; |
261 | | - |
| 261 | + |
262 | 262 | } else { |
263 | 263 | // Relative core skin path append $wgStylePath |
264 | 264 | $style = $wgStylePath ."/". $style; |
265 | 265 | } |
266 | | - |
| 266 | + |
267 | 267 | $cssClass = $this->getClassFromPath( $style ); |
268 | 268 | if( $cssClass ) { |
269 | 269 | $this->addScriptClass( $cssClass, $bucketKey, 'css'); |
— | — | @@ -298,6 +298,10 @@ |
299 | 299 | // No dir for bucket key since dir does not require a separate bucket. |
300 | 300 | unset( $options['dir'] ); |
301 | 301 | $bucketKey = implode( '.', $options ); |
| 302 | + // If an empty bucket put into the allpage bucket |
| 303 | + if( trim( $bucketKey) == '' ){ |
| 304 | + $bucketKey = 'allpage'; |
| 305 | + } |
302 | 306 | |
303 | 307 | // Update the css bucket options: |
304 | 308 | $this->setClassBucketOptions( $bucketKey, $options ); |
— | — | @@ -372,10 +376,13 @@ |
373 | 377 | $wgScriptLoaderNamedPaths, $wgScriptPath; |
374 | 378 | |
375 | 379 | // Set core Classes and styles: |
376 | | - $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' , 'mw.style.mwCommon' ); |
| 380 | + $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' ); |
377 | 381 | |
| 382 | + // Include the core css |
| 383 | + $this->addStyleClass( 'mw.style.mwCommon' ); |
378 | 384 | |
379 | 385 | |
| 386 | + |
380 | 387 | // Merge in any scripts that have been set as "allpage" |
381 | 388 | // Since the all page are on every page view they should just be part of the core |
382 | 389 | // script request. |
— | — | @@ -383,6 +390,7 @@ |
384 | 391 | $coreClasses = array_merge($coreClasses, $this->mScriptLoaderClassList[ 'js' ][ 'allpage' ] ); |
385 | 392 | } |
386 | 393 | |
| 394 | + |
387 | 395 | // Make sure scripts are the first scripts include on the page. |
388 | 396 | // Some extensions directly modify $this->mScripts early on and break |
389 | 397 | // order of includes. |
Index: trunk/extensions/JS2Support/mwEmbed/mwEmbed.js |
— | — | @@ -2287,6 +2287,7 @@ |
2288 | 2288 | if( ! $j( targetObject ).data( 'events' ) || |
2289 | 2289 | ! $j( targetObject ).data( 'events' )[ triggerName ] ) { |
2290 | 2290 | callback(); |
| 2291 | + return ; |
2291 | 2292 | } |
2292 | 2293 | var callbackCount = $j( targetObject ).data( 'events' )[ triggerName ].length; |
2293 | 2294 | if( !callbackCount ){ |
Index: trunk/extensions/JS2Support/mwEmbed/README |
— | — | @@ -1,7 +1,5 @@ |
2 | | -*********************************************** |
| 2 | +*********************************************** test |
3 | 3 | * |
4 | | -* mwEmbed version 1.1 |
5 | | -* |
6 | 4 | * For an overview of all mwEmbed files see: |
7 | 5 | * http://www.mediawiki.org/wiki/MwEmbed |
8 | 6 | * |
— | — | @@ -11,9 +9,14 @@ |
12 | 10 | * All mwEmbed code is Released under the GPL2 as |
13 | 11 | * a stand alone component of mediaWiki |
14 | 12 | * |
15 | | -* Libraries used include their licence info in their included path |
| 13 | +* Libraries used include their license info in their included path |
16 | 14 | * |
17 | | -* Copyright (C) 2007 - 2010 Michael Dale <mdale@wikimedia.org>, |
| 15 | +* Copyright (C) 2007 - 2010 Kaltura, Wikimedia Foundation |
| 16 | +* |
| 17 | +* Sub modules and libraries carry specific copyright while the |
| 18 | +* the entire package is always releasable under the GPL 2 |
| 19 | +* |
| 20 | +* Author Michael Dale <mdale@wikimedia.org>, |
18 | 21 | * and many others. |
19 | 22 | * |
20 | 23 | * This program is free software; you can redistribute it and/or modify |
— | — | @@ -31,4 +34,4 @@ |
32 | 35 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
33 | 36 | * http://www.gnu.org/copyleft/gpl.html |
34 | 37 | * |
35 | | -********************************************* |
\ No newline at end of file |
| 38 | +********************************************* |
Index: trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php |
— | — | @@ -60,6 +60,9 @@ |
61 | 61 | // The includeAllModuleMessages string regular expression |
62 | 62 | private static $includeAllMsgsRegEx = "/mw\.includeAllModuleMessages\s*\(\s*\)\;?/"; |
63 | 63 | |
| 64 | + //Temporary store for message js |
| 65 | + private static $addMessageJs = ''; |
| 66 | + |
64 | 67 | /** |
65 | 68 | * Output the javascript from cache |
66 | 69 | * |
— | — | @@ -98,7 +101,7 @@ |
99 | 102 | try { |
100 | 103 | jsClassLoader::loadClassPaths(); |
101 | 104 | } catch( Exception $e ) { |
102 | | - $this->errorMsg .= $e->getMessage() ; |
| 105 | + $this->errorMsg .= $e->getMessage() ; |
103 | 106 | } |
104 | 107 | |
105 | 108 | // Reset the requestKey: |
— | — | @@ -148,15 +151,15 @@ |
149 | 152 | // Output the current language class js |
150 | 153 | $this->output .= jsClassLoader::getLanguageJs( $this->langCode ); |
151 | 154 | |
152 | | - // Add the required core mwEmbed style sheets Commted out |
153 | | - // because when creating stand alone packages js package with css |
154 | | - // the paths get messed up. |
155 | | - /* |
| 155 | + // Add the required core mwEmbed style sheets Commted out |
| 156 | + // because when creating stand alone packages js package with css |
| 157 | + // the paths get messed up. |
| 158 | + /* |
156 | 159 | if( !isset( $this->namedFileList[ 'mw.style.mwCommon' ] ) ) { |
157 | 160 | $this->output .= $this->getScriptText( 'mw.style.mwCommon' ); |
158 | 161 | } |
159 | 162 | */ |
160 | | - |
| 163 | + |
161 | 164 | // Output "special" IE comment tag to support "special" mwEmbed tags. |
162 | 165 | $this->notMinifiedTopOutput .='/*@cc_on@if(@_jscript_version<9){\'video audio source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n"; |
163 | 166 | } |
— | — | @@ -725,7 +728,7 @@ |
726 | 729 | try { |
727 | 730 | jsClassLoader::loadClassPaths(); |
728 | 731 | } catch( Exception $e ) { |
729 | | - $this->errorMsg .= $e->getMessage() ; |
| 732 | + $this->errorMsg .= $e->getMessage() ; |
730 | 733 | } |
731 | 734 | |
732 | 735 | if ( isset( $wgScriptLoaderNamedPaths[ $reqClass ] ) ) { |
— | — | @@ -813,13 +816,23 @@ |
814 | 817 | |
815 | 818 | // Do language swap by index: |
816 | 819 | if ( $wgEnableScriptLocalization ){ |
817 | | - // Get the mw.addMessage javascript from scriptText and moduleName |
818 | | - $addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName); |
819 | 820 | //@@NOTE getAddMessagesFromClass could identify which mode we are in and we would not need to |
820 | 821 | // try each of these search patterns in the same order as before. |
821 | 822 | |
| 823 | + // Get the mw.addMessage javascript |
| 824 | + self::$addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName); |
| 825 | + |
822 | 826 | // Check for mw.includeAllModuleMsgs() call to be replaced with all the msgs |
823 | | - $scriptText = preg_replace( self::$includeAllMsgsRegEx, $addMessageJs, $scriptText, 1, $count ); |
| 827 | + // Use preg_replace_callback to avoid back-refrence substitution |
| 828 | + $scriptText = preg_replace_callback( |
| 829 | + self::$includeAllMsgsRegEx, |
| 830 | + 'jsScriptLoader::preg_addMessageJs', |
| 831 | + $scriptText, |
| 832 | + 1, |
| 833 | + $count |
| 834 | + ); |
| 835 | + |
| 836 | + |
824 | 837 | if( $count != 0 ){ |
825 | 838 | return $scriptText; |
826 | 839 | } |
— | — | @@ -828,21 +841,23 @@ |
829 | 842 | $inx = self::getAddMessagesIndex( $scriptText ); |
830 | 843 | if( $inx ){ |
831 | 844 | // Return the final string (without double {}) |
832 | | - return substr($scriptText, 0, $inx['sfull']) . $addMessageJs . substr($scriptText, $inx['efull']); |
| 845 | + return substr($scriptText, 0, $inx['sfull']) . self::$addMessageJs . substr($scriptText, $inx['efull']); |
833 | 846 | } |
834 | 847 | |
835 | 848 | // Replace mw.addMessageKeys with localized msgs in javascript string |
836 | 849 | $inx = self::getAddMessageKeyIndex( $scriptText ); |
837 | 850 | if( $inx ) { |
838 | 851 | // Return the final string (without double {}) |
839 | | - return substr( $scriptText, 0, $inx['sfull'] ). $addMessageJs . substr($scriptText, $inx['efull']); |
| 852 | + return substr( $scriptText, 0, $inx['sfull'] ). self::$addMessageJs . substr($scriptText, $inx['efull']); |
840 | 853 | } |
841 | 854 | } |
842 | 855 | // Return the javascript str unmodified if we did not transform with the localisation |
843 | 856 | return $scriptText; |
844 | 857 | } |
845 | | - |
846 | | - |
| 858 | + /* simple function to return addMessageJs without preg_replace back reference substitution */ |
| 859 | + private static function preg_addMessageJs(){ |
| 860 | + return self::$addMessageJs; |
| 861 | + } |
847 | 862 | /** |
848 | 863 | * Get the "addMesseges" function index ( for replacing msg text with localized json ) |
849 | 864 | * |