Introducing $wgFeed variable. Allows tuning sydication feeds off, when desired.
authorHuji <huji@users.mediawiki.org>
Fri, 22 Feb 2008 12:33:51 +0000 (12:33 +0000)
committerHuji <huji@users.mediawiki.org>
Fri, 22 Feb 2008 12:33:51 +0000 (12:33 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/OutputPage.php
includes/PageHistory.php
includes/QueryPage.php
includes/SpecialRecentchanges.php
languages/messages/MessagesEn.php

index 662e2ed..c823ecb 100644 (file)
@@ -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 ===
 
index f30d34a..f97d2af 100644 (file)
@@ -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;
index 1fe36a5..917a730 100644 (file)
@@ -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;
        }
        
index 0c44682..2cd56f9 100644 (file)
@@ -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' );
index eb4e71b..243f976 100644 (file)
@@ -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](
index 60a04e0..2fee735 100644 (file)
@@ -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." );
index 43d0d9c..2825d70 100644 (file)
@@ -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',