Overview

Packages

  • None
  • SimplePie

Classes

  • SimplePie
  • SimplePie_Author
  • SimplePie_Autoloader
  • SimplePie_Cache
  • SimplePie_Cache_DB
  • SimplePie_Cache_File
  • SimplePie_Cache_Memcache
  • SimplePie_Cache_MySQL
  • SimplePie_Caption
  • SimplePie_Category
  • SimplePie_Content_Type_Sniffer
  • SimplePie_Copyright
  • SimplePie_Core
  • SimplePie_Credit
  • SimplePie_Decode_HTML_Entities
  • SimplePie_Enclosure
  • SimplePie_File
  • SimplePie_gzdecode
  • SimplePie_HTTP_Parser
  • SimplePie_IRI
  • SimplePie_Item
  • SimplePie_Locator
  • SimplePie_Misc
  • SimplePie_Net_IPv6
  • SimplePie_Parse_Date
  • SimplePie_Parser
  • SimplePie_Rating
  • SimplePie_Registry
  • SimplePie_Restriction
  • SimplePie_Sanitize
  • SimplePie_Source
  • SimplePie_XML_Declaration_Parser

Interfaces

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