r67658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67657‎ | r67658 | r67659 >
Date:18:45, 8 June 2010
Author:dale
Status:deferred
Tags:
Comment:
* added missing return runTriggersCallback callback
* some fixes for messages output ( avoid back trace substitution)
* added some release notes
Modified paths:
  • /trunk/extensions/JS2Support/ScriptLoaderOutputPage.php (modified) (history)
  • /trunk/extensions/JS2Support/mwEmbed/README (modified) (history)
  • /trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php (modified) (history)
  • /trunk/extensions/JS2Support/mwEmbed/mwEmbed.js (modified) (history)

Diff [purge]

Index: trunk/extensions/JS2Support/ScriptLoaderOutputPage.php
@@ -246,23 +246,23 @@
247247 // If script-loader enabled check if we can add the script via script-loader
248248 if( $this->isScriptGroupingEnabled() ) {
249249 global $wgStylePath, $wgScript;
250 -
251 - // Append style path if a relative path
 250+
 251+ // Append style path if a relative path
252252 if( substr( $style, 0, 1 ) == '/' ){
253253 // already absolute path don't modify path
254 -
 254+
255255 } else if (
256256 substr( $style, 0, 5 ) == 'http:' ||
257257 substr( $style, 0, 6 ) == 'https:' ) {
258 -
259 - // Remote css can't group:
 258+
 259+ // Remote css can't group:
260260 $this->styles[ $style ] = $options;
261 -
 261+
262262 } else {
263263 // Relative core skin path append $wgStylePath
264264 $style = $wgStylePath ."/". $style;
265265 }
266 -
 266+
267267 $cssClass = $this->getClassFromPath( $style );
268268 if( $cssClass ) {
269269 $this->addScriptClass( $cssClass, $bucketKey, 'css');
@@ -298,6 +298,10 @@
299299 // No dir for bucket key since dir does not require a separate bucket.
300300 unset( $options['dir'] );
301301 $bucketKey = implode( '.', $options );
 302+ // If an empty bucket put into the allpage bucket
 303+ if( trim( $bucketKey) == '' ){
 304+ $bucketKey = 'allpage';
 305+ }
302306
303307 // Update the css bucket options:
304308 $this->setClassBucketOptions( $bucketKey, $options );
@@ -372,10 +376,13 @@
373377 $wgScriptLoaderNamedPaths, $wgScriptPath;
374378
375379 // Set core Classes and styles:
376 - $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' , 'mw.style.mwCommon' );
 380+ $coreClasses = array( 'wikibits', 'window.jQuery', 'mwEmbed' );
377381
 382+ // Include the core css
 383+ $this->addStyleClass( 'mw.style.mwCommon' );
378384
379385
 386+
380387 // Merge in any scripts that have been set as "allpage"
381388 // Since the all page are on every page view they should just be part of the core
382389 // script request.
@@ -383,6 +390,7 @@
384391 $coreClasses = array_merge($coreClasses, $this->mScriptLoaderClassList[ 'js' ][ 'allpage' ] );
385392 }
386393
 394+
387395 // Make sure scripts are the first scripts include on the page.
388396 // Some extensions directly modify $this->mScripts early on and break
389397 // order of includes.
Index: trunk/extensions/JS2Support/mwEmbed/mwEmbed.js
@@ -2287,6 +2287,7 @@
22882288 if( ! $j( targetObject ).data( 'events' ) ||
22892289 ! $j( targetObject ).data( 'events' )[ triggerName ] ) {
22902290 callback();
 2291+ return ;
22912292 }
22922293 var callbackCount = $j( targetObject ).data( 'events' )[ triggerName ].length;
22932294 if( !callbackCount ){
Index: trunk/extensions/JS2Support/mwEmbed/README
@@ -1,7 +1,5 @@
2 -***********************************************
 2+*********************************************** test
33 *
4 -* mwEmbed version 1.1
5 -*
64 * For an overview of all mwEmbed files see:
75 * http://www.mediawiki.org/wiki/MwEmbed
86 *
@@ -11,9 +9,14 @@
1210 * All mwEmbed code is Released under the GPL2 as
1311 * a stand alone component of mediaWiki
1412 *
15 -* Libraries used include their licence info in their included path
 13+* Libraries used include their license info in their included path
1614 *
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>,
1821 * and many others.
1922 *
2023 * This program is free software; you can redistribute it and/or modify
@@ -31,4 +34,4 @@
3235 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3336 * http://www.gnu.org/copyleft/gpl.html
3437 *
35 -*********************************************
\ No newline at end of file
 38+*********************************************
Index: trunk/extensions/JS2Support/mwEmbed/jsScriptLoader.php
@@ -60,6 +60,9 @@
6161 // The includeAllModuleMessages string regular expression
6262 private static $includeAllMsgsRegEx = "/mw\.includeAllModuleMessages\s*\(\s*\)\;?/";
6363
 64+ //Temporary store for message js
 65+ private static $addMessageJs = '';
 66+
6467 /**
6568 * Output the javascript from cache
6669 *
@@ -98,7 +101,7 @@
99102 try {
100103 jsClassLoader::loadClassPaths();
101104 } catch( Exception $e ) {
102 - $this->errorMsg .= $e->getMessage() ;
 105+ $this->errorMsg .= $e->getMessage() ;
103106 }
104107
105108 // Reset the requestKey:
@@ -148,15 +151,15 @@
149152 // Output the current language class js
150153 $this->output .= jsClassLoader::getLanguageJs( $this->langCode );
151154
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+ /*
156159 if( !isset( $this->namedFileList[ 'mw.style.mwCommon' ] ) ) {
157160 $this->output .= $this->getScriptText( 'mw.style.mwCommon' );
158161 }
159162 */
160 -
 163+
161164 // Output "special" IE comment tag to support "special" mwEmbed tags.
162165 $this->notMinifiedTopOutput .='/*@cc_on@if(@_jscript_version<9){\'video audio source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n";
163166 }
@@ -725,7 +728,7 @@
726729 try {
727730 jsClassLoader::loadClassPaths();
728731 } catch( Exception $e ) {
729 - $this->errorMsg .= $e->getMessage() ;
 732+ $this->errorMsg .= $e->getMessage() ;
730733 }
731734
732735 if ( isset( $wgScriptLoaderNamedPaths[ $reqClass ] ) ) {
@@ -813,13 +816,23 @@
814817
815818 // Do language swap by index:
816819 if ( $wgEnableScriptLocalization ){
817 - // Get the mw.addMessage javascript from scriptText and moduleName
818 - $addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName);
819820 //@@NOTE getAddMessagesFromClass could identify which mode we are in and we would not need to
820821 // try each of these search patterns in the same order as before.
821822
 823+ // Get the mw.addMessage javascript
 824+ self::$addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName);
 825+
822826 // 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+
824837 if( $count != 0 ){
825838 return $scriptText;
826839 }
@@ -828,21 +841,23 @@
829842 $inx = self::getAddMessagesIndex( $scriptText );
830843 if( $inx ){
831844 // 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']);
833846 }
834847
835848 // Replace mw.addMessageKeys with localized msgs in javascript string
836849 $inx = self::getAddMessageKeyIndex( $scriptText );
837850 if( $inx ) {
838851 // 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']);
840853 }
841854 }
842855 // Return the javascript str unmodified if we did not transform with the localisation
843856 return $scriptText;
844857 }
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+ }
847862 /**
848863 * Get the "addMesseges" function index ( for replacing msg text with localized json )
849864 *

Status & tagging log