Merge "Revert "Load 'mediawiki.legacy.commonPrint' styles with a media type property""
[lhc/web/wiklou.git] / includes / OutputPage.php
index 72d8a7c..552e181 100644 (file)
@@ -142,9 +142,6 @@ class OutputPage extends ContextSource {
        /** @var string Inline CSS styles. Use addInlineStyle() sparingly */
        protected $mInlineStyles = '';
 
-       /** @todo Unused? */
-       private $mLinkColours;
-
        /**
         * @var string Used by skin template.
         * Example: $tpl->set( 'displaytitle', $out->mPageLinkTitle );
@@ -2012,21 +2009,20 @@ class OutputPage extends ContextSource {
         * Add an HTTP header that will influence on the cache
         *
         * @param string $header Header name
-        * @param array|null $option
-        * @todo FIXME: Document the $option parameter; it appears to be for
-        *        X-Vary-Options but what format is acceptable?
+        * @param string[]|null $option Options for X-Vary-Options. Possible options are:
+        *  - "string-contains=$XXX" varies on whether the header value as a string
+        *    contains $XXX as a substring.
+        *  - "list-contains=$XXX" varies on whether the header value as a
+        *    comma-separated list contains $XXX as one of the list items.
         */
-       public function addVaryHeader( $header, $option = null ) {
+       public function addVaryHeader( $header, array $option = null ) {
                if ( !array_key_exists( $header, $this->mVaryHeader ) ) {
-                       $this->mVaryHeader[$header] = (array)$option;
-               } elseif ( is_array( $option ) ) {
-                       if ( is_array( $this->mVaryHeader[$header] ) ) {
-                               $this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option );
-                       } else {
-                               $this->mVaryHeader[$header] = $option;
-                       }
+                       $this->mVaryHeader[$header] = array();
+               }
+               if ( !is_array( $option ) ) {
+                       $option = array();
                }
-               $this->mVaryHeader[$header] = array_unique( (array)$this->mVaryHeader[$header] );
+               $this->mVaryHeader[$header] = array_unique( array_merge( $this->mVaryHeader[$header], $option ) );
        }
 
        /**
@@ -2702,14 +2698,14 @@ class OutputPage extends ContextSource {
                }
 
                $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n";
+               $ret .= $this->getInlineHeadScripts() . "\n";
+               $ret .= $this->buildCssLinks() . "\n";
+               $ret .= $this->getExternalHeadScripts() . "\n";
 
                foreach ( $this->getHeadLinksArray() as $item ) {
                        $ret .= $item . "\n";
                }
 
-               $ret .= $this->buildCssLinks() . "\n";
-               $ret .= $this->getHeadScripts() . "\n";
-
                foreach ( $this->mHeadItems as $item ) {
                        $ret .= $item . "\n";
                }
@@ -2878,7 +2874,7 @@ class OutputPage extends ContextSource {
 
                                // Inline private modules. These can't be loaded through load.php for security
                                // reasons, see bug 34907. Note that these modules should be loaded from
-                               // getHeadScripts() before the first loader call. Otherwise other modules can't
+                               // getExternalHeadScripts() before the first loader call. Otherwise other modules can't
                                // properly use them as dependencies (bug 30914)
                                if ( $group === 'private' ) {
                                        if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
@@ -2980,6 +2976,30 @@ class OutputPage extends ContextSource {
         * @return string HTML fragment
         */
        function getHeadScripts() {
+               return $this->getInlineHeadScripts() . "\n" . $this->getExternalHeadScripts();
+       }
+
+       /**
+        * <script src="..."> tags for "<head>". This is the startup module
+        * and other modules marked with position 'top'.
+        *
+        * @return string HTML fragment
+        */
+       function getExternalHeadScripts() {
+               $links = array();
+
+               // Startup - this provides the client with the module manifest and loads jquery and mediawiki base modules
+               $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS );
+
+               return self::getHtmlFromLoaderLinks( $links );
+       }
+
+       /**
+        * <script>...</script> tags to put in "<head>".
+        *
+        * @return string HTML fragment
+        */
+       function getInlineHeadScripts() {
                $links = array();
 
                // Client profile classes for <html>. Allows for easy hiding/showing of UI components.
@@ -2993,9 +3013,6 @@ class OutputPage extends ContextSource {
                        . '.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );'
                );
 
-               // Startup - this provides the client with the module manifest and loads jquery and mediawiki base modules
-               $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS );
-
                // Load config before anything else
                $links[] = ResourceLoader::makeInlineScript(
                        ResourceLoader::makeConfigSetScript( $this->getJSVars() )
@@ -3024,22 +3041,16 @@ class OutputPage extends ContextSource {
                        ResourceLoaderModule::TYPE_SCRIPTS
                );
 
-               if ( $this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) {
-                       $links[] = $this->getScriptsForBottomQueue();
-               }
-
                return self::getHtmlFromLoaderLinks( $links );
        }
 
        /**
-        * JS stuff to put at the 'bottom', which can either be the bottom of the
-        * "<body>" or the bottom of the "<head>" depending on
-        * $wgResourceLoaderExperimentalAsyncLoading: modules marked with position
-        * 'bottom', legacy scripts ($this->mScripts), user preferences, site JS
-        * and user JS.
+        * JS stuff to put at the 'bottom', which goes at the bottom of the `<body>`.
+        * These are modules marked with position 'bottom', legacy scripts ($this->mScripts),
+        * site JS, and user JS.
         *
         * @param bool $unused Previously used to let this method change its output based
-        *  on whether it was called by getHeadScripts() or getBottomScripts().
+        *  on whether it was called by getExternalHeadScripts() or getBottomScripts().
         * @return string
         */
        function getScriptsForBottomQueue( $unused = null ) {
@@ -3120,11 +3131,7 @@ class OutputPage extends ContextSource {
                // In case the skin wants to add bottom CSS
                $this->getSkin()->setupSkinUserCss( $this );
 
-               if ( $this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) {
-                       // Already handled by getHeadScripts()
-                       return '';
-               }
-               return  $this->getScriptsForBottomQueue();
+               return $this->getScriptsForBottomQueue();
        }
 
        /**