Followup r78786: pass $fname in the raw SQL case too
[lhc/web/wiklou.git] / includes / OutputPage.php
index a80d4eb..47c5605 100644 (file)
@@ -1617,8 +1617,7 @@ class OutputPage {
                $sk = $wgUser->getSkin();
 
                // Add base resources
-               $this->addModules( array( 'mediawiki.legacy.wikibits' ) );
-               $this->addModules( array( 'mediawiki.util' ) );
+               $this->addModules( array( 'mediawiki.legacy.wikibits', 'mediawiki.util' ) );
 
                // Add various resources if required
                if ( $wgUseAjax ) {
@@ -1627,7 +1626,7 @@ class OutputPage {
                        wfRunHooks( 'AjaxAddScript', array( &$this ) );
 
                        if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
-                               $this->addModules( 'mediawiki.legacy.ajaxwatch' );
+                               $this->addModules( 'mediawiki.action.watch.ajax' );
                        }
 
                        if ( $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
@@ -1702,21 +1701,6 @@ class OutputPage {
                print $outs;
        }
 
-       /**
-        * @todo document
-        */
-       public static function setEncodings() {
-               global $wgInputEncoding, $wgOutputEncoding;
-
-               $wgInputEncoding = strtolower( $wgInputEncoding );
-
-               if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
-                       $wgOutputEncoding = strtolower( $wgOutputEncoding );
-                       return;
-               }
-               $wgOutputEncoding = $wgInputEncoding;
-       }
-
        /**
         * @deprecated use wfReportTime() instead.
         *
@@ -1818,9 +1802,7 @@ class OutputPage {
                $this->mRedirect = '';
                $this->mBodytext = '';
 
-               array_unshift( $params, 'parse' );
-               array_unshift( $params, $msg );
-               $this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );
+               $this->addWikiMsgArray( $msg, $params );
 
                $this->returnToMain();
        }
@@ -1905,7 +1887,7 @@ class OutputPage {
                $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
                $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
                $this->setRobotPolicy( 'noindex,nofollow' );
-               $this->setArticleFlag( false );
+               $this->setArticleRelated( false );
 
                $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
                $loginLink = $skin->link(
@@ -2374,11 +2356,12 @@ class OutputPage {
                                }
                                continue;
                        }
-                       // Special handling for user and site groups; because users might change their stuff on-wiki like site or
-                       // user pages, or user preferences; we need to find the highest timestamp of these user-changable modules so
-                       // we can ensure cache misses on change
+                       // Special handling for user and site groups; because users might change their stuff
+                       // on-wiki like site or user pages, or user preferences; we need to find the highest
+                       // timestamp of these user-changable modules so we can ensure cache misses on change
                        if ( $group === 'user' || $group === 'site' ) {
-                               // Create a fake request based on the one we are about to make so modules return correct times
+                               // Create a fake request based on the one we are about to make so modules return
+                               // correct times
                                $context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
                                // Get the maximum timestamp
                                $timestamp = 1;
@@ -2425,48 +2408,50 @@ class OutputPage {
                // Startup - this will immediately load jquery and mediawiki modules
                $scripts = $this->makeResourceLoaderLink( $sk, 'startup', 'scripts', true );
 
-               // Configuration -- This could be merged together with the load and go, but makeGlobalVariablesScript returns a
-               // whole script tag -- grumble grumble...
+               // Configuration -- This could be merged together with the load and go, but
+               // makeGlobalVariablesScript returns a whole script tag -- grumble grumble...
                $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n";
 
-               // Script and Messages "only"
-               
-               // Scripts
+               // Script and Messages "only" requests
                $scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleScripts(), 'scripts' );
-
-               // Messages
                $scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleMessages(), 'messages' );
 
-               // Modules - let the client calculate dependencies and batch requests as it likes
+               // Modules requests - let the client calculate dependencies and batch requests as it likes
                if ( $this->getModules() ) {
-                       $modules = FormatJson::encode( $this->getModules() );
                        $scripts .= Html::inlineScript(
-                               "if ( window.mediaWiki ) { mediaWiki.loader.load( {$modules} ); mediaWiki.loader.go(); }"
+                               ResourceLoader::makeLoaderConditionalScript(
+                                       Xml::encodeJsCall( 'mediaWiki.loader.load', array( $this->getModules() ) ) .
+                                       Xml::encodeJsCall( 'mediaWiki.loader.go', array() )
+                               )
                        ) . "\n";
                }
 
+               // Legacy Scripts
+               $scripts .= "\n" . $this->mScripts;
+
+               // Add site JS if enabled
+               if ( $wgUseSiteJs ) {
+                       $scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' );
+               }
+
                // Add user JS if enabled - trying to load user.options as a bundle if possible
                $userOptionsAdded = false;
                if ( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
                        $action = $wgRequest->getVal( 'action', 'view' );
                        if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) {
                                # XXX: additional security check/prompt?
-                               $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) );
+                               $scripts .= Html::inlineScript( "\n" . $wgRequest->getText( 'wpTextbox1' ) . "\n" ) . "\n";
                        } else {
-                               $scripts .= $this->makeResourceLoaderLink( $sk, array( 'user', 'user.options' ), 'scripts' );
+                               $scripts .= $this->makeResourceLoaderLink(
+                                       $sk, array( 'user', 'user.options' ), 'scripts'
+                               );
                                $userOptionsAdded = true;
                        }
                }
                if ( !$userOptionsAdded ) {
                        $scripts .= $this->makeResourceLoaderLink( $sk, 'user.options', 'scripts' );
                }
-               $scripts .= "\n" . $this->mScripts;
-
-               // Add site JS if enabled
-               if ( $wgUseSiteJs ) {
-                       $scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' );
-               }
-
+               
                return $scripts;
        }
 
@@ -2585,8 +2570,28 @@ class OutputPage {
                        }
                }
 
-               $tags[] = $this->makeResourceLoaderLink( $sk, $this->getModuleStyles(), 'styles' );
-
+               // Split the styles into three groups
+               $styles = array( 'other' => array(), 'user' => array(), 'site' => array() );
+               $resourceLoader = $this->getResourceLoader();
+               foreach ( $this->getModuleStyles() as $name ) {
+                       $group = $resourceLoader->getModule( $name )->getGroup();
+                       // Modules in groups named "other" or anything different than "user" or "site" will
+                       // be placed in the "other" group
+                       $styles[isset( $styles[$group] ) ? $group : 'other'][] = $name;
+               }
+
+               // We want site and user styles to override dynamically added styles from modules, but we want
+               // dynamically added styles to override statically added styles from other modules. So the order
+               // has to be other, dynamic, site, user
+               // Add statically added styles for other modules
+               $tags[] = $this->makeResourceLoaderLink( $sk, $styles['other'], 'styles' );
+               // Add marker tag to mark the place where the client-side loader should inject dynamic styles
+               // We use a <meta> tag with a made-up name for this because that's valid HTML
+               $tags[] = Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
+               // Add site and user styles
+               $tags[] = $this->makeResourceLoaderLink(
+                       $sk, array_merge( $styles['site'], $styles['user'] ), 'styles'
+               );
                return implode( "\n", $tags );
        }