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