Index: branches/js2-work/phase3/includes/DefaultSettings.php |
— | — | @@ -2863,13 +2863,6 @@ |
2864 | 2864 | */ |
2865 | 2865 | $wgAutoloadClasses = array(); |
2866 | 2866 | |
2867 | | - |
2868 | | -/* |
2869 | | - * Array mapping JavaScript class to web path for use by the script loader. |
2870 | | - * This is populated in AutoLoader.php. |
2871 | | - */ |
2872 | | -$wgScriptLoaderNamedPaths = array(); |
2873 | | - |
2874 | 2867 | /** |
2875 | 2868 | * For defining the location of loader.js files of |
2876 | 2869 | * Extension mwEmbed modules. ( ie modules hosted inside of extensions ) |
Index: branches/js2-work/phase3/js/mwEmbed/loader.js |
— | — | @@ -141,9 +141,9 @@ |
142 | 142 | "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
143 | 143 | "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
144 | 144 | |
145 | | - "mw.style.redmond" : "jquery/jquery.ui/themes/redmond/jquery-ui-1.7.1.custom.css", |
146 | | - "mw.style.smoothness" : "jquery/jquery.ui/themes/smoothness/jquery-ui-1.7.1.custom.css", |
147 | | - "mw.style.common" : "skins/common/common.css", |
| 145 | + "mw.style.jquery-ui-redmond" : "jquery/jquery.ui/themes/redmond/jquery-ui-1.7.1.custom.css", |
| 146 | + "mw.style.jquery-ui-smoothness" : "jquery/jquery.ui/themes/smoothness/jquery-ui-1.7.1.custom.css", |
| 147 | + "mw.style.mw-common" : "skins/common/common.css", |
148 | 148 | |
149 | 149 | "mw.testLang" : "tests/testLang.js", |
150 | 150 | |
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -39,7 +39,6 @@ |
40 | 40 | self::$classesLoaded = true; |
41 | 41 | |
42 | 42 | $mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' )? $IP: $IP .'/' .$wgMwEmbedDirectory; |
43 | | - |
44 | 43 | // Add the mwEmbed localizations |
45 | 44 | $wgExtensionMessagesFiles[ 'mwEmbed' ] = $mwEmbedAbsolutePath . '/languages/mwEmbed.i18n.php'; |
46 | 45 | |
— | — | @@ -73,7 +72,8 @@ |
74 | 73 | |
75 | 74 | // Get all the classes from the enabled mwEmbed modules folder |
76 | 75 | foreach( self::$moduleList as $na => $moduleName){ |
77 | | - self::proccessModulePath( $mwEmbedAbsolutePath . '/modules/' . $moduleName ); |
| 76 | + $relativeSlash = ( $wgMwEmbedDirectory == '' )? '' : '/'; |
| 77 | + self::proccessModulePath( $wgMwEmbedDirectory . $relativeSlash . 'modules/' . $moduleName ); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Get all the extension loader paths registered mwEmbed modules |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | // Get the module name |
95 | 95 | $moduleName = end( explode('/', $path ) ); |
96 | 96 | |
97 | | - // Set the directory context for js defined paths |
| 97 | + // Set the directory context for relative js/css paths |
98 | 98 | self::$directoryContext = $path; |
99 | 99 | |
100 | 100 | // Check for the loader.js |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | self::$combinedLoadersJs .= $fileContent; |
127 | 127 | |
128 | 128 | preg_replace_callback( |
129 | | - self::$classReplaceExp, |
| 129 | + self::$classReplaceExp, |
130 | 130 | 'jsClassLoader::preg_classPathLoader', |
131 | 131 | $fileContent |
132 | 132 | ); |
Index: branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php |
— | — | @@ -34,6 +34,10 @@ |
35 | 35 | |
36 | 36 | /*Localization:*/ |
37 | 37 | $wgEnableScriptLocalization = true; |
| 38 | +// Array to store all loaded msgs |
| 39 | +$wgMessageCache = array(); |
| 40 | +// flag for loading msgs |
| 41 | +$wgLoadedMsgKeysFlag = false; |
38 | 42 | |
39 | 43 | $mwLanguageCode = 'en'; |
40 | 44 | $wgLang = false; |
— | — | @@ -99,6 +103,8 @@ |
100 | 104 | |
101 | 105 | /** |
102 | 106 | * Copied from mediaWIki GlobalFunctions.php wfMsgGetKey |
| 107 | + * but we return [] instead of < > since < does not |
| 108 | + * look good in javascript msg strings |
103 | 109 | * |
104 | 110 | * Fetch a message string value, but don't replace any keys yet. |
105 | 111 | * @param $key String |
— | — | @@ -109,25 +115,40 @@ |
110 | 116 | * @return string |
111 | 117 | * @private |
112 | 118 | */ |
113 | | -function wfMsgGetKey( $msgKey, $na, $langKey=false ) { |
114 | | - global $messages, $mwLanguageCode; |
115 | | - if(!$langKey){ |
| 119 | +function wfMsgGetKey( $msgKey, $na, $langKey = false ) { |
| 120 | + global $wgLoadedMsgKeysFlag, $wgMessageCache, $mwLanguageCode; |
| 121 | + |
| 122 | + if( !$langKey ){ |
116 | 123 | $langKey = $mwLanguageCode; |
117 | 124 | } |
118 | | - if ( isset( $messages[$mwLanguageCode] ) && isset( $messages[$langKey][$msgKey] ) ) { |
119 | | - return $messages[$langKey][$msgKey]; |
| 125 | + |
| 126 | + // Make sure msg Keys are loaded |
| 127 | + if( !$wgLoadedMsgKeysFlag ) { |
| 128 | + wfLoadMsgKeys( $langKey ); |
| 129 | + } |
| 130 | + |
| 131 | + |
| 132 | + if ( isset( $wgMessageCache[$msgKey] ) ) { |
| 133 | + return $wgMessageCache[$msgKey]; |
120 | 134 | } else { |
121 | | - return '<' . $msgKey . '>'; |
| 135 | + return '[' . $msgKey . ']'; |
122 | 136 | } |
123 | 137 | } |
124 | | -$wgLoadedMsgKeysFlag = false; |
125 | | -function loadMsgKeys(){ |
126 | | - global $wgLoadedMsgKeysFlag; |
127 | | - if( $wgLoadedMsgKeysFlag ) { |
128 | | - return true; |
| 138 | +/** |
| 139 | + * Load all the msg keys into $wgMessageCache |
| 140 | + * @param $langKey String Language key to be used |
| 141 | + */ |
| 142 | +function wfLoadMsgKeys( $langKey ){ |
| 143 | + global $wgExtensionMessagesFiles, $wgMessageCache; |
| 144 | + foreach( $wgExtensionMessagesFiles as $msgFile ){ |
| 145 | + if( !is_file( $msgFile ) ) { |
| 146 | + throw new MWException( "Missing msgFile: " . htmlspecialchars( $msgFile ) . "\n" ); |
| 147 | + } |
| 148 | + require( $msgFile ); |
| 149 | + // Save some time by only including the current language in the cache: |
| 150 | + $wgMessageCache = array_merge( $wgMessageCache, $messages[ $langKey ] ); |
129 | 151 | } |
130 | | - // Get the messages file: |
131 | | - require_once( realpath( dirname( __FILE__ ) ) . '/../languages/mwEmbed.i18n.php' ); |
| 152 | + $wgLoadedMsgKeysFlag = true; |
132 | 153 | } |
133 | 154 | |
134 | 155 | /** |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -1520,8 +1520,7 @@ |
1521 | 1521 | mw.log( 'run setup directly' ); |
1522 | 1522 | //DOM is already ready run setup directly ( will run mwOnLoadFunctions on finish ) |
1523 | 1523 | mw.setupMwEmbed(); |
1524 | | - } |
1525 | | - |
| 1524 | + } |
1526 | 1525 | return ; |
1527 | 1526 | } |
1528 | 1527 | // If mwReadyFlag is already "true" issue the callback directly: |
— | — | @@ -1534,7 +1533,7 @@ |
1535 | 1534 | mw.runReadyHooks = function ( ) { |
1536 | 1535 | // Run all the queued functions: |
1537 | 1536 | while( mwOnLoadFunctions.length ) { |
1538 | | - mwOnLoadFunctions.pop()(); |
| 1537 | + mwOnLoadFunctions.shift()(); |
1539 | 1538 | } |
1540 | 1539 | |
1541 | 1540 | // Sets mwReadyFlag to true so that future addOnLoadHook calls |
— | — | @@ -1631,7 +1630,7 @@ |
1632 | 1631 | * @param {String} cssClassName Name of style sheet that has been defined |
1633 | 1632 | * @param {String} cssString Css Payload to be added to head of document |
1634 | 1633 | */ |
1635 | | - mw.addStyleString = function( cssClassName, cssString ) { |
| 1634 | + mw.addStyleString = function( cssClassName, cssString ) { |
1636 | 1635 | if( mw.style[ cssClassName ] ) { |
1637 | 1636 | mw.log(" Style: ( " + cssClassName + ' ) already set' ); |
1638 | 1637 | return true; |
— | — | @@ -1639,8 +1638,8 @@ |
1640 | 1639 | // Set the style to true ( to not request it again ) |
1641 | 1640 | mw.style[ cssClassName ] = true; |
1642 | 1641 | // Wait for the DOM to be ready before adding in the css: |
1643 | | - mw.ready( function() { |
1644 | | - mw.log('Adding style:' + cssClassName +" to dom"); |
| 1642 | + mw.ready( function() { |
| 1643 | + mw.log( 'Adding style:' + cssClassName + " to dom " ); |
1645 | 1644 | var styleNode = document.createElement('style'); |
1646 | 1645 | styleNode.type = "text/css"; |
1647 | 1646 | // Use cssText or createTextNode depending on browser: |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | exit(); |
17 | 17 | } |
18 | 18 | // No cache hit, load stand alone ScriptLoader config |
| 19 | + |
19 | 20 | // ( if running as a remote, mediaWiki variables are already included as part of mediaWiki |
20 | 21 | require_once( realpath( dirname( __FILE__ ) ) . '/includes/noMediaWikiConfig.php' ); |
21 | 22 | $myScriptLoader->doScriptLoader(); |
— | — | @@ -22,8 +23,8 @@ |
23 | 24 | |
24 | 25 | class jsScriptLoader { |
25 | 26 | |
26 | | - // The list of javascript files |
27 | | - var $jsFileList = array(); |
| 27 | + // The list of named javascript & css files |
| 28 | + var $namedFileList = array(); |
28 | 29 | |
29 | 30 | // The language code for the script-loader request |
30 | 31 | var $langCode = ''; |
— | — | @@ -107,13 +108,11 @@ |
108 | 109 | |
109 | 110 | // Build the output |
110 | 111 | // Swap in the appropriate language per js_file |
111 | | - foreach ( $this->jsFileList as $classKey => $filePath ) { |
112 | | - |
| 112 | + foreach ( $this->namedFileList as $classKey => $filePath ) { |
113 | 113 | // Get the localized script content |
114 | 114 | $this->output .= $this->getLocalizedScriptText( $classKey ); |
115 | 115 | |
116 | | - // If the core mwEmbed class entry point add some |
117 | | - // other "core" files: |
| 116 | + // If the core mwEmbed class request add some other "core" files: |
118 | 117 | if( $classKey == 'mwEmbed' ){ |
119 | 118 | // Output core components ( parts of mwEmbed that are in different files ) |
120 | 119 | $this->output .= jsClassLoader::getCombinedComponentJs( $this ); |
— | — | @@ -124,12 +123,15 @@ |
125 | 124 | // Output the current language class js |
126 | 125 | $this->output .= jsClassLoader::getLanguageJs( $this->langCode ); |
127 | 126 | |
128 | | - // Output the "common" css file |
129 | | - $this->output .= $this->getScriptText( 'mw.style.common' ); |
| 127 | + // Check that mwEmbed required style sheets are part of the request, |
| 128 | + // if not include them here |
| 129 | + // This is so mwEmbed requests gets basic interface css |
| 130 | + foreach( array('mw.style.mw-common', 'mw.style.jquery-ui-redmond' ) as $styleKey ){ |
| 131 | + if( !isset( $this->namedFileList[ $styleKey ] ) ) { |
| 132 | + $this->output .= $this->getScriptText( $styleKey ); |
| 133 | + } |
| 134 | + } |
130 | 135 | |
131 | | - // Output the jQuery ui theme css |
132 | | - $this->output .= $this->getScriptText( 'mw.style.redmond' ); |
133 | | - |
134 | 136 | // Output special IE comment tag to support special mwEmbed tags. |
135 | 137 | $this->notMinifiedTopOutput .='/*@cc_on\'video source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})@*/'."\n"; |
136 | 138 | } |
— | — | @@ -545,7 +547,7 @@ |
546 | 548 | |
547 | 549 | // Check for the requested classes |
548 | 550 | if ( $reqClassList ) { |
549 | | - // sanitize the class list and populate jsFileList |
| 551 | + // sanitize the class list and populate namedFileList |
550 | 552 | foreach ( $reqClassList as $reqClass ) { |
551 | 553 | if ( trim( $reqClass ) != '' ) { |
552 | 554 | if ( substr( $reqClass, 0, 3 ) == 'WT:' ) { |
— | — | @@ -565,7 +567,7 @@ |
566 | 568 | } |
567 | 569 | } |
568 | 570 | if( $doAddWT ){ |
569 | | - $this->jsFileList[$reqClass] = true; |
| 571 | + $this->namedFileList[$reqClass] = true; |
570 | 572 | $this->requestKey .= $reqClass; |
571 | 573 | $this->jsvarurl = true; |
572 | 574 | } |
— | — | @@ -578,7 +580,7 @@ |
579 | 581 | if( !$filePath ){ |
580 | 582 | $this->errorMsg .= 'Requested class: ' . xml::escapeJsString( $reqClass ) . ' not found' . "\n"; |
581 | 583 | }else{ |
582 | | - $this->jsFileList[ $reqClass ] = $filePath; |
| 584 | + $this->namedFileList[ $reqClass ] = $filePath; |
583 | 585 | $this->requestKey .= $reqClass; |
584 | 586 | } |
585 | 587 | } |
— | — | @@ -636,7 +638,7 @@ |
637 | 639 | |
638 | 640 | // Check for the requested classes |
639 | 641 | if ( $reqClassList && count( $reqClassList ) > 0 ) { |
640 | | - // Clean the class list and populate jsFileList |
| 642 | + // Clean the class list and populate namedFileList |
641 | 643 | foreach ( $reqClassList as $reqClass ) { |
642 | 644 | //do some simple checks: |
643 | 645 | if ( trim( $reqClass ) != '' ){ |
— | — | @@ -710,6 +712,7 @@ |
711 | 713 | global $wgScriptLoaderNamedPaths; |
712 | 714 | // Make sure the class is loaded: |
713 | 715 | jsClassLoader::loadClassPaths(); |
| 716 | + |
714 | 717 | if ( isset( $wgScriptLoaderNamedPaths[ $reqClass ] ) ) { |
715 | 718 | return $wgScriptLoaderNamedPaths[ $reqClass ]; |
716 | 719 | } else { |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | */ |
6 | 6 | var urlparts = getRemoteEmbedPath(); |
7 | 7 | var mwEmbedHostPath = urlparts[0]; |
8 | | -var mwRemoteVersion = 'r120'; |
| 8 | +var mwRemoteVersion = 'r121'; |
9 | 9 | var mwUseScriptLoader = true; |
10 | 10 | |
11 | 11 | // Log the mwRemote version ( will determine what version of js we get ) |
— | — | @@ -173,7 +173,6 @@ |
174 | 174 | function mwLoadPlayer( callback ){ |
175 | 175 | // the jsPlayerRequest includes both javascript and style sheets for the embedPlayer |
176 | 176 | var jsPlayerRequest = [ |
177 | | - 'mw.style.common', |
178 | 177 | 'mw.EmbedPlayer', |
179 | 178 | '$j.ui', |
180 | 179 | 'ctrlBuilder', |
— | — | @@ -194,7 +193,7 @@ |
195 | 194 | if ( navigator.userAgent && navigator.userAgent.indexOf("Firefox") != -1 ){ |
196 | 195 | jsPlayerRequest.push( 'nativeEmbed' ); |
197 | 196 | } |
198 | | - |
| 197 | + |
199 | 198 | loadMwEmbed( jsPlayerRequest, function() { |
200 | 199 | callback(); |
201 | 200 | }); |
Index: branches/js2-work/phase3/mwScriptLoader.php |
— | — | @@ -24,11 +24,14 @@ |
25 | 25 | * http://www.gnu.org/copyleft/gpl.html |
26 | 26 | */ |
27 | 27 | |
| 28 | +// Set a constant so the script-loader knows its not being used in "stand alone mode" |
| 29 | +define( 'SCRIPTLOADER_MEDIAWIKI', true); |
| 30 | + |
28 | 31 | //First do a quick static check for the cached file |
29 | | -define('MW_CACHE_SCRIPT_CHECK', true); |
30 | 32 | require_once( dirname(__FILE__) . '/js/mwEmbed/jsScriptLoader.php'); |
31 | 33 | $myScriptLoader = new jsScriptLoader(); |
32 | 34 | if( $myScriptLoader->outputFromCache() ){ |
| 35 | + // We do a simple exit call since we have not touch mediaWiki code yet |
33 | 36 | exit(); |
34 | 37 | } |
35 | 38 | |