Change calls from Xml::namespaceSelector() to Html::namespaceSelector() since the...
[lhc/web/wiklou.git] / includes / OutputPage.php
index c4c0bd8..47f6641 100644 (file)
@@ -1075,7 +1075,7 @@ class OutputPage extends ContextSource {
        /**
         * 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 ) {
@@ -1085,7 +1085,7 @@ class OutputPage extends ContextSource {
        /**
         * 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 ) {
@@ -1309,7 +1309,7 @@ class OutputPage extends ContextSource {
        /**
         * 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
         */
@@ -1366,7 +1366,7 @@ class OutputPage extends ContextSource {
        /**
         * Set the displayed file version
         *
-        * @param $file File|false
+        * @param $file File|bool
         * @return Mixed: previous value
         */
        public function setFileVersion( $file ) {
@@ -2344,7 +2344,7 @@ $templates
         * 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
         */
@@ -2501,7 +2501,7 @@ $templates
         * @param $only String ResourceLoaderModule TYPE_ class constant
         * @param $useESI boolean
         * @param $extraQuery Array with extra query parameters to add to each request. array( param => value )
-        * @param $loadCall boolean If true, output a mw.loader.load() call rather than a <script src="..."> tag
+        * @param $loadCall boolean If true, output an (asynchronous) mw.loader.load() call rather than a <script src="..."> tag
         * @return string html <script> and <style> tags
         */
        protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array(), $loadCall = false ) {
@@ -2644,7 +2644,7 @@ $templates
                                } else if ( $loadCall ) { 
                                        $link = Html::inlineScript(
                                                ResourceLoader::makeLoaderConditionalScript(
-                                                       Xml::encodeJsCall( 'mw.loader.load', array( $url ) )
+                                                       Xml::encodeJsCall( 'mw.loader.load', array( $url, 'text/javascript', true ) )
                                                )
                                        );
                                } else {
@@ -2681,6 +2681,8 @@ $templates
                );
 
                // 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 );
 
@@ -2695,9 +2697,7 @@ $templates
                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 ) )
                                )
                        );
                }
@@ -2739,7 +2739,7 @@ $templates
                if ( $modules ) {
                        $scripts .= Html::inlineScript(
                                ResourceLoader::makeLoaderConditionalScript(
-                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules ) )
+                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
                                )
                        );
                }
@@ -2788,6 +2788,7 @@ $templates
 
        /**
         * JS stuff to put at the bottom of the <body>
+        * @return string
         */
        function getBottomScripts() {
                global $wgResourceLoaderExperimentalAsyncLoading;
@@ -2829,7 +2830,7 @@ $templates
         * @return array
         */
        public function getJSVars() {
-               global $wgUseAjax, $wgEnableMWSuggest;
+               global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
 
                $latestRevID = 0;
                $pageID = 0;
@@ -2839,6 +2840,10 @@ $templates
                $ns = $title->getNamespace();
                $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $title->getNsText();
 
+               // Get the relevant title so that AJAX features can use the correct page name
+               // when making API requests from certain special pages (bug 34972).
+               $relevantTitle = $this->getSkin()->getRelevantTitle();
+
                if ( $ns == NS_SPECIAL ) {
                        list( $canonicalName, /*...*/ ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
                } elseif ( $this->canUseWikiPage() ) {
@@ -2880,9 +2885,10 @@ $templates
                        'wgPageContentLanguage' => $lang->getCode(),
                        'wgSeparatorTransformTable' => $compactSeparatorTransTable,
                        'wgDigitTransformTable' => $compactDigitTransTable,
+                       'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey(),
                );
-               if ( $lang->hasVariants() ) {
-                       $vars['wgUserVariant'] = $lang->getPreferredVariant();
+               if ( $wgContLang->hasVariants() ) {
+                       $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
                }
                foreach ( $title->getRestrictionTypes() as $type ) {
                        $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
@@ -2932,7 +2938,7 @@ $templates
        }
 
        /**
-        * @param $unused Unused
+        * @param $unused
         * @param $addContentType bool
         *
         * @return string HTML tag links to be put in the header.
@@ -3270,7 +3276,7 @@ $templates
 
                // Per-user preference styles
                if ( $wgAllowUserCssPrefs ) {
-                       $moduleStyles[] = 'user.options';
+                       $moduleStyles[] = 'user.cssprefs';
                }
 
                foreach ( $moduleStyles as $name ) {
@@ -3432,7 +3438,7 @@ $templates
         * @param $args array
         */
        public function addWikiMsgArray( $name, $args ) {
-               $this->addWikiText( $this->msg( $name, $args )->plain() );
+               $this->addHTML( $this->msg( $name, $args )->parseAsBlock() );
        }
 
        /**