Merge "Changed "archived (revisions)" to "deleted (revisions)""
[lhc/web/wiklou.git] / includes / OutputPage.php
index 0f0b2f5..26f9efa 100644 (file)
@@ -1818,6 +1818,11 @@ class OutputPage extends ContextSource {
                        }
                }
 
+               // enable OOUI if requested via ParserOutput
+               if ( $parserOutput->getEnableOOUI() ) {
+                       $this->enableOOUI();
+               }
+
                // Link flags are ignored for now, but may in the future be
                // used to mark individual language links.
                $linkFlags = array();
@@ -2904,7 +2909,8 @@ class OutputPage extends ContextSource {
 
                                // Automatically select style/script elements
                                if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
-                                       $link = Html::linkedStyle( $url );
+                                       $media = $group === 'print' ? 'print' : 'all';
+                                       $link = Html::linkedStyle( $url, $media );
                                } else {
                                        if ( $context->getRaw() || $isRaw ) {
                                                // Startup module can't load itself, needs to use <script> instead of mw.loader.load
@@ -2918,6 +2924,15 @@ class OutputPage extends ContextSource {
                                                        Xml::encodeJsCall( 'mw.loader.load', array( $url ) )
                                                );
                                        }
+
+                                       // For modules requested directly in the html via <script> or mw.loader.load
+                                       // tell mw.loader they are being loading to prevent duplicate requests.
+                                       foreach ( $grpModules as $key => $module ) {
+                                               // Don't output state=loading for the startup module.
+                                               if ( $key !== 'startup' ) {
+                                                       $links['states'][$key] = 'loading';
+                                               }
+                                       }
                                }
 
                                if ( $group == 'noscript' ) {
@@ -3942,21 +3957,34 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
-        * MediaWiki and this OutputPage instance.
+        * Helper function to setup the PHP implementation of OOUI to use in this request.
         *
-        * @since 1.25
+        * @since 1.26
+        * @param String $skinName The Skin name to determine the correct OOUI theme
+        * @param String $dir Language direction
         */
-       public function enableOOUI() {
+       public static function setupOOUI( $skinName = '', $dir = 'ltr' ) {
                $themes = ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
                // Make keys (skin names) lowercase for case-insensitive matching.
                $themes = array_change_key_case( $themes, CASE_LOWER );
-               $skinName = strtolower( $this->getSkin()->getSkinName() );
                $theme = isset( $themes[ $skinName ] ) ? $themes[ $skinName ] : 'MediaWiki';
                // For example, 'OOUI\MediaWikiTheme'.
                $themeClass = "OOUI\\{$theme}Theme";
                OOUI\Theme::setSingleton( new $themeClass() );
-               OOUI\Element::setDefaultDir( $this->getLanguage()->getDir() );
+               OOUI\Element::setDefaultDir( $dir );
+       }
+
+       /**
+        * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
+        * MediaWiki and this OutputPage instance.
+        *
+        * @since 1.25
+        */
+       public function enableOOUI() {
+               self::setupOOUI(
+                       strtolower( $this->getSkin()->getSkinName() ),
+                       $this->getLanguage()->getDir()
+               );
                $this->addModuleStyles( array(
                        'oojs-ui.styles',
                        'oojs-ui.styles.icons',