*/
$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)
$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 = '';
} 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 ));
}
*/
function getURIDparam( $classAry = array() ) {
global $wgDebugJavaScript, $wgStyleVersion, $IP, $wgScriptModifiedCheck;
+ global $wgContLanguageCode;
+
+
if( $wgDebugJavaScript ) {
return 'urid=' . time();
} else {
if( $frev != 0 )
$urid.= "_" . $frev;
+
+ //Always the language key param to keep urls distinct per language
+ $urid.='&lang='.$wgContLanguageCode;
+
return $urid;
}
}
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 ) {
* 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;
}
/*
* 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 = {};
*/
// 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 = '';
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
}
// Check if we should minify
- if ( $wgEnableScriptMinify && !$this->debug ) {
+ if ( !$this->debug ) {
// do the minification and output
$this->jsout = JSMin::minify( $this->jsout );
}
}
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() {
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;
$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] ) ) {
}
function doProcessJsFile( $file_path ) {
global $IP, $wgEnableScriptLocalization, $IP;
-
// Load the file
$str = @file_get_contents( "{$IP}/{$file_path}" );
$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
}
}
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() {
}
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 ) );
$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' );
//@@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(){
//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:
}
//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( '<h3>Upload Completed:</h3>' + result_txt + '<br>' + 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( '<h3>' + gM('mwe-upload_completed') + '</h3>' + result_txt + '<br>' + form_txt);
- }
}
};
"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 <b>$1<\/b>",
"mwe-unknown_license" : "Unknown license",
"mwe-no_import_by_url" : "This user or wiki <b>cannot<\/b> import assets from remote URLs.<p>Do you need to login?<\/p><p>Is upload_by_url permission set for you?<br \/>Does the wiki have <a href=\"http:\/\/www.mediawiki.org\/wiki\/Manual:$wgAllowCopyUploads\">$wgAllowCopyUploads<\/a> enabled?<\/p>",
"mwe-results_from" : "Results from <a href=\"$1\" target=\"_new\" >$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",
//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)
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+=' <a href="#" id="rsd_pprev">' + gM('rsd_results_prev') + ' ' + cp.limit + '</a>';
_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'
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 <stevenlevithan.com>
// MIT License
/**
* 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
*
"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 ){
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();
]
], function() {
iObj['instance_name'] = 'rsdMVRS';
- _global['rsdMVRS'] = new remoteSearchDriver( iObj );
+ if( ! _global['rsdMVRS'] )
+ _global['rsdMVRS'] = new remoteSearchDriver( iObj );
if( callback ) {
callback( _global['rsdMVRS'] );
}
}
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( '<span class="error">' );
- if( sp != -1 ) {
- se = result_page.indexOf( '</span>', sp );
- res.error_txt = result_page.substr( sp, sp - se ) + '</span>';
- } else {
- // Look for warning
- sp = result_page.indexOf( '<ul class="warning">' )
- if( sp != -1 ) {
- se = result_page.indexOf( '</ul>', sp );
- res.error_txt = result_page.substr( sp, se - sp ) + '</ul>';
- // Try to add the ignore form item
- sfp = result_page.indexOf( '<form method="post"' );
- if( sfp != -1 ) {
- sfe = result_page.indexOf( '</form>', sfp );
- res.form_txt = result_page.substr( sfp, sfe - sfp ) + '</form>';
- }
- } else {
- // One more error type check
- sp = result_page.indexOf( 'class="mw-warning-with-logexcerpt">' )
- if( sp != -1 ) {
- se = result_page.indexOf( '</div>', sp );
- res.error_txt = result_page.substr( sp, se - sp ) + '</div>';
- }
- }
- }
- return res;
-}
// Do a "normal" request
function do_request( req_url, callback ) {
js_log( 'do_request::req_url:' + req_url + ' != ' + parseUri( req_url ).host );
// 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;
'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
'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}}',
// $wgMwEmbedDirectory becomes the root $IP
$wgMwEmbedDirectory = '';
-$wgFileCacheDirectory = realpath( dirname( __FILE__ ) ) . '/script-cache';
-
$wgUseFileCache = true;
// Init our wg Globals
// 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;
}
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' );
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(
* 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;
}
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' );
-<?php require './mwScriptLoader.php';
\ No newline at end of file
+<?php require './mwScriptLoader.php';
\ No newline at end of file