r79215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79214‎ | r79215 | r79216 >
Date:22:38, 29 December 2010
Author:gigs
Status:ok
Tags:
Comment:
More minor cleanup of the output
Internationalized the last echoed error
Simplified the output object selection logic
Modified paths:
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.i18n.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
@@ -83,34 +83,28 @@
8484
8585 $this->unload_params(); // populates this->params as a side effect
8686
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+ }
8895
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'] ](
97100 $wgSitename,
98101 $wgSitename . ' ' . $this->params['feed'] . ' feed',
99102 $wgServer . $wgScriptPath,
100103 date( DATE_ATOM ),
101104 $wgSitename
102105 );
103 - }
104106
105107 $feed->outHeader();
106108
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 -
115109 $dbr = wfGetDB( DB_SLAVE );
116110 $sql = $this->dpl_buildSQL();
117111 // Debug line
@@ -121,7 +115,8 @@
122116 if ( $dbr->numRows( $res ) == 0 ) {
123117 $feed->outFooter();
124118 if ( false == $this->params['suppressErrors'] ) {
125 - return htmlspecialchars( wfMsg( 'googlenewssitemap_noresults' ) );
 119+ echo htmlspecialchars( wfMsg( 'googlenewssitemap_noresults' ) );
 120+ return;
126121 } else {
127122 return '';
128123 }
@@ -271,15 +266,11 @@
272267 } // end buildSQL
273268
274269 /**
275 - * Parse parameters
276 - **
277 - * FIXME this includes a lot of DynamicPageList cruft in need of thinning.
 270+ * Parse parameters, populates $this->params
278271 **/
279272 public function unload_params() {
280273 global $wgContLang;
281274 global $wgRequest;
282 - global $wgOut;
283 - $wgOut->disable();
284275
285276 $this->params = array();
286277 $parser = new Parser;
@@ -320,13 +311,13 @@
321312 $this->categories[] = $feed;
322313 $this->params['catCount'] = count( $this->categories );
323314 } else {
324 - echo "\$feed is not an object.\n";
 315+ $this->params['error'] = htmlspecialchars( wfMsg( 'googlenewssitemap_badfeedobject' ) );
325316 // continue;
326317 }
327318 }
328319
329320 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!!";
331322 }
332323
333324 // disallow showing date if the query doesn't have an inclusion category parameter
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.i18n.php
@@ -21,6 +21,7 @@
2222 'googlenewssitemap_toofewcats' => 'Error: Too few categories!',
2323 'googlenewssitemap_noresults' => 'Error: No results!',
2424 'googlenewssitemap_noincludecats' => 'Error: You need to include at least one category, or specify a namespace!',
 25+ 'googlenewssitemap_badfeedobject' => '$feed is not an object.',
2526 );
2627
2728 /** Message documentation (Message documentation)
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php
@@ -57,7 +57,7 @@
5858 'path' => __FILE__,
5959 'name' => 'GoogleNewsSitemap',
6060 'author' => 'Amgine',
61 - 'description' => 'Outputs xml based on defined criteria',
 61+ 'description' => 'Outputs a sitemap compatible with Google News',
6262 'descriptionmsg' => 'googlenewssitemap-desc',
6363 'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleNewsSitemap',
6464 );

Status & tagging log