* mw.config is the new way, and global config variable lookups are deprecated
* Based on two phase3-wide quick searches:
-- of " wg": http://toolserver.org/~krinkle/wikimedia-svn-search/view.php?id=321&hash=
81700bf7486e4fee3b7bc1f83eb9eba6
-- of "!wg": http://toolserver.org/~krinkle/wikimedia-svn-search/view.php?id=327&hash=
47c9d54a7a1d5d58a724dd834585f40d
Related changes:
* Changed some php comments mentioning "wg" variables to include the dollar sign, and a typo when the wf function prefix was meant.
* Removed TODO comment in wikibits.js and made it use the JS equivalent of wfUrlencode, which we have now, mw.util.wikiUrlencode
* SpecialUpload.php: use OutputPage::addJsConfigVars instead of creating a new script tag through OutputPage::addScript(Skin::makeVariablesScript(..))
* Renamed wgUploadSetup in upload.js and made it local. Not used anywhere in ./trunk/phase3 and ./trunk/extensions
* Fix OutputPage::addJsConfigVars so that it can actually be called with an array instead of two arguments for key/value
* Some minor whitespace/convention stuff around the same line
15 files changed:
- lim Integer Limit of items to show, default is 50
- conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
- showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty if set to true (default), "No matching items in log" is displayed if loglist is empty
- lim Integer Limit of items to show, default is 50
- conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
- showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty if set to true (default), "No matching items in log" is displayed if loglist is empty
- - msgKey Array If you want a nice box with a message, set this to the key of the message. First element is the message key, additional optional elements are parameters for the key that are processed with wgMsgExt and option 'parse'
+ - msgKey Array If you want a nice box with a message, set this to the key of the message. First element is the message key, additional optional elements are parameters for the key that are processed with wfMsgExt and option 'parse'
- offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset
- wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
- flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
- offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset
- wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
- flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
- * Display the form (sending to wgOut), with an appropriate error
+ * Display the form (sending to $wgOut), with an appropriate error
* message or stack of messages, and any validation errors, etc.
* @param $submitResult Mixed output from HTMLForm::trySubmit()
*/
* message or stack of messages, and any validation errors, etc.
* @param $submitResult Mixed output from HTMLForm::trySubmit()
*/
* Add one or more variables to be set in mw.config in JavaScript.
*
* @param $key {String|Array} Key or array of key/value pars.
* Add one or more variables to be set in mw.config in JavaScript.
*
* @param $key {String|Array} Key or array of key/value pars.
- * @param $value {Mixed} Value of the configuration variable.
+ * @param $value {Mixed} [optional] Value of the configuration variable.
- public function addJsConfigVars( $keys, $value ) {
+ public function addJsConfigVars( $keys, $value = null ) {
if ( is_array( $keys ) ) {
foreach ( $keys as $key => $value ) {
$this->mJsConfigVars[$key] = $value;
if ( is_array( $keys ) ) {
foreach ( $keys as $key => $value ) {
$this->mJsConfigVars[$key] = $value;
* if set to true (default), "No matching items in log" is displayed if loglist is empty
* - msgKey Array If you want a nice box with a message, set this to the key of the message.
* First element is the message key, additional optional elements are parameters for the key
* if set to true (default), "No matching items in log" is displayed if loglist is empty
* - msgKey Array If you want a nice box with a message, set this to the key of the message.
* First element is the message key, additional optional elements are parameters for the key
- * that are processed with wgMsgExt and option 'parse'
+ * that are processed with wfMsgExt and option 'parse'
* - offset Set to overwrite offset parameter in $wgRequest
* set to '' to unset offset
* - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
* - offset Set to overwrite offset parameter in $wgRequest
* set to '' to unset offset
* - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
);
$out = $this->getOutput();
);
$out = $this->getOutput();
- $out->addScript( Skin::makeVariablesScript( $scriptVars ) );
+ $out->addJsConfigVars( $scriptVars );
'email',
'prefs-help-realname',
'email',
'prefs-help-realname',
- # 3 messages depending upon wgEmailConfirmToEdit and $wgEnableUserEmail
+ # 3 messages depending upon $wgEmailConfirmToEdit and $wgEnableUserEmail
'prefs-help-email',
'prefs-help-email-others',
'prefs-help-email-required',
'prefs-help-email',
'prefs-help-email-others',
'prefs-help-email-required',
'size-gigabytes',
'largefileserver',
),
'size-gigabytes',
'largefileserver',
),
- 'dependencies' => array( 'mediawiki.libs.jpegmeta' ),
+ 'dependencies' => array( 'mediawiki.libs.jpegmeta', 'mediawiki.util' ),
),
/* MediaWiki Legacy */
),
/* MediaWiki Legacy */
'scripts' => 'common/ajax.js',
'remoteBasePath' => $GLOBALS['wgStylePath'],
'localBasePath' => $GLOBALS['wgStyleDirectory'],
'scripts' => 'common/ajax.js',
'remoteBasePath' => $GLOBALS['wgStylePath'],
'localBasePath' => $GLOBALS['wgStyleDirectory'],
- 'dependencies' => 'mediawiki.legacy.wikibits',
+ 'dependencies' => array( 'mediawiki.util', 'mediawiki.legacy.wikibits' ),
),
'mediawiki.legacy.commonPrint' => array(
'styles' => array( 'common/commonPrint.css' => array( 'media' => 'print' ) ),
),
'mediawiki.legacy.commonPrint' => array(
'styles' => array( 'common/commonPrint.css' => array( 'media' => 'print' ) ),
var i, x, n;
var uri;
var post_data;
var i, x, n;
var uri;
var post_data;
- uri = wgServer +
- ( ( wgScript == null ) ? ( wgScriptPath + '/index.php' ) : wgScript ) +
- '?action=ajax';
+ uri = mw.util.wikiScript() + '?action=ajax';
if ( sajax_request_type == 'GET' ) {
if ( uri.indexOf( '?' ) == -1 ) {
uri = uri + '?rs=' + encodeURIComponent( func_name );
if ( sajax_request_type == 'GET' ) {
if ( uri.indexOf( '?' ) == -1 ) {
uri = uri + '?rs=' + encodeURIComponent( func_name );
var query = os_timer.query;
os_timer = null;
var path = mw.config.get( 'wgMWSuggestTemplate' ).replace( "{namespaces}", os_getNamespaces( r ) )
var query = os_timer.query;
os_timer = null;
var path = mw.config.get( 'wgMWSuggestTemplate' ).replace( "{namespaces}", os_getNamespaces( r ) )
- .replace( "{dbname}", wgDBname )
+ .replace( "{dbname}", mw.config.get( 'wgDBname' ) )
.replace( "{searchTerms}", os_encodeQuery( query ) );
// try to get from cache, if not fetch using ajax
.replace( "{searchTerms}", os_encodeQuery( query ) );
// try to get from cache, if not fetch using ajax
- * Is this protection level cascadeable?
- * @param level String
- *
- * @return boolean
- *
+ * Checks if a cerain protection level is cascadeable.
+ * @param level {String}
+ * @return {Boolean}
*/
'isCascadeableLevel': function( level ) {
*/
'isCascadeableLevel': function( level ) {
- for (var k = 0; k < wgCascadeableLevels.length; k++) {
- if ( wgCascadeableLevels[k] == level ) {
- return true;
+ var cascadeLevels, len, i;
+
+ cascadeLevels = mw.config.get( 'wgCascadeableLevels' );
+ // cascadeLevels isn't defined on all pages
+ if ( cascadeLevels ) {
+ for ( i = 0, len = cascadeLevels.length; i < len; i += 1 ) {
+ if ( cascadeLevels[i] === level ) {
+ return true;
+ }
+( function () {
+var ajaxUploadDestCheck = mw.config.get( 'wgAjaxUploadDestCheck' ),
+ fileExtensions = mw.config.get( 'wgFileExtensions' );
+
window.licenseSelectorCheck = function() {
var selector = document.getElementById( "wpLicense" );
var selection = selector.options[selector.selectedIndex].value;
window.licenseSelectorCheck = function() {
var selector = document.getElementById( "wpLicense" );
var selection = selector.options[selector.selectedIndex].value;
wgUploadLicenseObj.fetchPreview( selection );
};
wgUploadLicenseObj.fetchPreview( selection );
};
-window.wgUploadSetup = function() {
+function uploadSetup() {
// Disable URL box if the URL copy upload source type is not selected
var e = document.getElementById( 'wpSourceTypeurl' );
if( e ) {
// Disable URL box if the URL copy upload source type is not selected
var e = document.getElementById( 'wpSourceTypeurl' );
if( e ) {
}
// AJAX wpDestFile warnings
}
// AJAX wpDestFile warnings
- if ( wgAjaxUploadDestCheck ) {
+ if ( ajaxUploadDestCheck ) {
// Insert an event handler that fetches upload warnings when wpDestFile
// has been changed
document.getElementById( 'wpDestFile' ).onchange = function ( e ) {
// Insert an event handler that fetches upload warnings when wpDestFile
// has been changed
document.getElementById( 'wpDestFile' ).onchange = function ( e ) {
}
var wpLicense = document.getElementById( 'wpLicense' );
}
var wpLicense = document.getElementById( 'wpLicense' );
- if ( wgAjaxLicensePreview && wpLicense ) {
+ if ( mw.config.get( 'wgAjaxLicensePreview' ) && wpLicense ) {
// License selector check
wpLicense.onchange = licenseSelectorCheck;
// License selector check
wpLicense.onchange = licenseSelectorCheck;
- for ( var i = 0; i < wgUploadSourceIds.length; i++ )
- document.getElementById( wgUploadSourceIds[i] ).onchange = function (e) {
+ var i,
+ uploadSourceIds = mw.config.get( 'wgUploadSourceIds' ),
+ len = uploadSourceIds.length;
+ for ( i = 0; i < len; i += 1 )
+ document.getElementById( uploadSourceIds[i] ).onchange = function (e) {
fillDestFilename( this.id );
};
};
fillDestFilename( this.id );
};
};
'timeoutID': false,
'keypress': function () {
'timeoutID': false,
'keypress': function () {
- if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
+ if ( !ajaxUploadDestCheck || !sajax_init_object() ) return;
// Find file to upload
var destFile = document.getElementById('wpDestFile');
// Find file to upload
var destFile = document.getElementById('wpDestFile');
},
'checkNow': function (fname) {
},
'checkNow': function (fname) {
- if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
+ if ( !ajaxUploadDestCheck || !sajax_init_object() ) return;
if ( this.timeoutID ) {
window.clearTimeout( this.timeoutID );
}
if ( this.timeoutID ) {
window.clearTimeout( this.timeoutID );
}
},
'timeout' : function() {
},
'timeout' : function() {
- if ( !wgAjaxUploadDestCheck || !sajax_init_object() ) return;
+ if ( !ajaxUploadDestCheck || !sajax_init_object() ) return;
injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
// Get variables into local scope so that they will be preserved for the
injectSpinner( document.getElementById( 'wpDestFile' ), 'destcheck' );
// Get variables into local scope so that they will be preserved for the
};
window.fillDestFilename = function(id) {
};
window.fillDestFilename = function(id) {
- if (!wgUploadAutoFill) {
+ if ( !mw.config.get( 'wgUploadAutoFill' ) ) {
return;
}
if (!document.getElementById) {
return;
}
if (!document.getElementById) {
// Clear the filename if it does not have a valid extension.
// URLs are less likely to have a useful extension, so don't include them in the
// extension check.
// Clear the filename if it does not have a valid extension.
// URLs are less likely to have a useful extension, so don't include them in the
// extension check.
- if( wgStrictFileExtensions && wgFileExtensions && id != 'wpUploadFileURL' ) {
+ if ( mw.config.get( 'wgStrictFileExtensions' ) && fileExtensions && id !== 'wpUploadFileURL' ) {
- if( fname.lastIndexOf( '.' ) != -1 ) {
+ if ( fname.lastIndexOf( '.' ) !== -1 ) {
var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 );
var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 );
- for( var i = 0; i < wgFileExtensions.length; i++ ) {
- if( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() ) {
+ for ( var i = 0; i < fileExtensions.length; i += 1 ) {
+ if ( fileExtensions[i].toLowerCase() === ext.toLowerCase() ) {
// Replace spaces by underscores
fname = fname.replace( / /g, '_' );
// Capitalise first letter if needed
// Replace spaces by underscores
fname = fname.replace( / /g, '_' );
// Capitalise first letter if needed
- if ( wgCapitalizeUploads ) {
+ if ( mw.config.get( 'wgCapitalizeUploads' ) ) {
fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) );
}
fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) );
}
'responseCache' : { '' : '' },
'fetchPreview': function( license ) {
'responseCache' : { '' : '' },
'fetchPreview': function( license ) {
- if( !wgAjaxLicensePreview ) return;
+ if ( !mw.config.get( 'wgAjaxLicensePreview' ) ) return;
for (cached in this.responseCache) {
if (cached == license) {
this.showPreview( this.responseCache[license] );
for (cached in this.responseCache) {
if (cached == license) {
this.showPreview( this.responseCache[license] );
var title = document.getElementById('wpDestFile').value;
if ( !title ) title = 'File:Sample.jpg';
var title = document.getElementById('wpDestFile').value;
if ( !title ) title = 'File:Sample.jpg';
- var url = wgScriptPath + '/api' + wgScriptExtension
+ var url = mw.util.wikiScript( 'api' )
+ '?action=parse&text={{' + encodeURIComponent( license ) + '}}'
+ '&title=' + encodeURIComponent( title )
+ '&prop=text&pst&format=json';
+ '?action=parse&text={{' + encodeURIComponent( license ) + '}}'
+ '&title=' + encodeURIComponent( title )
+ '&prop=text&pst&format=json';
-addOnloadHook( wgUploadSetup );
+$( document ).ready( uploadSetup );
+
+}() );
};
window.importScript = function( page ) {
};
window.importScript = function( page ) {
- // TODO: might want to introduce a utility function to match wfUrlencode() in PHP
- var uri = wgScript + '?title=' +
- encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
+ var uri = mw.config.get( 'wgScript' ) + '?title=' +
+ mw.util.wikiUrlencode( page ) +
'&action=raw&ctype=text/javascript';
return importScriptURI( uri );
};
'&action=raw&ctype=text/javascript';
return importScriptURI( uri );
};
};
window.importStylesheet = function( page ) {
};
window.importStylesheet = function( page ) {
- return importStylesheetURI( wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent( page.replace(/ /g,'_') ) );
+ return importStylesheetURI( mw.config.get( 'wgScript' ) + '?action=raw&ctype=text/css&title=' + mw.util.wikiUrlencode( page ) );
};
window.importStylesheetURI = function( url, media ) {
};
window.importStylesheetURI = function( url, media ) {
$this->assertEquals(
array( NS_MAIN, NS_USER, NS_CATEGORY ),
MWNamespace::getcontentNamespaces(),
$this->assertEquals(
array( NS_MAIN, NS_USER, NS_CATEGORY ),
MWNamespace::getcontentNamespaces(),
- 'NS_MAIN is forced in wgContentNamespaces even if unwanted'
+ 'NS_MAIN is forced in $wgContentNamespaces even if unwanted'
);
# test other cases, return $wgcontentNamespaces as is
);
# test other cases, return $wgcontentNamespaces as is
- * test uploading a 100 bytes file with wgMaxUploadSize = 100
+ * test uploading a 100 bytes file with $wgMaxUploadSize = 100
*
* This method should be abstracted so we can test different settings.
*/
*
* This method should be abstracted so we can test different settings.
*/
- * Test wgNoFollowLinks in sidebar
+ * Test $wgNoFollowLinks in sidebar
*/
function testRespectWgnofollowlinks() {
global $wgNoFollowLinks;
*/
function testRespectWgnofollowlinks() {
global $wgNoFollowLinks;
$attribs = $this->getAttribs();
$this->assertArrayNotHasKey( 'rel', $attribs,
$attribs = $this->getAttribs();
$this->assertArrayNotHasKey( 'rel', $attribs,
- 'External URL in sidebar do not have rel=nofollow when wgNoFollowLinks = false'
+ 'External URL in sidebar do not have rel=nofollow when $wgNoFollowLinks = false'
- * Test wgExternaLinkTarget in sidebar
+ * Test $wgExternaLinkTarget in sidebar
*/
function testRespectExternallinktarget() {
global $wgExternalLinkTarget;
*/
function testRespectExternallinktarget() {
global $wgExternalLinkTarget;