r78111 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78110‎ | r78111 | r78112 >
Date:02:40, 9 December 2010
Author:reedy
Status:deferred
Tags:
Comment:
Stylize
Modified paths:
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php (modified) (history)
  • /trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44
55 /**
66 * Class GNSM creates Atom/RSS feeds for Wikinews
@@ -51,21 +51,21 @@
5252 var $wgDPLallowUnlimitedResults = true; // Allow unlimited results
5353 var $wgDPLallowUnlimitedCategories = false; // Allow unlimited categories
5454
55 -
 55+
5656 /**
5757 * @var array Parameters array
5858 **/
5959 var $params = array();
6060 var $categories = array();
6161 var $notCategories = array();
62 -
 62+
6363 /**
6464 * Constructor
6565 **/
6666 public function __construct() {
6767 parent::__construct( 'GoogleNewsSitemap' );
6868 }
69 -
 69+
7070 /**
7171 * main()
7272 **/
@@ -78,39 +78,39 @@
7979 // global $wfTimeStamp;
8080 wfLoadExtensionMessages( 'GoogleNewsSitemap' );
8181 global $wgFeedClasses, $wgLocaltimezone;
82 -
 82+
8383 // Not sure how clean $wgLocaltimezone is
8484 // In fact, it's default setting is null...
8585 if ( null == $wgLocaltimezone )
8686 $wgLocaltimezone = date_default_timezone_get();
8787 date_default_timezone_set( $wgLocaltimezone );
88 - //$url = __FILE__;
 88+ // $url = __FILE__;
8989
90 - $this->unload_params(); //populates this->params as a side effect
 90+ $this->unload_params(); // populates this->params as a side effect
9191
92 -
 92+
