r84144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84143‎ | r84144 | r84145 >
Date:02:56, 17 March 2011
Author:bawolff
Status:ok
Tags:
Comment:
Add back support for the semi-useless (Since only supported in atom not rss) comment link feature.

Also update the code docs for FeedSMItem::__construct
Modified paths:
  • /trunk/extensions/GoogleNewsSitemap/FeedSMItem.php (modified) (history)
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php (modified) (history)
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
@@ -146,6 +146,7 @@
147147 */
148148
149149 private function makeFeed( $feed, $res ) {
 150+ global $wgGNSMcommentNamespace;
150151 $feed->outHeader();
151152 foreach ( $res as $row ) {
152153 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
@@ -162,7 +163,8 @@
163164 $feedItem = new FeedSMItem(
164165 $title,
165166 $this->pubDate,
166 - $this->getKeywords( $title )
 167+ $this->getKeywords( $title ),
 168+ $wgGNSMcommentNamespace
167169 );
168170 $feed->outItem( $feedItem );
169171 }
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php
@@ -75,3 +75,9 @@
7676 $wgGNSMmaxResultCount = 50; // Maximum number of results to allow
7777 $wgGNSMfallbackCategory = 'Published'; // Fallback category if no categories are specified.
7878
 79+// $wgGNSMcommentNamespace can be false to mean do not include a <comments> element in the feeds,
 80+// or it can be true, to mean use the talk page of the relevent page as the comments page
 81+// or it can be a specific namespace number ( or NS_BLAH constant) to denote a specific namespace.
 82+// For example, on many Wikinews sites, the comment namespace is Comments (102), not talk.
 83+$wgGNSMcommentNamespace = true;
 84+
Index: trunk/extensions/GoogleNewsSitemap/FeedSMItem.php
@@ -16,14 +16,38 @@
1717 private $title;
1818
1919 /**
20 - * @param Title $title
21 - * @param $pubDate
22 - * @param string $keywords
 20+ * @param Title $title Title object that this entry is for.
 21+ * @param String $pubDate Publish date formattable by wfTimestamp.
 22+ * @param String $keywords Comma separated list of keywords
 23+ * @param Mixed Boolean or Integer. Namespace containing comments page for entry.
 24+ * True for the corresponding talk page of $title
 25+ * False for none
 26+ * An integer for the page name of $title in the specific namespace denoted by that integer.
2327 */
24 - function __construct( $title, $pubDate, $keywords = '' ) {
25 - parent::__construct( $title->getText(), '' /* description */, $title->getFullUrl(), $pubDate );
 28+ function __construct( $title, $pubDate, $keywords = '', $comment = true ) {
 29+
 30+ if ( !$title ) {
 31+ // Paranoia
 32+ throw new MWException( "Invalid title object passed to FeedSMItem" );
 33+ }
 34+
 35+ $commentsURL = '';
 36+ if ( $comment === true ) {
 37+ // The comment ns is this article's talk namespace.
 38+ $commentsURL = $title->getTalkPage()->getFullUrl();
 39+ } else if ( is_int( $comment ) ) {
 40+ // There's a specific comments namespace.
 41+ $commentsTitle = Title::makeTitle( $comment, $title->getDBkey() );
 42+ if ( $commentsTitle ) {
 43+ $commentsURL = $commentsTitle->getFullUrl();
 44+ }
 45+ }
 46+
2647 $this->title = $title;
2748 $this->keywords = $keywords;
 49+
 50+ parent::__construct( $title->getText(), '' /* Description */,
 51+ $title->getFullUrl(), $pubDate, '' /* Author */, $commentsURL );
2852 }
2953
3054 /**

Status & tagging log