Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -146,6 +146,7 @@ |
147 | 147 | */ |
148 | 148 | |
149 | 149 | private function makeFeed( $feed, $res ) { |
| 150 | + global $wgGNSMcommentNamespace; |
150 | 151 | $feed->outHeader(); |
151 | 152 | foreach ( $res as $row ) { |
152 | 153 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
— | — | @@ -162,7 +163,8 @@ |
163 | 164 | $feedItem = new FeedSMItem( |
164 | 165 | $title, |
165 | 166 | $this->pubDate, |
166 | | - $this->getKeywords( $title ) |
| 167 | + $this->getKeywords( $title ), |
| 168 | + $wgGNSMcommentNamespace |
167 | 169 | ); |
168 | 170 | $feed->outItem( $feedItem ); |
169 | 171 | } |
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php |
— | — | @@ -75,3 +75,9 @@ |
76 | 76 | $wgGNSMmaxResultCount = 50; // Maximum number of results to allow |
77 | 77 | $wgGNSMfallbackCategory = 'Published'; // Fallback category if no categories are specified. |
78 | 78 | |
| 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 @@ |
17 | 17 | private $title; |
18 | 18 | |
19 | 19 | /** |
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. |
23 | 27 | */ |
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 | + |
26 | 47 | $this->title = $title; |
27 | 48 | $this->keywords = $keywords; |
| 49 | + |
| 50 | + parent::__construct( $title->getText(), '' /* Description */, |
| 51 | + $title->getFullUrl(), $pubDate, '' /* Author */, $commentsURL ); |
28 | 52 | } |
29 | 53 | |
30 | 54 | /** |