Index: trunk/extensions/JS2Support/ScriptLoaderOutputPage.php |
— | — | @@ -287,6 +287,8 @@ |
288 | 288 | // Set core Classes |
289 | 289 | $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' ); |
290 | 290 | |
| 291 | + |
| 292 | + |
291 | 293 | // Merge in any scripts that have been set as "allpage" |
292 | 294 | // Since the all page are on every page view they should just be part of the core |
293 | 295 | // script request. |
— | — | @@ -309,10 +311,23 @@ |
310 | 312 | foreach( $coreClasses as $className ){ |
311 | 313 | $this->addScriptClass( $className ); |
312 | 314 | } |
| 315 | + |
| 316 | + // Add the mwEmbed "core-components" ( language, parsing etc ) |
| 317 | + $coreComponets = jsClassLoader::getComponentsList(); |
| 318 | + foreach( $coreComponets as $className ) { |
| 319 | + $this->addScriptClass( $className ); |
| 320 | + } |
| 321 | + |
313 | 322 | // Also add the "loader" classes ( script-loader won't run them ) |
314 | 323 | foreach( $wgExtensionJavascriptLoader as $loaderPath){ |
| 324 | + // Set the loader context for each loader javascript file |
| 325 | + // ( so that javascript modules can use relative paths ) |
| 326 | + $loaderDir = dirname( "$wgScriptPath/$loaderPath" ) . "/"; |
| 327 | + $this->addScript( Html::inlineScript( |
| 328 | + "mw.setConfig( 'loaderContext', '" . xml::escapeJsString( $loaderDir ) . "');" |
| 329 | + ) ); |
315 | 330 | $this->addScriptFile( |
316 | | - "$wgScriptPath/extensions/$loaderPath" |
| 331 | + "$wgScriptPath/$loaderPath" |
317 | 332 | ); |
318 | 333 | } |
319 | 334 | } |
— | — | @@ -408,7 +423,7 @@ |
409 | 424 | * @param $type 'js' or 'css' for type of head item being included |
410 | 425 | * @return boolean False if the class wasn't found, True on success |
411 | 426 | */ |
412 | | -function addScriptClass( $className, $scriptRequestBucket = 'page' , $type='js') { |
| 427 | + function addScriptClass( $className, $scriptRequestBucket = 'page' , $type='js') { |
413 | 428 | global $wgDebugJavaScript, $wgScriptLoaderNamedPaths, $IP, |
414 | 429 | $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath, |
415 | 430 | $wgUser; |
Index: trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php |
— | — | @@ -159,15 +159,19 @@ |
160 | 160 | // Save to the file cache |
161 | 161 | if ( $wgUseFileCache && !$this->debug ) { |
162 | 162 | $status = $this->sFileCache->saveToFileCache( $this->output ); |
163 | | - if ( $status !== true ) |
164 | | - $this->errorMsg .= $status; |
| 163 | + if ( $status !== true ) { |
| 164 | + $this->errorMsg .= $status; |
| 165 | + } |
165 | 166 | } |
166 | 167 | |
167 | 168 | // Check for an error msg |
168 | 169 | if ( $this->errorMsg != '' ) { |
169 | 170 | //just set the content type (don't send cache header) |
170 | 171 | header( 'Content-Type: text/javascript' ); |
171 | | - echo 'alert(\'Error With ScriptLoader ::' . str_replace( "\n", '\'+"\n"+' . "\n'", $this->errorMsg ) . '\');'; |
| 172 | + echo 'alert(\'Error With ScriptLoader ::' . |
| 173 | + str_replace( "\n", '\'+"\n"+' . "\n'", |
| 174 | + xml::escapeJsString( $this->errorMsg ) |
| 175 | + ) . '\');'."\n"; |
172 | 176 | echo trim( $this->output ); |
173 | 177 | } else { |
174 | 178 | // All good, let's output "cache" headers |
— | — | @@ -923,7 +927,7 @@ |
924 | 928 | function getInlineMsgFromClass( $class ){ |
925 | 929 | $messageSet = $this->getMsgKeysFromClass( $class ); |
926 | 930 | if( $messageSet ){ |
927 | | - self::updateMessageValues ( $messageSet ); |
| 931 | + self::updateMessageValues ( $messageSet , $this->langCode ); |
928 | 932 | return 'mw.addMessages(' . FormatJson::encode( $messageSet ) . ');'; |
929 | 933 | }else{ |
930 | 934 | //if could not parse return empty string: |