balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

Item.php (99078B)


      1 <?php
      2 /**
      3  * SimplePie
      4  *
      5  * A PHP-Based RSS and Atom Feed Framework.
      6  * Takes the hard work out of managing a complete RSS/Atom solution.
      7  *
      8  * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without modification, are
     12  * permitted provided that the following conditions are met:
     13  *
     14  * 	* Redistributions of source code must retain the above copyright notice, this list of
     15  * 	  conditions and the following disclaimer.
     16  *
     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.
     20  *
     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
     23  * 	  written permission.
     24  *
     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.
     34  *
     35  * @package SimplePie
     36  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
     37  * @author Ryan Parman
     38  * @author Sam Sneddon
     39  * @author Ryan McCue
     40  * @link http://simplepie.org/ SimplePie
     41  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
     42  */
     43 
     44 
     45 /**
     46  * Manages all item-related data
     47  *
     48  * Used by {@see SimplePie::get_item()} and {@see SimplePie::get_items()}
     49  *
     50  * This class can be overloaded with {@see SimplePie::set_item_class()}
     51  *
     52  * @package SimplePie
     53  * @subpackage API
     54  */
     55 class SimplePie_Item
     56 {
     57 	/**
     58 	 * Parent feed
     59 	 *
     60 	 * @access private
     61 	 * @var SimplePie
     62 	 */
     63 	var $feed;
     64 
     65 	/**
     66 	 * Raw data
     67 	 *
     68 	 * @access private
     69 	 * @var array
     70 	 */
     71 	var $data = array();
     72 
     73 	/**
     74 	 * Registry object
     75 	 *
     76 	 * @see set_registry
     77 	 * @var SimplePie_Registry
     78 	 */
     79 	protected $registry;
     80 
     81 	/**
     82 	 * Create a new item object
     83 	 *
     84 	 * This is usually used by {@see SimplePie::get_items} and
     85 	 * {@see SimplePie::get_item}. Avoid creating this manually.
     86 	 *
     87 	 * @param SimplePie $feed Parent feed
     88 	 * @param array $data Raw data
     89 	 */
     90 	public function __construct($feed, $data)
     91 	{
     92 		$this->feed = $feed;
     93 		$this->data = $data;
     94 	}
     95 
     96 	/**
     97 	 * Set the registry handler
     98 	 *
     99 	 * This is usually used by {@see SimplePie_Registry::create}
    100 	 *
    101 	 * @since 1.3
    102 	 * @param SimplePie_Registry $registry
    103 	 */
    104 	public function set_registry(SimplePie_Registry $registry)
    105 	{
    106 		$this->registry = $registry;
    107 	}
    108 
    109 	/**
    110 	 * Get a string representation of the item
    111 	 *
    112 	 * @return string
    113 	 */
    114 	public function __toString()
    115 	{
    116 		return md5(serialize($this->data));
    117 	}
    118 
    119 	/**
    120 	 * Remove items that link back to this before destroying this object
    121 	 */
    122 	public function __destruct()
    123 	{
    124 		if (!gc_enabled())
    125 		{
    126 			unset($this->feed);
    127 		}
    128 	}
    129 
    130 	/**
    131 	 * Get data for an item-level element
    132 	 *
    133 	 * This method allows you to get access to ANY element/attribute that is a
    134 	 * sub-element of the item/entry tag.
    135 	 *
    136 	 * See {@see SimplePie::get_feed_tags()} for a description of the return value
    137 	 *
    138 	 * @since 1.0
    139 	 * @see http://simplepie.org/wiki/faq/supported_xml_namespaces
    140 	 * @param string $namespace The URL of the XML namespace of the elements you're trying to access
    141 	 * @param string $tag Tag name
    142 	 * @return array
    143 	 */
    144 	public function get_item_tags($namespace, $tag)
    145 	{
    146 		if (isset($this->data['child'][$namespace][$tag]))
    147 		{
    148 			return $this->data['child'][$namespace][$tag];
    149 		}
    150 
    151 		return null;
    152 	}
    153 
    154 	/**
    155 	 * Get the base URL value from the parent feed
    156 	 *
    157 	 * Uses `<xml:base>`
    158 	 *
    159 	 * @param array $element
    160 	 * @return string
    161 	 */
    162 	public function get_base($element = array())
    163 	{
    164 		return $this->feed->get_base($element);
    165 	}
    166 
    167 	/**
    168 	 * Sanitize feed data
    169 	 *
    170 	 * @access private
    171 	 * @see SimplePie::sanitize()
    172 	 * @param string $data Data to sanitize
    173 	 * @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
    174 	 * @param string $base Base URL to resolve URLs against
    175 	 * @return string Sanitized data
    176 	 */
    177 	public function sanitize($data, $type, $base = '')
    178 	{
    179 		return $this->feed->sanitize($data, $type, $base);
    180 	}
    181 
    182 	/**
    183 	 * Get the parent feed
    184 	 *
    185 	 * Note: this may not work as you think for multifeeds!
    186 	 *
    187 	 * @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
    188 	 * @since 1.0
    189 	 * @return SimplePie
    190 	 */
    191 	public function get_feed()
    192 	{
    193 		return $this->feed;
    194 	}
    195 
    196 	/**
    197 	 * Get the unique identifier for the item
    198 	 *
    199 	 * This is usually used when writing code to check for new items in a feed.
    200 	 *
    201 	 * Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute
    202 	 * for RDF. If none of these are supplied (or `$hash` is true), creates an
    203 	 * MD5 hash based on the permalink, title and content.
    204 	 *
    205 	 * @since Beta 2
    206 	 * @param boolean $hash Should we force using a hash instead of the supplied ID?
    207 	 * @param string|false $fn User-supplied function to generate an hash
    208 	 * @return string|null
    209 	 */
    210 	public function get_id($hash = false, $fn = 'md5')
    211 	{
    212 		if (!$hash)
    213 		{
    214 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
    215 			{
    216 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    217 			}
    218 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
    219 			{
    220 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    221 			}
    222 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
    223 			{
    224 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    225 			}
    226 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
    227 			{
    228 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    229 			}
    230 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
    231 			{
    232 				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    233 			}
    234 			elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
    235 			{
    236 				return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
    237 			}
    238 		}
    239 		if ($fn === false)
    240 		{
    241 			return null;
    242 		}
    243 		elseif (!is_callable($fn))
    244 		{
    245 			trigger_error('User-supplied function $fn must be callable', E_USER_WARNING);
    246 			$fn = 'md5';
    247 		}
    248 		return call_user_func($fn,
    249 		       $this->get_permalink().$this->get_title().$this->get_content());
    250 	}
    251 
    252 	/**
    253 	 * Get the title of the item
    254 	 *
    255 	 * Uses `<atom:title>`, `<title>` or `<dc:title>`
    256 	 *
    257 	 * @since Beta 2 (previously called `get_item_title` since 0.8)
    258 	 * @return string|null
    259 	 */
    260 	public function get_title()
    261 	{
    262 		if (!isset($this->data['title']))
    263 		{
    264 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
    265 			{
    266 				$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]));
    267 			}
    268 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
    269 			{
    270 				$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]));
    271 			}
    272 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
    273 			{
    274 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    275 			}
    276 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
    277 			{
    278 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    279 			}
    280 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
    281 			{
    282 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
    283 			}
    284 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
    285 			{
    286 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    287 			}
    288 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
    289 			{
    290 				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    291 			}
    292 			else
    293 			{
    294 				$this->data['title'] = null;
    295 			}
    296 		}
    297 		return $this->data['title'];
    298 	}
    299 
    300 	/**
    301 	 * Get the content for the item
    302 	 *
    303 	 * Prefers summaries over full content , but will return full content if a
    304 	 * summary does not exist.
    305 	 *
    306 	 * To prefer full content instead, use {@see get_content}
    307 	 *
    308 	 * Uses `<atom:summary>`, `<description>`, `<dc:description>` or
    309 	 * `<itunes:subtitle>`
    310 	 *
    311 	 * @since 0.8
    312 	 * @param boolean $description_only Should we avoid falling back to the content?
    313 	 * @return string|null
    314 	 */
    315 	public function get_description($description_only = false)
    316 	{
    317 		if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) &&
    318 		    ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
    319 		{
    320 			return $return;
    321 		}
    322 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) &&
    323 		        ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
    324 		{
    325 			return $return;
    326 		}
    327 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) &&
    328 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0]))))
    329 		{
    330 			return $return;
    331 		}
    332 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) &&
    333 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
    334 		{
    335 			return $return;
    336 		}
    337 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) &&
    338 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
    339 		{
    340 			return $return;
    341 		}
    342 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) &&
    343 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
    344 		{
    345 			return $return;
    346 		}
    347 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) &&
    348 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
    349 		{
    350 			return $return;
    351 		}
    352 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) &&
    353 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
    354 		{
    355 			return $return;
    356 		}
    357 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) &&
    358 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML)))
    359 		{
    360 			return $return;
    361 		}
    362 
    363 		elseif (!$description_only)
    364 		{
    365 			return $this->get_content(true);
    366 		}
    367 
    368 		return null;
    369 	}
    370 
    371 	/**
    372 	 * Get the content for the item
    373 	 *
    374 	 * Prefers full content over summaries, but will return a summary if full
    375 	 * content does not exist.
    376 	 *
    377 	 * To prefer summaries instead, use {@see get_description}
    378 	 *
    379 	 * Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module)
    380 	 *
    381 	 * @since 1.0
    382 	 * @param boolean $content_only Should we avoid falling back to the description?
    383 	 * @return string|null
    384 	 */
    385 	public function get_content($content_only = false)
    386 	{
    387 		if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) &&
    388 		    ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
    389 		{
    390 			return $return;
    391 		}
    392 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) &&
    393 		        ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
    394 		{
    395 			return $return;
    396 		}
    397 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) &&
    398 		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
    399 		{
    400 			return $return;
    401 		}
    402 		elseif (!$content_only)
    403 		{
    404 			return $this->get_description(true);
    405 		}
    406 
    407 		return null;
    408 	}
    409 
    410 	/**
    411 	 * Get the media:thumbnail of the item
    412 	 *
    413 	 * Uses `<media:thumbnail>`
    414 	 *
    415 	 *
    416 	 * @return array|null
    417 	 */
    418 	public function get_thumbnail()
    419 	{
    420 		if (!isset($this->data['thumbnail']))
    421 		{
    422 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
    423 			{
    424 				$this->data['thumbnail'] = $return[0]['attribs'][''];
    425 			}
    426 			else
    427 			{
    428 				$this->data['thumbnail'] = null;
    429 			}
    430 		}
    431 		return $this->data['thumbnail'];
    432 	}
    433 
    434 	/**
    435 	 * Get a category for the item
    436 	 *
    437 	 * @since Beta 3 (previously called `get_categories()` since Beta 2)
    438 	 * @param int $key The category that you want to return.  Remember that arrays begin with 0, not 1
    439 	 * @return SimplePie_Category|null
    440 	 */
    441 	public function get_category($key = 0)
    442 	{
    443 		$categories = $this->get_categories();
    444 		if (isset($categories[$key]))
    445 		{
    446 			return $categories[$key];
    447 		}
    448 
    449 		return null;
    450 	}
    451 
    452 	/**
    453 	 * Get all categories for the item
    454 	 *
    455 	 * Uses `<atom:category>`, `<category>` or `<dc:subject>`
    456 	 *
    457 	 * @since Beta 3
    458 	 * @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects
    459 	 */
    460 	public function get_categories()
    461 	{
    462 		$categories = array();
    463 
    464 		$type = 'category';
    465 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, $type) as $category)
    466 		{
    467 			$term = null;
    468 			$scheme = null;
    469 			$label = null;
    470 			if (isset($category['attribs']['']['term']))
    471 			{
    472 				$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
    473 			}
    474 			if (isset($category['attribs']['']['scheme']))
    475 			{
    476 				$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
    477 			}
    478 			if (isset($category['attribs']['']['label']))
    479 			{
    480 				$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
    481 			}
    482 			$categories[] = $this->registry->create('Category', array($term, $scheme, $label, $type));
    483 		}
    484 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, $type) as $category)
    485 		{
    486 			// This is really the label, but keep this as the term also for BC.
    487 			// Label will also work on retrieving because that falls back to term.
    488 			$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    489 			if (isset($category['attribs']['']['domain']))
    490 			{
    491 				$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
    492 			}
    493 			else
    494 			{
    495 				$scheme = null;
    496 			}
    497 			$categories[] = $this->registry->create('Category', array($term, $scheme, null, $type));
    498 		}
    499 
    500 		$type = 'subject';
    501 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, $type) as $category)
    502 		{
    503 			$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null, $type));
    504 		}
    505 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, $type) as $category)
    506 		{
    507 			$categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null, $type));
    508 		}
    509 
    510 		if (!empty($categories))
    511 		{
    512 			return array_unique($categories);
    513 		}
    514 
    515 		return null;
    516 	}
    517 
    518 	/**
    519 	 * Get an author for the item
    520 	 *
    521 	 * @since Beta 2
    522 	 * @param int $key The author that you want to return.  Remember that arrays begin with 0, not 1
    523 	 * @return SimplePie_Author|null
    524 	 */
    525 	public function get_author($key = 0)
    526 	{
    527 		$authors = $this->get_authors();
    528 		if (isset($authors[$key]))
    529 		{
    530 			return $authors[$key];
    531 		}
    532 
    533 		return null;
    534 	}
    535 
    536 	/**
    537 	 * Get a contributor for the item
    538 	 *
    539 	 * @since 1.1
    540 	 * @param int $key The contrbutor that you want to return.  Remember that arrays begin with 0, not 1
    541 	 * @return SimplePie_Author|null
    542 	 */
    543 	public function get_contributor($key = 0)
    544 	{
    545 		$contributors = $this->get_contributors();
    546 		if (isset($contributors[$key]))
    547 		{
    548 			return $contributors[$key];
    549 		}
    550 
    551 		return null;
    552 	}
    553 
    554 	/**
    555 	 * Get all contributors for the item
    556 	 *
    557 	 * Uses `<atom:contributor>`
    558 	 *
    559 	 * @since 1.1
    560 	 * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects
    561 	 */
    562 	public function get_contributors()
    563 	{
    564 		$contributors = array();
    565 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
    566 		{
    567 			$name = null;
    568 			$uri = null;
    569 			$email = null;
    570 			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
    571 			{
    572 				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    573 			}
    574 			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
    575 			{
    576 				$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]));
    577 			}
    578 			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
    579 			{
    580 				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    581 			}
    582 			if ($name !== null || $email !== null || $uri !== null)
    583 			{
    584 				$contributors[] = $this->registry->create('Author', array($name, $uri, $email));
    585 			}
    586 		}
    587 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
    588 		{
    589 			$name = null;
    590 			$url = null;
    591 			$email = null;
    592 			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
    593 			{
    594 				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    595 			}
    596 			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
    597 			{
    598 				$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]));
    599 			}
    600 			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
    601 			{
    602 				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    603 			}
    604 			if ($name !== null || $email !== null || $url !== null)
    605 			{
    606 				$contributors[] = $this->registry->create('Author', array($name, $url, $email));
    607 			}
    608 		}
    609 
    610 		if (!empty($contributors))
    611 		{
    612 			return array_unique($contributors);
    613 		}
    614 
    615 		return null;
    616 	}
    617 
    618 	/**
    619 	 * Get all authors for the item
    620 	 *
    621 	 * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>`
    622 	 *
    623 	 * @since Beta 2
    624 	 * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects
    625 	 */
    626 	public function get_authors()
    627 	{
    628 		$authors = array();
    629 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
    630 		{
    631 			$name = null;
    632 			$uri = null;
    633 			$email = null;
    634 			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
    635 			{
    636 				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    637 			}
    638 			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
    639 			{
    640 				$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]));
    641 			}
    642 			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
    643 			{
    644 				$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    645 			}
    646 			if ($name !== null || $email !== null || $uri !== null)
    647 			{
    648 				$authors[] = $this->registry->create('Author', array($name, $uri, $email));
    649 			}
    650 		}
    651 		if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
    652 		{
    653 			$name = null;
    654 			$url = null;
    655 			$email = null;
    656 			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
    657 			{
    658 				$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    659 			}
    660 			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
    661 			{
    662 				$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]));
    663 			}
    664 			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
    665 			{
    666 				$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    667 			}
    668 			if ($name !== null || $email !== null || $url !== null)
    669 			{
    670 				$authors[] = $this->registry->create('Author', array($name, $url, $email));
    671 			}
    672 		}
    673 		if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
    674 		{
    675 			$authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)));
    676 		}
    677 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
    678 		{
    679 			$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
    680 		}
    681 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
    682 		{
    683 			$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
    684 		}
    685 		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
    686 		{
    687 			$authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
    688 		}
    689 
    690 		if (!empty($authors))
    691 		{
    692 			return array_unique($authors);
    693 		}
    694 		elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
    695 		{
    696 			return $authors;
    697 		}
    698 		elseif ($authors = $this->feed->get_authors())
    699 		{
    700 			return $authors;
    701 		}
    702 
    703 		return null;
    704 	}
    705 
    706 	/**
    707 	 * Get the copyright info for the item
    708 	 *
    709 	 * Uses `<atom:rights>` or `<dc:rights>`
    710 	 *
    711 	 * @since 1.1
    712 	 * @return string
    713 	 */
    714 	public function get_copyright()
    715 	{
    716 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
    717 		{
    718 			return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
    719 		}
    720 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
    721 		{
    722 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    723 		}
    724 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
    725 		{
    726 			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    727 		}
    728 
    729 		return null;
    730 	}
    731 
    732 	/**
    733 	 * Get the posting date/time for the item
    734 	 *
    735 	 * Uses `<atom:published>`, `<atom:updated>`, `<atom:issued>`,
    736 	 * `<atom:modified>`, `<pubDate>` or `<dc:date>`
    737 	 *
    738 	 * Note: obeys PHP's timezone setting. To get a UTC date/time, use
    739 	 * {@see get_gmdate}
    740 	 *
    741 	 * @since Beta 2 (previously called `get_item_date` since 0.8)
    742 	 *
    743 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
    744 	 * @return int|string|null
    745 	 */
    746 	public function get_date($date_format = 'j F Y, g:i a')
    747 	{
    748 		if (!isset($this->data['date']))
    749 		{
    750 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
    751 			{
    752 				$this->data['date']['raw'] = $return[0]['data'];
    753 			}
    754 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
    755 			{
    756 				$this->data['date']['raw'] = $return[0]['data'];
    757 			}
    758 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
    759 			{
    760 				$this->data['date']['raw'] = $return[0]['data'];
    761 			}
    762 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
    763 			{
    764 				$this->data['date']['raw'] = $return[0]['data'];
    765 			}
    766 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
    767 			{
    768 				$this->data['date']['raw'] = $return[0]['data'];
    769 			}
    770 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
    771 			{
    772 				$this->data['date']['raw'] = $return[0]['data'];
    773 			}
    774 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
    775 			{
    776 				$this->data['date']['raw'] = $return[0]['data'];
    777 			}
    778 			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
    779 			{
    780 				$this->data['date']['raw'] = $return[0]['data'];
    781 			}
    782 
    783 			if (!empty($this->data['date']['raw']))
    784 			{
    785 				$parser = $this->registry->call('Parse_Date', 'get');
    786 				$this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
    787 			}
    788 			else
    789 			{
    790 				$this->data['date'] = null;
    791 			}
    792 		}
    793 		if ($this->data['date'])
    794 		{
    795 			$date_format = (string) $date_format;
    796 			switch ($date_format)
    797 			{
    798 				case '':
    799 					return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
    800 
    801 				case 'U':
    802 					return $this->data['date']['parsed'];
    803 
    804 				default:
    805 					return date($date_format, $this->data['date']['parsed']);
    806 			}
    807 		}
    808 
    809 		return null;
    810 	}
    811 
    812 	/**
    813 	 * Get the update date/time for the item
    814 	 *
    815 	 * Uses `<atom:updated>`
    816 	 *
    817 	 * Note: obeys PHP's timezone setting. To get a UTC date/time, use
    818 	 * {@see get_gmdate}
    819 	 *
    820 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
    821 	 * @return int|string|null
    822 	 */
    823 	public function get_updated_date($date_format = 'j F Y, g:i a')
    824 	{
    825 		if (!isset($this->data['updated']))
    826 		{
    827 			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
    828 			{
    829 				$this->data['updated']['raw'] = $return[0]['data'];
    830 			}
    831 
    832 			if (!empty($this->data['updated']['raw']))
    833 			{
    834 				$parser = $this->registry->call('Parse_Date', 'get');
    835 				$this->data['updated']['parsed'] = $parser->parse($this->data['updated']['raw']);
    836 			}
    837 			else
    838 			{
    839 				$this->data['updated'] = null;
    840 			}
    841 		}
    842 		if ($this->data['updated'])
    843 		{
    844 			$date_format = (string) $date_format;
    845 			switch ($date_format)
    846 			{
    847 				case '':
    848 					return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
    849 
    850 				case 'U':
    851 					return $this->data['updated']['parsed'];
    852 
    853 				default:
    854 					return date($date_format, $this->data['updated']['parsed']);
    855 			}
    856 		}
    857 
    858 		return null;
    859 	}
    860 
    861 	/**
    862 	 * Get the localized posting date/time for the item
    863 	 *
    864 	 * Returns the date formatted in the localized language. To display in
    865 	 * languages other than the server's default, you need to change the locale
    866 	 * with {@link http://php.net/setlocale setlocale()}. The available
    867 	 * localizations depend on which ones are installed on your web server.
    868 	 *
    869 	 * @since 1.0
    870 	 *
    871 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
    872 	 * @return int|string|null
    873 	 */
    874 	public function get_local_date($date_format = '%c')
    875 	{
    876 		if (!$date_format)
    877 		{
    878 			return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
    879 		}
    880 		elseif (($date = $this->get_date('U')) !== null && $date !== false)
    881 		{
    882 			return strftime($date_format, $date);
    883 		}
    884 
    885 		return null;
    886 	}
    887 
    888 	/**
    889 	 * Get the posting date/time for the item (UTC time)
    890 	 *
    891 	 * @see get_date
    892 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
    893 	 * @return int|string|null
    894 	 */
    895 	public function get_gmdate($date_format = 'j F Y, g:i a')
    896 	{
    897 		$date = $this->get_date('U');
    898 		if ($date === null)
    899 		{
    900 			return null;
    901 		}
    902 
    903 		return gmdate($date_format, $date);
    904 	}
    905 
    906 	/**
    907 	 * Get the update date/time for the item (UTC time)
    908 	 *
    909 	 * @see get_updated_date
    910 	 * @param string $date_format Supports any PHP date format from {@see http://php.net/date}
    911 	 * @return int|string|null
    912 	 */
    913 	public function get_updated_gmdate($date_format = 'j F Y, g:i a')
    914 	{
    915 		$date = $this->get_updated_date('U');
    916 		if ($date === null)
    917 		{
    918 			return null;
    919 		}
    920 
    921 		return gmdate($date_format, $date);
    922 	}
    923 
    924 	/**
    925 	 * Get the permalink for the item
    926 	 *
    927 	 * Returns the first link available with a relationship of "alternate".
    928 	 * Identical to {@see get_link()} with key 0
    929 	 *
    930 	 * @see get_link
    931 	 * @since 0.8
    932 	 * @return string|null Permalink URL
    933 	 */
    934 	public function get_permalink()
    935 	{
    936 		$link = $this->get_link();
    937 		$enclosure = $this->get_enclosure(0);
    938 		if ($link !== null)
    939 		{
    940 			return $link;
    941 		}
    942 		elseif ($enclosure !== null)
    943 		{
    944 			return $enclosure->get_link();
    945 		}
    946 
    947 		return null;
    948 	}
    949 
    950 	/**
    951 	 * Get a single link for the item
    952 	 *
    953 	 * @since Beta 3
    954 	 * @param int $key The link that you want to return.  Remember that arrays begin with 0, not 1
    955 	 * @param string $rel The relationship of the link to return
    956 	 * @return string|null Link URL
    957 	 */
    958 	public function get_link($key = 0, $rel = 'alternate')
    959 	{
    960 		$links = $this->get_links($rel);
    961 		if ($links && $links[$key] !== null)
    962 		{
    963 			return $links[$key];
    964 		}
    965 
    966 		return null;
    967 	}
    968 
    969 	/**
    970 	 * Get all links for the item
    971 	 *
    972 	 * Uses `<atom:link>`, `<link>` or `<guid>`
    973 	 *
    974 	 * @since Beta 2
    975 	 * @param string $rel The relationship of links to return
    976 	 * @return array|null Links found for the item (strings)
    977 	 */
    978 	public function get_links($rel = 'alternate')
    979 	{
    980 		if (!isset($this->data['links']))
    981 		{
    982 			$this->data['links'] = array();
    983 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
    984 			{
    985 				if (isset($link['attribs']['']['href']))
    986 				{
    987 					$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
    988 					$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
    989 
    990 				}
    991 			}
    992 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
    993 			{
    994 				if (isset($link['attribs']['']['href']))
    995 				{
    996 					$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
    997 					$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
    998 				}
    999 			}
   1000 			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
   1001 			{
   1002 				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
   1003 			}
   1004 			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
   1005 			{
   1006 				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
   1007 			}
   1008 			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
   1009 			{
   1010 				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
   1011 			}
   1012 			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
   1013 			{
   1014 				if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
   1015 				{
   1016 					$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
   1017 				}
   1018 			}
   1019 
   1020 			$keys = array_keys($this->data['links']);
   1021 			foreach ($keys as $key)
   1022 			{
   1023 				if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key)))
   1024 				{
   1025 					if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
   1026 					{
   1027 						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
   1028 						$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
   1029 					}
   1030 					else
   1031 					{
   1032 						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
   1033 					}
   1034 				}
   1035 				elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
   1036 				{
   1037 					$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
   1038 				}
   1039 				$this->data['links'][$key] = array_unique($this->data['links'][$key]);
   1040 			}
   1041 		}
   1042 		if (isset($this->data['links'][$rel]))
   1043 		{
   1044 			return $this->data['links'][$rel];
   1045 		}
   1046 
   1047 		return null;
   1048 	}
   1049 
   1050 	/**
   1051 	 * Get an enclosure from the item
   1052 	 *
   1053 	 * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
   1054 	 *
   1055 	 * @since Beta 2
   1056 	 * @todo Add ability to prefer one type of content over another (in a media group).
   1057 	 * @param int $key The enclosure that you want to return.  Remember that arrays begin with 0, not 1
   1058 	 * @return SimplePie_Enclosure|null
   1059 	 */
   1060 	public function get_enclosure($key = 0, $prefer = null)
   1061 	{
   1062 		$enclosures = $this->get_enclosures();
   1063 		if (isset($enclosures[$key]))
   1064 		{
   1065 			return $enclosures[$key];
   1066 		}
   1067 
   1068 		return null;
   1069 	}
   1070 
   1071 	/**
   1072 	 * Get all available enclosures (podcasts, etc.)
   1073 	 *
   1074 	 * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
   1075 	 *
   1076 	 * At this point, we're pretty much assuming that all enclosures for an item
   1077 	 * are the same content.  Anything else is too complicated to
   1078 	 * properly support.
   1079 	 *
   1080 	 * @since Beta 2
   1081 	 * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
   1082 	 * @todo If an element exists at a level, but its value is empty, we should fall back to the value from the parent (if it exists).
   1083 	 * @return SimplePie_Enclosure[]|null List of SimplePie_Enclosure items
   1084 	 */
   1085 	public function get_enclosures()
   1086 	{
   1087 		if (!isset($this->data['enclosures']))
   1088 		{
   1089 			$this->data['enclosures'] = array();
   1090 
   1091 			// Elements
   1092 			$captions_parent = null;
   1093 			$categories_parent = null;
   1094 			$copyrights_parent = null;
   1095 			$credits_parent = null;
   1096 			$description_parent = null;
   1097 			$duration_parent = null;
   1098 			$hashes_parent = null;
   1099 			$keywords_parent = null;
   1100 			$player_parent = null;
   1101 			$ratings_parent = null;
   1102 			$restrictions_parent = null;
   1103 			$thumbnails_parent = null;
   1104 			$title_parent = null;
   1105 
   1106 			// Let's do the channel and item-level ones first, and just re-use them if we need to.
   1107 			$parent = $this->get_feed();
   1108 
   1109 			// CAPTIONS
   1110 			if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
   1111 			{
   1112 				foreach ($captions as $caption)
   1113 				{
   1114 					$caption_type = null;
   1115 					$caption_lang = null;
   1116 					$caption_startTime = null;
   1117 					$caption_endTime = null;
   1118 					$caption_text = null;
   1119 					if (isset($caption['attribs']['']['type']))
   1120 					{
   1121 						$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1122 					}
   1123 					if (isset($caption['attribs']['']['lang']))
   1124 					{
   1125 						$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   1126 					}
   1127 					if (isset($caption['attribs']['']['start']))
   1128 					{
   1129 						$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
   1130 					}
   1131 					if (isset($caption['attribs']['']['end']))
   1132 					{
   1133 						$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
   1134 					}
   1135 					if (isset($caption['data']))
   1136 					{
   1137 						$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1138 					}
   1139 					$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
   1140 				}
   1141 			}
   1142 			elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
   1143 			{
   1144 				foreach ($captions as $caption)
   1145 				{
   1146 					$caption_type = null;
   1147 					$caption_lang = null;
   1148 					$caption_startTime = null;
   1149 					$caption_endTime = null;
   1150 					$caption_text = null;
   1151 					if (isset($caption['attribs']['']['type']))
   1152 					{
   1153 						$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1154 					}
   1155 					if (isset($caption['attribs']['']['lang']))
   1156 					{
   1157 						$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   1158 					}
   1159 					if (isset($caption['attribs']['']['start']))
   1160 					{
   1161 						$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
   1162 					}
   1163 					if (isset($caption['attribs']['']['end']))
   1164 					{
   1165 						$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
   1166 					}
   1167 					if (isset($caption['data']))
   1168 					{
   1169 						$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1170 					}
   1171 					$captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
   1172 				}
   1173 			}
   1174 			if (is_array($captions_parent))
   1175 			{
   1176 				$captions_parent = array_values(array_unique($captions_parent));
   1177 			}
   1178 
   1179 			// CATEGORIES
   1180 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
   1181 			{
   1182 				$term = null;
   1183 				$scheme = null;
   1184 				$label = null;
   1185 				if (isset($category['data']))
   1186 				{
   1187 					$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1188 				}
   1189 				if (isset($category['attribs']['']['scheme']))
   1190 				{
   1191 					$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1192 				}
   1193 				else
   1194 				{
   1195 					$scheme = 'http://search.yahoo.com/mrss/category_schema';
   1196 				}
   1197 				if (isset($category['attribs']['']['label']))
   1198 				{
   1199 					$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
   1200 				}
   1201 				$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
   1202 			}
   1203 			foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
   1204 			{
   1205 				$term = null;
   1206 				$scheme = null;
   1207 				$label = null;
   1208 				if (isset($category['data']))
   1209 				{
   1210 					$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1211 				}
   1212 				if (isset($category['attribs']['']['scheme']))
   1213 				{
   1214 					$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1215 				}
   1216 				else
   1217 				{
   1218 					$scheme = 'http://search.yahoo.com/mrss/category_schema';
   1219 				}
   1220 				if (isset($category['attribs']['']['label']))
   1221 				{
   1222 					$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
   1223 				}
   1224 				$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
   1225 			}
   1226 			foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
   1227 			{
   1228 				$term = null;
   1229 				$scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
   1230 				$label = null;
   1231 				if (isset($category['attribs']['']['text']))
   1232 				{
   1233 					$label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
   1234 				}
   1235 				$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
   1236 
   1237 				if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
   1238 				{
   1239 					foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
   1240 					{
   1241 						if (isset($subcategory['attribs']['']['text']))
   1242 						{
   1243 							$label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
   1244 						}
   1245 						$categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label));
   1246 					}
   1247 				}
   1248 			}
   1249 			if (is_array($categories_parent))
   1250 			{
   1251 				$categories_parent = array_values(array_unique($categories_parent));
   1252 			}
   1253 
   1254 			// COPYRIGHT
   1255 			if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
   1256 			{
   1257 				$copyright_url = null;
   1258 				$copyright_label = null;
   1259 				if (isset($copyright[0]['attribs']['']['url']))
   1260 				{
   1261 					$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
   1262 				}
   1263 				if (isset($copyright[0]['data']))
   1264 				{
   1265 					$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1266 				}
   1267 				$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
   1268 			}
   1269 			elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
   1270 			{
   1271 				$copyright_url = null;
   1272 				$copyright_label = null;
   1273 				if (isset($copyright[0]['attribs']['']['url']))
   1274 				{
   1275 					$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
   1276 				}
   1277 				if (isset($copyright[0]['data']))
   1278 				{
   1279 					$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1280 				}
   1281 				$copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
   1282 			}
   1283 
   1284 			// CREDITS
   1285 			if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
   1286 			{
   1287 				foreach ($credits as $credit)
   1288 				{
   1289 					$credit_role = null;
   1290 					$credit_scheme = null;
   1291 					$credit_name = null;
   1292 					if (isset($credit['attribs']['']['role']))
   1293 					{
   1294 						$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
   1295 					}
   1296 					if (isset($credit['attribs']['']['scheme']))
   1297 					{
   1298 						$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1299 					}
   1300 					else
   1301 					{
   1302 						$credit_scheme = 'urn:ebu';
   1303 					}
   1304 					if (isset($credit['data']))
   1305 					{
   1306 						$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1307 					}
   1308 					$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
   1309 				}
   1310 			}
   1311 			elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
   1312 			{
   1313 				foreach ($credits as $credit)
   1314 				{
   1315 					$credit_role = null;
   1316 					$credit_scheme = null;
   1317 					$credit_name = null;
   1318 					if (isset($credit['attribs']['']['role']))
   1319 					{
   1320 						$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
   1321 					}
   1322 					if (isset($credit['attribs']['']['scheme']))
   1323 					{
   1324 						$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1325 					}
   1326 					else
   1327 					{
   1328 						$credit_scheme = 'urn:ebu';
   1329 					}
   1330 					if (isset($credit['data']))
   1331 					{
   1332 						$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1333 					}
   1334 					$credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
   1335 				}
   1336 			}
   1337 			if (is_array($credits_parent))
   1338 			{
   1339 				$credits_parent = array_values(array_unique($credits_parent));
   1340 			}
   1341 
   1342 			// DESCRIPTION
   1343 			if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
   1344 			{
   1345 				if (isset($description_parent[0]['data']))
   1346 				{
   1347 					$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1348 				}
   1349 			}
   1350 			elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
   1351 			{
   1352 				if (isset($description_parent[0]['data']))
   1353 				{
   1354 					$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1355 				}
   1356 			}
   1357 
   1358 			// DURATION
   1359 			if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
   1360 			{
   1361 				$seconds = null;
   1362 				$minutes = null;
   1363 				$hours = null;
   1364 				if (isset($duration_parent[0]['data']))
   1365 				{
   1366 					$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   1367 					if (sizeof($temp) > 0)
   1368 					{
   1369 						$seconds = (int) array_pop($temp);
   1370 					}
   1371 					if (sizeof($temp) > 0)
   1372 					{
   1373 						$minutes = (int) array_pop($temp);
   1374 						$seconds += $minutes * 60;
   1375 					}
   1376 					if (sizeof($temp) > 0)
   1377 					{
   1378 						$hours = (int) array_pop($temp);
   1379 						$seconds += $hours * 3600;
   1380 					}
   1381 					unset($temp);
   1382 					$duration_parent = $seconds;
   1383 				}
   1384 			}
   1385 
   1386 			// HASHES
   1387 			if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
   1388 			{
   1389 				foreach ($hashes_iterator as $hash)
   1390 				{
   1391 					$value = null;
   1392 					$algo = null;
   1393 					if (isset($hash['data']))
   1394 					{
   1395 						$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1396 					}
   1397 					if (isset($hash['attribs']['']['algo']))
   1398 					{
   1399 						$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
   1400 					}
   1401 					else
   1402 					{
   1403 						$algo = 'md5';
   1404 					}
   1405 					$hashes_parent[] = $algo.':'.$value;
   1406 				}
   1407 			}
   1408 			elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
   1409 			{
   1410 				foreach ($hashes_iterator as $hash)
   1411 				{
   1412 					$value = null;
   1413 					$algo = null;
   1414 					if (isset($hash['data']))
   1415 					{
   1416 						$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1417 					}
   1418 					if (isset($hash['attribs']['']['algo']))
   1419 					{
   1420 						$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
   1421 					}
   1422 					else
   1423 					{
   1424 						$algo = 'md5';
   1425 					}
   1426 					$hashes_parent[] = $algo.':'.$value;
   1427 				}
   1428 			}
   1429 			if (is_array($hashes_parent))
   1430 			{
   1431 				$hashes_parent = array_values(array_unique($hashes_parent));
   1432 			}
   1433 
   1434 			// KEYWORDS
   1435 			if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
   1436 			{
   1437 				if (isset($keywords[0]['data']))
   1438 				{
   1439 					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   1440 					foreach ($temp as $word)
   1441 					{
   1442 						$keywords_parent[] = trim($word);
   1443 					}
   1444 				}
   1445 				unset($temp);
   1446 			}
   1447 			elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
   1448 			{
   1449 				if (isset($keywords[0]['data']))
   1450 				{
   1451 					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   1452 					foreach ($temp as $word)
   1453 					{
   1454 						$keywords_parent[] = trim($word);
   1455 					}
   1456 				}
   1457 				unset($temp);
   1458 			}
   1459 			elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
   1460 			{
   1461 				if (isset($keywords[0]['data']))
   1462 				{
   1463 					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   1464 					foreach ($temp as $word)
   1465 					{
   1466 						$keywords_parent[] = trim($word);
   1467 					}
   1468 				}
   1469 				unset($temp);
   1470 			}
   1471 			elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
   1472 			{
   1473 				if (isset($keywords[0]['data']))
   1474 				{
   1475 					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   1476 					foreach ($temp as $word)
   1477 					{
   1478 						$keywords_parent[] = trim($word);
   1479 					}
   1480 				}
   1481 				unset($temp);
   1482 			}
   1483 			if (is_array($keywords_parent))
   1484 			{
   1485 				$keywords_parent = array_values(array_unique($keywords_parent));
   1486 			}
   1487 
   1488 			// PLAYER
   1489 			if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
   1490 			{
   1491 				if (isset($player_parent[0]['attribs']['']['url']))
   1492 				{
   1493 					$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   1494 				}
   1495 			}
   1496 			elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
   1497 			{
   1498 				if (isset($player_parent[0]['attribs']['']['url']))
   1499 				{
   1500 					$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   1501 				}
   1502 			}
   1503 
   1504 			// RATINGS
   1505 			if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
   1506 			{
   1507 				foreach ($ratings as $rating)
   1508 				{
   1509 					$rating_scheme = null;
   1510 					$rating_value = null;
   1511 					if (isset($rating['attribs']['']['scheme']))
   1512 					{
   1513 						$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1514 					}
   1515 					else
   1516 					{
   1517 						$rating_scheme = 'urn:simple';
   1518 					}
   1519 					if (isset($rating['data']))
   1520 					{
   1521 						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1522 					}
   1523 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   1524 				}
   1525 			}
   1526 			elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
   1527 			{
   1528 				foreach ($ratings as $rating)
   1529 				{
   1530 					$rating_scheme = 'urn:itunes';
   1531 					$rating_value = null;
   1532 					if (isset($rating['data']))
   1533 					{
   1534 						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1535 					}
   1536 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   1537 				}
   1538 			}
   1539 			elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
   1540 			{
   1541 				foreach ($ratings as $rating)
   1542 				{
   1543 					$rating_scheme = null;
   1544 					$rating_value = null;
   1545 					if (isset($rating['attribs']['']['scheme']))
   1546 					{
   1547 						$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1548 					}
   1549 					else
   1550 					{
   1551 						$rating_scheme = 'urn:simple';
   1552 					}
   1553 					if (isset($rating['data']))
   1554 					{
   1555 						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1556 					}
   1557 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   1558 				}
   1559 			}
   1560 			elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
   1561 			{
   1562 				foreach ($ratings as $rating)
   1563 				{
   1564 					$rating_scheme = 'urn:itunes';
   1565 					$rating_value = null;
   1566 					if (isset($rating['data']))
   1567 					{
   1568 						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1569 					}
   1570 					$ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   1571 				}
   1572 			}
   1573 			if (is_array($ratings_parent))
   1574 			{
   1575 				$ratings_parent = array_values(array_unique($ratings_parent));
   1576 			}
   1577 
   1578 			// RESTRICTIONS
   1579 			if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
   1580 			{
   1581 				foreach ($restrictions as $restriction)
   1582 				{
   1583 					$restriction_relationship = null;
   1584 					$restriction_type = null;
   1585 					$restriction_value = null;
   1586 					if (isset($restriction['attribs']['']['relationship']))
   1587 					{
   1588 						$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
   1589 					}
   1590 					if (isset($restriction['attribs']['']['type']))
   1591 					{
   1592 						$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1593 					}
   1594 					if (isset($restriction['data']))
   1595 					{
   1596 						$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1597 					}
   1598 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   1599 				}
   1600 			}
   1601 			elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
   1602 			{
   1603 				foreach ($restrictions as $restriction)
   1604 				{
   1605 					$restriction_relationship = 'allow';
   1606 					$restriction_type = null;
   1607 					$restriction_value = 'itunes';
   1608 					if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
   1609 					{
   1610 						$restriction_relationship = 'deny';
   1611 					}
   1612 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   1613 				}
   1614 			}
   1615 			elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
   1616 			{
   1617 				foreach ($restrictions as $restriction)
   1618 				{
   1619 					$restriction_relationship = null;
   1620 					$restriction_type = null;
   1621 					$restriction_value = null;
   1622 					if (isset($restriction['attribs']['']['relationship']))
   1623 					{
   1624 						$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
   1625 					}
   1626 					if (isset($restriction['attribs']['']['type']))
   1627 					{
   1628 						$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1629 					}
   1630 					if (isset($restriction['data']))
   1631 					{
   1632 						$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1633 					}
   1634 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   1635 				}
   1636 			}
   1637 			elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
   1638 			{
   1639 				foreach ($restrictions as $restriction)
   1640 				{
   1641 					$restriction_relationship = 'allow';
   1642 					$restriction_type = null;
   1643 					$restriction_value = 'itunes';
   1644 					if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
   1645 					{
   1646 						$restriction_relationship = 'deny';
   1647 					}
   1648 					$restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   1649 				}
   1650 			}
   1651 			if (is_array($restrictions_parent))
   1652 			{
   1653 				$restrictions_parent = array_values(array_unique($restrictions_parent));
   1654 			}
   1655 			else
   1656 			{
   1657 				$restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default'));
   1658 			}
   1659 
   1660 			// THUMBNAILS
   1661 			if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
   1662 			{
   1663 				foreach ($thumbnails as $thumbnail)
   1664 				{
   1665 					if (isset($thumbnail['attribs']['']['url']))
   1666 					{
   1667 						$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   1668 					}
   1669 				}
   1670 			}
   1671 			elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
   1672 			{
   1673 				foreach ($thumbnails as $thumbnail)
   1674 				{
   1675 					if (isset($thumbnail['attribs']['']['url']))
   1676 					{
   1677 						$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   1678 					}
   1679 				}
   1680 			}
   1681 
   1682 			// TITLES
   1683 			if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
   1684 			{
   1685 				if (isset($title_parent[0]['data']))
   1686 				{
   1687 					$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1688 				}
   1689 			}
   1690 			elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
   1691 			{
   1692 				if (isset($title_parent[0]['data']))
   1693 				{
   1694 					$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1695 				}
   1696 			}
   1697 
   1698 			// Clear the memory
   1699 			unset($parent);
   1700 
   1701 			// Attributes
   1702 			$bitrate = null;
   1703 			$channels = null;
   1704 			$duration = null;
   1705 			$expression = null;
   1706 			$framerate = null;
   1707 			$height = null;
   1708 			$javascript = null;
   1709 			$lang = null;
   1710 			$length = null;
   1711 			$medium = null;
   1712 			$samplingrate = null;
   1713 			$type = null;
   1714 			$url = null;
   1715 			$width = null;
   1716 
   1717 			// Elements
   1718 			$captions = null;
   1719 			$categories = null;
   1720 			$copyrights = null;
   1721 			$credits = null;
   1722 			$description = null;
   1723 			$hashes = null;
   1724 			$keywords = null;
   1725 			$player = null;
   1726 			$ratings = null;
   1727 			$restrictions = null;
   1728 			$thumbnails = null;
   1729 			$title = null;
   1730 
   1731 			// If we have media:group tags, loop through them.
   1732 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
   1733 			{
   1734 				if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
   1735 				{
   1736 					// If we have media:content tags, loop through them.
   1737 					foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
   1738 					{
   1739 						if (isset($content['attribs']['']['url']))
   1740 						{
   1741 							// Attributes
   1742 							$bitrate = null;
   1743 							$channels = null;
   1744 							$duration = null;
   1745 							$expression = null;
   1746 							$framerate = null;
   1747 							$height = null;
   1748 							$javascript = null;
   1749 							$lang = null;
   1750 							$length = null;
   1751 							$medium = null;
   1752 							$samplingrate = null;
   1753 							$type = null;
   1754 							$url = null;
   1755 							$width = null;
   1756 
   1757 							// Elements
   1758 							$captions = null;
   1759 							$categories = null;
   1760 							$copyrights = null;
   1761 							$credits = null;
   1762 							$description = null;
   1763 							$hashes = null;
   1764 							$keywords = null;
   1765 							$player = null;
   1766 							$ratings = null;
   1767 							$restrictions = null;
   1768 							$thumbnails = null;
   1769 							$title = null;
   1770 
   1771 							// Start checking the attributes of media:content
   1772 							if (isset($content['attribs']['']['bitrate']))
   1773 							{
   1774 								$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
   1775 							}
   1776 							if (isset($content['attribs']['']['channels']))
   1777 							{
   1778 								$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
   1779 							}
   1780 							if (isset($content['attribs']['']['duration']))
   1781 							{
   1782 								$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
   1783 							}
   1784 							else
   1785 							{
   1786 								$duration = $duration_parent;
   1787 							}
   1788 							if (isset($content['attribs']['']['expression']))
   1789 							{
   1790 								$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
   1791 							}
   1792 							if (isset($content['attribs']['']['framerate']))
   1793 							{
   1794 								$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
   1795 							}
   1796 							if (isset($content['attribs']['']['height']))
   1797 							{
   1798 								$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
   1799 							}
   1800 							if (isset($content['attribs']['']['lang']))
   1801 							{
   1802 								$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   1803 							}
   1804 							if (isset($content['attribs']['']['fileSize']))
   1805 							{
   1806 								$length = ceil($content['attribs']['']['fileSize']);
   1807 							}
   1808 							if (isset($content['attribs']['']['medium']))
   1809 							{
   1810 								$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
   1811 							}
   1812 							if (isset($content['attribs']['']['samplingrate']))
   1813 							{
   1814 								$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
   1815 							}
   1816 							if (isset($content['attribs']['']['type']))
   1817 							{
   1818 								$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1819 							}
   1820 							if (isset($content['attribs']['']['width']))
   1821 							{
   1822 								$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
   1823 							}
   1824 							$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   1825 
   1826 							// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
   1827 
   1828 							// CAPTIONS
   1829 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
   1830 							{
   1831 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
   1832 								{
   1833 									$caption_type = null;
   1834 									$caption_lang = null;
   1835 									$caption_startTime = null;
   1836 									$caption_endTime = null;
   1837 									$caption_text = null;
   1838 									if (isset($caption['attribs']['']['type']))
   1839 									{
   1840 										$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1841 									}
   1842 									if (isset($caption['attribs']['']['lang']))
   1843 									{
   1844 										$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   1845 									}
   1846 									if (isset($caption['attribs']['']['start']))
   1847 									{
   1848 										$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
   1849 									}
   1850 									if (isset($caption['attribs']['']['end']))
   1851 									{
   1852 										$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
   1853 									}
   1854 									if (isset($caption['data']))
   1855 									{
   1856 										$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1857 									}
   1858 									$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
   1859 								}
   1860 								if (is_array($captions))
   1861 								{
   1862 									$captions = array_values(array_unique($captions));
   1863 								}
   1864 							}
   1865 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
   1866 							{
   1867 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
   1868 								{
   1869 									$caption_type = null;
   1870 									$caption_lang = null;
   1871 									$caption_startTime = null;
   1872 									$caption_endTime = null;
   1873 									$caption_text = null;
   1874 									if (isset($caption['attribs']['']['type']))
   1875 									{
   1876 										$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   1877 									}
   1878 									if (isset($caption['attribs']['']['lang']))
   1879 									{
   1880 										$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   1881 									}
   1882 									if (isset($caption['attribs']['']['start']))
   1883 									{
   1884 										$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
   1885 									}
   1886 									if (isset($caption['attribs']['']['end']))
   1887 									{
   1888 										$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
   1889 									}
   1890 									if (isset($caption['data']))
   1891 									{
   1892 										$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1893 									}
   1894 									$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
   1895 								}
   1896 								if (is_array($captions))
   1897 								{
   1898 									$captions = array_values(array_unique($captions));
   1899 								}
   1900 							}
   1901 							else
   1902 							{
   1903 								$captions = $captions_parent;
   1904 							}
   1905 
   1906 							// CATEGORIES
   1907 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
   1908 							{
   1909 								foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
   1910 								{
   1911 									$term = null;
   1912 									$scheme = null;
   1913 									$label = null;
   1914 									if (isset($category['data']))
   1915 									{
   1916 										$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1917 									}
   1918 									if (isset($category['attribs']['']['scheme']))
   1919 									{
   1920 										$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1921 									}
   1922 									else
   1923 									{
   1924 										$scheme = 'http://search.yahoo.com/mrss/category_schema';
   1925 									}
   1926 									if (isset($category['attribs']['']['label']))
   1927 									{
   1928 										$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
   1929 									}
   1930 									$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
   1931 								}
   1932 							}
   1933 							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
   1934 							{
   1935 								foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
   1936 								{
   1937 									$term = null;
   1938 									$scheme = null;
   1939 									$label = null;
   1940 									if (isset($category['data']))
   1941 									{
   1942 										$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1943 									}
   1944 									if (isset($category['attribs']['']['scheme']))
   1945 									{
   1946 										$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   1947 									}
   1948 									else
   1949 									{
   1950 										$scheme = 'http://search.yahoo.com/mrss/category_schema';
   1951 									}
   1952 									if (isset($category['attribs']['']['label']))
   1953 									{
   1954 										$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
   1955 									}
   1956 									$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
   1957 								}
   1958 							}
   1959 							if (is_array($categories) && is_array($categories_parent))
   1960 							{
   1961 								$categories = array_values(array_unique(array_merge($categories, $categories_parent)));
   1962 							}
   1963 							elseif (is_array($categories))
   1964 							{
   1965 								$categories = array_values(array_unique($categories));
   1966 							}
   1967 							elseif (is_array($categories_parent))
   1968 							{
   1969 								$categories = array_values(array_unique($categories_parent));
   1970 							}
   1971 
   1972 							// COPYRIGHTS
   1973 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
   1974 							{
   1975 								$copyright_url = null;
   1976 								$copyright_label = null;
   1977 								if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
   1978 								{
   1979 									$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
   1980 								}
   1981 								if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
   1982 								{
   1983 									$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1984 								}
   1985 								$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
   1986 							}
   1987 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
   1988 							{
   1989 								$copyright_url = null;
   1990 								$copyright_label = null;
   1991 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
   1992 								{
   1993 									$copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
   1994 								}
   1995 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
   1996 								{
   1997 									$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   1998 								}
   1999 								$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
   2000 							}
   2001 							else
   2002 							{
   2003 								$copyrights = $copyrights_parent;
   2004 							}
   2005 
   2006 							// CREDITS
   2007 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
   2008 							{
   2009 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
   2010 								{
   2011 									$credit_role = null;
   2012 									$credit_scheme = null;
   2013 									$credit_name = null;
   2014 									if (isset($credit['attribs']['']['role']))
   2015 									{
   2016 										$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
   2017 									}
   2018 									if (isset($credit['attribs']['']['scheme']))
   2019 									{
   2020 										$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2021 									}
   2022 									else
   2023 									{
   2024 										$credit_scheme = 'urn:ebu';
   2025 									}
   2026 									if (isset($credit['data']))
   2027 									{
   2028 										$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2029 									}
   2030 									$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
   2031 								}
   2032 								if (is_array($credits))
   2033 								{
   2034 									$credits = array_values(array_unique($credits));
   2035 								}
   2036 							}
   2037 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
   2038 							{
   2039 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
   2040 								{
   2041 									$credit_role = null;
   2042 									$credit_scheme = null;
   2043 									$credit_name = null;
   2044 									if (isset($credit['attribs']['']['role']))
   2045 									{
   2046 										$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
   2047 									}
   2048 									if (isset($credit['attribs']['']['scheme']))
   2049 									{
   2050 										$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2051 									}
   2052 									else
   2053 									{
   2054 										$credit_scheme = 'urn:ebu';
   2055 									}
   2056 									if (isset($credit['data']))
   2057 									{
   2058 										$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2059 									}
   2060 									$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
   2061 								}
   2062 								if (is_array($credits))
   2063 								{
   2064 									$credits = array_values(array_unique($credits));
   2065 								}
   2066 							}
   2067 							else
   2068 							{
   2069 								$credits = $credits_parent;
   2070 							}
   2071 
   2072 							// DESCRIPTION
   2073 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
   2074 							{
   2075 								$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2076 							}
   2077 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
   2078 							{
   2079 								$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2080 							}
   2081 							else
   2082 							{
   2083 								$description = $description_parent;
   2084 							}
   2085 
   2086 							// HASHES
   2087 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
   2088 							{
   2089 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
   2090 								{
   2091 									$value = null;
   2092 									$algo = null;
   2093 									if (isset($hash['data']))
   2094 									{
   2095 										$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2096 									}
   2097 									if (isset($hash['attribs']['']['algo']))
   2098 									{
   2099 										$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
   2100 									}
   2101 									else
   2102 									{
   2103 										$algo = 'md5';
   2104 									}
   2105 									$hashes[] = $algo.':'.$value;
   2106 								}
   2107 								if (is_array($hashes))
   2108 								{
   2109 									$hashes = array_values(array_unique($hashes));
   2110 								}
   2111 							}
   2112 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
   2113 							{
   2114 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
   2115 								{
   2116 									$value = null;
   2117 									$algo = null;
   2118 									if (isset($hash['data']))
   2119 									{
   2120 										$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2121 									}
   2122 									if (isset($hash['attribs']['']['algo']))
   2123 									{
   2124 										$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
   2125 									}
   2126 									else
   2127 									{
   2128 										$algo = 'md5';
   2129 									}
   2130 									$hashes[] = $algo.':'.$value;
   2131 								}
   2132 								if (is_array($hashes))
   2133 								{
   2134 									$hashes = array_values(array_unique($hashes));
   2135 								}
   2136 							}
   2137 							else
   2138 							{
   2139 								$hashes = $hashes_parent;
   2140 							}
   2141 
   2142 							// KEYWORDS
   2143 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
   2144 							{
   2145 								if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
   2146 								{
   2147 									$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   2148 									foreach ($temp as $word)
   2149 									{
   2150 										$keywords[] = trim($word);
   2151 									}
   2152 									unset($temp);
   2153 								}
   2154 								if (is_array($keywords))
   2155 								{
   2156 									$keywords = array_values(array_unique($keywords));
   2157 								}
   2158 							}
   2159 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
   2160 							{
   2161 								if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
   2162 								{
   2163 									$temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   2164 									foreach ($temp as $word)
   2165 									{
   2166 										$keywords[] = trim($word);
   2167 									}
   2168 									unset($temp);
   2169 								}
   2170 								if (is_array($keywords))
   2171 								{
   2172 									$keywords = array_values(array_unique($keywords));
   2173 								}
   2174 							}
   2175 							else
   2176 							{
   2177 								$keywords = $keywords_parent;
   2178 							}
   2179 
   2180 							// PLAYER
   2181 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
   2182 							{
   2183 								$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2184 							}
   2185 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
   2186 							{
   2187 								$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2188 							}
   2189 							else
   2190 							{
   2191 								$player = $player_parent;
   2192 							}
   2193 
   2194 							// RATINGS
   2195 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
   2196 							{
   2197 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
   2198 								{
   2199 									$rating_scheme = null;
   2200 									$rating_value = null;
   2201 									if (isset($rating['attribs']['']['scheme']))
   2202 									{
   2203 										$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2204 									}
   2205 									else
   2206 									{
   2207 										$rating_scheme = 'urn:simple';
   2208 									}
   2209 									if (isset($rating['data']))
   2210 									{
   2211 										$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2212 									}
   2213 									$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   2214 								}
   2215 								if (is_array($ratings))
   2216 								{
   2217 									$ratings = array_values(array_unique($ratings));
   2218 								}
   2219 							}
   2220 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
   2221 							{
   2222 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
   2223 								{
   2224 									$rating_scheme = null;
   2225 									$rating_value = null;
   2226 									if (isset($rating['attribs']['']['scheme']))
   2227 									{
   2228 										$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2229 									}
   2230 									else
   2231 									{
   2232 										$rating_scheme = 'urn:simple';
   2233 									}
   2234 									if (isset($rating['data']))
   2235 									{
   2236 										$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2237 									}
   2238 									$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   2239 								}
   2240 								if (is_array($ratings))
   2241 								{
   2242 									$ratings = array_values(array_unique($ratings));
   2243 								}
   2244 							}
   2245 							else
   2246 							{
   2247 								$ratings = $ratings_parent;
   2248 							}
   2249 
   2250 							// RESTRICTIONS
   2251 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
   2252 							{
   2253 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
   2254 								{
   2255 									$restriction_relationship = null;
   2256 									$restriction_type = null;
   2257 									$restriction_value = null;
   2258 									if (isset($restriction['attribs']['']['relationship']))
   2259 									{
   2260 										$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
   2261 									}
   2262 									if (isset($restriction['attribs']['']['type']))
   2263 									{
   2264 										$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2265 									}
   2266 									if (isset($restriction['data']))
   2267 									{
   2268 										$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2269 									}
   2270 									$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   2271 								}
   2272 								if (is_array($restrictions))
   2273 								{
   2274 									$restrictions = array_values(array_unique($restrictions));
   2275 								}
   2276 							}
   2277 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
   2278 							{
   2279 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
   2280 								{
   2281 									$restriction_relationship = null;
   2282 									$restriction_type = null;
   2283 									$restriction_value = null;
   2284 									if (isset($restriction['attribs']['']['relationship']))
   2285 									{
   2286 										$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
   2287 									}
   2288 									if (isset($restriction['attribs']['']['type']))
   2289 									{
   2290 										$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2291 									}
   2292 									if (isset($restriction['data']))
   2293 									{
   2294 										$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2295 									}
   2296 									$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   2297 								}
   2298 								if (is_array($restrictions))
   2299 								{
   2300 									$restrictions = array_values(array_unique($restrictions));
   2301 								}
   2302 							}
   2303 							else
   2304 							{
   2305 								$restrictions = $restrictions_parent;
   2306 							}
   2307 
   2308 							// THUMBNAILS
   2309 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
   2310 							{
   2311 								foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
   2312 								{
   2313 									$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2314 								}
   2315 								if (is_array($thumbnails))
   2316 								{
   2317 									$thumbnails = array_values(array_unique($thumbnails));
   2318 								}
   2319 							}
   2320 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
   2321 							{
   2322 								foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
   2323 								{
   2324 									$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2325 								}
   2326 								if (is_array($thumbnails))
   2327 								{
   2328 									$thumbnails = array_values(array_unique($thumbnails));
   2329 								}
   2330 							}
   2331 							else
   2332 							{
   2333 								$thumbnails = $thumbnails_parent;
   2334 							}
   2335 
   2336 							// TITLES
   2337 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
   2338 							{
   2339 								$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2340 							}
   2341 							elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
   2342 							{
   2343 								$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2344 							}
   2345 							else
   2346 							{
   2347 								$title = $title_parent;
   2348 							}
   2349 
   2350 							$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));
   2351 						}
   2352 					}
   2353 				}
   2354 			}
   2355 
   2356 			// If we have standalone media:content tags, loop through them.
   2357 			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
   2358 			{
   2359 				foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
   2360 				{
   2361 					if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
   2362 					{
   2363 						// Attributes
   2364 						$bitrate = null;
   2365 						$channels = null;
   2366 						$duration = null;
   2367 						$expression = null;
   2368 						$framerate = null;
   2369 						$height = null;
   2370 						$javascript = null;
   2371 						$lang = null;
   2372 						$length = null;
   2373 						$medium = null;
   2374 						$samplingrate = null;
   2375 						$type = null;
   2376 						$url = null;
   2377 						$width = null;
   2378 
   2379 						// Elements
   2380 						$captions = null;
   2381 						$categories = null;
   2382 						$copyrights = null;
   2383 						$credits = null;
   2384 						$description = null;
   2385 						$hashes = null;
   2386 						$keywords = null;
   2387 						$player = null;
   2388 						$ratings = null;
   2389 						$restrictions = null;
   2390 						$thumbnails = null;
   2391 						$title = null;
   2392 
   2393 						// Start checking the attributes of media:content
   2394 						if (isset($content['attribs']['']['bitrate']))
   2395 						{
   2396 							$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
   2397 						}
   2398 						if (isset($content['attribs']['']['channels']))
   2399 						{
   2400 							$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
   2401 						}
   2402 						if (isset($content['attribs']['']['duration']))
   2403 						{
   2404 							$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
   2405 						}
   2406 						else
   2407 						{
   2408 							$duration = $duration_parent;
   2409 						}
   2410 						if (isset($content['attribs']['']['expression']))
   2411 						{
   2412 							$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
   2413 						}
   2414 						if (isset($content['attribs']['']['framerate']))
   2415 						{
   2416 							$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
   2417 						}
   2418 						if (isset($content['attribs']['']['height']))
   2419 						{
   2420 							$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
   2421 						}
   2422 						if (isset($content['attribs']['']['lang']))
   2423 						{
   2424 							$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   2425 						}
   2426 						if (isset($content['attribs']['']['fileSize']))
   2427 						{
   2428 							$length = ceil($content['attribs']['']['fileSize']);
   2429 						}
   2430 						if (isset($content['attribs']['']['medium']))
   2431 						{
   2432 							$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
   2433 						}
   2434 						if (isset($content['attribs']['']['samplingrate']))
   2435 						{
   2436 							$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
   2437 						}
   2438 						if (isset($content['attribs']['']['type']))
   2439 						{
   2440 							$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2441 						}
   2442 						if (isset($content['attribs']['']['width']))
   2443 						{
   2444 							$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
   2445 						}
   2446 						if (isset($content['attribs']['']['url']))
   2447 						{
   2448 							$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2449 						}
   2450 						// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
   2451 
   2452 						// CAPTIONS
   2453 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
   2454 						{
   2455 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
   2456 							{
   2457 								$caption_type = null;
   2458 								$caption_lang = null;
   2459 								$caption_startTime = null;
   2460 								$caption_endTime = null;
   2461 								$caption_text = null;
   2462 								if (isset($caption['attribs']['']['type']))
   2463 								{
   2464 									$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2465 								}
   2466 								if (isset($caption['attribs']['']['lang']))
   2467 								{
   2468 									$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
   2469 								}
   2470 								if (isset($caption['attribs']['']['start']))
   2471 								{
   2472 									$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
   2473 								}
   2474 								if (isset($caption['attribs']['']['end']))
   2475 								{
   2476 									$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
   2477 								}
   2478 								if (isset($caption['data']))
   2479 								{
   2480 									$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2481 								}
   2482 								$captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text));
   2483 							}
   2484 							if (is_array($captions))
   2485 							{
   2486 								$captions = array_values(array_unique($captions));
   2487 							}
   2488 						}
   2489 						else
   2490 						{
   2491 							$captions = $captions_parent;
   2492 						}
   2493 
   2494 						// CATEGORIES
   2495 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
   2496 						{
   2497 							foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
   2498 							{
   2499 								$term = null;
   2500 								$scheme = null;
   2501 								$label = null;
   2502 								if (isset($category['data']))
   2503 								{
   2504 									$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2505 								}
   2506 								if (isset($category['attribs']['']['scheme']))
   2507 								{
   2508 									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2509 								}
   2510 								else
   2511 								{
   2512 									$scheme = 'http://search.yahoo.com/mrss/category_schema';
   2513 								}
   2514 								if (isset($category['attribs']['']['label']))
   2515 								{
   2516 									$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
   2517 								}
   2518 								$categories[] = $this->registry->create('Category', array($term, $scheme, $label));
   2519 							}
   2520 						}
   2521 						if (is_array($categories) && is_array($categories_parent))
   2522 						{
   2523 							$categories = array_values(array_unique(array_merge($categories, $categories_parent)));
   2524 						}
   2525 						elseif (is_array($categories))
   2526 						{
   2527 							$categories = array_values(array_unique($categories));
   2528 						}
   2529 						elseif (is_array($categories_parent))
   2530 						{
   2531 							$categories = array_values(array_unique($categories_parent));
   2532 						}
   2533 						else
   2534 						{
   2535 							$categories = null;
   2536 						}
   2537 
   2538 						// COPYRIGHTS
   2539 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
   2540 						{
   2541 							$copyright_url = null;
   2542 							$copyright_label = null;
   2543 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
   2544 							{
   2545 								$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
   2546 							}
   2547 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
   2548 							{
   2549 								$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2550 							}
   2551 							$copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label));
   2552 						}
   2553 						else
   2554 						{
   2555 							$copyrights = $copyrights_parent;
   2556 						}
   2557 
   2558 						// CREDITS
   2559 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
   2560 						{
   2561 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
   2562 							{
   2563 								$credit_role = null;
   2564 								$credit_scheme = null;
   2565 								$credit_name = null;
   2566 								if (isset($credit['attribs']['']['role']))
   2567 								{
   2568 									$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
   2569 								}
   2570 								if (isset($credit['attribs']['']['scheme']))
   2571 								{
   2572 									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2573 								}
   2574 								else
   2575 								{
   2576 									$credit_scheme = 'urn:ebu';
   2577 								}
   2578 								if (isset($credit['data']))
   2579 								{
   2580 									$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2581 								}
   2582 								$credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name));
   2583 							}
   2584 							if (is_array($credits))
   2585 							{
   2586 								$credits = array_values(array_unique($credits));
   2587 							}
   2588 						}
   2589 						else
   2590 						{
   2591 							$credits = $credits_parent;
   2592 						}
   2593 
   2594 						// DESCRIPTION
   2595 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
   2596 						{
   2597 							$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2598 						}
   2599 						else
   2600 						{
   2601 							$description = $description_parent;
   2602 						}
   2603 
   2604 						// HASHES
   2605 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
   2606 						{
   2607 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
   2608 							{
   2609 								$value = null;
   2610 								$algo = null;
   2611 								if (isset($hash['data']))
   2612 								{
   2613 									$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2614 								}
   2615 								if (isset($hash['attribs']['']['algo']))
   2616 								{
   2617 									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
   2618 								}
   2619 								else
   2620 								{
   2621 									$algo = 'md5';
   2622 								}
   2623 								$hashes[] = $algo.':'.$value;
   2624 							}
   2625 							if (is_array($hashes))
   2626 							{
   2627 								$hashes = array_values(array_unique($hashes));
   2628 							}
   2629 						}
   2630 						else
   2631 						{
   2632 							$hashes = $hashes_parent;
   2633 						}
   2634 
   2635 						// KEYWORDS
   2636 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
   2637 						{
   2638 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
   2639 							{
   2640 								$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
   2641 								foreach ($temp as $word)
   2642 								{
   2643 									$keywords[] = trim($word);
   2644 								}
   2645 								unset($temp);
   2646 							}
   2647 							if (is_array($keywords))
   2648 							{
   2649 								$keywords = array_values(array_unique($keywords));
   2650 							}
   2651 						}
   2652 						else
   2653 						{
   2654 							$keywords = $keywords_parent;
   2655 						}
   2656 
   2657 						// PLAYER
   2658 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
   2659 						{
   2660 							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) {
   2661 								$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2662 							}
   2663 						}
   2664 						else
   2665 						{
   2666 							$player = $player_parent;
   2667 						}
   2668 
   2669 						// RATINGS
   2670 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
   2671 						{
   2672 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
   2673 							{
   2674 								$rating_scheme = null;
   2675 								$rating_value = null;
   2676 								if (isset($rating['attribs']['']['scheme']))
   2677 								{
   2678 									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
   2679 								}
   2680 								else
   2681 								{
   2682 									$rating_scheme = 'urn:simple';
   2683 								}
   2684 								if (isset($rating['data']))
   2685 								{
   2686 									$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2687 								}
   2688 								$ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value));
   2689 							}
   2690 							if (is_array($ratings))
   2691 							{
   2692 								$ratings = array_values(array_unique($ratings));
   2693 							}
   2694 						}
   2695 						else
   2696 						{
   2697 							$ratings = $ratings_parent;
   2698 						}
   2699 
   2700 						// RESTRICTIONS
   2701 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
   2702 						{
   2703 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
   2704 							{
   2705 								$restriction_relationship = null;
   2706 								$restriction_type = null;
   2707 								$restriction_value = null;
   2708 								if (isset($restriction['attribs']['']['relationship']))
   2709 								{
   2710 									$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
   2711 								}
   2712 								if (isset($restriction['attribs']['']['type']))
   2713 								{
   2714 									$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2715 								}
   2716 								if (isset($restriction['data']))
   2717 								{
   2718 									$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2719 								}
   2720 								$restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value));
   2721 							}
   2722 							if (is_array($restrictions))
   2723 							{
   2724 								$restrictions = array_values(array_unique($restrictions));
   2725 							}
   2726 						}
   2727 						else
   2728 						{
   2729 							$restrictions = $restrictions_parent;
   2730 						}
   2731 
   2732 						// THUMBNAILS
   2733 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
   2734 						{
   2735 							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
   2736 							{
   2737 								if (isset($thumbnail['attribs']['']['url'])) {
   2738 									$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
   2739 								}
   2740 							}
   2741 							if (is_array($thumbnails))
   2742 							{
   2743 								$thumbnails = array_values(array_unique($thumbnails));
   2744 							}
   2745 						}
   2746 						else
   2747 						{
   2748 							$thumbnails = $thumbnails_parent;
   2749 						}
   2750 
   2751 						// TITLES
   2752 						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
   2753 						{
   2754 							$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
   2755 						}
   2756 						else
   2757 						{
   2758 							$title = $title_parent;
   2759 						}
   2760 
   2761 						$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));
   2762 					}
   2763 				}
   2764 			}
   2765 
   2766 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
   2767 			{
   2768 				if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
   2769 				{
   2770 					// Attributes
   2771 					$bitrate = null;
   2772 					$channels = null;
   2773 					$duration = null;
   2774 					$expression = null;
   2775 					$framerate = null;
   2776 					$height = null;
   2777 					$javascript = null;
   2778 					$lang = null;
   2779 					$length = null;
   2780 					$medium = null;
   2781 					$samplingrate = null;
   2782 					$type = null;
   2783 					$url = null;
   2784 					$width = null;
   2785 
   2786 					$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
   2787 					if (isset($link['attribs']['']['type']))
   2788 					{
   2789 						$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2790 					}
   2791 					if (isset($link['attribs']['']['length']))
   2792 					{
   2793 						$length = ceil($link['attribs']['']['length']);
   2794 					}
   2795 					if (isset($link['attribs']['']['title']))
   2796 					{
   2797 						$title = $this->sanitize($link['attribs']['']['title'], SIMPLEPIE_CONSTRUCT_TEXT);
   2798 					}
   2799 					else
   2800 					{
   2801 						$title = $title_parent;
   2802 					}
   2803 
   2804 					// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
   2805 					$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, $width));
   2806 				}
   2807 			}
   2808 
   2809 			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
   2810 			{
   2811 				if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
   2812 				{
   2813 					// Attributes
   2814 					$bitrate = null;
   2815 					$channels = null;
   2816 					$duration = null;
   2817 					$expression = null;
   2818 					$framerate = null;
   2819 					$height = null;
   2820 					$javascript = null;
   2821 					$lang = null;
   2822 					$length = null;
   2823 					$medium = null;
   2824 					$samplingrate = null;
   2825 					$type = null;
   2826 					$url = null;
   2827 					$width = null;
   2828 
   2829 					$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
   2830 					if (isset($link['attribs']['']['type']))
   2831 					{
   2832 						$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2833 					}
   2834 					if (isset($link['attribs']['']['length']))
   2835 					{
   2836 						$length = ceil($link['attribs']['']['length']);
   2837 					}
   2838 
   2839 					// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
   2840 					$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));
   2841 				}
   2842 			}
   2843 
   2844 			if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
   2845 			{
   2846 				if (isset($enclosure[0]['attribs']['']['url']))
   2847 				{
   2848 					// Attributes
   2849 					$bitrate = null;
   2850 					$channels = null;
   2851 					$duration = null;
   2852 					$expression = null;
   2853 					$framerate = null;
   2854 					$height = null;
   2855 					$javascript = null;
   2856 					$lang = null;
   2857 					$length = null;
   2858 					$medium = null;
   2859 					$samplingrate = null;
   2860 					$type = null;
   2861 					$url = null;
   2862 					$width = null;
   2863 
   2864 					$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
   2865 					if (isset($enclosure[0]['attribs']['']['type']))
   2866 					{
   2867 						$type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
   2868 					}
   2869 					if (isset($enclosure[0]['attribs']['']['length']))
   2870 					{
   2871 						$length = ceil($enclosure[0]['attribs']['']['length']);
   2872 					}
   2873 
   2874 					// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
   2875 					$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));
   2876 				}
   2877 			}
   2878 
   2879 			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))
   2880 			{
   2881 				// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
   2882 				$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));
   2883 			}
   2884 
   2885 			$this->data['enclosures'] = array_values(array_unique($this->data['enclosures']));
   2886 		}
   2887 		if (!empty($this->data['enclosures']))
   2888 		{
   2889 			return $this->data['enclosures'];
   2890 		}
   2891 
   2892 		return null;
   2893 	}
   2894 
   2895 	/**
   2896 	 * Get the latitude coordinates for the item
   2897 	 *
   2898 	 * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
   2899 	 *
   2900 	 * Uses `<geo:lat>` or `<georss:point>`
   2901 	 *
   2902 	 * @since 1.0
   2903 	 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
   2904 	 * @link http://www.georss.org/ GeoRSS
   2905 	 * @return string|null
   2906 	 */
   2907 	public function get_latitude()
   2908 	{
   2909 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
   2910 		{
   2911 			return (float) $return[0]['data'];
   2912 		}
   2913 		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))
   2914 		{
   2915 			return (float) $match[1];
   2916 		}
   2917 
   2918 		return null;
   2919 	}
   2920 
   2921 	/**
   2922 	 * Get the longitude coordinates for the item
   2923 	 *
   2924 	 * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
   2925 	 *
   2926 	 * Uses `<geo:long>`, `<geo:lon>` or `<georss:point>`
   2927 	 *
   2928 	 * @since 1.0
   2929 	 * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
   2930 	 * @link http://www.georss.org/ GeoRSS
   2931 	 * @return string|null
   2932 	 */
   2933 	public function get_longitude()
   2934 	{
   2935 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
   2936 		{
   2937 			return (float) $return[0]['data'];
   2938 		}
   2939 		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
   2940 		{
   2941 			return (float) $return[0]['data'];
   2942 		}
   2943 		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))
   2944 		{
   2945 			return (float) $match[2];
   2946 		}
   2947 
   2948 		return null;
   2949 	}
   2950 
   2951 	/**
   2952 	 * Get the `<atom:source>` for the item
   2953 	 *
   2954 	 * @since 1.1
   2955 	 * @return SimplePie_Source|null
   2956 	 */
   2957 	public function get_source()
   2958 	{
   2959 		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
   2960 		{
   2961 			return $this->registry->create('Source', array($this, $return[0]));
   2962 		}
   2963 
   2964 		return null;
   2965 	}
   2966 }