Merge "Convert mediawiki.toc and mediawiki.user to using mw.cookie"
[lhc/web/wiklou.git] / includes / OutputPage.php
index cac89f4..db22166 100644 (file)
@@ -162,9 +162,6 @@ class OutputPage extends ContextSource {
        /** @var array */
        protected $mModuleStyles = array();
 
-       /** @var array */
-       protected $mModuleMessages = array();
-
        /** @var ResourceLoader */
        protected $mResourceLoader;
 
@@ -613,24 +610,24 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of module messages to include on this page
         *
+        * @deprecated since 1.26 Obsolete
         * @param bool $filter
         * @param string|null $position
-        *
         * @return array Array of module names
         */
        public function getModuleMessages( $filter = false, $position = null ) {
-               return $this->getModules( $filter, $position, 'mModuleMessages' );
+               wfDeprecated( __METHOD__, '1.26' );
+               return array();
        }
 
        /**
-        * Add only messages of one or more modules recognized by the resource loader.
-        * Module messages added through this function will be loaded by the resource
-        * loader when the page loads.
+        * Load messages of one or more ResourceLoader modules.
         *
+        * @deprecated since 1.26 Use addModules() instead
         * @param string|array $modules Module name (string) or array of module names
         */
        public function addModuleMessages( $modules ) {
-               $this->mModuleMessages = array_merge( $this->mModuleMessages, (array)$modules );
+               wfDeprecated( __METHOD__, '1.26' );
        }
 
        /**
@@ -1401,8 +1398,10 @@ class OutputPage extends ContextSource {
 
        /**
         * Adds help link with an icon via page indicators.
-        * @param string $to
-        * @param bool $overrideBaseUrl
+        * Link target can be overridden by a local message containing a wikilink:
+        * the message key is: lowercase action or special page name + '-helppage'.
+        * @param string $to Target MediaWiki.org page title or encoded URL.
+        * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
         * @since 1.25
         */
        public function addHelpLink( $to, $overrideBaseUrl = false ) {
@@ -1415,6 +1414,7 @@ class OutputPage extends ContextSource {
                        $toUrlencoded = wfUrlencode( str_replace( ' ', '_', $to ) );
                        $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$toUrlencoded";
                }
+
                $link = Html::rawElement(
                        'a',
                        array(
@@ -1758,7 +1758,6 @@ class OutputPage extends ContextSource {
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
-               $this->addModuleMessages( $parserOutput->getModuleMessages() );
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
                $this->mPreventClickjacking = $this->mPreventClickjacking
                        || $parserOutput->preventClickjacking();
@@ -1805,7 +1804,6 @@ class OutputPage extends ContextSource {
                $this->addModules( $parserOutput->getModules() );
                $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
-               $this->addModuleMessages( $parserOutput->getModuleMessages() );
 
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
        }
@@ -2854,10 +2852,8 @@ class OutputPage extends ContextSource {
                                                        $resourceLoader->makeModuleResponse( $context, $grpModules )
                                                );
                                        } else {
-                                               $links['html'] .= Html::inlineScript(
-                                                       ResourceLoader::makeLoaderConditionalScript(
-                                                               $resourceLoader->makeModuleResponse( $context, $grpModules )
-                                                       )
+                                               $links['html'] .= ResourceLoader::makeInlineScript(
+                                                       $resourceLoader->makeModuleResponse( $context, $grpModules )
                                                );
                                        }
                                        $links['html'] .= "\n";
@@ -2896,10 +2892,8 @@ class OutputPage extends ContextSource {
                                        if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
                                                $link = Html::linkedStyle( $url );
                                        } elseif ( $loadCall ) {
-                                               $link = Html::inlineScript(
-                                                       ResourceLoader::makeLoaderConditionalScript(
-                                                               Xml::encodeJsCall( 'mw.loader.load', array( $url, 'text/javascript', true ) )
-                                                       )
+                                               $link = ResourceLoader::makeInlineScript(
+                                                       Xml::encodeJsCall( 'mw.loader.load', array( $url, 'text/javascript', true ) )
                                                );
                                        } else {
                                                $link = Html::linkedScript( $url );
@@ -2908,10 +2902,8 @@ class OutputPage extends ContextSource {
                                                        // browsers not supported by the startup module would unconditionally
                                                        // execute this module. Otherwise users will get "ReferenceError: mw is
                                                        // undefined" or "jQuery is undefined" from e.g. a "site" module.
-                                                       $link = Html::inlineScript(
-                                                               ResourceLoader::makeLoaderConditionalScript(
-                                                                       Xml::encodeJsCall( 'document.write', array( $link ) )
-                                                               )
+                                                       $link = ResourceLoader::makeInlineScript(
+                                                               Xml::encodeJsCall( 'document.write', array( $link ) )
                                                        );
                                                }
 
@@ -2955,10 +2947,8 @@ class OutputPage extends ContextSource {
                }
 
                if ( count( $states ) ) {
-                       $html = Html::inlineScript(
-                               ResourceLoader::makeLoaderConditionalScript(
-                                       ResourceLoader::makeLoaderStateScript( $states )
-                               )
+                       $html = ResourceLoader::makeInlineScript(
+                               ResourceLoader::makeLoaderStateScript( $states )
                        ) . "\n" . $html;
                }
 
@@ -2977,10 +2967,8 @@ class OutputPage extends ContextSource {
                $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true );
 
                // Load config before anything else
-               $links[] = Html::inlineScript(
-                       ResourceLoader::makeLoaderConditionalScript(
-                               ResourceLoader::makeConfigSetScript( $this->getJSVars() )
-                       )
+               $links[] = ResourceLoader::makeInlineScript(
+                       ResourceLoader::makeConfigSetScript( $this->getJSVars() )
                );
 
                // Load embeddable private modules before any loader links
@@ -2990,11 +2978,6 @@ class OutputPage extends ContextSource {
                $links[] = $this->makeResourceLoaderLink( $embedScripts, ResourceLoaderModule::TYPE_COMBINED );
 
                // Scripts and messages "only" requests marked for top inclusion
-               // Messages should go first
-               $links[] = $this->makeResourceLoaderLink(
-                       $this->getModuleMessages( true, 'top' ),
-                       ResourceLoaderModule::TYPE_MESSAGES
-               );
                $links[] = $this->makeResourceLoaderLink(
                        $this->getModuleScripts( true, 'top' ),
                        ResourceLoaderModule::TYPE_SCRIPTS
@@ -3004,10 +2987,8 @@ class OutputPage extends ContextSource {
                // Only load modules that have marked themselves for loading at the top
                $modules = $this->getModules( true, 'top' );
                if ( $modules ) {
-                       $links[] = Html::inlineScript(
-                               ResourceLoader::makeLoaderConditionalScript(
-                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules ) )
-                               )
+                       $links[] = ResourceLoader::makeInlineScript(
+                               Xml::encodeJsCall( 'mw.loader.load', array( $modules ) )
                        );
                }
 
@@ -3030,14 +3011,9 @@ class OutputPage extends ContextSource {
         * @return string
         */
        function getScriptsForBottomQueue( $inHead ) {
-               // Scripts and messages "only" requests marked for bottom inclusion
+               // Scripts "only" requests marked for bottom inclusion
                // If we're in the <head>, use load() calls rather than <script src="..."> tags
-               // Messages should go first
                $links = array();
-               $links[] = $this->makeResourceLoaderLink( $this->getModuleMessages( true, 'bottom' ),
-                       ResourceLoaderModule::TYPE_MESSAGES, /* $useESI = */ false, /* $extraQuery = */ array(),
-                       /* $loadCall = */ $inHead
-               );
                $links[] = $this->makeResourceLoaderLink( $this->getModuleScripts( true, 'bottom' ),
                        ResourceLoaderModule::TYPE_SCRIPTS, /* $useESI = */ false, /* $extraQuery = */ array(),
                        /* $loadCall = */ $inHead
@@ -3047,10 +3023,8 @@ class OutputPage extends ContextSource {
                // Only load modules that have marked themselves for loading at the bottom
                $modules = $this->getModules( true, 'bottom' );
                if ( $modules ) {
-                       $links[] = Html::inlineScript(
-                               ResourceLoader::makeLoaderConditionalScript(
-                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
-                               )
+                       $links[] = ResourceLoader::makeInlineScript(
+                               Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
                        );
                }
 
@@ -3923,6 +3897,11 @@ class OutputPage extends ContextSource {
        public function enableOOUI() {
                OOUI\Theme::setSingleton( new OOUI\MediaWikiTheme() );
                OOUI\Element::setDefaultDir( $this->getLanguage()->getDir() );
-               $this->addModuleStyles( 'oojs-ui.styles' );
+               $this->addModuleStyles( array(
+                       'oojs-ui.styles',
+                       'oojs-ui.styles.icons',
+                       'oojs-ui.styles.indicators',
+                       'oojs-ui.styles.textures',
+               ) );
        }
 }