9393 $wgFeedClasses[] = array( 'sitemap' => 'SitemapFeed' );
94 -
95 - if ( 'sitemap' == $this->params['feed'] ){
 94+
 95+ if ( 'sitemap' == $this->params['feed'] ) {
9696 $feed = new SitemapFeed(
97 - $wgServer.$wgScriptPath,
 97+ $wgServer . $wgScriptPath,
9898 date( DATE_ATOM )
9999 );
100 - }else{
 100+ } else {
101101 // FIXME: These should be configurable at some point
102102 $feed = new $wgFeedClasses[ $this->params['feed'] ](
103103 $wgSitename,
104104 $wgSitename . ' ' . $this->params['feed'] . ' feed',
105 - $wgServer.$wgScriptPath,
 105+ $wgServer . $wgScriptPath,
106106 date( DATE_ATOM ),
107107 $wgSitename
108108 );
109109 }
110110
111111 $feed->outHeader();
112 -
 112+
113113 // main routine to output items
114 - if ( isset( $this->param['error'] ) ){
 114+ if ( isset( $this->param['error'] ) ) {
115115 $wgOut->disable();
116116 echo $this->param['error'];
117117 $feed->outFooter();
@@ -119,31 +119,31 @@
120120
121121 $dbr =& wfGetDB( DB_SLAVE );
122122 $sql = $this->dpl_buildSQL();
123 - //Debug line
124 - //echo "\n<p>$sql</p>\n";
 123+ // Debug line
 124+ // echo "\n<p>$sql</p>\n";
125125 $res = $dbr->query ( $sql );
126 -
 126+
127127 // FIXME: figure out how to fail with no results gracefully
128 - if ( $dbr->numRows( $res ) == 0 ){
 128+ if ( $dbr->numRows( $res ) == 0 ) {
129129 $feed->outFooter();
130 - if ( false == $this->params['suppressErrors'] )
 130+ if ( false == $this->params['suppressErrors'] )
131131 return htmlspecialchars( wfMsg( 'gnsm_noresults' ) );
132132 else
133133 return '';
134134 }
135 -
136 - while ($row = $dbr->fetchObject( $res ) ) {
137 - $title = Title::makeTitle( $row->page_namespace, $row->page_title);
138 -
139 - if ( ! $title ){
 135+
 136+ while ( $row = $dbr->fetchObject( $res ) ) {
 137+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
 138+
 139+ if ( ! $title ) {
140140 $feed->outFooter();
141141 return;
142142 }
143 -
 143+
144144 $titleText = ( true == $this->params['nameSpace'] ) ? $title->getPrefixedText() : $title->getText();
145 -
146 - if ( 'sitemap' == $this->params['feed'] ){
147 -
 145+
 146+ if ( 'sitemap' == $this->params['feed'] ) {
 147+
148148 $this->pubDate = isset( $row->cl_timestamp ) ? $row->cl_timestamp : date( DATE_ATOM );
149149 $feedArticle = new Article( $title );
150150
@@ -154,53 +154,53 @@
155155 wfTimeStamp( TS_ISO_8601, $feedArticle->getTouched() ),
156156 $feed->getPriority( $this->priority )
157157 );
158 -
159 - }elseif ( ('atom' == $this->params['feed'] ) || ( 'rss' == $this->params['feed'] ) ){
160 -
 158+
 159+ } elseif ( ( 'atom' == $this->params['feed'] ) || ( 'rss' == $this->params['feed'] ) ) {
 160+
161161 $this->Date = isset( $row->cl_timestamp ) ? $row->cl_timestamp : date( DATE_ATOM );
162 - if ( isset( $row->comment ) ){
 162+ if ( isset( $row->comment ) ) {
163163 $comments = htmlspecialchars( $row->comment );
164 - }else{
 164+ } else {
165165 $talkpage = $title->getTalkPage();
166166 $comments = $talkpage->getFullURL();
167167 }
168 - $titleText = (true === $this->params['nameSpace'] ) ? $title->getPrefixedText() : $title->getText();
 168+ $titleText = ( true === $this->params['nameSpace'] ) ? $title->getPrefixedText() : $title->getText();
169169 $feedItem = new FeedItem(
170170 $titleText,
171171 $this->feedItemDesc( $row ),
172172 $title->getFullURL(),
173173 $this->Date,
174174 $this->feedItemAuthor( $row ),
175 - $comments);
 175+ $comments );
176176 }
177177 $feed->outItem( $feedItem );
178 - }//end while fetchobject
 178+ }// end while fetchobject
179179 $feed->outFooter();
180 - } //end public function execute
181 -
 180+ } // end public function execute
 181+
182182 /**
183183 * Build sql
184184 **/
185 - public function dpl_buildSQL(){
186 -
 185+ public function dpl_buildSQL() {
 186+
187187 $sqlSelectFrom = 'SELECT page_namespace, page_title, page_id, c1.cl_timestamp FROM ' . $this->params['dbr']->tableName( 'page' );
188 -
189 - if ( $this->params['nameSpace'] ){
 188+
 189+ if ( $this->params['nameSpace'] ) {
190190 $sqlWhere = ' WHERE page_namespace=' . $this->params['nameSpace'] . ' ';
191 - }else{
 191+ } else {
192192 $sqlWhere = ' WHERE 1=1 ';
193193 }
194 -
 194+
195195 // If flagged revisions is in use, check which options selected.
196196 // FIXME: double check the default options in function::dpl_parm; what should it default to?
197 - if( function_exists('efLoadFlaggedRevs') ) {
 197+ if ( function_exists( 'efLoadFlaggedRevs' ) ) {
198198 $flaggedPages = $this->params['dbr']->tableName( 'flaggedpages' );
199199 $filterSet = array( 'only', 'exclude' );
200200 # Either involves the same JOIN here...
201 - if( in_array( $this->params['stable'], $filterSet ) || in_array( $this->params['quality'], $filterSet ) ) {
 201+ if ( in_array( $this->params['stable'], $filterSet ) || in_array( $this->params['quality'], $filterSet ) ) {
202202 $sqlSelectFrom .= " LEFT JOIN $flaggedPages ON page_id = fp_page_id";
203203 }
204 - switch( $this->params['stable'] ){
 204+ switch( $this->params['stable'] ) {
205205 case 'only':
206206 $sqlWhere .= ' AND fp_stable IS NOT NULL ';
207207 break;
@@ -208,7 +208,7 @@
209209 $sqlWhere .= ' AND fp_stable IS NULL ';
210210 break;
211211 }
212 - switch( $this->params['quality'] ){
 212+ switch( $this->params['quality'] ) {
213213 case 'only':
214214 $sqlWhere .= ' AND fp_quality >= 1';
215215 break;
@@ -217,8 +217,8 @@
218218 break;
219219 }
220220 }
221 -
222 - switch ( $this->params['redirects'] ){
 221+
 222+ switch ( $this->params['redirects'] ) {
223223 case 'only':
224224 $sqlWhere .= ' AND page_is_redirect = 1 ';
225225 break;
@@ -226,61 +226,61 @@
227227 $sqlWhere .= ' AND page_is_redirect = 0 ';
228228 break;
229229 }
230 -
 230+
231231 $currentTableNumber = 0;
232 -
233 - for ( $i = 0; $i < $this->params['catCount']; $i++ ){
 232+
 233+ for ( $i = 0; $i < $this->params['catCount']; $i++ ) {
234234 $sqlSelectFrom .= ' INNER JOIN ' . $this->params['dbr']->tableName( 'categorylinks' );
235235 $sqlSelectFrom .= ' AS c' . ( $currentTableNumber + 1 ) . ' ON page_id = c';
236236 $sqlSelectFrom .= ( $currentTableNumber + 1 ) . '.cl_from AND c' . ( $currentTableNumber + 1 );
237237
238238 $sqlSelectFrom .= '.cl_to=' . $this->params['dbr']->addQuotes( $this->categories[$i]->getDBkey() );
239 -
 239+
240240 $currentTableNumber++;
241241 }
242242
243 - for ( $i = 0; $i < $this->params['notCatCount']; $i++ ){
244 - //echo "notCategory parameter $i<br />\n";
 243+ for ( $i = 0; $i < $this->params['notCatCount']; $i++ ) {
 244+ // echo "notCategory parameter $i<br />\n";
245245 $sqlSelectFrom .= ' LEFT OUTER JOIN ' . $this->params['dbr']->tableName( 'categorylinks' );
246246 $sqlSelectFrom .= ' AS c' . ( $currentTableNumber + 1 ) . ' ON page_id = c' . ( $currentTableNumber + 1 );
247247 $sqlSelectFrom .= '.cl_from AND c' . ( $currentTableNumber + 1 );
248248 $sqlSelectFrom .= '.cl_to=' . $this->params['dbr']->addQuotes( $this->notCategories[$i]->getDBkey() );
249 -
 249+
250250 $sqlWhere .= ' AND c' . ( $currentTableNumber + 1 ) . '.cl_to IS NULL';
251251
252252 $currentTableNumber++;
253253 }
254 -
255 - if ('lastedit' == $this->params['orderMethod'] ){
 254+
 255+ if ( 'lastedit' == $this->params['orderMethod'] ) {
256256 $sqlWhere .= ' ORDER BY page_touched ';
257 - }else{
 257+ } else {
258258 $sqlWhere .= ' ORDER BY c1.cl_timestamp ';
259259 }
260 -
261 - if ( 'descending' == $this->params['order'] ){
 260+
 261+ if ( 'descending' == $this->params['order'] ) {
262262 $sqlWhere .= 'DESC';
263 - }else{
 263+ } else {
264264 $sqlWhere .= 'ASC';
265265 }
266266
267267 // FIXME: Note: this is not a boolean type check - will also trap count = 0 which may
268268 // accidentally give unlimited returns
269 - if ( 0 < $this->params['count'] ){
 269+ if ( 0 < $this->params['count'] ) {
270270 $sqlWhere .= ' LIMIT ' . $this->params['count'];
271271 }
272 -
273 - //debug line
274 - //echo "<p>$sqlSelectFrom$sqlWhere;</p>\n";
275 -
 272+
 273+ // debug line
 274+ // echo "<p>$sqlSelectFrom$sqlWhere;</p>\n";
 275+
276276 return $sqlSelectFrom . $sqlWhere;
277 - } //end buildSQL
278 -
 277+ } // end buildSQL
 278+
279279 /**
280280 * Parse parameters
281281 **
282282 * FIXME this includes a lot of DynamicPageList cruft in need of thinning.
283283 **/
284 - public function unload_params(){
 284+ public function unload_params() {
285285 global $wgContLang;
286286 global $wgRequest;
287287 global $wgOut;
@@ -288,61 +288,61 @@
289289
290290 $this->params = array();
291291 $parser = new Parser;
292 - $poptions = new ParserOptions;
293 - $category = $wgRequest->getArray('category', 'Published');
294 - //$title = Title::newFromText( $parser->transformMsg( $category, $poptions ) );
295 - //if ( is_object( $title ) ){
 292+ $poptions = new ParserOptions;
 293+ $category = $wgRequest->getArray( 'category', 'Published' );
 294+ // $title = Title::newFromText( $parser->transformMsg( $category, $poptions ) );
 295+ // if ( is_object( $title ) ){
296296 // $this->categories[] = $title;
297297 // }
298 - //FIXME:notcats
299 - //$this->notCategories[] = $wgRequest->getArray('notcategory');
300 - $this->params['nameSpace'] = $wgContLang->getNsIndex($wgRequest->getVal('namespace',0));
301 - $this->params['count'] = $wgRequest->getInt('count', $this->wgDPLmaxResultCount);
302 - if (($this->params['count'] > $this->wgDPLmaxResultCount)||($this->params['count'] < $this->wgDPLminResultCount))
 298+ // FIXME:notcats
 299+ // $this->notCategories[] = $wgRequest->getArray('notcategory');
 300+ $this->params['nameSpace'] = $wgContLang->getNsIndex( $wgRequest->getVal( 'namespace', 0 ) );
 301+ $this->params['count'] = $wgRequest->getInt( 'count', $this->wgDPLmaxResultCount );
 302+ if ( ( $this->params['count'] > $this->wgDPLmaxResultCount ) || ( $this->params['count'] < $this->wgDPLminResultCount ) )
303303 $this->params['count'] = $this->wgDPLmaxResultCount;
304304
305 - $this->params['order'] = $wgRequest->getVal('order', 'descending');
306 - $this->params['orderMethod'] = $wgRequest->getVal('ordermethod', 'categoryadd');
307 - $this->params['redirects'] = $wgRequest->getVal('redirects', 'exclude');
308 - $this->params['stable'] = $wgRequest->getVal('stable','only');
309 - $this->params['quality'] = $wgRequest->getVal('qualitypages', 'only');
310 - $this->params['suppressErrors']=$wgRequest->getBool('supresserrors', false);
311 - $this->params['useNameSpace'] = $wgRequest->getBool('usenamespace', false);
312 - $this->params['useCurId'] = $wgRequest->getBool('usecurid', false);
313 - $this->params['feed'] = $wgRequest->getVal('feed', 'sitemap');
 305+ $this->params['order'] = $wgRequest->getVal( 'order', 'descending' );
 306+ $this->params['orderMethod'] = $wgRequest->getVal( 'ordermethod', 'categoryadd' );
 307+ $this->params['redirects'] = $wgRequest->getVal( 'redirects', 'exclude' );
 308+ $this->params['stable'] = $wgRequest->getVal( 'stable', 'only' );
 309+ $this->params['quality'] = $wgRequest->getVal( 'qualitypages', 'only' );
 310+ $this->params['suppressErrors'] = $wgRequest->getBool( 'supresserrors', false );
 311+ $this->params['useNameSpace'] = $wgRequest->getBool( 'usenamespace', false );
 312+ $this->params['useCurId'] = $wgRequest->getBool( 'usecurid', false );
 313+ $this->params['feed'] = $wgRequest->getVal( 'feed', 'sitemap' );
314314
315 -
 315+
316316 $this->params['catCount'] = count( $this->categories );
317317 $this->params['notCatCount'] = count( $this->notCategories );
318318 $totalCatCount = $this->params['catCount'] + $this->params['notCatCount'];
319 - if (( $this->params['catCount'] < 1 && false == $this->params['nameSpace'] ) || ( $totalCatCount < $this->wgDPlminCategories )){
320 - //echo "Boom on catCount\n";
 319+ if ( ( $this->params['catCount'] < 1 && false == $this->params['nameSpace'] ) || ( $totalCatCount < $this->wgDPlminCategories ) ) {
 320+ // echo "Boom on catCount\n";
321321 $parser = new Parser;
322322 $poptions = new ParserOptions;
323323 $feed = Title::newFromText( $parser->transformMsg( 'Published', $poptions ) );
324 - if ( is_object( $feed ) ){
 324+ if ( is_object( $feed ) ) {
325325 $this->categories[] = $feed;
326 - $this->params['catCount'] = count( $this->categories );
327 - }else{
 326+ $this->params['catCount'] = count( $this->categories );
 327+ } else {
328328 echo "\$feed is not an object.\n";
329 - //continue;
 329+ // continue;
330330 }
331331 }
332 -
333 - if ( ( $totalCatCount > $this->wgDPlmaxCategories ) && ( !$this->wgDPLallowUnlimitedCategories ) ){
 332+
 333+ if ( ( $totalCatCount > $this->wgDPlmaxCategories ) && ( !$this->wgDPLallowUnlimitedCategories ) ) {
334334 $this->params['error'] = htmlspecialchars( wfMsg( 'intersection_toomanycats' ) ); // "!!too many categories!!";
335335 }
336 -
337 - //disallow showing date if the query doesn't have an inclusion category parameter
 336+
 337+ // disallow showing date if the query doesn't have an inclusion category parameter
338338 if ( $this->params['count'] < 1 )
339339 $this->params['addFirstCategoryDate'] = false;
340 -
 340+
341341 $this->params['dbr'] =& wfGetDB( DB_SLAVE );
342 - //print_r($this->notCategories);
343 - //print_r($this->categories);
 342+ // print_r($this->notCategories);
 343+ // print_r($this->categories);
344344 return;
345345 }
346 -
 346+
347347 function feedItemAuthor( $row ) {
348348 return isset( $row->user_text ) ? $row->user_text : 'Wikinews';
349349 }
@@ -350,38 +350,38 @@
351351 function feedItemDesc( $row ) {
352352 return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
353353 }
354 -
355 - function getKeywords ( $title ){
 354+
 355+ function getKeywords ( $title ) {
356356 $cats = $title->getParentCategories();
357357 $str = '';
358 - #the following code is based (stolen) from r56954 of flagged revs.
 358+ # the following code is based (stolen) from r56954 of flagged revs.
359359 $catMap = Array();
360360 $catMask = Array();
361361 $msg = wfMsg( 'gnsm_categorymap' );
362362 if ( !wfEmptyMsg( 'gnsm_categorymap', $msg ) ) {
363 - $list = explode( "\n*", "\n$msg");
364 - foreach($list as $item) {
365 - $mapping = explode('|', $item, 2);
 363+ $list = explode( "\n*", "\n$msg" );
 364+ foreach ( $list as $item ) {
 365+ $mapping = explode( '|', $item, 2 );
366366 if ( count( $mapping ) == 2 ) {
367 - if ( trim( $mapping[1] ) == '__MASK__') {
368 - $catMask[trim($mapping[0])] = true;
 367+ if ( trim( $mapping[1] ) == '__MASK__' ) {
 368+ $catMask[trim( $mapping[0] )] = true;
369369 } else {
370 - $catMap[trim($mapping[0])] = trim($mapping[1]);
 370+ $catMap[trim( $mapping[0] )] = trim( $mapping[1] );
371371 }
372372 }
373373 }
374374 }
375 - foreach ( $cats as $key => $val ){
 375+ foreach ( $cats as $key => $val ) {
376376 $cat = str_replace( '_', ' ', trim( substr( $key, strpos( $key, ':' ) + 1 ) ) );
377 - if (!isset($catMask[$cat])) {
378 - if (isset($catMap[$cat])) {
 377+ if ( !isset( $catMask[$cat] ) ) {
 378+ if ( isset( $catMap[$cat] ) ) {
379379 $str .= ', ' . str_replace( '_', ' ', trim ( $catMap[$cat] ) );
380380 } else {
381381 $str .= ', ' . $cat;
382382 }
383383 }
384384 }
385 - $str = substr( $str, 2 ); #to remove leading ', '
 385+ $str = substr( $str, 2 ); # to remove leading ', '
386386 return $str;
387387 }
388388
@@ -392,7 +392,7 @@
393393 **
394394 * Base class for basic SiteMap support, for building url containers.
395395 **/
396 -class feedSMItem{
 396+class feedSMItem {
397397 /**
398398 * Var string
399399 **/
@@ -401,77 +401,77 @@
402402 var $keywords = '';
403403 var $lastMod = '';
404404 var $priority = '';
405 -
406 - function __construct( $url, $pubDate, $keywords = '', $lastMod = '', $priority = ''){
 405+
 406+ function __construct( $url, $pubDate, $keywords = '', $lastMod = '', $priority = '' ) {
407407 $this->url = $url;
408408 $this->pubDate = $pubDate;
409409 $this->keywords = $keywords;
410410 $this->lastMod = $lastMod;
411411 $this->priority = $priority;
412412 }
413 -
414 - public function xmlEncode( $string ){
 413+
 414+ public function xmlEncode( $string ) {
415415 $string = str_replace( "\r\n", "\n", $string );
416416 $string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string );
417417 return htmlspecialchars( $string );
418418 }
419 -
420 - public function getUrl(){
 419+
 420+ public function getUrl() {
421421 return $this->url;
422422 }
423 -
424 - public function getPriority(){
 423+
 424+ public function getPriority() {
425425 return $this->priority;
426426 }
427 -
428 - public function getLastMod(){
 427+
 428+ public function getLastMod() {
429429 return $this->lastMod;
430430 }
431431
432 - public function getKeywords (){
 432+ public function getKeywords () {
433433 return $this->xmlEncode( $this->keywords );
434434 }
435 -
436 - public function getPubDate(){
 435+
 436+ public function getPubDate() {
437437 return $this->pubDate;
438438 }
439 -
 439+
440440 function formatTime( $ts ) {
441441 // need to use RFC 822 time format at least for rss2.0
442442 return gmdate( 'Y-m-d\TH:i:s', wfTimestamp( TS_UNIX, $ts ) );
443443 }
444 -
 444+
445445 }
446446
447 -class SitemapFeed extends feedSMItem{
 447+class SitemapFeed extends feedSMItem {
448448 private $writer;
449449
450450
451 - function __construct(){
 451+ function __construct() {
452452 global $wgOut;
453 - $this->writer=new XMLWriter();
 453+ $this->writer = new XMLWriter();
454454 $wgOut->disable();
455455 }
456456 /**
457457 * Output feed headers
458458 **/
459 - function outHeader(){
 459+ function outHeader() {
460460 global $wgOut;
461 - global $wgRequest;
 461+ global $wgRequest;
462462
463 - //FIXME: Why can't we just pick one mime type and always send that?
 463+ // FIXME: Why can't we just pick one mime type and always send that?
464464 $ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
465465 $allowedctypes = array( 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' );
466466 $mimetype = in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml';
467467 header( "Content-type: $mimetype; charset=UTF-8" );
468468 $wgOut->sendCacheControl();
469469
470 - $this->writer->openURI('php://output');
471 - $this->writer->setIndent(true);
472 - $this->writer->startDocument("1.0", "UTF-8");
473 - $this->writer->startElement("urlset");
474 - $this->writer->writeAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
475 - $this->writer->writeAttribute("xmlns:news", "http://www.google.com/schemas/sitemap-news/0.9");
 470+ $this->writer->openURI( 'php://output' );
 471+ $this->writer->setIndent( true );
 472+ $this->writer->startDocument( "1.0", "UTF-8" );
 473+ $this->writer->startElement( "urlset" );
 474+ $this->writer->writeAttribute( "xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9" );
 475+ $this->writer->writeAttribute( "xmlns:news", "http://www.google.com/schemas/sitemap-news/0.9" );
476476 $this->writer->flush();
477477 }
478478 /**
@@ -480,37 +480,37 @@
481481 **/
482482 function outItem( $item ) {
483483
484 - $this->writer->startElement("url");
485 - $this->writer->startElement("loc");
486 - $this->writer->text($item->getUrl());
 484+ $this->writer->startElement( "url" );
 485+ $this->writer->startElement( "loc" );
 486+ $this->writer->text( $item->getUrl() );
487487 $this->writer->endElement();
488 - $this->writer->startElement("news:news");
489 - $this->writer->startElement("news:publication_date");
490 - $this->writer->text($item->getPubDate());
 488+ $this->writer->startElement( "news:news" );
 489+ $this->writer->startElement( "news:publication_date" );
 490+ $this->writer->text( $item->getPubDate() );
491491 $this->writer->endElement();
492 - if( $item->getKeywords() ){
493 - $this->writer->startElement("news:keywords");
494 - $this->writer->text($item->getKeywords());
 492+ if ( $item->getKeywords() ) {
 493+ $this->writer->startElement( "news:keywords" );
 494+ $this->writer->text( $item->getKeywords() );
495495 $this->writer->endElement();
496496 }
497 - $this->writer->endElement(); //end news:news
498 - if( $item->getLastMod() ){
499 - $this->writer->startElement("lastmod");
500 - $this->writer->text($item->getLastMod());
 497+ $this->writer->endElement(); // end news:news
 498+ if ( $item->getLastMod() ) {
 499+ $this->writer->startElement( "lastmod" );
 500+ $this->writer->text( $item->getLastMod() );
501501 $this->writer->endElement();
502502 }
503 - if( $item->getPriority() ){
504 - $this->writer->startElement("priority");
505 - $this->writer->text($item->getPriority());
 503+ if ( $item->getPriority() ) {
 504+ $this->writer->startElement( "priority" );
 505+ $this->writer->text( $item->getPriority() );
506506 $this->writer->endElement();
507507 }
508 - $this->writer->endElement(); //end url
 508+ $this->writer->endElement(); // end url
509509 }
510 -
 510+
511511 /**
512512 * Output SiteMap 0.9 footer
513513 **/
514 - function outFooter(){
 514+ function outFooter() {
515515 $this->writer->endDocument();
516516 $this->writer->flush();
517517 }
Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) {
 3+if ( !defined( 'MEDIAWIKI' ) ) {
44 echo <<<EOT
55 To install GoogleNewsSitemap extension, an extension special page, put the following line in LocalSettings.php:
66 require_once( dirname(__FILE__) . '/extensions/GoogleNewsSitemap/GoogleNewsSitemap.php' );
@@ -62,7 +62,7 @@
6363 'url' => 'http://www.mediawiki.org/wiki/Extension:GoogleNewsSitemap',
6464 );
6565
66 -$dir = dirname(__FILE__) . '/';
 66+$dir = dirname( __FILE__ ) . '/';
6767 $wgExtensionMessagesFiles['GoogleNewsSitemap'] = $dir . 'GoogleNewsSitemap.i18n.php';
6868 $wgExtensionAliasesFiles['GoogleNewsSitemap'] = $dir . 'GoogleNewsSitemap.alias.php';
6969 $wgAutoloadClasses['GoogleNewsSitemap'] = $dir . 'GoogleNewsSitemap_body.php';

Status & tagging log