5 * A PHP-Based RSS and Atom Feed Framework.
6 * Takes the hard work out of managing a complete RSS/Atom solution.
8 * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
11 * Redistribution and use in source and binary forms, with or without modification, are
12 * permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright notice, this list of
15 * conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright notice, this list
18 * of conditions and the following disclaimer in the documentation and/or other materials
19 * provided with the distribution.
21 * * Neither the name of the SimplePie Team nor the names of its contributors may be used
22 * to endorse or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
26 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
28 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
39 * @author Geoffrey Sneddon
41 * @link http://simplepie.org/ SimplePie
42 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
47 * Manages all item-related data
49 * Used by {@see SimplePie::get_item()} and {@see SimplePie::get_items()}
51 * This class can be overloaded with {@see SimplePie::set_item_class()}
78 * @var SimplePie_Registry
83 * Create a new item object
85 * This is usually used by {@see SimplePie::get_items} and
86 * {@see SimplePie::get_item}. Avoid creating this manually.
88 * @param SimplePie $feed Parent feed
89 * @param array $data Raw data
91 public function __construct($feed, $data)
98 * Set the registry handler
100 * This is usually used by {@see SimplePie_Registry::create}
103 * @param SimplePie_Registry $registry
105 public function set_registry(SimplePie_Registry $registry)
107 $this->registry = $registry;
111 * Get a string representation of the item
115 public function __toString()
117 return md5(serialize($this->data));
121 * Remove items that link back to this before destroying this object
123 public function __destruct()
125 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
132 * Get data for an item-level element
134 * This method allows you to get access to ANY element/attribute that is a
135 * sub-element of the item/entry tag.
137 * See {@see SimplePie::get_feed_tags()} for a description of the return value
140 * @see http://simplepie.org/wiki/faq/supported_xml_namespaces
141 * @param string $namespace The URL of the XML namespace of the elements you're trying to access
142 * @param string $tag Tag name
145 public function get_item_tags($namespace, $tag)
147 if (isset($this->data['child'][$namespace][$tag]))
149 return $this->data['child'][$namespace][$tag];
158 * Get the base URL value from the parent feed
162 * @param array $element
165 public function get_base($element = array())
167 return $this->feed->get_base($element);
174 * @see SimplePie::sanitize()
175 * @param string $data Data to sanitize
176 * @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
177 * @param string $base Base URL to resolve URLs against
178 * @return string Sanitized data
180 public function sanitize($data, $type, $base = '')
182 return $this->feed->sanitize($data, $type, $base);
186 * Get the parent feed
188 * Note: this may not work as you think for multifeeds!
190 * @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
194 public function get_feed()
200 * Get the unique identifier for the item
202 * This is usually used when writing code to check for new items in a feed.
204 * Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute
205 * for RDF. If none of these are supplied (or `$hash` is true), creates an
206 * MD5 hash based on the permalink and title. If either of those are not
207 * supplied, creates a hash based on the full feed data.
210 * @param boolean $hash Should we force using a hash instead of the supplied ID?
213 public function get_id($hash = false)
217 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
219 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
221 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
223 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
225 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
227 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
229 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
231 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
233 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
235 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
237 elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
239 return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
241 elseif (($return = $this->get_permalink()) !== null)
245 elseif (($return = $this->get_title()) !== null)
250 if ($this->get_permalink() !== null || $this->get_title() !== null)
252 return md5($this->get_permalink() . $this->get_title());
256 return md5(serialize($this->data));
261 * Get the title of the item
263 * Uses `<atom:title>`, `<title>` or `<dc:title>`
265 * @since Beta 2 (previously called `get_item_title` since 0.8)
266 * @return string|null
268 public function get_title()
270 if (!isset($this->data['title']))
272 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
274 $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
276 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
278 $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
280 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
282 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
284 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
286 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
288 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
290 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
292 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
294 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
296 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
298 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
302 $this->data['title'] = null;
305 return $this->data['title'];
309 * Get the content for the item
311 * Prefers summaries over full content , but will return full content if a
312 * summary does not exist.
314 * To prefer full content instead, use {@see get_content}
316 * Uses `<atom:summary>`, `<description>`, `<dc:description>` or
317 * `<itunes:subtitle>`
320 * @param boolean $description_only Should we avoid falling back to the content?
321 * @return string|null
323 public function get_description($description_only = false)
325 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
327 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
329 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
331 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
333 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
335 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
337 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
339 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
341 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
343 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
345 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
347 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
349 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
351 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
353 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
355 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
357 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
359 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML);
362 elseif (!$description_only)
364 return $this->get_content(true);
373 * Get the content for the item
375 * Prefers full content over summaries, but will return a summary if full
376 * content does not exist.
378 * To prefer summaries instead, use {@see get_description}
380 * Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module)
383 * @param boolean $content_only Should we avoid falling back to the description?
384 * @return string|null
386 public function get_content($content_only = false)
388 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
390 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
392 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
394 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
396 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
398 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
400 elseif (!$content_only)
402 return $this->get_description(true);
411 * Get a category for the item
413 * @since Beta 3 (previously called `get_categories()` since Beta 2)
414 * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
415 * @return SimplePie_Category|null
417 public function get_category($key = 0)
419 $categories = $this->get_categories();
420 if (isset($categories[$key]))
422 return $categories[$key];
431 * Get all categories for the item
433 * Uses `<atom:category>`, `<category>` or `<dc:subject>`
436 * @return array|null List of {@see SimplePie_Category} objects
438 public function get_categories()
440 $categories = array();
442 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
447 if (isset($category['attribs']['']['term']))
449 $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
451 if (isset($category['attribs']['']['scheme']))
453 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
455 if (isset($category['attribs']['']['label']))
457 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
459 $categories[] = $this->registry->create('Category', array($term, $scheme, $label));
461 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
463 // This is really the label, but keep this as the term also for BC.
464 // Label will also work on retrieving because that falls back to term.
465 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
466 if (isset($category['attribs']['']['domain']))
468 $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
474 $categories[] = $this->registry->create('Category', array($term, $scheme, null));
476 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
478 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
480 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
482 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
485 if (!empty($categories))
487 return array_unique($categories);
496 * Get an author for the item
499 * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
500 * @return SimplePie_Author|null
502 public function get_author($key = 0)
504 $authors = $this->get_authors();
505 if (isset($authors[$key]))
507 return $authors[$key];
516 * Get a contributor for the item
519 * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
520 * @return SimplePie_Author|null
522 public function get_contributor($key = 0)
524 $contributors = $this->get_contributors();
525 if (isset($contributors[$key]))
527 return $contributors[$key];
536 * Get all contributors for the item
538 * Uses `<atom:contributor>`
541 * @return array|null List of {@see SimplePie_Author} objects
543 public function get_contributors()
545 $contributors = array();
546 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
551 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
553 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
555 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
557 $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
559 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
561 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
563 if ($name !== null || $email !== null || $uri !== null)
565 $contributors[] = $this->registry->create('Author', array($name, $uri, $email));
568 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
573 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
575 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
577 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
579 $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
581 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
583 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
585 if ($name !== null || $email !== null || $url !== null)
587 $contributors[] = $this->registry->create('Author', array($name, $url, $email));
591 if (!empty($contributors))
593 return array_unique($contributors);
602 * Get all authors for the item
604 * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>`
607 * @return array|null List of {@see SimplePie_Author} objects
609 public function get_authors()
612 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
617 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
619 $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
621 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
623 $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
625 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
627 $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
629 if ($name !== null || $email !== null || $uri !== null)
631 $authors[] = $this->registry->create('Author', array($name, $uri, $email));
634 if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
639 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
641 $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
643 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
645 $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
647 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
649 $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
651 if ($name !== null || $email !== null || $url !== null)
653 $authors[] = $this->registry->create('Author', array($name, $url, $email));
656 if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
658 $authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)));
660 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
662 $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
664 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
666 $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
668 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
670 $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
673 if (!empty($authors))
675 return array_unique($authors);
677 elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
681 elseif ($authors = $this->feed->get_authors())
692 * Get the copyright info for the item
694 * Uses `<atom:rights>` or `<dc:rights>`
699 public function get_copyright()
701 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
703 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
705 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
707 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
709 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
711 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
720 * Get the posting date/time for the item
722 * Uses `<atom:published>`, `<atom:updated>`, `<atom:issued>`,
723 * `<atom:modified>`, `<pubDate>` or `<dc:date>`
725 * Note: obeys PHP's timezone setting. To get a UTC date/time, use
728 * @since Beta 2 (previously called `get_item_date` since 0.8)
730 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
731 * @return int|string|null
733 public function get_date($date_format = 'j F Y, g:i a')
735 if (!isset($this->data['date']))
737 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
739 $this->data['date']['raw'] = $return[0]['data'];
741 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
743 $this->data['date']['raw'] = $return[0]['data'];
745 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
747 $this->data['date']['raw'] = $return[0]['data'];
749 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
751 $this->data['date']['raw'] = $return[0]['data'];
753 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
755 $this->data['date']['raw'] = $return[0]['data'];
757 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
759 $this->data['date']['raw'] = $return[0]['data'];
761 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
763 $this->data['date']['raw'] = $return[0]['data'];
765 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
767 $this->data['date']['raw'] = $return[0]['data'];
770 if (!empty($this->data['date']['raw']))
772 $parser = $this->registry->call('Parse_Date', 'get');
773 $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
777 $this->data['date'] = null;
780 if ($this->data['date'])
782 $date_format = (string) $date_format;
783 switch ($date_format)
786 return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
789 return $this->data['date']['parsed'];
792 return date($date_format, $this->data['date']['parsed']);
802 * Get the update date/time for the item
804 * Uses `<atom:updated>`
806 * Note: obeys PHP's timezone setting. To get a UTC date/time, use
809 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
810 * @return int|string|null
812 public function get_updated_date($date_format = 'j F Y, g:i a')
814 if (!isset($this->data['updated']))
816 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
818 $this->data['updated']['raw'] = $return[0]['data'];
821 if (!empty($this->data['updated']['raw']))
823 $parser = $this->registry->call('Parse_Date', 'get');
824 $this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']);
828 $this->data['updated'] = null;
831 if ($this->data['updated'])
833 $date_format = (string) $date_format;
834 switch ($date_format)
837 return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
840 return $this->data['updated']['parsed'];
843 return date($date_format, $this->data['updated']['parsed']);
853 * Get the localized posting date/time for the item
855 * Returns the date formatted in the localized language. To display in
856 * languages other than the server's default, you need to change the locale
857 * with {@link http://php.net/setlocale setlocale()}. The available
858 * localizations depend on which ones are installed on your web server.
862 * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
863 * @return int|string|null
865 public function get_local_date($date_format = '%c')
869 return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
871 elseif (($date = $this->get_date('U')) !== null && $date !== false)
873 return strftime($date_format, $date);
882 * Get the posting date/time for the item (UTC time)
885 * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
886 * @return int|string|null
888 public function get_gmdate($date_format = 'j F Y, g:i a')
890 $date = $this->get_date('U');
896 return gmdate($date_format, $date);
900 * Get the update date/time for the item (UTC time)
902 * @see get_updated_date
903 * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
904 * @return int|string|null
906 public function get_updated_gmdate($date_format = 'j F Y, g:i a')
908 $date = $this->get_updated_date('U');
914 return gmdate($date_format, $date);
918 * Get the permalink for the item
920 * Returns the first link available with a relationship of "alternate".
921 * Identical to {@see get_link()} with key 0
925 * @return string|null Permalink URL
927 public function get_permalink()
929 $link = $this->get_link();
930 $enclosure = $this->get_enclosure(0);
935 elseif ($enclosure !== null)
937 return $enclosure->get_link();
946 * Get a single link for the item
949 * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1
950 * @param string $rel The relationship of the link to return
951 * @return string|null Link URL
953 public function get_link($key = 0, $rel = 'alternate')
955 $links = $this->get_links($rel);
956 if ($links[$key] !== null)
967 * Get all links for the item
969 * Uses `<atom:link>`, `<link>` or `<guid>`
972 * @param string $rel The relationship of links to return
973 * @return array|null Links found for the item (strings)
975 public function get_links($rel = 'alternate')
977 if (!isset($this->data['links']))
979 $this->data['links'] = array();
980 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
982 if (isset($link['attribs']['']['href']))
984 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
985 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
989 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
991 if (isset($link['attribs']['']['href']))
993 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
994 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
997 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
999 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1001 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
1003 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1005 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
1007 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1009 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
1011 if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
1013 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
1017 $keys = array_keys($this->data['links']);
1018 foreach ($keys as $key)
1020 if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key)))
1022 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
1024 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
1025 $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
1029 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
1032 elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
1034 $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
1036 $this->data['links'][$key] = array_unique($this->data['links'][$key]);
1039 if (isset($this->data['links'][$rel]))
1041 return $this->data['links'][$rel];
1050 * Get an enclosure from the item
1052 * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
1055 * @todo Add ability to prefer one type of content over another (in a media group).
1056 * @param int $key The enclosure that you want to return. Remember that arrays begin with 0, not 1
1057 * @return SimplePie_Enclosure|null
1059 public function get_enclosure($key = 0, $prefer = null)
1061 $enclosures = $this->get_enclosures();
1062 if (isset($enclosures[$key]))
1064 return $enclosures[$key];
1073 * Get all available enclosures (podcasts, etc.)
1075 * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
1077 * At this point, we're pretty much assuming that all enclosures for an item
1078 * are the same content. Anything else is too complicated to
1082 * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
1083 * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
1084 * @return array|null List of SimplePie_Enclosure items
1086 public function get_enclosures()
1088 if (!isset($this->data['enclosures']))
1090 $this->data['enclosures'] = array();
1093 $captions_parent = null;
1094 $categories_parent = null;
1095 $copyrights_parent = null;
1096 $credits_parent = null;
1097 $description_parent = null;
1098 $duration_parent = null;
1099 $hashes_parent = null;
1100 $keywords_parent = null;
1101 $player_parent = null;
1102 $ratings_parent = null;
1103 $restrictions_parent = null;
1104 $thumbnails_parent = null;
1105 $title_parent = null;
1107 // Let's do the channel and item-level ones first, and just re-use them if we need to.
1108 $parent = $this->get_feed();
1111 if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
1113 foreach ($captions as $caption)
1115 $caption_type = null;
1116 $caption_lang = null;
1117 $caption_startTime = null;
1118 $caption_endTime = null;
1119 $caption_text = null;
1120 if (isset($caption['attribs']['']['type']))
1122 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1124 if (isset($caption['attribs']['']['lang']))
1126 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1128 if (isset($caption['attribs']['']['start']))
1130 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
1132 if (isset($caption['attribs']['']['end']))
1134 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
1136 if (isset($caption['data']))
1138 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1140 $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
1143 elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
1145 foreach ($captions as $caption)
1147 $caption_type = null;
1148 $caption_lang = null;
1149 $caption_startTime = null;
1150 $caption_endTime = null;
1151 $caption_text = null;
1152 if (isset($caption['attribs']['']['type']))
1154 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1156 if (isset($caption['attribs']['']['lang']))
1158 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1160 if (isset($caption['attribs']['']['start']))
1162 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
1164 if (isset($caption['attribs']['']['end']))
1166 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
1168 if (isset($caption['data']))
1170 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1172 $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
1175 if (is_array($captions_parent))
1177 $captions_parent = array_values(array_unique($captions_parent));
1181 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
1186 if (isset($category['data']))
1188 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1190 if (isset($category['attribs']['']['scheme']))
1192 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1196 $scheme = 'http://search.yahoo.com/mrss/category_schema';
1198 if (isset($category['attribs']['']['label']))
1200 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
1202 $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
1204 foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
1209 if (isset($category['data']))
1211 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1213 if (isset($category['attribs']['']['scheme']))
1215 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1219 $scheme = 'http://search.yahoo.com/mrss/category_schema';
1221 if (isset($category['attribs']['']['label']))
1223 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
1225 $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
1227 foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
1230 $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
1232 if (isset($category['attribs']['']['text']))
1234 $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
1236 $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
1238 if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
1240 foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
1242 if (isset($subcategory['attribs']['']['text']))
1244 $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
1246 $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
1250 if (is_array($categories_parent))
1252 $categories_parent = array_values(array_unique($categories_parent));
1256 if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
1258 $copyright_url = null;
1259 $copyright_label = null;
1260 if (isset($copyright[0]['attribs']['']['url']))
1262 $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
1264 if (isset($copyright[0]['data']))
1266 $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1268 $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
1270 elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
1272 $copyright_url = null;
1273 $copyright_label = null;
1274 if (isset($copyright[0]['attribs']['']['url']))
1276 $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
1278 if (isset($copyright[0]['data']))
1280 $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1282 $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
1286 if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
1288 foreach ($credits as $credit)
1290 $credit_role = null;
1291 $credit_scheme = null;
1292 $credit_name = null;
1293 if (isset($credit['attribs']['']['role']))
1295 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
1297 if (isset($credit['attribs']['']['scheme']))
1299 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1303 $credit_scheme = 'urn:ebu';
1305 if (isset($credit['data']))
1307 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1309 $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
1312 elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
1314 foreach ($credits as $credit)
1316 $credit_role = null;
1317 $credit_scheme = null;
1318 $credit_name = null;
1319 if (isset($credit['attribs']['']['role']))
1321 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
1323 if (isset($credit['attribs']['']['scheme']))
1325 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1329 $credit_scheme = 'urn:ebu';
1331 if (isset($credit['data']))
1333 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1335 $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
1338 if (is_array($credits_parent))
1340 $credits_parent = array_values(array_unique($credits_parent));
1344 if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
1346 if (isset($description_parent[0]['data']))
1348 $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1351 elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
1353 if (isset($description_parent[0]['data']))
1355 $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1360 if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
1365 if (isset($duration_parent[0]['data']))
1367 $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
1368 if (sizeof($temp) > 0)
1370 $seconds = (int) array_pop($temp);
1372 if (sizeof($temp) > 0)
1374 $minutes = (int) array_pop($temp);
1375 $seconds += $minutes * 60;
1377 if (sizeof($temp) > 0)
1379 $hours = (int) array_pop($temp);
1380 $seconds += $hours * 3600;
1383 $duration_parent = $seconds;
1388 if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
1390 foreach ($hashes_iterator as $hash)
1394 if (isset($hash['data']))
1396 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1398 if (isset($hash['attribs']['']['algo']))
1400 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
1406 $hashes_parent[] = $algo.':'.$value;
1409 elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
1411 foreach ($hashes_iterator as $hash)
1415 if (isset($hash['data']))
1417 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1419 if (isset($hash['attribs']['']['algo']))
1421 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
1427 $hashes_parent[] = $algo.':'.$value;
1430 if (is_array($hashes_parent))
1432 $hashes_parent = array_values(array_unique($hashes_parent));
1436 if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
1438 if (isset($keywords[0]['data']))
1440 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
1441 foreach ($temp as $word)
1443 $keywords_parent[] = trim($word);
1448 elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
1450 if (isset($keywords[0]['data']))
1452 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
1453 foreach ($temp as $word)
1455 $keywords_parent[] = trim($word);
1460 elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
1462 if (isset($keywords[0]['data']))
1464 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
1465 foreach ($temp as $word)
1467 $keywords_parent[] = trim($word);
1472 elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
1474 if (isset($keywords[0]['data']))
1476 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
1477 foreach ($temp as $word)
1479 $keywords_parent[] = trim($word);
1484 if (is_array($keywords_parent))
1486 $keywords_parent = array_values(array_unique($keywords_parent));
1490 if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
1492 if (isset($player_parent[0]['attribs']['']['url']))
1494 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1497 elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
1499 if (isset($player_parent[0]['attribs']['']['url']))
1501 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1506 if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
1508 foreach ($ratings as $rating)
1510 $rating_scheme = null;
1511 $rating_value = null;
1512 if (isset($rating['attribs']['']['scheme']))
1514 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1518 $rating_scheme = 'urn:simple';
1520 if (isset($rating['data']))
1522 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1524 $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1527 elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
1529 foreach ($ratings as $rating)
1531 $rating_scheme = 'urn:itunes';
1532 $rating_value = null;
1533 if (isset($rating['data']))
1535 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1537 $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1540 elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
1542 foreach ($ratings as $rating)
1544 $rating_scheme = null;
1545 $rating_value = null;
1546 if (isset($rating['attribs']['']['scheme']))
1548 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1552 $rating_scheme = 'urn:simple';
1554 if (isset($rating['data']))
1556 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1558 $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1561 elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
1563 foreach ($ratings as $rating)
1565 $rating_scheme = 'urn:itunes';
1566 $rating_value = null;
1567 if (isset($rating['data']))
1569 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1571 $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
1574 if (is_array($ratings_parent))
1576 $ratings_parent = array_values(array_unique($ratings_parent));
1580 if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
1582 foreach ($restrictions as $restriction)
1584 $restriction_relationship = null;
1585 $restriction_type = null;
1586 $restriction_value = null;
1587 if (isset($restriction['attribs']['']['relationship']))
1589 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
1591 if (isset($restriction['attribs']['']['type']))
1593 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1595 if (isset($restriction['data']))
1597 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1599 $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1602 elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
1604 foreach ($restrictions as $restriction)
1606 $restriction_relationship = 'allow';
1607 $restriction_type = null;
1608 $restriction_value = 'itunes';
1609 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
1611 $restriction_relationship = 'deny';
1613 $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1616 elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
1618 foreach ($restrictions as $restriction)
1620 $restriction_relationship = null;
1621 $restriction_type = null;
1622 $restriction_value = null;
1623 if (isset($restriction['attribs']['']['relationship']))
1625 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
1627 if (isset($restriction['attribs']['']['type']))
1629 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1631 if (isset($restriction['data']))
1633 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1635 $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1638 elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
1640 foreach ($restrictions as $restriction)
1642 $restriction_relationship = 'allow';
1643 $restriction_type = null;
1644 $restriction_value = 'itunes';
1645 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
1647 $restriction_relationship = 'deny';
1649 $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
1652 if (is_array($restrictions_parent))
1654 $restrictions_parent = array_values(array_unique($restrictions_parent));
1658 $restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default'));
1662 if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
1664 foreach ($thumbnails as $thumbnail)
1666 if (isset($thumbnail['attribs']['']['url']))
1668 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1672 elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
1674 foreach ($thumbnails as $thumbnail)
1676 if (isset($thumbnail['attribs']['']['url']))
1678 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1684 if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
1686 if (isset($title_parent[0]['data']))
1688 $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1691 elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
1693 if (isset($title_parent[0]['data']))
1695 $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1713 $samplingrate = null;
1723 $description = null;
1728 $restrictions = null;
1732 // If we have media:group tags, loop through them.
1733 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
1735 if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
1737 // If we have media:content tags, loop through them.
1738 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
1740 if (isset($content['attribs']['']['url']))
1753 $samplingrate = null;
1763 $description = null;
1768 $restrictions = null;
1772 // Start checking the attributes of media:content
1773 if (isset($content['attribs']['']['bitrate']))
1775 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
1777 if (isset($content['attribs']['']['channels']))
1779 $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
1781 if (isset($content['attribs']['']['duration']))
1783 $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
1787 $duration = $duration_parent;
1789 if (isset($content['attribs']['']['expression']))
1791 $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
1793 if (isset($content['attribs']['']['framerate']))
1795 $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
1797 if (isset($content['attribs']['']['height']))
1799 $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
1801 if (isset($content['attribs']['']['lang']))
1803 $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1805 if (isset($content['attribs']['']['fileSize']))
1807 $length = ceil($content['attribs']['']['fileSize']);
1809 if (isset($content['attribs']['']['medium']))
1811 $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
1813 if (isset($content['attribs']['']['samplingrate']))
1815 $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
1817 if (isset($content['attribs']['']['type']))
1819 $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1821 if (isset($content['attribs']['']['width']))
1823 $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
1825 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
1827 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
1830 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
1832 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
1834 $caption_type = null;
1835 $caption_lang = null;
1836 $caption_startTime = null;
1837 $caption_endTime = null;
1838 $caption_text = null;
1839 if (isset($caption['attribs']['']['type']))
1841 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1843 if (isset($caption['attribs']['']['lang']))
1845 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1847 if (isset($caption['attribs']['']['start']))
1849 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
1851 if (isset($caption['attribs']['']['end']))
1853 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
1855 if (isset($caption['data']))
1857 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1859 $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
1861 if (is_array($captions))
1863 $captions = array_values(array_unique($captions));
1866 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
1868 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
1870 $caption_type = null;
1871 $caption_lang = null;
1872 $caption_startTime = null;
1873 $caption_endTime = null;
1874 $caption_text = null;
1875 if (isset($caption['attribs']['']['type']))
1877 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
1879 if (isset($caption['attribs']['']['lang']))
1881 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
1883 if (isset($caption['attribs']['']['start']))
1885 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
1887 if (isset($caption['attribs']['']['end']))
1889 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
1891 if (isset($caption['data']))
1893 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1895 $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
1897 if (is_array($captions))
1899 $captions = array_values(array_unique($captions));
1904 $captions = $captions_parent;
1908 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
1910 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
1915 if (isset($category['data']))
1917 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1919 if (isset($category['attribs']['']['scheme']))
1921 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1925 $scheme = 'http://search.yahoo.com/mrss/category_schema';
1927 if (isset($category['attribs']['']['label']))
1929 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
1931 $categories[] = $this->registry->create('Category', array($term, $scheme, $label));
1934 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
1936 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
1941 if (isset($category['data']))
1943 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1945 if (isset($category['attribs']['']['scheme']))
1947 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
1951 $scheme = 'http://search.yahoo.com/mrss/category_schema';
1953 if (isset($category['attribs']['']['label']))
1955 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
1957 $categories[] = $this->registry->create('Category', array($term, $scheme, $label));
1960 if (is_array($categories) && is_array($categories_parent))
1962 $categories = array_values(array_unique(array_merge($categories, $categories_parent)));
1964 elseif (is_array($categories))
1966 $categories = array_values(array_unique($categories));
1968 elseif (is_array($categories_parent))
1970 $categories = array_values(array_unique($categories_parent));
1974 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
1976 $copyright_url = null;
1977 $copyright_label = null;
1978 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
1980 $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
1982 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
1984 $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
1986 $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
1988 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
1990 $copyright_url = null;
1991 $copyright_label = null;
1992 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
1994 $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
1996 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
1998 $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2000 $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
2004 $copyrights = $copyrights_parent;
2008 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
2010 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
2012 $credit_role = null;
2013 $credit_scheme = null;
2014 $credit_name = null;
2015 if (isset($credit['attribs']['']['role']))
2017 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
2019 if (isset($credit['attribs']['']['scheme']))
2021 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2025 $credit_scheme = 'urn:ebu';
2027 if (isset($credit['data']))
2029 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2031 $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
2033 if (is_array($credits))
2035 $credits = array_values(array_unique($credits));
2038 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
2040 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
2042 $credit_role = null;
2043 $credit_scheme = null;
2044 $credit_name = null;
2045 if (isset($credit['attribs']['']['role']))
2047 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
2049 if (isset($credit['attribs']['']['scheme']))
2051 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2055 $credit_scheme = 'urn:ebu';
2057 if (isset($credit['data']))
2059 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2061 $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
2063 if (is_array($credits))
2065 $credits = array_values(array_unique($credits));
2070 $credits = $credits_parent;
2074 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
2076 $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2078 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
2080 $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2084 $description = $description_parent;
2088 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
2090 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
2094 if (isset($hash['data']))
2096 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2098 if (isset($hash['attribs']['']['algo']))
2100 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
2106 $hashes[] = $algo.':'.$value;
2108 if (is_array($hashes))
2110 $hashes = array_values(array_unique($hashes));
2113 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
2115 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
2119 if (isset($hash['data']))
2121 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2123 if (isset($hash['attribs']['']['algo']))
2125 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
2131 $hashes[] = $algo.':'.$value;
2133 if (is_array($hashes))
2135 $hashes = array_values(array_unique($hashes));
2140 $hashes = $hashes_parent;
2144 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
2146 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
2148 $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
2149 foreach ($temp as $word)
2151 $keywords[] = trim($word);
2155 if (is_array($keywords))
2157 $keywords = array_values(array_unique($keywords));
2160 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
2162 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
2164 $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
2165 foreach ($temp as $word)
2167 $keywords[] = trim($word);
2171 if (is_array($keywords))
2173 $keywords = array_values(array_unique($keywords));
2178 $keywords = $keywords_parent;
2182 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2184 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2186 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2188 $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2192 $player = $player_parent;
2196 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
2198 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
2200 $rating_scheme = null;
2201 $rating_value = null;
2202 if (isset($rating['attribs']['']['scheme']))
2204 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2208 $rating_scheme = 'urn:simple';
2210 if (isset($rating['data']))
2212 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2214 $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
2216 if (is_array($ratings))
2218 $ratings = array_values(array_unique($ratings));
2221 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
2223 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
2225 $rating_scheme = null;
2226 $rating_value = null;
2227 if (isset($rating['attribs']['']['scheme']))
2229 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2233 $rating_scheme = 'urn:simple';
2235 if (isset($rating['data']))
2237 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2239 $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
2241 if (is_array($ratings))
2243 $ratings = array_values(array_unique($ratings));
2248 $ratings = $ratings_parent;
2252 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
2254 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
2256 $restriction_relationship = null;
2257 $restriction_type = null;
2258 $restriction_value = null;
2259 if (isset($restriction['attribs']['']['relationship']))
2261 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
2263 if (isset($restriction['attribs']['']['type']))
2265 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2267 if (isset($restriction['data']))
2269 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2271 $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
2273 if (is_array($restrictions))
2275 $restrictions = array_values(array_unique($restrictions));
2278 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
2280 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
2282 $restriction_relationship = null;
2283 $restriction_type = null;
2284 $restriction_value = null;
2285 if (isset($restriction['attribs']['']['relationship']))
2287 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
2289 if (isset($restriction['attribs']['']['type']))
2291 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2293 if (isset($restriction['data']))
2295 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2297 $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
2299 if (is_array($restrictions))
2301 $restrictions = array_values(array_unique($restrictions));
2306 $restrictions = $restrictions_parent;
2310 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
2312 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
2314 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2316 if (is_array($thumbnails))
2318 $thumbnails = array_values(array_unique($thumbnails));
2321 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
2323 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
2325 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2327 if (is_array($thumbnails))
2329 $thumbnails = array_values(array_unique($thumbnails));
2334 $thumbnails = $thumbnails_parent;
2338 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2340 $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2342 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2344 $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2348 $title = $title_parent;
2351 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width));
2357 // If we have standalone media:content tags, loop through them.
2358 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
2360 foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
2362 if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2375 $samplingrate = null;
2385 $description = null;
2390 $restrictions = null;
2394 // Start checking the attributes of media:content
2395 if (isset($content['attribs']['']['bitrate']))
2397 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
2399 if (isset($content['attribs']['']['channels']))
2401 $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
2403 if (isset($content['attribs']['']['duration']))
2405 $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
2409 $duration = $duration_parent;
2411 if (isset($content['attribs']['']['expression']))
2413 $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
2415 if (isset($content['attribs']['']['framerate']))
2417 $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
2419 if (isset($content['attribs']['']['height']))
2421 $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
2423 if (isset($content['attribs']['']['lang']))
2425 $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2427 if (isset($content['attribs']['']['fileSize']))
2429 $length = ceil($content['attribs']['']['fileSize']);
2431 if (isset($content['attribs']['']['medium']))
2433 $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
2435 if (isset($content['attribs']['']['samplingrate']))
2437 $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
2439 if (isset($content['attribs']['']['type']))
2441 $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2443 if (isset($content['attribs']['']['width']))
2445 $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
2447 if (isset($content['attribs']['']['url']))
2449 $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2451 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel
2454 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
2456 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
2458 $caption_type = null;
2459 $caption_lang = null;
2460 $caption_startTime = null;
2461 $caption_endTime = null;
2462 $caption_text = null;
2463 if (isset($caption['attribs']['']['type']))
2465 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2467 if (isset($caption['attribs']['']['lang']))
2469 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2471 if (isset($caption['attribs']['']['start']))
2473 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
2475 if (isset($caption['attribs']['']['end']))
2477 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
2479 if (isset($caption['data']))
2481 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2483 $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
2485 if (is_array($captions))
2487 $captions = array_values(array_unique($captions));
2492 $captions = $captions_parent;
2496 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
2498 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
2503 if (isset($category['data']))
2505 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2507 if (isset($category['attribs']['']['scheme']))
2509 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2513 $scheme = 'http://search.yahoo.com/mrss/category_schema';
2515 if (isset($category['attribs']['']['label']))
2517 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2519 $categories[] = $this->registry->create('Category', array($term, $scheme, $label));
2522 if (is_array($categories) && is_array($categories_parent))
2524 $categories = array_values(array_unique(array_merge($categories, $categories_parent)));
2526 elseif (is_array($categories))
2528 $categories = array_values(array_unique($categories));
2530 elseif (is_array($categories_parent))
2532 $categories = array_values(array_unique($categories_parent));
2540 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
2542 $copyright_url = null;
2543 $copyright_label = null;
2544 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
2546 $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
2548 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
2550 $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2552 $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
2556 $copyrights = $copyrights_parent;
2560 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
2562 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
2564 $credit_role = null;
2565 $credit_scheme = null;
2566 $credit_name = null;
2567 if (isset($credit['attribs']['']['role']))
2569 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
2571 if (isset($credit['attribs']['']['scheme']))
2573 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2577 $credit_scheme = 'urn:ebu';
2579 if (isset($credit['data']))
2581 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2583 $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
2585 if (is_array($credits))
2587 $credits = array_values(array_unique($credits));
2592 $credits = $credits_parent;
2596 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
2598 $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2602 $description = $description_parent;
2606 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
2608 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
2612 if (isset($hash['data']))
2614 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2616 if (isset($hash['attribs']['']['algo']))
2618 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
2624 $hashes[] = $algo.':'.$value;
2626 if (is_array($hashes))
2628 $hashes = array_values(array_unique($hashes));
2633 $hashes = $hashes_parent;
2637 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
2639 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
2641 $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
2642 foreach ($temp as $word)
2644 $keywords[] = trim($word);
2648 if (is_array($keywords))
2650 $keywords = array_values(array_unique($keywords));
2655 $keywords = $keywords_parent;
2659 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
2661 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2665 $player = $player_parent;
2669 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
2671 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
2673 $rating_scheme = null;
2674 $rating_value = null;
2675 if (isset($rating['attribs']['']['scheme']))
2677 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2681 $rating_scheme = 'urn:simple';
2683 if (isset($rating['data']))
2685 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2687 $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
2689 if (is_array($ratings))
2691 $ratings = array_values(array_unique($ratings));
2696 $ratings = $ratings_parent;
2700 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
2702 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
2704 $restriction_relationship = null;
2705 $restriction_type = null;
2706 $restriction_value = null;
2707 if (isset($restriction['attribs']['']['relationship']))
2709 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
2711 if (isset($restriction['attribs']['']['type']))
2713 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2715 if (isset($restriction['data']))
2717 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2719 $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
2721 if (is_array($restrictions))
2723 $restrictions = array_values(array_unique($restrictions));
2728 $restrictions = $restrictions_parent;
2732 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
2734 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
2736 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
2738 if (is_array($thumbnails))
2740 $thumbnails = array_values(array_unique($thumbnails));
2745 $thumbnails = $thumbnails_parent;
2749 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
2751 $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2755 $title = $title_parent;
2758 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width));
2763 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
2765 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
2778 $samplingrate = null;
2783 $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2784 if (isset($link['attribs']['']['type']))
2786 $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2788 if (isset($link['attribs']['']['length']))
2790 $length = ceil($link['attribs']['']['length']);
2793 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
2794 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
2798 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
2800 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
2813 $samplingrate = null;
2818 $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2819 if (isset($link['attribs']['']['type']))
2821 $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2823 if (isset($link['attribs']['']['length']))
2825 $length = ceil($link['attribs']['']['length']);
2828 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
2829 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
2833 if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
2835 if (isset($enclosure[0]['attribs']['']['url']))
2848 $samplingrate = null;
2853 $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
2854 if (isset($enclosure[0]['attribs']['']['type']))
2856 $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
2858 if (isset($enclosure[0]['attribs']['']['length']))
2860 $length = ceil($enclosure[0]['attribs']['']['length']);
2863 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
2864 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
2868 if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
2870 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
2871 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width));
2874 $this->data['enclosures'] = array_values(array_unique($this->data['enclosures']));
2876 if (!empty($this->data['enclosures']))
2878 return $this->data['enclosures'];
2887 * Get the latitude coordinates for the item
2889 * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
2891 * Uses `<geo:lat>` or `<georss:point>`
2894 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
2895 * @link http://www.georss.org/ GeoRSS
2896 * @return string|null
2898 public function get_latitude()
2900 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
2902 return (float) $return[0]['data'];
2904 elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
2906 return (float) $match[1];
2915 * Get the longitude coordinates for the item
2917 * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
2919 * Uses `<geo:long>`, `<geo:lon>` or `<georss:point>`
2922 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
2923 * @link http://www.georss.org/ GeoRSS
2924 * @return string|null
2926 public function get_longitude()
2928 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
2930 return (float) $return[0]['data'];
2932 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2934 return (float) $return[0]['data'];
2936 elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
2938 return (float) $match[2];
2947 * Get the `<atom:source>` for the item
2950 * @return SimplePie_Source|null
2952 public function get_source()
2954 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
2956 return $this->registry->create('Source', array($this, $return[0]));