| Index: trunk/extensions/RSS/RSSData.php |
| — | — | @@ -5,7 +5,7 @@ |
| 6 | 6 | public $items; |
| 7 | 7 | |
| 8 | 8 | function __construct( $xml ) { |
| 9 | | - if( !( $xml instanceOf DOMDocument ) ) { |
| | 9 | + if ( !( $xml instanceOf DOMDocument ) ) { |
| 10 | 10 | return null; |
| 11 | 11 | } |
| 12 | 12 | $xpath = new DOMXPath( $xml ); |
| Index: trunk/extensions/RSS/RSS.php |
| — | — | @@ -84,7 +84,7 @@ |
| 85 | 85 | } |
| 86 | 86 | $parser->disableCache(); |
| 87 | 87 | |
| 88 | | - $rss = new RSS($input, $args); |
| | 88 | + $rss = new RSS( $input, $args ); |
| 89 | 89 | |
| 90 | 90 | $status = $rss->fetch(); |
| 91 | 91 | |
| — | — | @@ -95,7 +95,7 @@ |
| 96 | 96 | if ( isset( $rss->ERROR ) ) |
| 97 | 97 | return wfMsg( 'rss-error', $rss->ERROR ); |
| 98 | 98 | |
| 99 | | - return $rss->renderFeed($parser, $frame); |
| | 99 | + return $rss->renderFeed( $parser, $frame ); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | static function explodeOnSpaces( $str ) { |
| — | — | @@ -103,9 +103,9 @@ |
| 104 | 104 | return is_array( $found ) ? $found : array(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | | - function __construct($url, $args) { |
| | 107 | + function __construct( $url, $args ) { |
| 108 | 108 | |
| 109 | | - if( isset($url) ) { |
| | 109 | + if ( isset( $url ) ) { |
| 110 | 110 | $this->url = $url; |
| 111 | 111 | } |
| 112 | 112 | |
| — | — | @@ -149,9 +149,9 @@ |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if ( isset( $args['template'] ) ) { |
| 153 | | - $titleObject = Title::newFromText($args['template'], NS_TEMPLATE); |
| 154 | | - $article = new Article($titleObject, 0); |
| 155 | | - $this->itemTemplate = $article->fetchContent(0); |
| | 153 | + $titleObject = Title::newFromText( $args['template'], NS_TEMPLATE ); |
| | 154 | + $article = new Article( $titleObject, 0 ); |
| | 155 | + $this->itemTemplate = $article->fetchContent( 0 ); |
| 156 | 156 | } else { |
| 157 | 157 | $this->itemTemplate = wfMsgNoTrans( 'rss-item' ); |
| 158 | 158 | } |
| — | — | @@ -188,29 +188,29 @@ |
| 189 | 189 | // 3. if cached obj fails freshness check, fetch remote |
| 190 | 190 | // 4. if remote fails, return stale object, or error |
| 191 | 191 | $key = wfMemcKey( $this->url ); |
| 192 | | - $cachedFeed = $this->loadFromCache($key); |
| 193 | | - if( $cachedFeed !== false ) { |
| 194 | | - wfDebugLog( 'RSS', 'Outputting cached feed for '.$this->url ); |
| | 192 | + $cachedFeed = $this->loadFromCache( $key ); |
| | 193 | + if ( $cachedFeed !== false ) { |
| | 194 | + wfDebugLog( 'RSS', 'Outputting cached feed for ' . $this->url ); |
| 195 | 195 | return true; |
| 196 | 196 | } |
| 197 | | - wfDebugLog( 'RSS', 'Cache Failed '.$this->url ); |
| | 197 | + wfDebugLog( 'RSS', 'Cache Failed ' . $this->url ); |
| 198 | 198 | |
| 199 | | - $status = $this->fetchRemote($key); |
| | 199 | + $status = $this->fetchRemote( $key ); |
| 200 | 200 | return $status; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | function loadFromCache( $key ) { |
| 204 | 204 | global $parserMemc; |
| 205 | 205 | |
| 206 | | - $data = $parserMemc->get($key); |
| 207 | | - if ($data === false) { |
| | 206 | + $data = $parserMemc->get( $key ); |
| | 207 | + if ( $data === false ) { |
| 208 | 208 | return false; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | | - list($etag, $last_modified, $rss) = |
| 212 | | - unserialize($data); |
| | 211 | + list( $etag, $last_modified, $rss ) = |
| | 212 | + unserialize( $data ); |
| 213 | 213 | |
| 214 | | - if( !isset( $rss->items ) ) { |
| | 214 | + if ( !isset( $rss->items ) ) { |
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| — | — | @@ -242,11 +242,11 @@ |
| 243 | 243 | global $wgRSSFetchTimeout, $wgRSSUseGzip; |
| 244 | 244 | |
| 245 | 245 | if ( $this->etag ) { |
| 246 | | - wfDebugLog( 'RSS', 'Used etag: '.$this->etag ); |
| | 246 | + wfDebugLog( 'RSS', 'Used etag: ' . $this->etag ); |
| 247 | 247 | $headers['If-None-Match'] = $this->etag; |
| 248 | 248 | } |
| 249 | 249 | if ( $this->last_modified ) { |
| 250 | | - wfDebugLog( 'RSS', 'Used last modified: '.$this->last_modified ); |
| | 250 | + wfDebugLog( 'RSS', 'Used last modified: ' . $this->last_modified ); |
| 251 | 251 | $headers['If-Last-Modified'] = $this->last_modified; |
| 252 | 252 | } |
| 253 | 253 | |
| — | — | @@ -266,11 +266,11 @@ |
| 267 | 267 | $this->client = $client; |
| 268 | 268 | |
| 269 | 269 | if ( !$fetch->isGood() ) { |
| 270 | | - wfDebug( 'RSS', 'Request Failed: '.$fetch->getWikiText() ); |
| | 270 | + wfDebug( 'RSS', 'Request Failed: ' . $fetch->getWikiText() ); |
| 271 | 271 | return $fetch; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | | - $ret = $this->responseToXML($key); |
| | 274 | + $ret = $this->responseToXML( $key ); |
| 275 | 275 | return $ret; |
| 276 | 276 | } |
| 277 | 277 | |
| — | — | @@ -278,7 +278,7 @@ |
| 279 | 279 | $output = ""; |
| 280 | 280 | if ( $this->itemTemplate ) { |
| 281 | 281 | $headcnt = 0; |
| 282 | | - if ($this->reversed) { |
| | 282 | + if ( $this->reversed ) { |
| 283 | 283 | $this->rss->items = array_reverse( $this->rss->items ); |
| 284 | 284 | } |
| 285 | 285 | |
| — | — | @@ -300,9 +300,9 @@ |
| 301 | 301 | $parts = explode( '|', $this->itemTemplate ); |
| 302 | 302 | |
| 303 | 303 | $output = ""; |
| 304 | | - if( count( $parts ) > 1 && isset( $parser ) && isset( $frame ) ) { |
| | 304 | + if ( count( $parts ) > 1 && isset( $parser ) && isset( $frame ) ) { |
| 305 | 305 | $rendered = array(); |
| 306 | | - foreach( $parts as $part ) { |
| | 306 | + foreach ( $parts as $part ) { |
| 307 | 307 | $bits = explode( '=', $part ); |
| 308 | 308 | $left = null; |
| 309 | 309 | |
| — | — | @@ -311,13 +311,13 @@ |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | if ( isset( $item[$left] ) ) { |
| 315 | | - $leftValue = preg_replace( '#{{{'.$left.'}}}#', $item[$left], $bits[1] ); |
| | 315 | + $leftValue = preg_replace( '#{{{' . $left . '}}}#', $item[$left], $bits[1] ); |
| 316 | 316 | $rendered[] = implode( '=', array( $left, $leftValue ) ); |
| 317 | 317 | } else { |
| 318 | 318 | $rendered[] = $part; |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | | - $rssTemp = implode(" | ", $rendered); |
| | 321 | + $rssTemp = implode( " | ", $rendered ); |
| 322 | 322 | $output .= $parser->recursiveTagParse( $rssTemp, $frame ); |
| 323 | 323 | } |
| 324 | 324 | return $output; |
| — | — | @@ -335,9 +335,9 @@ |
| 336 | 336 | |
| 337 | 337 | // if RSS parsed successfully |
| 338 | 338 | if ( $this->rss && !$this->rss->ERROR ) { |
| 339 | | - $this->etag = $this->client->getResponseHeader('Etag'); |
| 340 | | - $this->last_modified = $this->client->getResponseHeader('Last-Modified'); |
| 341 | | - wfDebugLog( 'RSS', 'Stored etag ('.$this->etag.') and Last-Modified ('.$this->last_modified.') and items ('.count($this->rss->items).')!' ); |
| | 339 | + $this->etag = $this->client->getResponseHeader( 'Etag' ); |
| | 340 | + $this->last_modified = $this->client->getResponseHeader( 'Last-Modified' ); |
| | 341 | + wfDebugLog( 'RSS', 'Stored etag (' . $this->etag . ') and Last-Modified (' . $this->last_modified . ') and items (' . count( $this->rss->items ) . ')!' ); |
| 342 | 342 | $this->storeInCache( $key ); |
| 343 | 343 | |
| 344 | 344 | return Status::newGood(); |
| — | — | @@ -347,15 +347,14 @@ |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | function canDisplay( $item ) { |
| 351 | | - if($this->filter($item['description'], 'filterOut')) { |
| 352 | | - error_log($item['description']); |
| | 351 | + if ( $this->filter( $item['description'], 'filterOut' ) ) { |
| 353 | 352 | return true; |
| 354 | 353 | } |
| 355 | 354 | return false; |
| 356 | 355 | } |
| 357 | 356 | |
| 358 | 357 | function filter( $text, $filterType ) { |
| 359 | | - if($filterType === 'filterOut') { |
| | 358 | + if ( $filterType === 'filterOut' ) { |
| 360 | 359 | $keep = false; |
| 361 | 360 | $filter = $this->filterOut; |
| 362 | 361 | } else { |
| — | — | @@ -363,9 +362,9 @@ |
| 364 | 363 | $filter = $this->filter; |
| 365 | 364 | } |
| 366 | 365 | |
| 367 | | - if( count($filter) == 0 ) return !$keep; |
| | 366 | + if ( count( $filter ) == 0 ) return !$keep; |
| 368 | 367 | |
| 369 | | - foreach( $filter as $term ) { |
| | 368 | + foreach ( $filter as $term ) { |
| 370 | 369 | if ( $term ) { |
| 371 | 370 | $match = preg_match( "|$term|i", $text ); |
| 372 | 371 | if ( $match ) { |