Replace imho ugly viewsourcefor subtitle with viewsourcetitle and viewsourceheader...
[lhc/web/wiklou.git] / includes / OutputPage.php
index 5334ec3..2c9e064 100644 (file)
@@ -1992,10 +1992,10 @@ class OutputPage {
                if ( !empty( $reasons ) ) {
                        // Permissions error
                        if( $source ) {
-                               $this->setPageTitle( wfMsg( 'viewsource' ) );
-                               $this->setSubtitle(
-                                       wfMsg( 'viewsourcefor', $skin->linkKnown( $this->getTitle() ) )
-                               );
+                               $title = $this->getTitle();
+                               $link = $skin->linkKnown( $title );
+                               $this->mPagetitle = wfMessage( 'viewsourceheader' )->rawParams( $link )->escaped();
+                               $this->mHTMLtitle = wfMessage( 'viewsourcetitle', $title->getPrefixedText() )->escaped();
                        } else {
                                $this->setPageTitle( wfMsg( 'badaccess' ) );
                        }
@@ -2280,8 +2280,10 @@ class OutputPage {
                return $ret;
        }
        
-       static function makeResourceLoaderLink( $skin, $modules, $only ) {
-               global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug;
+       // TODO: Document
+       static function makeResourceLoaderLink( $skin, $modules, $only, $useESI = false ) {
+               global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug, $wgResourceLoaderUseESI,
+                       $wgResourceLoaderInlinePrivateModules;
                // TODO: Should this be a static function of ResourceLoader instead?
                // TODO: Divide off modules starting with "user", and add the user parameter to them
                $query = array(
@@ -2307,31 +2309,60 @@ class OutputPage {
                $links = '';
                foreach ( $groups as $group => $modules ) {
                        $query['modules'] = implode( '|', array_keys( $modules ) );
-                       // Special handling for user group
-                       if ( $group === 'user' && $wgUser->isLoggedIn() ) {
+                       // Special handling for user-specific groups
+                       if ( ( $group === 'user' || $group === 'private' ) && $wgUser->isLoggedIn() ) {
                                $query['user'] = $wgUser->getName();
                        }
+                       // Support inlining of private modules if configured as such
+                       if ( $group === 'private' && $wgResourceLoaderInlinePrivateModules ) {
+                               $context = new ResourceLoaderContext( new FauxRequest( $query ) );
+                               if ( $only == 'styles' ) {
+                                       $links .= Html::inlineStyle(
+                                               ResourceLoader::makeLoaderConditionalScript(
+                                                       ResourceLoader::makeModuleResponse( $context, $modules )
+                                               )
+                                       );
+                               } else {
+                                       $links .= Html::inlineScript(
+                                               ResourceLoader::makeLoaderConditionalScript(
+                                                       ResourceLoader::makeModuleResponse( $context, $modules )
+                                               )
+                                       );
+                               }
+                               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
                        if ( $group === 'user' || $group === 'site' ) {
                                // Create a fake request based on the one we are about to make so modules return correct times
-                               $request = new ResourceLoaderContext( new FauxRequest( $query ) );
+                               $context = new ResourceLoaderContext( new FauxRequest( $query ) );
                                // Get the maximum timestamp
                                $timestamp = 0;
                                foreach ( $modules as $module ) {
-                                       $timestamp = max( $timestamp, $module->getModifiedTime( $request ) );
+                                       $timestamp = max( $timestamp, $module->getModifiedTime( $context ) );
                                }
                                // Add a version parameter so cache will break when things change
                                $query['version'] = wfTimestamp( TS_ISO_8601, round( $timestamp, -2 ) );
                        }
                        // Make queries uniform in order
                        ksort( $query );
-                       // Automatically select style/script elements
-                       if ( $only === 'styles' ) {
-                               $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+                       
+                       $url = wfAppendQuery( $wgLoadScript, $query );
+                       if ( $useESI && $wgResourceLoaderUseESI ) {
+                               $esi = Xml::element( 'esi:include', array( 'src' => $url ) );
+                               if ( $only == 'styles' ) {
+                                       $links .= Html::inlineStyle( $esi );
+                               } else {
+                                       $links .= Html::inlineScript( $esi );
+                               }
                        } else {
-                               $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+                               // Automatically select style/script elements
+                               if ( $only === 'styles' ) {
+                                       $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+                               } else {
+                                       $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
+                               }
                        }
                }
                return $links;
@@ -2348,8 +2379,8 @@ class OutputPage {
        function getHeadScripts( Skin $sk ) {
                global $wgUser, $wgRequest, $wgUseSiteJs, $wgResourceLoaderDebug;
                
-               // Statup - this will immediately load jquery and mediawiki modules
-               $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts' );
+               // Startup - this will immediately load jquery and mediawiki modules
+               $scripts = self::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...