Localisation updates from Betawiki.
[lhc/web/wiklou.git] / includes / OutputPage.php
index 834c393..25385f0 100644 (file)
@@ -63,6 +63,10 @@ class OutputPage {
                $this->mRedirect = str_replace( "\n", '', $url );
                $this->mRedirectCode = $responsecode;
        }
+       
+       public function getRedirect() {
+               return $this->mRedirect;
+       }
 
        /**
         * Set the HTTP status code to send with the output.
@@ -351,10 +355,12 @@ class OutputPage {
                wfIncrStats('pcache_not_possible');
 
                $popts = $this->parserOptions();
-               $popts->setTidy($tidy);
+               $oldTidy = $popts->setTidy($tidy);
 
                $parserOutput = $wgParser->parse( $text, $title, $popts,
                        $linestart, true, $this->mRevisionId );
+                       
+               $popts->setTidy( $oldTidy );
 
                $this->addParserOutput( $parserOutput );
 
@@ -758,6 +764,9 @@ class OutputPage {
 
                $name = User::whoIs( $wgUser->blockedBy() );
                $reason = $wgUser->blockedFor();
+               if( $reason == '' ) {
+                       $reason = wfMsg( 'blockednoreason' );
+               }
                $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $wgUser->mBlock->mTimestamp ), true );
                $ip = wfGetIP();
 
@@ -847,7 +856,7 @@ class OutputPage {
                $this->enableClientCache( false );
                $this->mRedirect = '';
                $this->mBodytext = '';
-               $this->addHTML( $this->formatPermissionsErrorMessage( $errors ) );
+               $this->addWikiText( $this->formatPermissionsErrorMessage( $errors ) );
        }
 
        /** @deprecated */
@@ -1009,7 +1018,7 @@ class OutputPage {
                        $this->setPageTitle( wfMsg( 'viewsource' ) );
                        $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) );
 
-                       $this->addHTML( $this->formatPermissionsErrorMessage( $reasons ) );
+                       $this->addWikiText( $this->formatPermissionsErrorMessage( $reasons ) );
                } else if( $protected ) {
                        $this->setPageTitle( wfMsg( 'viewsource' ) );
                        $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) );
@@ -1026,7 +1035,7 @@ class OutputPage {
                                        $titles = '';
                                        foreach( $cascadeSources as $title )
                                                $titles .= "* [[:" . $title->getPrefixedText()  . "]]\n";
-                                       $this->addWikiText( wfMsgExt( 'cascadeprotected', 'parsemag', $count ) . "\n{$titles}" );
+                                       $this->addWikiText( wfMsgExt( 'cascadeprotected', 'parsemag', $count, "\n{$titles}" ) );
                        } elseif( !$wgTitle->isProtected( 'edit' ) && $wgTitle->isNamespaceProtected() ) {
                                // Namespace protection
                                $ns = $wgTitle->getNamespace() == NS_MAIN
@@ -1058,7 +1067,7 @@ class OutputPage {
                $article = new Article( $wgTitle );
                $this->addHTML( $skin->formatTemplates( $article->getUsedTemplates() ) );
 
-               $this->returnToMain( false );
+               $this->returnToMain( false, $wgTitle );
        }
 
        /** @deprecated */
@@ -1275,16 +1284,51 @@ class OutputPage {
                        }
                        $ret .= " />\n";
                }
+               
                if( $this->isSyndicated() ) {
                        # FIXME: centralize the mime-type and name information in Feed.php
-                       $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
-                       $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
-                       $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
-                       $ret .= "<link rel='alternate' type='application/atom+xml' title='Atom 1.0' href='$link' />\n";
+                       # Use the page name for the title (accessed through $wgTitle since
+                       # there's no other way).  In principle, this could lead to issues
+                       # with having the same name for different feeds corresponding to
+                       # the same page, but we can't avoid that at this low a level.
+                       global $wgTitle;
+                       $ret .= $this->feedLink(
+                               'rss',
+                               $wgRequest->appendQuery( 'feed=rss' ),
+                               wfMsg( 'page-rss-feed', $wgTitle->getPrefixedText() ) );
+                       $ret .= $this->feedLink(
+                               'atom',
+                               $wgRequest->appendQuery( 'feed=atom' ),
+                               wfMsg( 'page-atom-feed', $wgTitle->getPrefixedText() ) );
                }
 
+               # Recent changes feed should appear on every page
+               # Put it after the per-page feed to avoid changing existing behavior.
+               # It's still available, probably via a menu in your browser.
+               global $wgSitename;
+               $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
+               $ret .= $this->feedLink(
+                       'rss',
+                       $rctitle->getFullURL( 'feed=rss' ),
+                       wfMsg( 'site-rss-feed', $wgSitename ) );
+               $ret .= $this->feedLink(
+                       'atom',
+                       $rctitle->getFullURL( 'feed=atom' ),
+                       wfMsg( 'site-atom-feed', $wgSitename ) );
+
                return $ret;
        }
+       
+       /**
+        * Generate a <link rel/> for an RSS feed.
+        */
+       private function feedLink( $type, $url, $text ) {
+               return Xml::element( 'link', array(
+                       'rel' => 'alternate',
+                       'type' => "application/$type+xml",
+                       'title' => $text,
+                       'href' => $url ) ) . "\n";
+       }
 
        /**
         * Turn off regular page output and return an error reponse