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
+ //@@todo fix: will break down if someone does }) in their msg text
const loadGMregEx = '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU';
function doScriptLoader() {
- global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgEnableScriptLoaderJsFile, $IP,
+ global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $IP,
$wgEnableScriptMinify, $wgUseFileCache;
// Process the request
*/
function procRequestVars() {
global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses,
- $wgJSAutoloadLocalClasses, $wgStyleVersion, $wgEnableScriptLoaderJsFile;
+ $wgJSAutoloadLocalClasses, $wgStyleVersion;
// Set debug flag
if ( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) || ( isset( $wgEnableScriptDebug ) && $wgEnableScriptDebug == true ) ) {
// Clean the class list and populate jsFileList
foreach ( $reqClassList as $reqClass ) {
if ( trim( $reqClass ) != '' ) {
- // Check for special case '-' class for user-generated JS
if ( substr( $reqClass, 0, 3 ) == 'WT:' ) {
- $this->jsFileList[$reqClass] = true;
- $this->rKey .= $reqClass;
- $this->jsvarurl = true;
+ $doAddWT = false;
+ // Check for special case '-' class for user-generated JS
+ if( substr( $reqClass, 3, 1) == '-'){
+ $doAddWT = true;
+ }else{
+ if( strtolower( substr( $reqClass, -3) ) == '.js'){
+ //make sure its a valid wikipage before doing processing
+ $t = Title::newFromDBkey( substr( $reqClass, 3) );
+ if( $t->exists()
+ && $t->getNamespace == NS_MEDIAWIKI
+ && $t->getNamespace == NS_USER){
+ $doAddWT = true;
+ }
+ }
+ }
+ if( $doAddWT ){
+ $this->jsFileList[$reqClass] = true;
+ $this->rKey .= $reqClass;
+ $this->jsvarurl = true;
+ }
continue;
}
}
}
- // Check for requested files, if enabled
- if ( $wgEnableScriptLoaderJsFile ) {
- if ( isset( $_GET['files'] ) ) {
- $reqFileList = explode( ',', isset( $_GET['files'] ) );
- // Clean the file list and populate jsFileList
- foreach ( $reqFileList as $reqFile ) {
- // No jumping dirs
- $reqFile = str_replace( '../', '', $reqFile );
- // Only allow alphanumeric underscores periods and ending with .js
- $reqFile = ereg_replace( "[^A-Za-z0-9_\-\/\.]", '', $reqFile );
- if ( substr( $reqFile, - 3 ) == '.js' ) {
- // Don't add it twice:
- if ( !in_array( $reqFile, $jsFileList ) ) {
- $this->jsFileList[] = $IP . $reqFile;
- $this->rKey .= $reqFile;
- }
- } else {
- $this->error_msg .= 'Not valid requested JavaScript file' . "\n";
- }
- }
- }
- }
-
+
// Add the language code to the rKey:
$this->rKey .= '_' . $wgContLanguageCode;
// Return the updated loadGM JSON with updated msgs:
return 'loadGM( ' . FormatJson::encode( $jmsg ) . ')';
} else {
- print_r($jvar);
-
// 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.
_this.doLoad([
'window.jQuery'
], function() {
- _global['$j'] = jQuery.noConflict();
-
- //setup our global settings using the (jQuery helper)
- $j.extend( mwConfig, mwConfigOptions);
-
- // Set up the skin path
- _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' +mwConfig['jui_skin'] + '/';
- _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/images/';
- _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg';
-
- // Make sure the skin/style sheets are always available:
- loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
- loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/styles.css' );
-
- // Set up AJAX to not send dynamic URLs for loading scripts (we control that with
- // the scriptLoader)
- $j.ajaxSetup({
- cache: true
- });
-
- js_log( 'jQuery loaded into $j' );
- // Set up mvEmbed jQuery bindings:
- mv_jqueryBindings();
+ //only do the $j setup once:
+ if(!_global['$j']){
+ _global['$j'] = jQuery.noConflict();
+
+ //setup our global settings using the (jQuery helper)
+ $j.extend( mwConfig, mwConfigOptions);
+
+ // Set up the skin path
+ _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' +mwConfig['jui_skin'] + '/';
+ _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/images/';
+ _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg';
+
+ // Make sure the skin/style sheets are always available:
+ loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' );
+ loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name'] + '/styles.css' );
+
+ // Set up AJAX to not send dynamic URLs for loading scripts (we control that with
+ // the scriptLoader)
+ $j.ajaxSetup({
+ cache: true
+ });
+
+ js_log( 'jQuery loaded into $j' );
+ // Set up mvEmbed jQuery bindings:
+ mv_jqueryBindings();
+ }
// Run the callback
if( callback ) {
callback();