r61988 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61987‎ | r61988 | r61989 >
Date:20:00, 4 February 2010
Author:dale
Status:deferred
Tags:
Comment:
* code comment updates for script-loader
* fix for empty pages in grabbing image properties
* removed autobuffer ( causing longer buffer time on media that is ready to be played)
* bumped remote version
* color fix for IE7 style sheet issues
Modified paths:
  • /branches/js2-work/phase3/js/editPage.js (modified) (history)
  • /branches/js2-work/phase3/js/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/includes/maintenance/mergeJavascriptMsg.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.proxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/genericEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Add_Media_Wizard.html (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/loader.js
@@ -16,7 +16,7 @@
1717 * Modules must define a loader.js file in the root
1818 * of the module folder.
1919 *
20 -* The loader file should be short and only include:
 20+* A loader file should only include:
2121 * Class paths of the module classes
2222 * Sytle sheets of the module
2323 * Loader function(s) that load module classes
@@ -47,27 +47,30 @@
4848 // Set the loaderContext for the classFiles paths call:
4949 mw.setConfig('loaderContext', '' );
5050
 51+/**
 52+ * Core set of mwEmbed classes:
 53+ */
5154 mw.addClassFilePaths( {
52 - "mwEmbed" : "mwEmbed.js",
53 - "window.jQuery" : "jquery/jquery-1.3.2.js",
 55+ "mwEmbed" : "mwEmbed.js",
 56+ "window.jQuery" : "jquery/jquery-1.3.2.js",
5457
55 - "ctrlBuilder" : "skins/ctrlBuilder.js",
56 - "kskinConfig" : "skins/kskin/kskinConfig.js",
57 - "mvpcfConfig" : "skins/mvpcf/mvpcfConfig.js",
 58+ "ctrlBuilder" : "skins/ctrlBuilder.js",
 59+ "kskinConfig" : "skins/kskin/kskinConfig.js",
 60+ "mvpcfConfig" : "skins/mvpcf/mvpcfConfig.js",
5861
59 - "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js",
60 - "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js",
61 - "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js",
62 - "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js",
63 - "$j.ui" : "jquery/jquery.ui/ui/ui.core.js",
 62+ "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js",
 63+ "$j.fn.autocomplete" : "jquery/plugins/jquery.autocomplete.js",
 64+ "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js",
 65+ "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js",
 66+ "$j.ui" : "jquery/jquery.ui/ui/ui.core.js",
6467
65 - "mw.testLang" : "tests/testLang.js",
 68+ "mw.testLang" : "tests/testLang.js",
6669
67 - "$j.cookie" : "jquery/plugins/jquery.cookie.js",
68 - "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js",
69 - "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js",
70 - "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js",
71 - "$j.browserTest" : "jquery/plugins/jquery.browserTest.js",
 70+ "$j.cookie" : "jquery/plugins/jquery.cookie.js",
 71+ "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js",
 72+ "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js",
 73+ "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js",
 74+ "$j.browserTest" : "jquery/plugins/jquery.browserTest.js",
7275
7376 "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js",
7477 "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js",
Index: branches/js2-work/phase3/js/mwEmbed/tests/Add_Media_Wizard.html
@@ -11,7 +11,7 @@
1212 border:medium none;
1313 }
1414 </style>
15 - <!--
 15+ <!--
1616 <script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
1717 -->
1818
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php
@@ -1,39 +1,50 @@
22 <?php
 3+/**
 4+ * The javascript class loader handles loading lists of available
 5+ * javascript classes into php from their defined locations in javascript.
 6+ */
37
48 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
59
610 class jsClassLoader {
 11+ // The list of mwEmbed modules that are enabled
712 private static $moduleList = array();
 13+
 14+ // Stores the contents of the combined loader.js files
815 private static $combinedLoadersJs = '';
 16+
 17+ // Reg Exp that supports extracting classes from loaders
918 private static $classReplaceExp = '/mw\.addClassFilePaths\s*\(\s*{(.*)}\s*\)\s*\;/siU';
1019
11 - private static $loadClassFlag = false;
 20+ // Flag to specify if the javascript class paths have been loaded.
 21+ private static $classesLoaded = false;
 22+
 23+ // The current directory context. Used in loading javascript modules outside of the mwEmbed folder
1224 private static $directoryContext = '';
 25+
1326 /**
1427 * Get the javascript class paths from javascript files
15 - *
16 - * Note:: if it is ~too costly~ to parse js we could cache in DB per file modified time
1728 */
1829 public static function loadClassPaths(){
1930 global $wgMwEmbedDirectory, $wgExtensionJavascriptLoader,
2031 $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $IP;
2132
22 - // Only run "once"
23 - if( self::$loadClassFlag )
 33+ // Only run once
 34+ if( self::$classesLoaded )
2435 return false;
25 - self::$loadClassFlag = true;
 36+ self::$classesLoaded = true;
2637
2738 // Load classes from mediaWiki $wgJSAutoloadLocalClasses var:
2839 $wgJSAutoloadClasses = array_merge( $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses );
2940
30 - // Load classes from mwEmbed.js
 41+ // Load javascript classes from mwEmbed.js
3142 if ( !is_file( $wgMwEmbedDirectory . 'mwEmbed.js' ) ) {
3243 // throw error no mwEmbed found
3344 throw new MWException( "mwEmbed.js missing check \$wgMwEmbedDirectory path\n" );
3445 return false;
3546 }
 47+
3648 // Read the mwEmbed loader file:
37 -
3849 $fileContent = file_get_contents( $wgMwEmbedDirectory . 'loader.js' );
3950
4051 // Get class paths from mwEmbed.js
@@ -63,6 +74,7 @@
6475 self::proccessLoaderPath( $IP . '/extensions/' . $loaderPath );
6576 }
6677 }
 78+
6779 /**
6880 * Process a loader path, passes off to proccessLoaderContent
6981 *
@@ -73,6 +85,7 @@
7486 $fileContent = file_get_contents( $path );
7587 self::proccessLoaderContent( $fileContent );
7688 }
 89+
7790 /**
7891 * Process loader content
7992 *
@@ -90,6 +103,7 @@
91104 $fileContent
92105 );
93106 }
 107+
94108 /**
95109 * Get the combined loader javascript
96110 *
@@ -99,6 +113,11 @@
100114 self::loadClassPaths();
101115 return self::$combinedLoadersJs;
102116 }
 117+
 118+ /**
 119+ * Build the list of modules from the mwEnabledModuleList replace callback
 120+ * @param String $jsvar Coma delimited list of modules
 121+ */
103122 private static function preg_buildModuleList( $jsvar ){
104123 global $wgMwEmbedDirectory;
105124 if(! isset( $jsvar[1] )){
@@ -113,8 +132,10 @@
114133 array_push( self::$moduleList, $moduleName );
115134 }
116135 }
 136+ // Enabled modules is not reused.
117137 return '';
118138 }
 139+
119140 /**
120141 * Adds javascript autoloader class names and paths
121142 * to $wgJSAutoloadClasses global
Index: branches/js2-work/phase3/js/mwEmbed/includes/maintenance/mergeJavascriptMsg.php
@@ -12,7 +12,7 @@
1313 exit();
1414 }
1515 define( 'MEDIAWIKI', true );
16 -// get the scriptLoader globals:
 16+// Get the scriptLoader globals:
1717 require_once( '../../jsScriptLoader.php' );
1818
1919 $mwSTART_MSG_KEY = '$messages[\'en\'] = array(';
@@ -33,7 +33,7 @@
3434 die();
3535 }
3636
37 -// get options (like override JS or override PHP)
 37+// Get options ( like override JS or override PHP )
3838 if ( in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
3939 print_help();
4040 }
@@ -96,14 +96,16 @@
9797 $jsFileText = file_get_contents( $fname );
9898 $mwPos = strpos( $fname, 'mwEmbed' ) + 7;
9999 $curFileName = substr( $fname, $mwPos );
100 - if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text
101 - $jsFileText,
102 - $matches ) ) {
 100+ // @@todo fix: will break down if someone does }) in their msg text
 101+ if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU',
 102+ $jsFileText,
 103+ $matches ) )
 104+ {
103105 $msgSet .= doJsonMerge( $matches[1] );
104106 }
105107 }
106108 }
107 -// rebuild and output to single php file if mergeToPHP is on
 109+// Rebuild and output to single php file if mergeToPHP is on
108110 if ( $mergeToPhp ) {
109111 if ( file_put_contents( $mwLangFilePath, trim( $preFile ) . "\n\t" . trim( $msgSet ) . "\n" . ltrim( $postFile ) ) ) {
110112 if( $showInfo )
@@ -111,7 +113,10 @@
112114 exit();
113115 }
114116 }
115 -
 117+/**
 118+ * Merges json messages into php file.
 119+ * @param string $json_txt Json text to be merged
 120+ */
116121 function doJsonMerge( $json_txt ) {
117122 global $curFileName, $fname, $messages, $mergeToJS, $jsFileText, $showInfo;
118123
@@ -126,7 +131,7 @@
127132 if ( count( $jmsg ) != 0 ) {
128133
129134 foreach ( $jmsg as $k => $v ) {
130 - // check if the existing value is changed and merge and merge ->right
 135+ // Check if the existing value is changed and merge and merge ->right
131136 if ( isset( $messages['en'][$k] ) ) {
132137 if ( $messages['en'][$k] != $v ) {
133138 $doReplaceFlag = true;
@@ -140,7 +145,7 @@
141146 } ;
142147 $outPhp .= "\t'{$k}' => '" . str_replace( '\'', '\\\'', $v ) . "',\n";
143148 }
144 - // merge the jsLanguage array back in and wrap the output
 149+ // Merge the jsLanguage array back in and wrap the output
145150 if ( $mergeToJS && $doReplaceFlag ) {
146151 $json = json_encode( $jsMsgAry );
147152 $json_txt = jsonReadable( $json );
@@ -151,8 +156,6 @@
152157 "mw.addMessages(" . $json_txt . ")",
153158 $jsFileText );
154159
155 - // print substr($str, 0, 600);
156 -
157160 if ( file_put_contents( $fname, $str ) ) {
158161 if( $showInfo )
159162 print "\nupdated $curFileName from php\n\n";
@@ -160,7 +163,7 @@
161164 die( "Could not write to: " . $fname );
162165 }
163166 }
164 - // return phpOut for building msgSet in outer function
 167+ // Return phpOut for building msgSet in outer function
165168 return $outPhp;
166169
167170 } else {
@@ -169,7 +172,11 @@
170173 return '';
171174 }
172175 }
173 -
 176+/**
 177+ * Formats a json string
 178+ *
 179+ * @param string $json Json string to be formated
 180+ */
174181 function jsonReadable( $json ) {
175182 $tabcount = 0;
176183 $result = '';
Index: branches/js2-work/phase3/js/mwEmbed/includes/noMediaWikiConfig.php
@@ -1,6 +1,10 @@
22 <?php
 3+/**
 4+ * No mediaWikiConfig sets variables for using the script-loader and mwEmbed modules
 5+ * without a complete mediaWiki install.
 6+ */
37
4 -//Optional set the path for google Closure Compiler ( for improved minification )
 8+// Optional set the path for google Closure Compiler ( for improved minification )
59 $wgClosureCompilerPath = false;
610 $wgJavaPath = false;
711
@@ -82,6 +86,19 @@
8387
8488 return @mkdir( $dir, $mode, true ); // PHP5 <3
8589 }
 90+
 91+/**
 92+ * Copied from mediaWIki GlobalFunctions.php wfMsgGetKey
 93+ *
 94+ * Fetch a message string value, but don't replace any keys yet.
 95+ * @param $key String
 96+ * @param $useDB Bool
 97+ * @param $langCode String: Code of the language to get the message for, or
 98+ * behaves as a content language switch if it is a boolean.
 99+ * @param $transform Boolean: whether to parse magic words, etc.
 100+ * @return string
 101+ * @private
 102+ */
86103 function wfMsgGetKey( $msgKey, $na, $langKey=false ) {
87104 global $messages, $mwLanguageCode;
88105 if(!$langKey){
@@ -93,8 +110,11 @@
94111 return '&lt;' . $msgKey . '&gt;';
95112 }
96113 }
97 -/* mediaWiki abstracts the json functions with fallbacks
98 -* here we just map directly to the call */
 114+
 115+/**
 116+ * mediaWiki abstracts the json functions with fallbacks
 117+ * here we just map directly to the call
 118+ */
99119 class FormatJson{
100120 public static function encode($value, $isHtml=false){
101121 return json_encode($value);
Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -179,7 +179,7 @@
180180 if ( $j( '#gnp_' + embedPlayer.id ).length == 0 ) {
181181 var toppos = ( embedPlayer.instanceOf == 'mvPlayList' ) ? 25 : 10;
182182 $j( this ).append( '<div id="gnp_' + embedPlayer.id + '" class="ui-state-highlight ui-corner-all" ' +
183 - 'style="position:absolute;display:none;background:#FFF;top:' + toppos + 'px;left:10px;right:10px;">' +
 183+ 'style="position:absolute;display:none;background:#FFF;color:#111;top:' + toppos + 'px;left:10px;right:10px;">' +
184184 gM( 'mwe-for_best_experience' ) +
185185 '<br><input id="ffwarn_' + embedPlayer.id + '" type=\"checkbox\">' +
186186 gM( 'mwe-do_not_warn_again' ) +
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -2421,12 +2421,15 @@
24222422 mw.getJSON( this.local_wiki_api_url, request, function( data ) {
24232423 if ( data.query.pages ) {
24242424 for ( var i in data.query.pages ) {
 2425+ if( i == '-1' ){
 2426+ callback( false );
 2427+ return ;
 2428+ }
24252429 for ( var j in data.query.pages[i] ) {
24262430 if ( j == 'missing'
24272431 && data.query.pages[i].imagerepository != 'shared'
24282432 && data.query.pages[i].imagerepository != 'commons' )
2429 - {
2430 - mw.log( fileName + " not found" );
 2433+ {
24312434 callback( false );
24322435 return;
24332436 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/genericEmbed.js
@@ -11,8 +11,10 @@
1212 'time_display':false,
1313 'volume_control':false
1414 },
 15+
1516 // Instance name:
1617 instanceOf:'genericEmbed',
 18+
1719 /*
1820 * Generic embed html
1921 *
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/nativeEmbed.js
@@ -61,8 +61,7 @@
6262 var eb = '<video ' +
6363 'id="' + this.pid + '" ' +
6464 'style="width:' + this.width + 'px;height:' + this.height + 'px;" ' +
65 - 'width="' + this.width + '" height="' + this.height + '" ' +
66 - 'autobuffer="true" ' +
 65+ 'width="' + this.width + '" height="' + this.height + '" ' +
6766 'autoplay="true" ' +
6867 'src="' + this.getSrc() + '" >' +
6968 '</video>';
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.proxy.js
@@ -158,8 +158,8 @@
159159 }
160160 var pUri = mw.parseUri( $.proxy.server_frame );
161161
162 - // FIXME we should have a Hosted iframe once we deploy mwEmbed on the servers.
163 - // A hosted iframe would be much faster since than a normal page view
 162+ // FIXME we should have a Hosted page once we deploy mwEmbed on the servers.
 163+ // A hosted page would be much faster since than a normal page view rewrite
164164
165165 var login_url = pUri.protocol + '://' + pUri.host;
166166 login_url += pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' );
@@ -326,17 +326,11 @@
327327 }
328328
329329 // FIXME Add in user based approval ::
330 -
331 - // offer the user the ability to "approve" requested domain save to
332 - // their user/ apiProxyDomainList.js page
333330
334 - // FIXME grab the users whitelist for our current domain
335 - /*var local_api = wgScriptPath + '/index' + wgScriptExtension + '?title=' +
336 - 'User:' + wgUserName + '/apiProxyDomainList.js' +
337 - '&action=raw&smaxage=0&gen=js';
338 - $j.get( local_api, function( data ){
339 - debugger;
340 - });*/
 331+ // FIXME grab the users whitelist for our current domain
 332+
 333+ // FIXME offer the user the ability to "approve" requested domain save to
 334+ // their user/ apiProxyDomainList.js page ( or better some user-prefrence setup )
341335
342336 }
343337
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -3,7 +3,7 @@
44 * For details see: http://www.mediawiki.org/wiki/MwEmbed
55 *
66 * All MediaWiki code is released under the GPL2.
7 - * For more information visit http://metavid.org/wiki/Code
 7+ * also see: http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/COPYING?view=markup
88 *
99 * @author Michael Dale ( mdale at wikimedia.org )
1010 * @author and many others, see svn log for details
@@ -11,7 +11,7 @@
1212 * mwEmbed uses the following libraries:
1313 *
1414 * jQuery:
15 - * http://jquery.com/
 15+ * http://jquery.com/ & jquery.ui
1616 *
1717 * mw.parseUri:
1818 * http://stevenlevithan.com/demo/parseuri/js/
@@ -1370,7 +1370,8 @@
13711371 * callback parameter is not needed we setup the callback automatically
13721372 * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param
13731373 * format is set to "json" automatically
1374 - * automatically issues request over "POST" if action={postActions}
 1374+ * automatically issues request over "POST"
 1375+ * ( If the api specifices the action must be done over a post request )
13751376 * automatically will setup apiProxy where needed.
13761377 *
13771378 * @param {Mixed} url or data request
@@ -1453,10 +1454,10 @@
14541455 }
14551456
14561457 /**
1457 - * Checks if a mw request data requires a proxy or not
 1458+ * Checks if a mw request data requires a post request or not
14581459 * @param {Object}
14591460 * @return {Boolean}
1460 - * true if the request requires a proxy
 1461+ * true if the request requires a post request
14611462 * false if the request does not
14621463 */
14631464 mw.checkRequestPost = function ( data ){
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php
@@ -11,12 +11,16 @@
1212
1313 // Check if we are being invoked in a MediaWiki context or stand alone usage:
1414 if ( !defined( 'MEDIAWIKI' ) && !defined( 'MW_CACHE_SCRIPT_CHECK' ) ){
 15+
1516 // Load noMediaWiki helper for quick cache result
1617 $myScriptLoader = new jsScriptLoader();
 18+
1719 if( $myScriptLoader->outputFromCache() )
1820 exit();
 21+
1922 //Else load up all the config and do normal stand alone ScriptLoader process:
2023 require_once( realpath( dirname( __FILE__ ) ) . '/includes/noMediaWikiConfig.php' );
 24+
2125 $myScriptLoader->doScriptLoader();
2226 }
2327
@@ -156,8 +160,8 @@
157161 /**
158162 * Get Minified js
159163 *
160 - * Takes the $js_string input
161 - * and
 164+ * @param {String} $js_string Javascript string to be minified
 165+ * @param {String} $requestKey Unique key for minification
162166 * @return minified javascript value
163167 */
164168 static function getMinifiedJs( & $js_string, $requestKey='' ){
@@ -176,6 +180,11 @@
177181 // Do the minification using php JSMin
178182 return JSMin::minify( $js_string );
179183 }
 184+ /**
 185+ * Optional function to use the google closer compiler to minify js
 186+ * @param {String} $js_string Javascript string to be minified
 187+ * @param {String} $requestKey request key used for temporary name in closure compile
 188+ */
180189 static function getClosureMinifiedJs( & $js_string, $requestKey=''){
181190 if( !is_file( $wgJavaPath ) || ! is_file( $wgClosureCompilerPath ) ){
182191 return false;
@@ -214,7 +223,7 @@
215224 return false;
216225 }
217226 /**
218 - * Gets Script Text
 227+ * Get the javascript text content from a given classKey
219228 *
220229 * @param {String} $classKey Class Key to grab text for
221230 * @param {String} [$file_name] Optional file path to get js text
@@ -268,21 +277,12 @@
269278 }else{
270279 // Dealing with files
271280
272 - // Check that the filename ends with .js and does not include ../ traversing
273 - if ( substr( $file_name, -3 ) != '.js' ) {
274 - $this->errorMsg .= "\nError file name must end with .js: " . htmlspecialchars( $file_name ) . " \n ";
275 - return false;
276 - }
277 - if ( strpos( $file_name, '../' ) !== false ) {
278 - $this->errorMsg .= "\nError file name must not traverse paths: " . htmlspecialchars( $file_name ) . " \n ";
279 - return false;
280 - }
281 -
282281 if ( trim( $file_name ) != '' ) {
283 - if ( $this->debug )
284 - $jsout .= "\n/**\n* File: " . htmlspecialchars( $file_name ) . "\n*/\n";
 282+ if ( $this->debug ){
 283+ $jsout .= "\n/**\n* File: " . htmlspecialchars( $file_name ) . "\n*/\n";
 284+ }
285285
286 - $jsFileStr = $this->doGetJsFile( $file_name ) . "\n";
 286+ $jsFileStr = $this->getFileContents( $file_name ) . "\n";
287287 if( $jsFileStr ){
288288 return $jsout . $jsFileStr;
289289 }else{
@@ -354,7 +354,8 @@
355355 }
356356
357357 /**
358 - * Post process request uses globals, configuration and mediaWiki to test wiki-titles and files exist etc.
 358+ * Post process request uses globals, configuration to
 359+ * validate classes and generate request key
359360 */
360361 function postProcRequestVars(){
361362 global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses,
@@ -444,8 +445,10 @@
445446 }
446447 }
447448 /**
448 - * Pre-process request variables ~without configuration~ or any utility functions
449 - * This is to quickly get a requestKey that we can check against the cache
 449+ * Pre-process request variables ~without configuration~ or any utility functions.
 450+ *
 451+ * This is to quickly get a requestKey that we can check against the cache,
 452+ * request key validation is done in postProcRequestVars
450453 */
451454 function preProcRequestVars() {
452455 $requestKey = '';
@@ -553,9 +556,21 @@
554557 * @param {String} $filePath File to get
555558 * @return {String} of the file contents
556559 */
557 - function doGetJsFile( $filePath ) {
 560+ function getFileContents( $filePath ) {
558561 global $IP;
559562
 563+ // Check that the filename ends with .js
 564+ if ( substr( $filePath, -3 ) != '.js' ) {
 565+ $this->errorMsg .= "\nError file name must end with .js: " . htmlspecialchars( $filePath ) . " \n ";
 566+ return false;
 567+ }
 568+
 569+ // Check the file does not include ../ traversing
 570+ if ( strpos( $filePath, '../' ) !== false ) {
 571+ $this->errorMsg .= "\nError file name must not traverse paths: " . htmlspecialchars( $filePath ) . " \n ";
 572+ return false;
 573+ }
 574+
560575 // Load the file
561576 wfSuppressWarnings();
562577 $str = file_get_contents( "{$IP}/{$filePath}" );
@@ -580,9 +595,11 @@
581596 */
582597 function doProcessJs( $str ){
583598 global $wgEnableScriptLocalization;
 599+
584600 // Strip out js_log debug lines (if not in debug mode)
585 - if( !$this->debug )
 601+ if( !$this->debug ){
586602 $str = preg_replace('/\n\s*mw\.log\(([^\)]*\))*\s*[\;\n]/U', "\n", $str);
 603+ }
587604
588605 // Do language swap by index:
589606 if ( $wgEnableScriptLocalization ){
@@ -593,7 +610,7 @@
594611 return substr($str, 0, $inx['s']-1) . $translated . substr($str, $inx['e']+1);
595612 }
596613 }
597 - //return the js str unmodified if we did not transform with the localisation.
 614+ // Return the js str unmodified if we did not transform with the localisation.
598615 return $str;
599616 }
600617
@@ -641,6 +658,7 @@
642659 }
643660 }
644661 }
 662+
645663 /**
646664 * Generates an in-line addMessege call for page output.
647665 * For use with OutputPage when the script-loader is disabled.
@@ -658,6 +676,7 @@
659677 return '';
660678 }
661679 }
 680+
662681 /**
663682 * Get the set of message associated with a given javascript class
664683 *
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js
@@ -4,7 +4,7 @@
55 */
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
8 -var mwRemoteVersion = 'r89';
 8+var mwRemoteVersion = 'r90';
99 var mwUseScriptLoader = true;
1010
1111 //Log the mwRemote version ( will determine what version of js we get )
Index: branches/js2-work/phase3/js/loader.js
@@ -5,8 +5,8 @@
66 mw.setConfig('loaderContext', wgScriptPath + '/js/');
77
88 mw.addClassFilePaths( {
9 - 'uploadPage' => 'js/uploadPage.js',
10 - 'editPage' => 'js/editPage.js',
11 - 'ajaxCategories' => 'js/ajaxcategories.js',
12 - 'apiProxyPage' => 'js/apiProxyPage.js'
 9+ 'uploadPage' : 'js/uploadPage.js',
 10+ 'editPage' : 'js/editPage.js',
 11+ 'ajaxCategories': 'js/ajaxcategories.js',
 12+ 'apiProxyPage' : 'js/apiProxyPage.js'
1313 } );
\ No newline at end of file
Index: branches/js2-work/phase3/js/editPage.js
@@ -56,7 +56,7 @@
5757 setTimeout( function() {
5858 if ( $j( '#btn-add-media-wiz' ).length == 0 && $j( '#toolbar' ).length != 0 ) {
5959 mw.log( 'Do old toolbar bind:' );
60 - didWikiEditorBind = true;
 60+ didWikiEditorBind = true;
6161 $j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' +
6262 mw.getConfig( 'images_path' ) + 'Button_add_media.png">' );
6363

Status & tagging log