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