r75093 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75092‎ | r75093 | r75094 >
Date:18:28, 20 October 2010
Author:catrope
Status:ok
Tags:
Comment:
Stylize RSS extension
Modified paths:
  • /trunk/extensions/RSS/RSS.php (modified) (history)
  • /trunk/extensions/RSS/RSSData.php (modified) (history)
  • /trunk/extensions/RSS/RSSFetch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RSS/RSSData.php
@@ -18,11 +18,11 @@
1919 $xpath = new DOMXPath( $this->xml );
2020 $items = $xpath->evaluate( '/rss/channel/item' );
2121
22 - foreach( $items as $item ) {
 22+ foreach ( $items as $item ) {
2323 $bit = array();
24 - foreach( $item->childNodes as $n ) {
 24+ foreach ( $item->childNodes as $n ) {
2525 $name = $this->rssTokenToName( $n->nodeName );
26 - if( $name != null ) {
 26+ if ( $name != null ) {
2727 $bit[$name] = $n->nodeValue;
2828 }
2929 }
Index: trunk/extensions/RSS/RSSFetch.php
@@ -60,8 +60,8 @@
6161 'wgRSSUseGzip' => true
6262 );
6363
64 - foreach( $nameValue as $n => $v) {
65 - if( !isset( $GLOBALS[$n] ) ) {
 64+ foreach ( $nameValue as $n => $v ) {
 65+ if ( !isset( $GLOBALS[$n] ) ) {
6666 $GLOBALS[$n] = $v;
6767 }
6868 }
@@ -200,8 +200,8 @@
201201 $client->setUserAgent( 'MediaWikiRSS/0.01 (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension' );
202202 /* $client->use_gzip = $wgRSSUseGzip; */
203203 if ( is_array( $headers ) && count( $headers ) > 0 ) {
204 - foreach( $headers as $h ) {
205 - if( count( $h ) > 1 ) {
 204+ foreach ( $headers as $h ) {
 205+ if ( count( $h ) > 1 ) {
206206 $client->setHeader( $h[0], $h[1] );
207207 }
208208 }
@@ -210,7 +210,7 @@
211211 $fetch = $client->execute();
212212
213213 /* @$client->fetch( $url ); */
214 - if( $fetch->isGood() ) {
 214+ if ( $fetch->isGood() ) {
215215 return $client;
216216 } else {
217217 wfDebugLog( 'RSS', 'error fetching $url: ' . $fetch->getWikiText() );
Index: trunk/extensions/RSS/RSS.php
@@ -14,7 +14,7 @@
1515 * @link http://www.mediawiki.org/wiki/Extension:RSS Documentation
1616 */
1717
18 -if( !defined( 'MEDIAWIKI' ) ) {
 18+if ( !defined( 'MEDIAWIKI' ) ) {
1919 die( "This is not a valid entry point.\n" );
2020 }
2121
@@ -70,14 +70,14 @@
7171 $url = $input;
7272
7373 # Get charset from argument array
74 - if( isset( $args['charset'] ) ) {
 74+ if ( isset( $args['charset'] ) ) {
7575 $charset = $args['charset'];
7676 } else {
7777 $charset = $wgOutputEncoding;
7878 }
7979
8080 # Get max number of headlines from argument-array
81 - if( isset( $args['max'] ) ) {
 81+ if ( isset( $args['max'] ) ) {
8282 $maxheads = $args['max'];
8383 } else {
8484 $maxheads = 32;
@@ -85,14 +85,14 @@
8686
8787 # Get short flag from argument array
8888 # If short is set, no description text is printed
89 - if( isset( $args['short'] ) ) {
 89+ if ( isset( $args['short'] ) ) {
9090 $short = true;
9191 } else {
9292 $short = false;
9393 }
9494
9595 # Get reverse flag from argument array
96 - if( isset( $args['reverse'] ) ) {
 96+ if ( isset( $args['reverse'] ) ) {
9797 $rss->items = array_reverse( $rss->items );
9898 }
9999
@@ -104,7 +104,7 @@
105105 }
106106
107107 # Get highlight terms from argument array
108 - if( isset( $args['highlight'] ) ) {
 108+ if ( isset( $args['highlight'] ) ) {
109109 $rssHighlight = $args['highlight'];
110110 $rssHighlight = str_replace( ' ', ' ', $rssHighlight );
111111 $rssHighlight = explode( ' ', trim( $rssHighlight ) );
@@ -113,7 +113,7 @@
114114 }
115115
116116 # Get filter terms from argument array
117 - if( isset( $args['filter'] ) ) {
 117+ if ( isset( $args['filter'] ) ) {
118118 $rssFilter = $args['filter'];
119119 $rssFilter = str_replace( ' ', ' ', $rssFilter );
120120 $rssFilter = explode( ' ', trim( $rssFilter ) );
@@ -122,7 +122,7 @@
123123 }
124124
125125 # Filterout terms
126 - if( isset( $args['filterout'] ) ) {
 126+ if ( isset( $args['filterout'] ) ) {
127127 $rssFilterout = $args['filterout'];
128128 $rssFilterout = str_replace( ' ', ' ', $rssFilterout );
129129 $rssFilterout = explode( ' ', trim( $rssFilterout ) );
@@ -130,7 +130,7 @@
131131 $rssFilterout = false;
132132 }
133133
134 - if( isset( $args['template'] ) ) {
 134+ if ( isset( $args['template'] ) ) {
135135 $template = 'Template:' . $args['template'];
136136 } else {
137137 $template = wfMsgNoTrans( 'rss-item' );
@@ -166,16 +166,16 @@
167167 */
168168 if ( $template ) {
169169 $headcnt = 0;
170 - foreach( $rss->items as $item ) {
171 - if( $maxheads > 0 && $headcnt >= $maxheads ) {
 170+ foreach ( $rss->items as $item ) {
 171+ if ( $maxheads > 0 && $headcnt >= $maxheads ) {
172172 continue;
173173 }
174174
175175 $decision = true;
176 - foreach( array( 'title', 'author', 'description', 'category' ) as $check ) {
177 - if( isset( $item[$check] ) ) {
 176+ foreach ( array( 'title', 'author', 'description', 'category' ) as $check ) {
 177+ if ( isset( $item[$check] ) ) {
178178 $decision &= wfRssFilter( $item[$check], $rssFilter ) & wfRssFilterout( $item[$check], $rssFilterout );
179 - if( !$decision ) {
 179+ if ( !$decision ) {
180180 continue 2;
181181 }
182182
@@ -186,12 +186,12 @@
187187
188188 $rssTemp = '';
189189
190 - foreach( explode( '|', $template ) as $bit ) {
 190+ foreach ( explode( '|', $template ) as $bit ) {
191191 $bits = explode( '=', $bit );
192 - if( count( $bits ) == 2 ) {
 192+ if ( count( $bits ) == 2 ) {
193193 $left = trim( $bits[0] );
194194
195 - if( isset( $item[$left] ) ) {
 195+ if ( isset( $item[$left] ) ) {
196196 $right = $item[$left];
197197 }
198198
@@ -213,7 +213,7 @@
214214 function wfRssFilter( $text, $rssFilter ) {
215215 $display = true;
216216 if ( is_array( $rssFilter ) ) {
217 - foreach( $rssFilter as $term ) {
 217+ foreach ( $rssFilter as $term ) {
218218 if ( $term ) {
219219 $display = false;
220220 if ( preg_match( "|$term|i", $text, $a ) ) {
@@ -257,7 +257,7 @@
258258 $count_color = count( $color );
259259
260260 if ( is_array( $rssHighlight ) ) {
261 - foreach( $rssHighlight as $term ) {
 261+ foreach ( $rssHighlight as $term ) {
262262 if ( $term ) {
263263 $text = preg_replace( "|\b(\w*?" . $term . "\w*?)\b|i", "$starttag" . "_" . $i . "\\1$endtag", $text );
264264 $i++;

Status & tagging log