Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -83,34 +83,28 @@ |
84 | 84 | |
85 | 85 | $this->unload_params(); // populates this->params as a side effect |
86 | 86 | |
87 | | - $wgFeedClasses[] = array( 'sitemap' => 'SitemapFeed' ); |
| 87 | + // if there's an error parsing the params, bail out and return |
| 88 | + if ( isset( $this->param['error'] ) ) { |
| 89 | + if ( false == $this->params['suppressErrors'] ) { |
| 90 | + $wgOut->disable(); |
| 91 | + echo $this->param['error']; |
| 92 | + } |
| 93 | + return; |
| 94 | + } |
88 | 95 | |
89 | | - if ( 'sitemap' == $this->params['feed'] ) { |
90 | | - $feed = new SitemapFeed( |
91 | | - $wgServer . $wgScriptPath, |
92 | | - date( DATE_ATOM ) |
93 | | - ); |
94 | | - } else { |
95 | | - // FIXME: These should be configurable at some point |
96 | | - $feed = new $wgFeedClasses[ $this->params['feed'] ]( |
| 96 | + |
| 97 | + $wgFeedClasses['sitemap'] = 'SitemapFeed' ; |
| 98 | + |
| 99 | + $feed = new $wgFeedClasses[ $this->params['feed'] ]( |
97 | 100 | $wgSitename, |
98 | 101 | $wgSitename . ' ' . $this->params['feed'] . ' feed', |
99 | 102 | $wgServer . $wgScriptPath, |
100 | 103 | date( DATE_ATOM ), |
101 | 104 | $wgSitename |
102 | 105 | ); |
103 | | - } |
104 | 106 | |
105 | 107 | $feed->outHeader(); |
106 | 108 | |
107 | | - // main routine to output items |
108 | | - if ( isset( $this->param['error'] ) ) { |
109 | | - $wgOut->disable(); |
110 | | - echo $this->param['error']; |
111 | | - $feed->outFooter(); |
112 | | - return; |
113 | | - } |
114 | | - |
115 | 109 | $dbr = wfGetDB( DB_SLAVE ); |
116 | 110 | $sql = $this->dpl_buildSQL(); |
117 | 111 | // Debug line |
— | — | @@ -121,7 +115,8 @@ |
122 | 116 | if ( $dbr->numRows( $res ) == 0 ) { |
123 | 117 | $feed->outFooter(); |
124 | 118 | if ( false == $this->params['suppressErrors'] ) { |
125 | | - return htmlspecialchars( wfMsg( 'googlenewssitemap_noresults' ) ); |
| 119 | + echo htmlspecialchars( wfMsg( 'googlenewssitemap_noresults' ) ); |
| 120 | + return; |
126 | 121 | } else { |
127 | 122 | return ''; |
128 | 123 | } |
— | — | @@ -271,15 +266,11 @@ |
272 | 267 | } // end buildSQL |
273 | 268 | |
274 | 269 | /** |
275 | | - * Parse parameters |
276 | | - ** |
277 | | - * FIXME this includes a lot of DynamicPageList cruft in need of thinning. |
| 270 | + * Parse parameters, populates $this->params |
278 | 271 | **/ |
279 | 272 | public function unload_params() { |
280 | 273 | global $wgContLang; |
281 | 274 | global $wgRequest; |
282 | | - global $wgOut; |
283 | | - $wgOut->disable(); |
284 | 275 | |
285 | 276 | $this->params = array(); |
286 | 277 | $parser = new Parser; |
— | — | @@ -320,13 +311,13 @@ |
321 | 312 | $this->categories[] = $feed; |
322 | 313 | $this->params['catCount'] = count( $this->categories ); |
323 | 314 | } else { |
324 | | - echo "\$feed is not an object.\n"; |
| 315 | + $this->params['error'] = htmlspecialchars( wfMsg( 'googlenewssitemap_badfeedobject' ) ); |
325 | 316 | // continue; |
326 | 317 | } |
327 | 318 | } |
328 | 319 | |
329 | 320 | if ( ( $totalCatCount > $this->wgDPlmaxCategories ) && ( !$this->wgDPLallowUnlimitedCategories ) ) { |
330 | | - $this->params['error'] = htmlspecialchars( wfMsg( 'intersection_toomanycats' ) ); // "!!too many categories!!"; |
| 321 | + $this->params['error'] = htmlspecialchars( wfMsg( 'googlenewssitemap_toomanycats' ) ); // "!!too many categories!!"; |
331 | 322 | } |
332 | 323 | |
333 | 324 | // disallow showing date if the query doesn't have an inclusion category parameter |
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.i18n.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | 'googlenewssitemap_toofewcats' => 'Error: Too few categories!', |
23 | 23 | 'googlenewssitemap_noresults' => 'Error: No results!', |
24 | 24 | 'googlenewssitemap_noincludecats' => 'Error: You need to include at least one category, or specify a namespace!', |
| 25 | + 'googlenewssitemap_badfeedobject' => '$feed is not an object.', |
25 | 26 | ); |
26 | 27 | |
27 | 28 | /** Message documentation (Message documentation) |
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | 'path' => __FILE__, |
59 | 59 | 'name' => 'GoogleNewsSitemap', |
60 | 60 | 'author' => 'Amgine', |
61 | | - 'description' => 'Outputs xml based on defined criteria', |
| 61 | + 'description' => 'Outputs a sitemap compatible with Google News', |
62 | 62 | 'descriptionmsg' => 'googlenewssitemap-desc', |
63 | 63 | 'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleNewsSitemap', |
64 | 64 | ); |