$sk = $wgUser->getSkin();
// Add base resources
- $this->addModules( array( 'mediawiki.legacy.wikibits' ) );
- $this->addModules( array( 'mediawiki.util' ) );
+ $this->addModules( array( 'mediawiki.legacy.wikibits', 'mediawiki.util' ) );
// Add various resources if required
if ( $wgUseAjax ) {
wfRunHooks( 'AjaxAddScript', array( &$this ) );
if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
- $this->addModules( 'mediawiki.legacy.ajaxwatch' );
+ $this->addModules( 'mediawiki.action.watch.ajax' );
}
if ( $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
print $outs;
}
- /**
- * @todo document
- */
- public static function setEncodings() {
- global $wgInputEncoding, $wgOutputEncoding;
-
- $wgInputEncoding = strtolower( $wgInputEncoding );
-
- if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
- $wgOutputEncoding = strtolower( $wgOutputEncoding );
- return;
- }
- $wgOutputEncoding = $wgInputEncoding;
- }
-
/**
* @deprecated use wfReportTime() instead.
*
$this->mRedirect = '';
$this->mBodytext = '';
- array_unshift( $params, 'parse' );
- array_unshift( $params, $msg );
- $this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );
+ $this->addWikiMsgArray( $msg, $params );
$this->returnToMain();
}
$this->setPageTitle( wfMsg( 'loginreqtitle' ) );
$this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotPolicy( 'noindex,nofollow' );
- $this->setArticleFlag( false );
+ $this->setArticleRelated( false );
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
$loginLink = $skin->link(
$ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n";
$ret .= implode( "\n", array(
- $this->getHeadLinks( $sk ),
- $this->buildCssLinks(),
+ $this->getHeadLinks(),
+ $this->buildCssLinks( $sk ),
$this->getHeadItems(),
) );
if ( $sk->usercss ) {
}
continue;
}
- // Special handling for user and site groups; because users might change their stuff on-wiki like site or
- // user pages, or user preferences; we need to find the highest timestamp of these user-changable modules so
- // we can ensure cache misses on change
+ // Special handling for user and site groups; because users might change their stuff
+ // on-wiki like site or user pages, or user preferences; we need to find the highest
+ // timestamp of these user-changable modules so we can ensure cache misses on change
if ( $group === 'user' || $group === 'site' ) {
- // Create a fake request based on the one we are about to make so modules return correct times
+ // Create a fake request based on the one we are about to make so modules return
+ // correct times
$context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
// Get the maximum timestamp
$timestamp = 1;
// Startup - this will immediately load jquery and mediawiki modules
$scripts = $this->makeResourceLoaderLink( $sk, 'startup', 'scripts', true );
- // Configuration -- This could be merged together with the load and go, but makeGlobalVariablesScript returns a
- // whole script tag -- grumble grumble...
+ // Configuration -- This could be merged together with the load and go, but
+ // makeGlobalVariablesScript returns a whole script tag -- grumble grumble...
$scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n";
- // Script and Messages "only"
-
- // Scripts
+ // Script and Messages "only" requests
$scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleScripts(), 'scripts' );
-
- // Messages
$scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleMessages(), 'messages' );
- // Modules - let the client calculate dependencies and batch requests as it likes
+ // Modules requests - let the client calculate dependencies and batch requests as it likes
if ( $this->getModules() ) {
- $modules = FormatJson::encode( $this->getModules() );
$scripts .= Html::inlineScript(
- "if ( window.mediaWiki ) { mediaWiki.loader.load( {$modules} ); mediaWiki.loader.go(); }"
+ ResourceLoader::makeLoaderConditionalScript(
+ Xml::encodeJsCall( 'mediaWiki.loader.load', array( $this->getModules() ) ) .
+ Xml::encodeJsCall( 'mediaWiki.loader.go', array() )
+ )
) . "\n";
}
+ // Legacy Scripts
+ $scripts .= "\n" . $this->mScripts;
+
+ // Add site JS if enabled
+ if ( $wgUseSiteJs ) {
+ $scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' );
+ }
+
// Add user JS if enabled - trying to load user.options as a bundle if possible
$userOptionsAdded = false;
if ( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
$action = $wgRequest->getVal( 'action', 'view' );
if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) {
# XXX: additional security check/prompt?
- $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) );
+ $scripts .= Html::inlineScript( "\n" . $wgRequest->getText( 'wpTextbox1' ) . "\n" ) . "\n";
} else {
- $scripts .= $this->makeResourceLoaderLink( $sk, array( 'user', 'user.options' ), 'scripts' );
+ $scripts .= $this->makeResourceLoaderLink(
+ $sk, array( 'user', 'user.options' ), 'scripts'
+ );
$userOptionsAdded = true;
}
}
if ( !$userOptionsAdded ) {
$scripts .= $this->makeResourceLoaderLink( $sk, 'user.options', 'scripts' );
}
- $scripts .= "\n" . $this->mScripts;
-
- // Add site JS if enabled
- if ( $wgUseSiteJs ) {
- $scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' );
- }
-
+
return $scripts;
}
/**
* @return string HTML tag links to be put in the header.
*/
- public function getHeadLinks( Skin $sk ) {
+ public function getHeadLinks() {
global $wgFeed;
// Ideally this should happen earlier, somewhere. :P
}
}
- $tags[] = $this->makeResourceLoaderLink( $sk, $this->getModuleStyles(), 'styles' );
-
return implode( "\n", $tags );
}
* Build a set of <link>s for the stylesheets specified in the $this->styles array.
* These will be applied to various media & IE conditionals.
*/
- public function buildCssLinks() {
- return implode( "\n", $this->buildCssLinksArray() );
+ public function buildCssLinks( $sk ) {
+ // Split the styles into three groups
+ $styles = array( 'other' => array(), 'user' => array(), 'site' => array() );
+ $resourceLoader = $this->getResourceLoader();
+ foreach ( $this->getModuleStyles() as $name ) {
+ $group = $resourceLoader->getModule( $name )->getGroup();
+ // Modules in groups named "other" or anything different than "user" or "site" will
+ // be placed in the "other" group
+ $styles[isset( $style[$group] ) ? $group : 'other'][] = $name;
+ }
+ // Add tags created using legacy methods
+ $tags = $this->buildCssLinksArray();
+ // Add ResourceLoader module style tags
+ $tags[] = $this->makeResourceLoaderLink(
+ $sk, array_merge( $styles['other'], $styles['site'], $styles['user'] ), 'styles'
+ );
+ return implode( "\n", $tags );
}
public function buildCssLinksArray() {