Index: trunk/extensions/RSS/RSS.php |
— | — | @@ -68,6 +68,7 @@ |
69 | 69 | protected $lastModified; |
70 | 70 | protected $xml; |
71 | 71 | protected $ERROR; |
| 72 | + protected $displayFields = array( 'author', 'title', 'encodedContent', 'description' ); |
72 | 73 | |
73 | 74 | public $client; |
74 | 75 | |
— | — | @@ -308,6 +309,12 @@ |
309 | 310 | $output = ""; |
310 | 311 | if ( count( $parts ) > 1 && isset( $parser ) && isset( $frame ) ) { |
311 | 312 | $rendered = array(); |
| 313 | + foreach ( $this->displayFields as $field ) { |
| 314 | + if ( isset( $item[$field] ) ) { |
| 315 | + $item[$field] = $this->highlightTerms( $item[$field] ); |
| 316 | + } |
| 317 | + } |
| 318 | + |
312 | 319 | foreach ( $parts as $part ) { |
313 | 320 | $bits = explode( '=', $part ); |
314 | 321 | $left = null; |
— | — | @@ -317,7 +324,8 @@ |
318 | 325 | } |
319 | 326 | |
320 | 327 | if ( isset( $item[$left] ) ) { |
321 | | - $leftValue = preg_replace( '#{{{' . $left . '}}}#', $item[$left], $bits[1] ); |
| 328 | + $leftValue = preg_replace( '#{{{' . $left . '}}}#', |
| 329 | + $item[$left], $bits[1] ); |
322 | 330 | $rendered[] = implode( '=', array( $left, $leftValue ) ); |
323 | 331 | } else { |
324 | 332 | $rendered[] = $part; |
— | — | @@ -343,7 +351,8 @@ |
344 | 352 | if ( $this->rss && !$this->rss->ERROR ) { |
345 | 353 | $this->etag = $this->client->getResponseHeader( 'Etag' ); |
346 | 354 | $this->lastModified = $this->client->getResponseHeader( 'Last-Modified' ); |
347 | | - wfDebugLog( 'RSS', 'Stored etag (' . $this->etag . ') and Last-Modified (' . $this->lastModified . ') and items (' . count( $this->rss->items ) . ')!' ); |
| 355 | + wfDebugLog( 'RSS', 'Stored etag (' . $this->etag . ') and Last-Modified (' . |
| 356 | + $this->lastModified . ') and items (' . count( $this->rss->items ) . ')!' ); |
348 | 357 | $this->storeInCache( $key ); |
349 | 358 | |
350 | 359 | return Status::newGood(); |
— | — | @@ -353,7 +362,17 @@ |
354 | 363 | } |
355 | 364 | |
356 | 365 | function canDisplay( $item ) { |
357 | | - if ( $this->filter( $item['description'], 'filterOut' ) ) { |
| 366 | + $check = ""; |
| 367 | + foreach ( $this->displayFields as $field ) { |
| 368 | + if ( isset( $item[$field] ) ) { |
| 369 | + $check .= $item[$field]; |
| 370 | + } |
| 371 | + } |
| 372 | + |
| 373 | + if ( $this->filter( $check, 'filterOut' ) ) { |
| 374 | + return false; |
| 375 | + } |
| 376 | + if ( $this->filter( $check, 'filter' ) ) { |
358 | 377 | return true; |
359 | 378 | } |
360 | 379 | return false; |
— | — | @@ -361,28 +380,20 @@ |
362 | 381 | |
363 | 382 | function filter( $text, $filterType ) { |
364 | 383 | if ( $filterType === 'filterOut' ) { |
365 | | - $keep = false; |
366 | 384 | $filter = $this->filterOut; |
367 | 385 | } else { |
368 | | - $keep = true; |
369 | 386 | $filter = $this->filter; |
370 | 387 | } |
371 | 388 | |
372 | | - if ( count( $filter ) == 0 ) return !$keep; |
| 389 | + if ( count( $filter ) == 0 ) return $filterType !== 'filterOut'; |
373 | 390 | |
374 | | - foreach ( $filter as $term ) { |
375 | | - if ( $term ) { |
376 | | - $match = preg_match( "|$term|i", $text ); |
| 391 | + $match = preg_match( '#(' . implode( "|", $filter ) . ')#i', $text ); |
377 | 392 | if ( $match ) { |
378 | | - return $keep; |
| 393 | + return true; |
379 | 394 | } |
| 395 | + return false; |
380 | 396 | } |
381 | | - return !$keep; |
382 | | - } |
383 | 397 | |
384 | | - } |
385 | | - |
386 | | - |
387 | 398 | function highlightTerms( $text ) { |
388 | 399 | $i = 0; |
389 | 400 | $starttag = 'v8x5u3t3u8h'; |