From: Brion Vibber Date: Mon, 24 Sep 2007 18:25:56 +0000 (+0000) Subject: Clean up r26058, r26059 a bit... X-Git-Tag: 1.31.0-rc.0~51310 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=5be2e63423891d08a2eb000738afd614967c7800;p=lhc%2Fweb%2Fwiklou.git Clean up r26058, r26059 a bit... * We've got these nice functions to do escaping of XML for us, use them. :) * Swapped order so per-page feeds (history, newpages, etc) show up first I'm still not too thrilled with the message texts on the titles. --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 82e19d548e..a0fd4efd1c 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1278,16 +1278,6 @@ class OutputPage { $ret .= " />\n"; } - # Recent changes feed should appear on every page - global $wgSitename; - $rctitle = SpecialPage::getTitleFor( 'Recentchanges' ); - $link = $rctitle->escapeFullURL( 'feed=rss' ); - $title = Sanitizer::encodeAttribute( wfMsg( 'site-rss-feed', $wgSitename ) ); - $ret .= "\n"; - $link = $rctitle->escapeFullURL( 'feed=atom' ); - $title = Sanitizer::encodeAttribute( wfMsg( 'site-atom-feed', $wgSitename ) ); - $ret .= "\n"; - if( $this->isSyndicated() ) { # FIXME: centralize the mime-type and name information in Feed.php # Use the page name for the title (accessed through $wgTitle since @@ -1295,17 +1285,43 @@ class OutputPage { # 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; - $pagetitle = $wgTitle->getPrefixedText(); - $link = $wgRequest->escapeAppendQuery( 'feed=rss' ); - $title = Sanitizer::encodeAttribute( wfMsg( 'page-rss-feed', $pagetitle ) ); - $ret .= "\n"; - $link = $wgRequest->escapeAppendQuery( 'feed=atom' ); - $title = Sanitizer::encodeAttribute( wfMsg( 'page-atom-feed', $pagetitle ) ); - $ret .= "\n"; + $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 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