From: Huji Date: Fri, 22 Feb 2008 12:33:51 +0000 (+0000) Subject: Introducing $wgFeed variable. Allows tuning sydication feeds off, when desired. X-Git-Tag: 1.31.0-rc.0~49400 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=206bbe7dc82d8527aa12ab0d5ad21449d7ab3b84;p=lhc%2Fweb%2Fwiklou.git Introducing $wgFeed variable. Allows tuning sydication feeds off, when desired. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 662e2ede2a..c823ecbd68 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -170,6 +170,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN confused when they are told they are range-blocked. * Put "not yet written" in the title attribute of red links, so that readers unfamiliar with the site might guess what the colour means. +* One can turn off syndicatino feeds by setting $wgFeed to false === Bug fixes in 1.12 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f30d34ad01..f97d2af4a2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2164,6 +2164,9 @@ $wgUseRCPatrol = true; /** Use new page patrolling to check new pages on special:Newpages */ $wgUseNPPatrol = true; +/** Provide syndication feeds (RSS, Atom) for eg REcentchanges, Newpages. */ +$wgFeed = true; + /** Set maximum number of results to return in syndication feeds (RSS, Atom) for * eg Recentchanges, Newpages. */ $wgFeedLimit = 50; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 1fe36a5f75..917a730c24 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1337,7 +1337,7 @@ class OutputPage { * @return string HTML tag links to be put in the header. */ public function getHeadLinks() { - global $wgRequest; + global $wgRequest, $wgFeed; $ret = ''; foreach ( $this->mMetatags as $tag ) { if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) { @@ -1372,33 +1372,35 @@ class OutputPage { $ret .= " />\n"; } - foreach( $this->getSyndicationLinks() as $format => $link ) { - # 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; - + if( $wgFeed ) { + foreach( $this->getSyndicationLinks() as $format => $link ) { + # 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( + $format, + $link, + wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep) + } + + # 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( - $format, - $link, - wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep) + 'atom', + $rctitle->getFullURL( 'feed=atom' ), + wfMsg( 'site-atom-feed', $wgSitename ) ); } - # 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; } diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 0c44682e6f..2cd56f9ec4 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -483,7 +483,14 @@ class PageHistory { function feed( $type ) { require_once 'SpecialRecentchanges.php'; - global $wgFeedClasses; + global $wgFeed, $wgFeedClasses; + + if ( !$wgFeed ) { + global $wgOut; + $wgOut->addWikiMsg( 'feed-unavailable' ); + return; + } + if( !isset( $wgFeedClasses[$type] ) ) { global $wgOut; $wgOut->addWikiMsg( 'feed-invalid' ); diff --git a/includes/QueryPage.php b/includes/QueryPage.php index eb4e71bf7b..243f9769bf 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -448,7 +448,13 @@ class QueryPage { * Similar to above, but packaging in a syndicated feed instead of a web page */ function doFeed( $class = '', $limit = 50 ) { - global $wgFeedClasses; + global $wgFeed, $wgFeedClasses; + + if ( !$wgFeed ) { + global $wgOut; + $wgOut->addWikiMsg( 'feed-unavailable' ); + return; + } if( isset($wgFeedClasses[$class]) ) { $feed = new $wgFeedClasses[$class]( diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 60a04e00a4..2fee735bd9 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -326,6 +326,13 @@ function rcFilterByCategories ( &$rows , $categories , $any ) { function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) { global $messageMemc, $wgFeedCacheTimeout; global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode; + global $wgFeed; + + if ( !$wgFeed ) { + global $wgOut; + $wgOut->addWikiMsg( 'feed-unavailable' ); + return; + } if( !isset( $wgFeedClasses[$feedFormat] ) ) { wfHttpError( 500, "Internal Server Error", "Unsupported feed type." ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 43d0d9c1c4..2825d70d05 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -711,6 +711,7 @@ XHTML id names. 'restorelink' => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}', 'feedlinks' => 'Feed:', 'feed-invalid' => 'Invalid subscription feed type.', +'feed-unavailable' => 'Syndication feeds are not available on {{SITENAME}}', 'site-rss-feed' => '$1 RSS Feed', 'site-atom-feed' => '$1 Atom Feed', 'page-rss-feed' => '"$1" RSS Feed',