Index: trunk/extensions/RSS/RELEASE-NOTES |
— | — | @@ -15,6 +15,9 @@ |
16 | 16 | * bug 30028 "Error parsing XML for RSS" - improve and harden Extension:RSS when |
17 | 17 | parsing differently flavoured RSS feeds |
18 | 18 | |
| 19 | +=== Version 1.91 2012-02-13 === |
| 20 | +* added optional date= attribute and $wgRSSDateDefaultFormat parameter |
| 21 | + |
19 | 22 | === Version 1.90 2011-08-15 === |
20 | 23 | * removed parsing of each single channel subelement (item) |
21 | 24 | * only the finally constructed feed is sent to the recursive parser: |
Index: trunk/extensions/RSS/RSSData.php |
— | — | @@ -55,11 +55,8 @@ |
56 | 56 | protected function rssTokenToName( $n ) { |
57 | 57 | switch( $n ) { |
58 | 58 | case 'dc:date': |
59 | | - return 'date'; |
60 | | - # parse "2010-10-18T18:07:00Z" |
61 | 59 | case 'pubDate': |
62 | 60 | return 'date'; |
63 | | - # parse RFC date |
64 | 61 | case 'dc:creator': |
65 | 62 | return 'author'; |
66 | 63 | case 'title': |
Index: trunk/extensions/RSS/RSSParser.php |
— | — | @@ -37,6 +37,8 @@ |
38 | 38 | * and return an object that can produce rendered output. |
39 | 39 | */ |
40 | 40 | function __construct( $url, $args ) { |
| 41 | + global $wgRSSDateDefaultFormat; |
| 42 | + |
41 | 43 | $this->url = $url; |
42 | 44 | |
43 | 45 | # Get max number of headlines from argument-array |
— | — | @@ -50,11 +52,18 @@ |
51 | 53 | } |
52 | 54 | |
53 | 55 | # Get date format from argument array |
54 | | - # FIXME: not used yet |
55 | | - if ( isset( $args['date'] ) ) { |
| 56 | + # or use a default value |
| 57 | + switch ( true ) { |
| 58 | + case ( isset( $args['date'] ) ): |
56 | 59 | $this->date = $args['date']; |
| 60 | + break; |
| 61 | + case ( isset( $wgRSSDateDefaultFormat ) ): |
| 62 | + $this->date = $wgRSSDateDefaultFormat; |
| 63 | + break; |
| 64 | + default: |
| 65 | + $this->date = "Y-m-d H:i:s"; |
57 | 66 | } |
58 | | - |
| 67 | + |
59 | 68 | # Get highlight terms from argument array |
60 | 69 | if ( isset( $args['highlight'] ) ) { |
61 | 70 | # mapping to lowercase here so the regex can be case insensitive below. |
— | — | @@ -291,11 +300,21 @@ |
292 | 301 | // rogue <script> tags neutered. |
293 | 302 | |
294 | 303 | foreach ( array_keys( $item ) as $info ) { |
295 | | - if ( $info != 'link' ) { |
| 304 | + switch ( $info ) { |
| 305 | + case 'link': |
| 306 | + $txt = $this->sanitizeUrl( $item[ $info ] ); |
| 307 | + break; |
| 308 | + case 'date': |
| 309 | + // PHP > 5.3.0 users can better use date_create_from_format method to reformat a date string |
| 310 | + $tempTimezone = date_default_timezone_get(); |
| 311 | + date_default_timezone_set( 'UTC' ); |
| 312 | + $txt = date( $this->date, strtotime( $item[ $info ] ) ); |
| 313 | + date_default_timezone_set( $tempTimezone ); |
| 314 | + break; |
| 315 | + default: |
296 | 316 | $txt = $this->highlightTerms( $this->escapeTemplateParameter( $item[ $info ] ) ); |
297 | | - } else { |
298 | | - $txt = $this->sanitizeUrl( $item[ $info ] ); |
299 | 317 | } |
| 318 | + |
300 | 319 | $renderedItem = str_replace( '{{{' . $info . '}}}', $txt, $renderedItem ); |
301 | 320 | } |
302 | 321 | |
Index: trunk/extensions/RSS/RSS.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | 'Rdb', 'Mafs', 'Alxndr', 'Thomas Gries', 'Chris Reigrut', |
28 | 28 | 'K001', 'Jack Phoenix', 'Jeroen De Dauw', 'Mark A. Hershberger' |
29 | 29 | ), |
30 | | - 'version' => '1.90 20110815', |
| 30 | + 'version' => '1.91 20120213', |
31 | 31 | 'url' => 'https://www.mediawiki.org/wiki/Extension:RSS', |
32 | 32 | 'descriptionmsg' => 'rss-desc', |
33 | 33 | ); |
— | — | @@ -65,3 +65,6 @@ |
66 | 66 | |
67 | 67 | // Proxy server to use for fetching feeds |
68 | 68 | $wgRSSProxy = false; |
| 69 | + |
| 70 | +// default date format of item publication dates see http://www.php.net/date |
| 71 | +$wgRSSDateDefaultFormat = "(Y-m-d H:i:s)"; |