r66243 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66242‎ | r66243 | r66244 >
Date:23:52, 11 May 2010
Author:dale
Status:deferred
Tags:
Comment:
some fixes for raw file mode ( wgEnableScriptLoader = false )
Modified paths:
  • /trunk/extensions/JS2Support/ScriptLoaderOutputPage.php (modified) (history)
  • /trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php (modified) (history)

Diff [purge]

Index: trunk/extensions/JS2Support/ScriptLoaderOutputPage.php
@@ -287,6 +287,8 @@
288288 // Set core Classes
289289 $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' );
290290
 291+
 292+
291293 // Merge in any scripts that have been set as "allpage"
292294 // Since the all page are on every page view they should just be part of the core
293295 // script request.
@@ -309,10 +311,23 @@
310312 foreach( $coreClasses as $className ){
311313 $this->addScriptClass( $className );
312314 }
 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+
313322 // Also add the "loader" classes ( script-loader won't run them )
314323 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+ ) );
315330 $this->addScriptFile(
316 - "$wgScriptPath/extensions/$loaderPath"
 331+ "$wgScriptPath/$loaderPath"
317332 );
318333 }
319334 }
@@ -408,7 +423,7 @@
409424 * @param $type 'js' or 'css' for type of head item being included
410425 * @return boolean False if the class wasn't found, True on success
411426 */
412 -function addScriptClass( $className, $scriptRequestBucket = 'page' , $type='js') {
 427+ function addScriptClass( $className, $scriptRequestBucket = 'page' , $type='js') {
413428 global $wgDebugJavaScript, $wgScriptLoaderNamedPaths, $IP,
414429 $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath,
415430 $wgUser;
Index: trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php
@@ -159,15 +159,19 @@
160160 // Save to the file cache
161161 if ( $wgUseFileCache && !$this->debug ) {
162162 $status = $this->sFileCache->saveToFileCache( $this->output );
163 - if ( $status !== true )
164 - $this->errorMsg .= $status;
 163+ if ( $status !== true ) {
 164+ $this->errorMsg .= $status;
 165+ }
165166 }
166167
167168 // Check for an error msg
168169 if ( $this->errorMsg != '' ) {
169170 //just set the content type (don't send cache header)
170171 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";
172176 echo trim( $this->output );
173177 } else {
174178 // All good, let's output "cache" headers
@@ -923,7 +927,7 @@
924928 function getInlineMsgFromClass( $class ){
925929 $messageSet = $this->getMsgKeysFromClass( $class );
926930 if( $messageSet ){
927 - self::updateMessageValues ( $messageSet );
 931+ self::updateMessageValues ( $messageSet , $this->langCode );
928932 return 'mw.addMessages(' . FormatJson::encode( $messageSet ) . ');';
929933 }else{
930934 //if could not parse return empty string:

Status & tagging log