/**
* Add new language links
*
- * @param $newLinkArray Associative array mapping language code to the page
+ * @param $newLinkArray array Associative array mapping language code to the page
* name
*/
public function addLanguageLinks( $newLinkArray ) {
/**
* Reset the language links and add new language links
*
- * @param $newLinkArray Associative array mapping language code to the page
+ * @param $newLinkArray array Associative array mapping language code to the page
* name
*/
public function setLanguageLinks( $newLinkArray ) {
/**
* Get/set the ParserOptions object to use for wikitext parsing
*
- * @param $options either the ParserOption to use or null to only get the
+ * @param $options ParserOptions|null either the ParserOption to use or null to only get the
* current ParserOption object
* @return ParserOptions object
*/
/**
* Set the displayed file version
*
- * @param $file File|false
+ * @param $file File|bool
* @return Mixed: previous value
*/
public function setFileVersion( $file ) {
* Add a "return to" link pointing to a specified title,
* or the title indicated in the request, or else the main page
*
- * @param $unused No longer used
+ * @param $unused
* @param $returnto Title or String to return to
* @param $returntoquery String: query string for the return to link
*/
* Add the default ResourceLoader modules to this object
*/
private function addDefaultModules() {
- global $wgIncludeLegacyJavaScript, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
+ global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
+ $wgAjaxWatch, $wgEnableMWSuggest;
// Add base resources
$this->addModules( array(
'mediawiki.user',
- 'mediawiki.util',
'mediawiki.page.startup',
'mediawiki.page.ready',
) );
$this->addModules( 'mediawiki.legacy.wikibits' );
}
+ if ( $wgPreloadJavaScriptMwUtil ) {
+ $this->addModules( 'mediawiki.util' );
+ }
+
+ MWDebug::addModules( $this );
+
// Add various resources if required
if ( $wgUseAjax ) {
$this->addModules( 'mediawiki.legacy.ajax' );
);
// Load embeddable private modules before any loader links
+ // This needs to be TYPE_COMBINED so these modules are properly wrapped
+ // in mw.loader.implement() calls and deferred until mw.user is available
$embedScripts = array( 'user.options', 'user.tokens' );
$scripts .= $this->makeResourceLoaderLink( $embedScripts, ResourceLoaderModule::TYPE_COMBINED );
if ( $modules ) {
$scripts .= Html::inlineScript(
ResourceLoader::makeLoaderConditionalScript(
- "mw.loader.setBlocking( true );\n" .
- Xml::encodeJsCall( 'mw.loader.load', array( $modules ) ) .
- "\nmw.loader.setBlocking( false );"
+ Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
)
);
}
/**
* JS stuff to put at the bottom of the <body>
+ * @return string
*/
function getBottomScripts() {
global $wgResourceLoaderExperimentalAsyncLoading;
public function getJSVars() {
global $wgUseAjax, $wgEnableMWSuggest;
+ $latestRevID = 0;
+ $pageID = 0;
+ $canonicalName = false; # bug 21115
+
$title = $this->getTitle();
$ns = $title->getNamespace();
$nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $title->getNsText();
+
if ( $ns == NS_SPECIAL ) {
list( $canonicalName, /*...*/ ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
- } else {
- $canonicalName = false; # bug 21115
+ } elseif ( $this->canUseWikiPage() ) {
+ $wikiPage = $this->getWikiPage();
+ $latestRevID = $wikiPage->getLatest();
+ $pageID = $wikiPage->getId();
}
$lang = $title->getPageLanguage();
'wgNamespaceNumber' => $title->getNamespace(),
'wgPageName' => $title->getPrefixedDBKey(),
'wgTitle' => $title->getText(),
- 'wgCurRevisionId' => $title->getLatestRevID(),
- 'wgArticleId' => $title->getArticleId(),
+ 'wgCurRevisionId' => $latestRevID,
+ 'wgArticleId' => $pageID,
'wgIsArticle' => $this->isArticle(),
'wgAction' => Action::getActionName( $this->getContext() ),
'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
}
/**
- * @param $unused Unused
+ * @param $unused
* @param $addContentType bool
*
* @return string HTML tag links to be put in the header.
// Per-user preference styles
if ( $wgAllowUserCssPrefs ) {
- $moduleStyles[] = 'user.options';
+ $moduleStyles[] = 'user.cssprefs';
}
foreach ( $moduleStyles as $name ) {