| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * File: A compiled file for RSS syndication |
| 4 | 4 | * Author: Kellan Elliot-McCrea <kellan@protest.net> |
| 5 | 5 | * WordPress development team <http://www.wordpress.org/> |
| 6 | 6 | * Charles Johnson <technophilia@radgeek.com> |
| 7 | - * Version: 0.7wp | |
| 7 | + * Version: 0.7wp (2005.05.07) | |
| 8 | 8 | * License: GPL |
| 9 | 9 | * |
| 10 | 10 | * Provenance: |
| 11 | 11 | * |
| @@ -33,10 +33,30 @@ | ||
| 33 | 33 | * |
| 34 | 34 | * 4. There are two WordPress-specific functions, get_rss() and wp_rss() |
| 35 | 35 | * |
| 36 | 36 | * 5. New cases added to MagpieRSS::feed_start_element(), |
| 37 | - * MagpieRSS::feed_end_element(), and MagpieRSS::normalize() to handle | |
| 38 | - * multiple categories correctly. | |
| 37 | + * MagpieRSS::feed_end_element(), and MagpieRSS::normalize() to handle: | |
| 38 | + * | |
| 39 | + * (a) Multiple categories | |
| 40 | + * (b) RSS 2.0 and Atom 0.6+ enclosures | |
| 41 | + * | |
| 42 | + * Categories are stored in $item['category'], $item['categories'], | |
| 43 | + * $item['dc']['subject'], and $item['dc']['subjects'] (the singular keys | |
| 44 | + * point to string values for the first category used; the plural keys | |
| 45 | + * point to an array of all the categories the item is in) | |
| 46 | + * | |
| 47 | + * Enclosures are stored in the array $item['enclosure'] as suggested | |
| 48 | + * at <http://magpie.laughingmeme.org/blog/?p=101>. So the URL of the first | |
| 49 | + * enclosure is $item['enclosure'][0]['url']; the length is | |
| 50 | + * $item['enclosure'][0]['length']; and the type is | |
| 51 | + * $item['enclosure'][0]['type'] | |
| 52 | + * | |
| 53 | + * Note that these are hacked-in solutions for inherited problems with | |
| 54 | + * MagpieRSS as of version 0.7. They are not guaranteed to be | |
| 55 | + * forward-compatible when/if Kellan solves these problems in the official | |
| 56 | + * Magpie branch in the future. If you have filters (for example) that | |
| 57 | + * depend on either categories or enclosures working as they currently do, | |
| 58 | + * keep an eye on the ChangeLog in future releases. | |
| 39 | 59 | */ |
| 40 | 60 | |
| 41 | 61 | define('RSS', 'RSS'); |
| 42 | 62 | define('ATOM', 'Atom'); |
| @@ -231,8 +251,17 @@ | ||
| 231 | 251 | { |
| 232 | 252 | $this->inimage = true; |
| 233 | 253 | } |
| 234 | 254 | |
| 255 | + # -- Handle RSS 2 enclosures. Suggested by <http://magpie.laughingmeme.org/blog/?p=101> | |
| 256 | + elseif ( | |
| 257 | + $this->feed_type == RSS and | |
| 258 | + $el == 'enclosure' ) | |
| 259 | + { | |
| 260 | + $this->current_item[$el][] = $attrs; | |
| 261 | + $this->incontent = $el; | |
| 262 | + } | |
| 263 | + | |
| 235 | 264 | # handle atom content constructs |
| 236 | 265 | elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
| 237 | 266 | { |
| 238 | 267 | // avoid clashing w/ RSS mod_content |
| @@ -264,12 +293,24 @@ | ||
| 264 | 293 | // as being equivalent to RSS's simple link element. |
| 265 | 294 | // |
| 266 | 295 | elseif ($this->feed_type == ATOM and $el == 'link' ) |
| 267 | 296 | { |
| 268 | - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) | |
| 297 | + # -- CWJ: Treat <link> elements without explicit rel as rel="alternate" | |
| 298 | + if ( !isset($attrs['rel']) or isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) | |
| 269 | 299 | { |
| 270 | 300 | $link_el = 'link'; |
| 271 | 301 | } |
| 302 | + # -- CWJ: support Atom 0.6+ enclosures | |
| 303 | + elseif ( isset($attrs['rel']) and $attrs['rel'] == 'enclosure' ) | |
| 304 | + { | |
| 305 | + $link_el = 'link_' . $attrs['rel']; | |
| 306 | + | |
| 307 | + # -- CWJ: Normalize to RSS 2.0 enclosure handling | |
| 308 | + $n = count($this->current_item[$attrs['rel']]); | |
| 309 | + $this->current_item[$attrs['rel']][$n] = $attrs; | |
| 310 | + $this->current_item[$attrs['rel']][$n]['url'] = | |
| 311 | + $this->current_item[$attrs['rel']][$n]['href']; | |
| 312 | + } | |
| 272 | 313 | else { |
| 273 | 314 | $link_el = 'link_' . $attrs['rel']; |
| 274 | 315 | } |
| 275 | 316 | |