From 60e6186f29c145e6e3c93dde65a6bca0a232c31c Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Sat, 24 Oct 2009 21:32:53 +0000 Subject: [PATCH] * improved script loader language support ** supports url language code parameter * improved performance on cached hit ( apache bench mark goes from old: Rps: 23.40 [#/sec] new: Rps: 378.61 [#/sec] ** we don't check existence of wiki title until after cache file check. ** we don't load all includes/WebStart.php before checking cache * some remote search bug ** improved speed and accuracy of language swapping ( token check no breakage with }) in msg text limitation * improved core js2 performance in parsing class defines from mv_embed.js ** only reads 8k of head at a time. * reduced expire time to one day (instead of one year on script requests) * removed $wgEnableScriptMinify (just use debug or ?debug instead) --- includes/DefaultSettings.php | 6 - includes/OutputPage.php | 29 +- js2/apiProxyPage.js | 3 + js2/mwEmbed/jsScriptLoader.php | 317 ++++++++++++------ .../libAddMedia/mvBaseUploadInterface.js | 4 +- js2/mwEmbed/libAddMedia/mvFirefogg.js | 51 +-- js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 15 +- .../libAddMedia/searchLibs/flickrSearch.js | 2 +- js2/mwEmbed/mv_embed.js | 317 ++++++++---------- js2/mwEmbed/php/jsAutoloadLocalClasses.php | 24 +- js2/mwEmbed/php/languages/mwEmbed.i18n.php | 4 +- js2/mwEmbed/php/noMediaWikiConfig.php | 21 +- js2/mwEmbed/tests/testApiProxy.html | 2 +- mwScriptLoader.php | 24 +- mwScriptLoader.php5 | 2 +- 15 files changed, 441 insertions(+), 380 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ef0166aec3..a5316f7e2f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2812,12 +2812,6 @@ $wgEnableJS2system = false; */ $wgEnableIframeApiProxy = false; -/* - * boolean; if we should minify the output. (note if you send ?debug=true in - * the page request it will automatically not group and not minify) - */ -$wgEnableScriptMinify = true; - /* * boolean; if we should enable javascript localization (it loads loadGM json * call with mediaWiki msgs) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 7879cbbb4e..146269b0e3 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -187,8 +187,7 @@ class OutputPage { $this->mScripts = ''; if( $wgEnableScriptLoader ){ - //directly add script_loader call - //(separate from other scriptloader calls that may include extensions with conditional js) + //directly add script_loader call for addCoreScripts2Top $this->mScripts = $this->getScriptLoaderJs( $core_classes ); } else { $so = ''; @@ -226,12 +225,11 @@ class OutputPage { } else { $path = $wgScriptPath . '/' . $path; } - $urlAppend = ( $wgDebugJavaScript ) ? time() : $this->getURIDparam( $js_class ); - $this->addScript( Html::linkedScript( "$path?$urlAppend" ) ); + $this->addScript( Html::linkedScript( $path . "?" . $this->getURIDparam( $js_class ) ) ); //merge in language text (if js2 is on and we have loadGM function) if( $wgEnableJS2system ){ - $inlineMsg = jsScriptLoader::getLocalizedMsgsFromClass( $js_class ); + $inlineMsg = jsScriptLoader::getInlineLoadGMFromClass( $js_class ); if( $inlineMsg != '' ) $this->addScript( Html::inlineScript( $inlineMsg )); } @@ -269,6 +267,9 @@ class OutputPage { */ function getURIDparam( $classAry = array() ) { global $wgDebugJavaScript, $wgStyleVersion, $IP, $wgScriptModifiedCheck; + global $wgContLanguageCode; + + if( $wgDebugJavaScript ) { return 'urid=' . time(); } else { @@ -307,6 +308,10 @@ class OutputPage { if( $frev != 0 ) $urid.= "_" . $frev; + + //Always the language key param to keep urls distinct per language + $urid.='&lang='.$wgContLanguageCode; + return $urid; } } @@ -589,24 +594,24 @@ class OutputPage { public function getOnloadHandler() { return $this->mOnloadHandler; } public function disable() { $this->mDoNothing = true; } public function isDisabled() { return $this->mDoNothing; } - + public function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; } - + public function setFeedAppendQuery( $val ) { global $wgFeedClasses; - + $this->mFeedLinks = array(); - + foreach( $wgFeedClasses as $type => $class ) { $query = "feed=$type&".$val; $this->mFeedLinks[$type] = $this->getTitle()->getLocalURL( $query ); } } - + public function addFeedLink( $format, $href ) { $this->mFeedLinks[$format] = $href; } - + public function isSyndicated() { return count($this->mFeedLinks); } public function setArticleRelated( $v ) { @@ -1940,7 +1945,7 @@ class OutputPage { * Return URLs for each supported syndication format for this page. * @return array associating format keys with URLs */ - public function getSyndicationLinks() { + public function getSyndicationLinks() { return $this->mFeedLinks; } diff --git a/js2/apiProxyPage.js b/js2/apiProxyPage.js index 0619e4abc1..8e2a99471e 100644 --- a/js2/apiProxyPage.js +++ b/js2/apiProxyPage.js @@ -7,6 +7,9 @@ /* * since this is proxy server set a pre-append debug flag to know which debug msgs are coming from where */ + +mwConfig['debug_pre'] = 'Proxy'; + if( !mwApiProxyConfig ) var mwApiProxyConfig = {}; diff --git a/js2/mwEmbed/jsScriptLoader.php b/js2/mwEmbed/jsScriptLoader.php index 3cc5e2ec43..c627290cbc 100644 --- a/js2/mwEmbed/jsScriptLoader.php +++ b/js2/mwEmbed/jsScriptLoader.php @@ -5,17 +5,22 @@ */ // Check if we are being invoked in a MediaWiki context or stand alone usage: -if ( !defined( 'MEDIAWIKI' ) ) { +//setup the script local script cache directory (has to be hard coded rather than config based for fast non-mediawiki hits +$wgScriptCacheDirectory = realpath( dirname( __FILE__ ) ) . '/php/script-cache'; + +if ( !defined( 'MEDIAWIKI' ) && !defined( 'MW_CACHE_SCRIPT_CHECK' ) ){ // Load noMediaWiki helper - require_once( realpath( dirname( __FILE__ ) ) . '/php/noMediaWikiConfig.php' ); $myScriptLoader = new jsScriptLoader(); + if( $myScriptLoader->outputFromCache() ) + exit(); + //else load up all the config and do normal doScriptLoader process: + require_once( realpath( dirname( __FILE__ ) ) . '/php/noMediaWikiConfig.php' ); $myScriptLoader->doScriptLoader(); -} else { - $wgExtensionMessagesFiles['mwEmbed'] = realpath( dirname( __FILE__ ) ) . '/php/mwEmbed.i18n.php'; } class jsScriptLoader { var $jsFileList = array(); + var $langCode = ''; var $jsout = ''; var $rKey = ''; // the request key var $error_msg = ''; @@ -23,32 +28,39 @@ class jsScriptLoader { var $jsvarurl = false; // whether we should include generated JS (special class '-') var $doProcReqFlag = true; - //@@todo fix: will break down if someone does }) in their msg text - const loadGMregEx = '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU'; + function outputFromCache(){ + // Process the request + $this->rKey = $this->preProcRequestVars(); + // Setup file cache object + $this->sFileCache = new simpleFileCache( $this->rKey ); + if ( $this->sFileCache->isFileCached() ) { + // Just output headers so we can use PHP's @readfile:: + $this->outputJsHeaders(); + $this->sFileCache->outputFromFileCache(); + return true; + } + return false; + } function doScriptLoader() { global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $IP, - $wgEnableScriptMinify, $wgUseFileCache; + $wgEnableScriptMinify, $wgUseFileCache, $wgExtensionMessagesFiles; - // Process the request - $this->procRequestVars(); + //load the ExtensionMessagesFiles + $wgExtensionMessagesFiles['mwEmbed'] = realpath( dirname( __FILE__ ) ) . '/php/languages/mwEmbed.i18n.php'; - // If the cache is on and the file is present, grab it from there - if ( $wgUseFileCache && !$this->debug ) { - // Setup file cache object - $this->sFileCache = new simpleFileCache( $this->rKey ); - if ( $this->sFileCache->isFileCached() ) { - // Just output headers so we can use PHP's "efficient" readfile - $this->outputJsHeaders(); - $this->sFileCache->outputFromFileCache(); - die(); - } - } + //reset the rKey: + $this->rKey = ''; + //do the post proc request with configuration vars: + $this->postProcRequestVars(); + //update the filename (if gzip is on) + $this->sFileCache->getCacheFileName(); // Setup script loader header info $this->jsout .= 'var mwSlScript = "' . $_SERVER['SCRIPT_NAME'] . '";' . "\n"; $this->jsout .= 'var mwSlGenISODate = "' . date( 'c' ) . '";' . "\n"; $this->jsout .= 'var mwSlURID = "' . htmlspecialchars( $this->urid ) . '";' . "\n"; + $this->jsout .= 'var mwLang = "' . htmlspecialchars( $this->langCode ) . '";' . "\n"; // Build the output // Swap in the appropriate language per js_file @@ -117,7 +129,7 @@ class jsScriptLoader { } // Check if we should minify - if ( $wgEnableScriptMinify && !$this->debug ) { + if ( !$this->debug ) { // do the minification and output $this->jsout = JSMin::minify( $this->jsout ); } @@ -138,15 +150,13 @@ class jsScriptLoader { } function outputJsHeaders() { - global $wgJsMimeType; // Output JS MIME type: - header( 'Content-Type: ' . $wgJsMimeType ); + header( 'Content-Type: text/javascript' ); header( 'Pragma: public' ); - // Cache forever - // The point is we never have to revalidate, since we should always change the request URL + // Cache for 1 day ( we should always change the request URL // based on the SVN or article version. - $one_year = 60 * 60 * 24 * 365; - header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM" ); + $one_day = 60 * 60 * 24; + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_day ) . " GM" ); } function outputJsWithHeaders() { @@ -163,11 +173,10 @@ class jsScriptLoader { echo $this->jsout; } } - - /** - * Process request variables and load them into $this + /* + * postProcRequestVars uses globals, configuration and mediaWiki to test wiki-titles and files exist etc. */ - function procRequestVars() { + function postProcRequestVars(){ global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgStyleVersion; @@ -244,6 +253,66 @@ class jsScriptLoader { $this->rKey .= '_min'; } } + /** + * Pre-process request variables without configuration to get a rKey for cache file check + */ + function preProcRequestVars() { + $rKey = ''; + // Check for debug (won't use the cache) + if ( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) ) { + //we are going to have to run postProcRequest + return false; + } + + // Check for the urid. Be sure to escape it as it goes into our JS output. + if ( isset( $_GET['urid'] ) && $_GET['urid'] != '' ) { + $urid = htmlspecialchars( $_GET['urid'] ); + }else{ + die( 'missing urid param'); + } + + //get the language code (if not provided use the "default" language + if ( isset( $_GET['lang'] ) && $_GET['lang'] != '' ) { + //make sure its a valid lang code: + $langCode = preg_replace( "/[^A-Za-z]/", '', $_GET['lang']); + }else{ + //set english as default + $langCode = 'en'; + } + + + $reqClassList = false; + if ( isset( $_GET['class'] ) && $_GET['class'] != '' ) { + $reqClassList = explode( ',', $_GET['class'] ); + } + + // Check for the requested classes + if ( count( $reqClassList ) > 0 ) { + // Clean the class list and populate jsFileList + foreach ( $reqClassList as $reqClass ) { + //do some simple checks: + if ( trim( $reqClass ) != '' ){ + if( substr( $reqClass, 0, 3 ) == 'WT:' && strtolower( substr( $reqClass, -3) ) == '.js' ){ + //wiki page requests (must end with .js): + $rKey .= $reqClass; + }else if( substr( $reqClass, 0, 3 ) != 'WT:' ){ + //normal class requests: + $reqClass = preg_replace( "/[^A-Za-z0-9_\-\.]/", '', $reqClass ); + $rKey .= $reqClass; + }else{ + //not a valid class don't add it + } + } + } + } + // Add the language code to the rKey: + $rKey .= '_' . $langCode; + + // Add the unique rid + $rKey .= $urid; + + return $rKey; + } public static function getJsPathFromClass( $reqClass ){ global $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses; if ( isset( $wgJSAutoloadLocalClasses[$reqClass] ) ) { @@ -256,7 +325,6 @@ class jsScriptLoader { } function doProcessJsFile( $file_path ) { global $IP, $wgEnableScriptLocalization, $IP; - // Load the file $str = @file_get_contents( "{$IP}/{$file_path}" ); @@ -265,56 +333,104 @@ class jsScriptLoader { $this->error_msg .= 'Requested File: ' . htmlspecialchars( $file_path ) . ' could not be read' . "\n"; return ''; } - $this->cur_file = $file_path; - // Strip out js_log debug lines. Not much luck with this regExp yet: // if( !$this->debug ) // $str = preg_replace('/\n\s*js_log\s*\([^\)]([^;]|\n])*;/', "\n", $str); // Do language swap - if ( $wgEnableScriptLocalization ) - $str = preg_replace_callback( - self::loadGMregEx, - array( $this, 'languageMsgReplace' ), - $str - ); + if ( $wgEnableScriptLocalization ){ + $inx = self::getLoadGmIndex( $str ); + if($inx){ + $translated = $this->languageMsgReplace( substr($str, $inx['s'], ($inx['e']-$inx['s']) )); + //return the final string (without double {}) + return substr($str, 0, $inx['s']-1) . $translated . substr($str, $inx['e']+1); + } + } return $str; } - static public function getLocalizedMsgsFromClass( $class ){ - global $IP; - $path = self::getJsPathFromClass( $class ); - // Load the file - $str = @file_get_contents( "{$IP}/{$path}" ); - //extract the msg: - preg_match(self::loadGMregEx, $str, $matches); - if( isset( $matches[1] )){ - return self::languageMsgReplace( $matches, false ); - } - //if could not parse return empty string: - return ''; + static public function getLoadGmIndex( $str ){ + $returnIndex = array(); + preg_match('/loadGM\s*\(\s*\{/', $str, $matches, PREG_OFFSET_CAPTURE ); + if( count($matches) == 0){ + return false; + } + if( count( $matches ) > 0 ){ + //offset + match str length gives startIndex: + $returnIndex['s'] = strlen( $matches[0][0] ) + $matches[0][1]; + $foundMatch = true; + } + $ignorenext = false; + $inquote = false; + //look for closing } not inside quotes:: + for ( $i = $returnIndex['s']; $i < strlen( $str ); $i++ ) { + $char = $str[$i]; + if ( $ignorenext ) { + $ignorenext = false; + } else { + //search for a close } that is not in quotes or escaped + switch( $char ) { + case '"': + $inquote = !$inquote; + break; + case '}': + if( ! $inquote){ + $returnIndex['e'] =$i; + return $returnIndex; + } + break; + case '\\': + if ( $inquote ) $ignorenext = true; + break; + } + } + } } - static public function languageMsgReplace( $jvar ) { - if ( !isset( $jvar[1] ) ) + + static public function getInlineLoadGMFromClass( $class ){ + global $IP; + $file_path = self::getJsPathFromClass( $class ); + $str = @file_get_contents( "{$IP}/{$file_path}" ); + + $inx = self::getLoadGmIndex( $str ); + if(!$inx) + return ''; + $jsmsg = FormatJson::decode( '{' . substr($str, $inx['s'], ($inx['e']-$inx['s'])) . '}', true); + if( $jsmsg ){ + self::getMsgKeys ( $jsmsg ); + return 'loadGM('. FormatJson::encode( $jsmsg ) . ')'; + }else{ + //if could not parse return empty string: return ''; - $jmsg = FormatJson::decode( '{' . $jvar[1] . '}', true ); + } + } + static public function getMsgKeys(& $jmsg, $langCode = false){ + global $wgContLanguageCode; + if(!$langCode) + $langCode = $wgContLanguageCode; + //get the msg keys for the a json array + foreach ( $jmsg as $msgKey => $default_en_value ) { + $jmsg[$msgKey] = wfMsgGetKey( $msgKey, true, $langCode, false ); + } + } + function languageMsgReplace( $json_str ) { + $jmsg = FormatJson::decode( '{' . $json_str . '}', true ); // Do the language lookup if ( $jmsg ) { //see if any msgKey has the PLURAL template tag //package in PLURAL mapping - foreach ( $jmsg as $msgKey => $default_en_value ) { - $jmsg[$msgKey] = wfMsgNoTrans( $msgKey ); - } + self::getMsgKeys($jmsg, $this->langCode); + // Return the updated loadGM JSON with updated msgs: - return 'loadGM( ' . FormatJson::encode( $jmsg ) . ')'; + return FormatJson::encode( $jmsg ); } else { // Could not parse JSON return error: (maybe a alert?) //we just make a note in the code, visitors will get the fallback language, //developers will read the js source when its not behaving as expected. - return "/* + return "\n/* * Could not parse JSON language messages in this file, * Please check that loadGM call contains valid JSON (not javascript) -*/\n\n" . $jvar[0]; //include the original fallback loadGM +*/\n\n" . $json_str; //include the original fallback loadGM } } @@ -328,28 +444,31 @@ class simpleFileCache { public function __construct( &$rKey ) { $this->rKey = $rKey; - $this->filename = $this->fileCacheName(); + $this->getCacheFileName(); } - public function fileCacheName() { - global $wgUseGzip; - if ( !$this->mFileCache ) { - global $wgFileCacheDirectory; + public function getCacheFileName() { + global $wgUseGzip, $wgScriptCacheDirectory; - $hash = md5( $this->rKey ); - # Avoid extension confusion - $key = str_replace( '.', '%2E', urlencode( $this->rKey ) ); + $hash = md5( $this->rKey ); + # Avoid extension confusion + $key = str_replace( '.', '%2E', urlencode( $this->rKey ) ); - $hash1 = substr( $hash, 0, 1 ); - $hash2 = substr( $hash, 0, 2 ); - $this->mFileCache = "{$wgFileCacheDirectory}/{$hash1}/{$hash2}/{$this->rKey}.js"; + $hash1 = substr( $hash, 0, 1 ); + $hash2 = substr( $hash, 0, 2 ); + $this->filename = "{$wgScriptCacheDirectory}/{$hash1}/{$hash2}/{$this->rKey}.js"; - if ( $wgUseGzip ) - $this->mFileCache .= '.gz'; + // Check for defined files:: + if( is_file( $this->filename ) ) + return $this->filename; - wfDebug( " fileCacheName() - {$this->mFileCache}\n" ); + if( is_file( $this->filename .'.gz') ){ + $this->filename.='.gz'; + return $this->filename; } - return $this->mFileCache; + //check the update the name based on the $wgUseGzip config var + if ( isset($wgUseGzip) && $wgUseGzip ) + $this->filename.='.gz'; } public function isFileCached() { @@ -357,38 +476,39 @@ class simpleFileCache { } public function outputFromFileCache() { - global $wgUseGzip; - if ( $wgUseGzip ) { - if ( wfClientAcceptsGzip() ) { - header( 'Content-Encoding: gzip' ); - readfile( $this->filename ); - } else { - /* Send uncompressed. Check if fileCache is in compressed state (ends with .gz) - * We're unlikely to execute this since $wgUseGzip would have created a new file - * above, but just in case. - */ - if ( substr( $this->filename, - 3 ) == '.gz' ) { - readgzfile( $this->filename ); - } else { - readfile( $this->filename ); - } - } + if ( $this->clientAcceptsGzip() && substr( $this->filename, - 3 ) == '.gz' ) { + header( 'Content-Encoding: gzip' ); + readfile( $this->filename ); + return true; + } + //output without gzip: + if ( substr( $this->filename, - 3 ) == '.gz' ) { + readgzfile( $this->filename ); } else { - // Just output the file readfile( $this->filename ); } return true; } + public function clientAcceptsGzip(){ + $m = array(); + if ( preg_match( + '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', + $_SERVER['HTTP_ACCEPT_ENCODING'], + $m ) ) { + if ( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) + return false; + return true; + } + return false; + } public function saveToFileCache( &$text ) { global $wgUseFileCache, $wgUseGzip; if ( !$wgUseFileCache ) { return 'Error: Called saveToFileCache with $wgUseFileCache off'; } - if ( strcmp( $text, '' ) == 0 ) return 'saveToFileCache: empty output file'; - - // Check the directories. If we could not create them, error out. - $status = $this->checkCacheDirs(); + if ( strcmp( $text, '' ) == 0 ) + return 'saveToFileCache: empty output file'; if ( $wgUseGzip ) { $outputText = gzencode( trim( $text ) ); @@ -396,6 +516,9 @@ class simpleFileCache { $outputText = trim( $text ); } + // Check the directories. If we could not create them, error out. + $status = $this->checkCacheDirs(); + if ( $status !== true ) return $status; $f = fopen( $this->filename, 'w' ); diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index 5839c90d63..9f18412b70 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -347,8 +347,8 @@ mvBaseUploadInterface.prototype = { //@@check if we are done if( data.upload['apiUploadResult'] ){ //update status to 100% - _this.updateProgress( 1 ); - //see if we need to load JSON substitue: + _this.updateProgress( 1 ); + //see if we need JSON mvJsLoader.doLoad( [ 'JSON' ],function(){ diff --git a/js2/mwEmbed/libAddMedia/mvFirefogg.js b/js2/mwEmbed/libAddMedia/mvFirefogg.js index 145f4772ad..867cc06f6e 100644 --- a/js2/mwEmbed/libAddMedia/mvFirefogg.js +++ b/js2/mwEmbed/libAddMedia/mvFirefogg.js @@ -812,8 +812,8 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface //done state with error? ..not really possible given how firefogg works js_log(" Upload done in chunks mode, but no resultUrl!"); } - }else if( _this.upload_mode == 'post' && _this.api_url ) { - _this.procPageResponse( response_text ); + }else{ + js_log("Error:: not supported upload mode" + _this.upload_mode); } }else{ //upload error: @@ -838,52 +838,5 @@ mvFirefogg.prototype = { //extends mvBaseUploadInterface } //dont' follow the link: return false; - }, - /** - * procPageResponse should be faded out in favor of the upload api soon.. - * its all very fragile to read the html output and guess at stuff - */ - procPageResponse:function( result_page ){ - var _this = this; - js_log('f:procPageResponse'); - var sstring = 'var wgTitle = "' + this.formData['filename'].replace('_',' '); - - if(wgArticlePath){ - var result_txt = gM('mwe-upload_done', wgArticlePath.replace(/\$1/, 'File:' + _this.formData['filename'] ) ); - }else{ - result_txt = 'File has uploaded but api "done" URL was provided. Check the log for result page output'; - } - - //set the error text in case we dont' get far along in processing the response - _this.updateProgressWin( gM('mwe-upload_completed'), result_txt ); - - if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){ - js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.done_upload_cb ); - if( _this.done_upload_cb == 'redirect' ){ - $j( '#dlbox-centered' ).html( '

Upload Completed:

' + result_txt + '
' + form_txt); - window.location = wgArticlePath.replace( /\$1/, 'File:' + _this.formData['wpDestFile'] ); - }else{ - //check if the add_done_action is a callback: - if( typeof _this.done_upload_cb == 'function' ) - _this.done_upload_cb(); - } - }else{ - //js_log( 'upload page error: did not find: ' +sstring + ' in ' + "\n" + result_page ); - var form_txt = ''; - if( !result_page ){ - //@@todo fix this: - //the mediaWiki upload system does not have an API so we can\'t read errors - }else{ - var res = grabWikiFormError( result_page ); - - if(res.error_txt) - result_txt = res.error_txt; - - if(res.form_txt) - form_txt = res.form_txt; - } - js_log( 'error text is: ' + result_txt ); - $j( '#dlbox-centered' ).html( '

' + gM('mwe-upload_completed') + '

' + result_txt + '
' + form_txt); - } } }; diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index c8e205f35a..cc56b0dc27 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -14,7 +14,7 @@ loadGM({ "rsd_box_layout" : "Box layout", "rsd_list_layout" : "List layout", "rsd_results_desc" : "Results $1 to $2", - "rsd_results_total" : " of $1 ", + "rsd_results_desc_total" : "Results $1 to $2 of $3", "rsd_results_next" : "next", "rsd_results_prev" : "previous", "rsd_no_results" : "No search results for $1<\/b>", @@ -34,7 +34,7 @@ loadGM({ "mwe-unknown_license" : "Unknown license", "mwe-no_import_by_url" : "This user or wiki cannot<\/b> import assets from remote URLs.

Do you need to login?<\/p>

Is upload_by_url permission set for you?
Does the wiki have $wgAllowCopyUploads<\/a> enabled?<\/p>", "mwe-results_from" : "Results from $2<\/a>", - "mwe-missing_desc_see_source" : "This asset is missing a description. Please see the [$1 orginal source] and help describe it.", + "mwe-missing_desc_see_source" : "This asset is missing a description. Please see the [$1 original source] and help describe it.", "rsd_config_error" : "Add media wizard configuration error: $1", "mwe-your_recent_uploads" : "Your recent uploads to $1", "mwe-upload_a_file" : "Upload a new file to $1", @@ -399,7 +399,7 @@ remoteSearchDriver.prototype = { //merge in the options: //@@todo for cleaner config we should set _this.opt to the provided options) - $j.extend( _this, default_remote_search_options, options); + $j.extend( _this, default_remote_search_options, options); //update the base text: if(_this.target_textbox) @@ -1804,11 +1804,14 @@ remoteSearchDriver.prototype = { var to_num = ( cp.limit > cp.sObj.num_results )? (cp.offset + cp.sObj.num_results): (cp.offset + cp.limit); - var out = gM('rsd_results_desc', [(cp.offset+1), to_num]); + var out = ''; //@@todo we should instead support the wiki number format template system instead of inline calls - if( cp.sObj.num_results > cp.limit) - out+= gM('rsd_results_total', $mw.lang.formatNumber( cp.sObj.num_results ) ); + if( cp.sObj.num_results > cp.limit){ + out+= gM('rsd_results_desc_total', [(cp.offset+1), to_num, $mw.lang.formatNumber( cp.sObj.num_results )] ); + }else{ + out+= gM('rsd_results_desc', [(cp.offset+1), to_num]); + } //check if we have more results (next prev link) if( cp.offset >= cp.limit ) out+=' ' + gM('rsd_results_prev') + ' ' + cp.limit + ''; diff --git a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js index e0b0683ed9..b1765ef0cb 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js @@ -26,7 +26,7 @@ flickrSearch.prototype = { _licence_keys: '4,5,7,8', _srctypes: ['t','sq','s','m','o'], licenceMap:{ - '4' : 'http://creativecommons.org/licenses+/by/3.0/', + '4' : 'http://creativecommons.org/licenses/by/3.0/', '5' : 'http://creativecommons.org/licenses/by-sa/3.0/', '7' : 'http://www.flickr.com/commons/usage/', '8' : 'http://www.usa.gov/copyright.shtml' diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 9c267c50db..0894758cb0 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -36,6 +36,151 @@ var mwDefaultConfig = { if( !mwConfig ) var mwConfig = {}; + +/** + * AutoLoader paths + * @path The path to the file (or set of files) with ending slash + * @gClasses The set of classes + * if it's an array, $j.className becomes jquery.className.js + * if it's an associative object then key => value pairs are used + */ +if( typeof mvAutoLoadClasses == 'undefined' ) + mvAutoLoadClasses = {}; + +// The script that loads the class set +function lcPaths( classSet ){ + for( var i in classSet ) { + mvAutoLoadClasses[i] = classSet[i]; + } +} + +function mvGetClassPath(k){ + if( mvAutoLoadClasses[k] ) { + //js_log('got class path:' + k + ' : '+ mvClassPaths[k]); + return mvAutoLoadClasses[k]; + } else { + js_log('Error:: Could not find path for requested class ' + k ); + return false; + } +} +if( typeof mvCssPaths == 'undefined' ) + mvCssPaths = {}; + +function lcCssPath( cssSet ) { + for( var i in cssSet ) { + mvCssPaths[i] = mv_embed_path + cssSet[i]; + } +} + +/* + * -- Load Class Paths -- + * + * MUST BE VALID JSON (NOT JS) + * This is used by the script loader to auto-load classes (so we only define + * this once for PHP & JavaScript) + * + * Right now the PHP AutoLoader only reads this mv_embed.js file. + * In the future we could have multiple lcPath calls that PHP reads + * (if our autoloading class list becomes too long) just have to add those + * files to the jsAutoLoader file list. + * (ie extensions that want to use the autoloader) + */ +lcPaths({ + "mv_embed" : "mv_embed.js", + "window.jQuery" : "jquery/jquery-1.3.2.js", + "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", + "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", + "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", + "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", + "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", + "$j.fn.ColorPicker" : "libClipEdit/colorpicker/js/colorpicker.js", + "$j.Jcrop" : "libClipEdit/Jcrop/js/jquery.Jcrop.js", + "$j.fn.simpleUploadForm" : "libAddMedia/simpleUploadForm.js", + + "$mw.proxy" : "libMwApi/mw.proxy.js", + + "ctrlBuilder" : "skins/ctrlBuilder.js", + "kskinConfig" : "skins/kskin/kskin.js", + "mvpcfConfig" : "skins/mvpcf/mvpcf.js", + + "JSON" : "libMwApi/json2.js", + "$j.cookie" : "jquery/plugins/jquery.cookie.js", + "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", + "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", + + "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", + "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", + "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js", + "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js", + "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js", + "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js", + "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js", + "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js", + "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js", + "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js", + "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js", + "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js", + "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js", + "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js", + "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js", + "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js", + "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js", + "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js", + "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js", + "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js", + "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js", + "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js", + "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", + "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js", + + "$mw.dragDropFile" : "libAddMedia/dragDropFile.js", + "mvFirefogg" : "libAddMedia/mvFirefogg.js", + "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js", + "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js", + "remoteSearchDriver" : "libAddMedia/remoteSearchDriver.js", + "seqRemoteSearchDriver" : "libSequencer/seqRemoteSearchDriver.js", + + "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", + "mediaWikiSearch" : "libAddMedia/searchLibs/mediaWikiSearch.js", + "metavidSearch" : "libAddMedia/searchLibs/metavidSearch.js", + "archiveOrgSearch" : "libAddMedia/searchLibs/archiveOrgSearch.js", + "flickrSearch" : "libAddMedia/searchLibs/flickrSearch.js", + "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", + + "mvClipEdit" : "libClipEdit/mvClipEdit.js", + + "embedVideo" : "libEmbedVideo/embedVideo.js", + "flashEmbed" : "libEmbedVideo/flashEmbed.js", + "genericEmbed" : "libEmbedVideo/genericEmbed.js", + "htmlEmbed" : "libEmbedVideo/htmlEmbed.js", + "javaEmbed" : "libEmbedVideo/javaEmbed.js", + "nativeEmbed" : "libEmbedVideo/nativeEmbed.js", + "quicktimeEmbed" : "libEmbedVideo/quicktimeEmbed.js", + "vlcEmbed" : "libEmbedVideo/vlcEmbed.js", + + "mvPlayList" : "libSequencer/mvPlayList.js", + "mvSequencer" : "libSequencer/mvSequencer.js", + "mvFirefoggRender" : "libSequencer/mvFirefoggRender.js", + "mvTimedEffectsEdit": "libSequencer/mvTimedEffectsEdit.js", + + "mvTextInterface" : "libTimedText/mvTextInterface.js" +}); + +// Dependency mapping for CSS files for self-contained included plugins: +lcCssPath({ + '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css', + '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css' +}) + + + + + + + + + + // parseUri 1.2.2 // (c) Steven Levithan // MIT License @@ -425,7 +570,7 @@ if( !mv_embed_path ) { /** * parser addMagic * - * lets you add a set of magic keys and associated callback funcions + * lets you add a set of magic keys and associated callback functions * callback: @param ( Object Template ) * callback: @return the transformed template output * @@ -656,141 +801,6 @@ $mw.lang.loadGM({ "mwe-ok" : "OK" }); -/** - * AutoLoader paths (this should mirror the file: jsAutoloadLocalClasses.php ) - * Any file _not_ listed here won't be auto-loadable - * @path The path to the file (or set of files) with ending slash - * @gClasses The set of classes - * if it's an array, $j.className becomes jquery.className.js - * if it's an associative object then key => value pairs are used - */ -if( typeof mvAutoLoadClasses == 'undefined' ) - mvAutoLoadClasses = {}; - -// The script that loads the class set -function lcPaths( classSet ){ - for( var i in classSet ) { - mvAutoLoadClasses[i] = classSet[i]; - } -} - -function mvGetClassPath(k){ - if( mvAutoLoadClasses[k] ) { - //js_log('got class path:' + k + ' : '+ mvClassPaths[k]); - return mvAutoLoadClasses[k]; - } else { - js_log('Error:: Could not find path for requested class ' + k ); - return false; - } -} -if( typeof mvCssPaths == 'undefined' ) - mvCssPaths = {}; - -function lcCssPath( cssSet ) { - for( var i in cssSet ) { - mvCssPaths[i] = mv_embed_path + cssSet[i]; - } -} - -/* - * -- Load Class Paths -- - * - * MUST BE VALID JSON (NOT JS) - * This is used by the script loader to auto-load classes (so we only define - * this once for PHP & JavaScript) - * - * Right now the PHP AutoLoader only reads this mv_embed.js file. - * In the future we could have multiple lcPath calls that PHP reads - * (if our autoloading class list becomes too long) just have to add those - * files to the jsAutoLoader file list. - */ -lcPaths({ - "mv_embed" : "mv_embed.js", - "window.jQuery" : "jquery/jquery-1.3.2.js", - "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", - "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", - "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", - "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", - "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", - "$j.fn.ColorPicker" : "libClipEdit/colorpicker/js/colorpicker.js", - "$j.Jcrop" : "libClipEdit/Jcrop/js/jquery.Jcrop.js", - "$j.fn.simpleUploadForm" : "libAddMedia/simpleUploadForm.js", - - "$mw.proxy" : "libMwApi/mw.proxy.js", - - "ctrlBuilder" : "skins/ctrlBuilder.js", - "kskinConfig" : "skins/kskin/kskin.js", - "mvpcfConfig" : "skins/mvpcf/mvpcf.js", - - "JSON" : "libMwApi/json2.js", - "$j.cookie" : "jquery/plugins/jquery.cookie.js", - "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", - "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", - - "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", - "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", - "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js", - "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js", - "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js", - "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js", - "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js", - "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js", - "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js", - "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js", - "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js", - "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js", - "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js", - "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js", - "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js", - "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js", - "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js", - "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js", - "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js", - "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js", - "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js", - "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js", - "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", - "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js", - - "$mw.dragDropFile" : "libAddMedia/dragDropFile.js", - "mvFirefogg" : "libAddMedia/mvFirefogg.js", - "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js", - "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js", - "remoteSearchDriver" : "libAddMedia/remoteSearchDriver.js", - "seqRemoteSearchDriver" : "libSequencer/seqRemoteSearchDriver.js", - - "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", - "mediaWikiSearch" : "libAddMedia/searchLibs/mediaWikiSearch.js", - "metavidSearch" : "libAddMedia/searchLibs/metavidSearch.js", - "archiveOrgSearch" : "libAddMedia/searchLibs/archiveOrgSearch.js", - "flickrSearch" : "libAddMedia/searchLibs/flickrSearch.js", - "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", - - "mvClipEdit" : "libClipEdit/mvClipEdit.js", - - "embedVideo" : "libEmbedVideo/embedVideo.js", - "flashEmbed" : "libEmbedVideo/flashEmbed.js", - "genericEmbed" : "libEmbedVideo/genericEmbed.js", - "htmlEmbed" : "libEmbedVideo/htmlEmbed.js", - "javaEmbed" : "libEmbedVideo/javaEmbed.js", - "nativeEmbed" : "libEmbedVideo/nativeEmbed.js", - "quicktimeEmbed" : "libEmbedVideo/quicktimeEmbed.js", - "vlcEmbed" : "libEmbedVideo/vlcEmbed.js", - - "mvPlayList" : "libSequencer/mvPlayList.js", - "mvSequencer" : "libSequencer/mvSequencer.js", - "mvFirefoggRender" : "libSequencer/mvFirefoggRender.js", - "mvTimedEffectsEdit": "libSequencer/mvTimedEffectsEdit.js", - - "mvTextInterface" : "libTimedText/mvTextInterface.js" -}); - -// Dependency mapping for CSS files for self-contained included plugins: -lcCssPath({ - '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css', - '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css' -}) - // Get the loading image function mv_get_loading_img( style, class_attr ){ @@ -1180,7 +1190,7 @@ var temp_f; if( window.onload ) { temp_f = window.onload; } -// Use the onload method as a backup (mwdomReady hanndles dobule init calls) +// Use the onload method as a backup window.onload = function () { if( temp_f ) temp_f(); @@ -1284,7 +1294,8 @@ function mv_jqueryBindings() { ] ], function() { iObj['instance_name'] = 'rsdMVRS'; - _global['rsdMVRS'] = new remoteSearchDriver( iObj ); + if( ! _global['rsdMVRS'] ) + _global['rsdMVRS'] = new remoteSearchDriver( iObj ); if( callback ) { callback( _global['rsdMVRS'] ); } @@ -1715,36 +1726,6 @@ function mwGetLocalApiUrl( url ) { } return false; } -// Grab wiki form error for wiki html page processing (should be deprecated because we use api now) -function grabWikiFormError( result_page ) { - var res = {}; - sp = result_page.indexOf( '' ); - if( sp != -1 ) { - se = result_page.indexOf( '', sp ); - res.error_txt = result_page.substr( sp, sp - se ) + ''; - } else { - // Look for warning - sp = result_page.indexOf( '

    ' ) - if( sp != -1 ) { - se = result_page.indexOf( '
', sp ); - res.error_txt = result_page.substr( sp, se - sp ) + ''; - // Try to add the ignore form item - sfp = result_page.indexOf( '
', sfp ); - res.form_txt = result_page.substr( sfp, sfe - sfp ) + '
'; - } - } else { - // One more error type check - sp = result_page.indexOf( 'class="mw-warning-with-logexcerpt">' ) - if( sp != -1 ) { - se = result_page.indexOf( '', sp ); - res.error_txt = result_page.substr( sp, se - sp ) + ''; - } - } - } - return res; -} // Do a "normal" request function do_request( req_url, callback ) { js_log( 'do_request::req_url:' + req_url + ' != ' + parseUri( req_url ).host ); diff --git a/js2/mwEmbed/php/jsAutoloadLocalClasses.php b/js2/mwEmbed/php/jsAutoloadLocalClasses.php index 6c2cbf2016..0a37c7c4a5 100644 --- a/js2/mwEmbed/php/jsAutoloadLocalClasses.php +++ b/js2/mwEmbed/php/jsAutoloadLocalClasses.php @@ -5,15 +5,23 @@ global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory; // Load classes from mv_embed.js if ( is_file( $wgMwEmbedDirectory . 'mv_embed.js' ) ) { - // Read the file - $str = @file_get_contents( $wgMwEmbedDirectory . 'mv_embed.js' ); - // Call jsClassPathLoader() for each lcPaths() call in the JS source - $str = preg_replace_callback( - '/lcPaths\s*\(\s*{(.*)}\s*\)\s*/siU', - 'jsClassPathLoader', - $str - ); + //read the head of the file:: + $f = fopen( $wgMwEmbedDirectory . 'mv_embed.js' , 'r'); + $jsvar = ''; + $file_head=''; + while (!feof($f)) { + $file_head.= fread($f, 8192); + // Call jsClassPathLoader() for each lcPaths() call in the JS source + $replace_test = preg_replace_callback( + '/lcPaths\s*\(\s*{(.*)}\s*\)\s*/siU', + 'jsClassPathLoader', + $file_head + ); + if( $replace_test !== false ) + break; + } + fclose( $f ); } function jsClassPathLoader( $jvar ) { global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory; diff --git a/js2/mwEmbed/php/languages/mwEmbed.i18n.php b/js2/mwEmbed/php/languages/mwEmbed.i18n.php index 4ced40eb93..8a18c80067 100644 --- a/js2/mwEmbed/php/languages/mwEmbed.i18n.php +++ b/js2/mwEmbed/php/languages/mwEmbed.i18n.php @@ -107,6 +107,8 @@ $messages['en'] = array( 'mwe-apiproxy-setup' => 'Setting up API proxy', 'mwe-load-drag-item' => 'Loading dragged item', 'mwe-ok' => 'OK', + 'mwe-load-drag-item' => "Loading draged item", + 'mwe-ok' => "Ok", /* * js file: /libMwApi/mw.proxy.js @@ -322,7 +324,7 @@ $messages['qqq'] = array( 'mwe-loading_txt' => '{{Identical|Loading}}', 'mwe-loading_title' => '{{Identical|Loading}}', 'mwe-error_load_lib' => 'Parameters: -* $1 Corresponds to the JavaScript file that was not retrievable or does not define its class name. +* $1 Corresponds to the JavaScript file that was not retrievable or does not define its class name. * $2 Is the class name that was associated with the JavaScript file that was not found or could not be retrieved.', 'mwe-ok' => '{{Identical|OK}}', 'mwe-cancel' => '{{Identical|Cancel}}', diff --git a/js2/mwEmbed/php/noMediaWikiConfig.php b/js2/mwEmbed/php/noMediaWikiConfig.php index 531e13476a..c0fb0a3e27 100644 --- a/js2/mwEmbed/php/noMediaWikiConfig.php +++ b/js2/mwEmbed/php/noMediaWikiConfig.php @@ -14,8 +14,6 @@ $IP = realpath( dirname( __FILE__ ) . '/../' ); // $wgMwEmbedDirectory becomes the root $IP $wgMwEmbedDirectory = ''; -$wgFileCacheDirectory = realpath( dirname( __FILE__ ) ) . '/script-cache'; - $wgUseFileCache = true; // Init our wg Globals @@ -49,23 +47,6 @@ require_once( realpath( dirname( __FILE__ ) ) . '/jsAutoloadLocalClasses.php' ); // Get the JSmin class: require_once( realpath( dirname( __FILE__ ) ) . '/minify/JSMin.php' ); -// Some static utility MediaWiki functions that we use: -function wfClientAcceptsGzip() { - global $wgUseGzip; - if ( $wgUseGzip ) { - # FIXME: we may want to blacklist some broken browsers - $m = array(); - if ( preg_match( - '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', - $_SERVER['HTTP_ACCEPT_ENCODING'], - $m ) ) { - if ( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) return false; - wfDebug( " accepts gzip\n" ); - return true; - } - } - return false; -} function wfDebug() { return false; } @@ -93,7 +74,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) { return @mkdir( $dir, $mode, true ); // PHP5 <3 } -function wfMsgNoTrans( $msgKey ) { +function wfMsgGetKey( $msgKey ) { global $messages, $mwLanguageCode; // Make sure we have the messages file: require_once( realpath( dirname( __FILE__ ) ) . '/languages/mwEmbed.i18n.php' ); diff --git a/js2/mwEmbed/tests/testApiProxy.html b/js2/mwEmbed/tests/testApiProxy.html index 3ae216c59a..2e146c125c 100644 --- a/js2/mwEmbed/tests/testApiProxy.html +++ b/js2/mwEmbed/tests/testApiProxy.html @@ -10,7 +10,7 @@ var remote_wiki_host = 'http://test.wikipedia.org'; var remote_script_path = '/w'; -js2AddOnloadHook( function(){ +js2AddOnloadHook( function(){ $j('#hostName').text( remote_wiki_host ); //run the api-proxy setup: $j.apiProxy( diff --git a/mwScriptLoader.php b/mwScriptLoader.php index c8841274a8..4755f84296 100644 --- a/mwScriptLoader.php +++ b/mwScriptLoader.php @@ -24,15 +24,26 @@ * http://www.gnu.org/copyleft/gpl.html */ +//first do a quick static check for the cached file +define('MW_CACHE_SCRIPT_CHECK', true); +require_once( dirname(__FILE__) . '/js2/mwEmbed/jsScriptLoader.php'); +$myScriptLoader = new jsScriptLoader(); +if( $myScriptLoader->outputFromCache() ){ + exit(); +} + +//Else load up mediaWiki stuff and continue scriptloader processing: + // include WebStart.php +ob_start(); require_once('includes/WebStart.php'); +$webstartwhitespace = ob_end_clean(); wfProfileIn( 'mwScriptLoader.php' ); - if( $wgRequest->isPathInfoBad() ){ wfHttpError( 403, 'Forbidden', - 'Invalid file extension found in PATH_INFO. ' . + 'Invalid file extension found in PATH_INFO. ' . 'mwScriptLoader must be accessed through the primary script entry point.' ); return; } @@ -44,12 +55,9 @@ if ( !$wgEnableScriptLoader ) { die( 1 ); } -//moved to setup.php -// load the mwEmbed language file: -//$wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php"; - -// run jsScriptLoader action: -$myScriptLoader = new jsScriptLoader(); +//load the language file and +// Run jsScriptLoader action: $myScriptLoader->doScriptLoader(); + wfProfileOut( 'mwScriptLoader.php' ); diff --git a/mwScriptLoader.php5 b/mwScriptLoader.php5 index 9bfe525b4a..d9c2ffc4df 100644 --- a/mwScriptLoader.php5 +++ b/mwScriptLoader.php5 @@ -1 +1 @@ -