Fix NS_PROJECT_TALK (bug #7792)
[lhc/web/wiklou.git] / includes / OutputPage.php
index 1dbcb9f..d83e1e1 100644 (file)
@@ -72,6 +72,16 @@ class OutputPage {
        function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
        function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
        function addScript( $script ) { $this->mScripts .= $script; }
+
+       /**
+        * Add a self-contained script tag with the given contents
+        * @param string $script JavaScript text, no <script> tags
+        */
+       function addInlineScript( $script ) {
+               global $wgJsMimeType;
+               $this->mScripts .= "<script type=\"$wgJsMimeType\"><!--\n$script\n--></script>";
+       }
+
        function getScript() { return $this->mScripts; }
 
        function setETag($tag) { $this->mETag = $tag; }
@@ -134,10 +144,12 @@ class OutputPage {
                                $this->sendCacheControl();
                                wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
                                $this->disable();
-                               // Don't output compressed blob
-                               while( $status = ob_get_status() ) {
-                                       ob_end_clean();
-                               }
+                               
+                               // Don't output a compressed blob when using ob_gzhandler;
+                               // it's technically against HTTP spec and seems to confuse
+                               // Firefox when the response gets split over two packets.
+                               wfClearOutputBuffers();
+                               
                                return true;
                        } else {
                                wfDebug( "$fname: READY  client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
@@ -512,8 +524,8 @@ class OutputPage {
        public function output() {
                global $wgUser, $wgOutputEncoding, $wgRequest;
                global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
-               global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgServer;
-               global $wgStyleVersion;
+               global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgAjaxWatch;
+               global $wgServer, $wgStyleVersion;
 
                if( $this->mDoNothing ){
                        return;
@@ -524,11 +536,14 @@ class OutputPage {
 
                if ( $wgUseAjax ) {
                        $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" );
-               }
+                       if( $wgAjaxSearch ) {
+                               $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js\"></script>\n" );
+                               $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
+                       }
 
-               if ( $wgUseAjax && $wgAjaxSearch ) {
-                       $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js?$wgStyleVersion\"></script>\n" );
-                       $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
+                       if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
+                               $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js\"></script>\n" );
+                       }
                }
 
                if ( '' != $this->mRedirect ) {
@@ -652,7 +667,7 @@ class OutputPage {
        /**
         * @todo document
         */
-       public function setEncodings() {
+       public static function setEncodings() {
                global $wgInputEncoding, $wgOutputEncoding;
                global $wgUser, $wgContLang;
 
@@ -699,7 +714,9 @@ class OutputPage {
                }
                $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
 
-               $this->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
+               $blockid = $wgUser->mBlock->mId;
+
+               $this->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name, $blockid ) );
                
                # Don't auto-return to special pages
                if( $return ) {
@@ -837,7 +854,7 @@ class OutputPage {
                
                # Don't return to the main page if the user can't read it
                # otherwise we'll end up in a pointless loop
-               $mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+               $mainPage = Title::newMainPage();
                if( $mainPage->userCanRead() )
                        $this->returnToMain( true, $mainPage );
        }
@@ -868,7 +885,7 @@ class OutputPage {
                        if( $wgTitle->getNamespace() == NS_MEDIAWIKI && !$wgUser->isAllowed( 'editinterface' ) ) {
                                $this->addWikiText( wfMsg( 'protectedinterface' ) );
                        } else {
-                               $this->addWikiText( wfMsg( 'protectedtext' ) );
+                               $this->addWikiText( wfMsg( 'protectedpagetext' ) );
                        }
                } else {
                        $this->setPageTitle( wfMsg( 'readonly' ) );
@@ -881,6 +898,7 @@ class OutputPage {
                }
 
                if( is_string( $source ) ) {
+                       $this->addWikiText( wfMsg( 'viewsourcetext' ) );
                        if( $source === '' ) {
                                global $wgTitle;
                                if ( $wgTitle->getNamespace() == NS_MEDIAWIKI ) {
@@ -974,7 +992,7 @@ class OutputPage {
                }
                
                if ( '' === $returnto ) {
-                       $returnto = wfMsgForContent( 'mainpage' );
+                       $returnto = Title::newMainPage();
                }
 
                if ( is_object( $returnto ) ) {