equal
deleted
inserted
replaced
3 * SimplePie |
3 * SimplePie |
4 * |
4 * |
5 * A PHP-Based RSS and Atom Feed Framework. |
5 * A PHP-Based RSS and Atom Feed Framework. |
6 * Takes the hard work out of managing a complete RSS/Atom solution. |
6 * Takes the hard work out of managing a complete RSS/Atom solution. |
7 * |
7 * |
8 * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors |
8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors |
9 * All rights reserved. |
9 * All rights reserved. |
10 * |
10 * |
11 * Redistribution and use in source and binary forms, with or without modification, are |
11 * Redistribution and use in source and binary forms, with or without modification, are |
12 * permitted provided that the following conditions are met: |
12 * permitted provided that the following conditions are met: |
13 * |
13 * |
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
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 |
32 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
33 * POSSIBILITY OF SUCH DAMAGE. |
33 * POSSIBILITY OF SUCH DAMAGE. |
34 * |
34 * |
35 * @package SimplePie |
35 * @package SimplePie |
36 * @version 1.3.1 |
36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue |
37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue |
|
38 * @author Ryan Parman |
37 * @author Ryan Parman |
39 * @author Geoffrey Sneddon |
38 * @author Sam Sneddon |
40 * @author Ryan McCue |
39 * @author Ryan McCue |
41 * @link http://simplepie.org/ SimplePie |
40 * @link http://simplepie.org/ SimplePie |
42 * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
41 * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
43 */ |
42 */ |
44 |
43 |
78 { |
77 { |
79 if (isset($this->data['child'][$namespace][$tag])) |
78 if (isset($this->data['child'][$namespace][$tag])) |
80 { |
79 { |
81 return $this->data['child'][$namespace][$tag]; |
80 return $this->data['child'][$namespace][$tag]; |
82 } |
81 } |
83 else |
82 |
84 { |
83 return null; |
85 return null; |
|
86 } |
|
87 } |
84 } |
88 |
85 |
89 public function get_base($element = array()) |
86 public function get_base($element = array()) |
90 { |
87 { |
91 return $this->item->get_base($element); |
88 return $this->item->get_base($element); |
129 } |
126 } |
130 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
127 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) |
131 { |
128 { |
132 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
129 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
133 } |
130 } |
134 else |
131 |
135 { |
132 return null; |
136 return null; |
|
137 } |
|
138 } |
133 } |
139 |
134 |
140 public function get_category($key = 0) |
135 public function get_category($key = 0) |
141 { |
136 { |
142 $categories = $this->get_categories(); |
137 $categories = $this->get_categories(); |
143 if (isset($categories[$key])) |
138 if (isset($categories[$key])) |
144 { |
139 { |
145 return $categories[$key]; |
140 return $categories[$key]; |
146 } |
141 } |
147 else |
142 |
148 { |
143 return null; |
149 return null; |
|
150 } |
|
151 } |
144 } |
152 |
145 |
153 public function get_categories() |
146 public function get_categories() |
154 { |
147 { |
155 $categories = array(); |
148 $categories = array(); |
199 |
192 |
200 if (!empty($categories)) |
193 if (!empty($categories)) |
201 { |
194 { |
202 return array_unique($categories); |
195 return array_unique($categories); |
203 } |
196 } |
204 else |
197 |
205 { |
198 return null; |
206 return null; |
|
207 } |
|
208 } |
199 } |
209 |
200 |
210 public function get_author($key = 0) |
201 public function get_author($key = 0) |
211 { |
202 { |
212 $authors = $this->get_authors(); |
203 $authors = $this->get_authors(); |
213 if (isset($authors[$key])) |
204 if (isset($authors[$key])) |
214 { |
205 { |
215 return $authors[$key]; |
206 return $authors[$key]; |
216 } |
207 } |
217 else |
208 |
218 { |
209 return null; |
219 return null; |
|
220 } |
|
221 } |
210 } |
222 |
211 |
223 public function get_authors() |
212 public function get_authors() |
224 { |
213 { |
225 $authors = array(); |
214 $authors = array(); |
282 |
271 |
283 if (!empty($authors)) |
272 if (!empty($authors)) |
284 { |
273 { |
285 return array_unique($authors); |
274 return array_unique($authors); |
286 } |
275 } |
287 else |
276 |
288 { |
277 return null; |
289 return null; |
|
290 } |
|
291 } |
278 } |
292 |
279 |
293 public function get_contributor($key = 0) |
280 public function get_contributor($key = 0) |
294 { |
281 { |
295 $contributors = $this->get_contributors(); |
282 $contributors = $this->get_contributors(); |
296 if (isset($contributors[$key])) |
283 if (isset($contributors[$key])) |
297 { |
284 { |
298 return $contributors[$key]; |
285 return $contributors[$key]; |
299 } |
286 } |
300 else |
287 |
301 { |
288 return null; |
302 return null; |
|
303 } |
|
304 } |
289 } |
305 |
290 |
306 public function get_contributors() |
291 public function get_contributors() |
307 { |
292 { |
308 $contributors = array(); |
293 $contributors = array(); |
353 |
338 |
354 if (!empty($contributors)) |
339 if (!empty($contributors)) |
355 { |
340 { |
356 return array_unique($contributors); |
341 return array_unique($contributors); |
357 } |
342 } |
358 else |
343 |
359 { |
344 return null; |
360 return null; |
|
361 } |
|
362 } |
345 } |
363 |
346 |
364 public function get_link($key = 0, $rel = 'alternate') |
347 public function get_link($key = 0, $rel = 'alternate') |
365 { |
348 { |
366 $links = $this->get_links($rel); |
349 $links = $this->get_links($rel); |
367 if (isset($links[$key])) |
350 if (isset($links[$key])) |
368 { |
351 { |
369 return $links[$key]; |
352 return $links[$key]; |
370 } |
353 } |
371 else |
354 |
372 { |
355 return null; |
373 return null; |
|
374 } |
|
375 } |
356 } |
376 |
357 |
377 /** |
358 /** |
378 * Added for parity between the parent-level and the item/entry-level. |
359 * Added for parity between the parent-level and the item/entry-level. |
379 */ |
360 */ |
448 |
429 |
449 if (isset($this->data['links'][$rel])) |
430 if (isset($this->data['links'][$rel])) |
450 { |
431 { |
451 return $this->data['links'][$rel]; |
432 return $this->data['links'][$rel]; |
452 } |
433 } |
453 else |
434 |
454 { |
435 return null; |
455 return null; |
|
456 } |
|
457 } |
436 } |
458 |
437 |
459 public function get_description() |
438 public function get_description() |
460 { |
439 { |
461 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) |
440 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) |
492 } |
471 } |
493 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
472 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) |
494 { |
473 { |
495 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
474 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); |
496 } |
475 } |
497 else |
476 |
498 { |
477 return null; |
499 return null; |
|
500 } |
|
501 } |
478 } |
502 |
479 |
503 public function get_copyright() |
480 public function get_copyright() |
504 { |
481 { |
505 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
482 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) |
520 } |
497 } |
521 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
498 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) |
522 { |
499 { |
523 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
500 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
524 } |
501 } |
525 else |
502 |
526 { |
503 return null; |
527 return null; |
|
528 } |
|
529 } |
504 } |
530 |
505 |
531 public function get_language() |
506 public function get_language() |
532 { |
507 { |
533 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) |
508 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) |
544 } |
519 } |
545 elseif (isset($this->data['xml_lang'])) |
520 elseif (isset($this->data['xml_lang'])) |
546 { |
521 { |
547 return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
522 return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
548 } |
523 } |
549 else |
524 |
550 { |
525 return null; |
551 return null; |
|
552 } |
|
553 } |
526 } |
554 |
527 |
555 public function get_latitude() |
528 public function get_latitude() |
556 { |
529 { |
557 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
530 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) |
560 } |
533 } |
561 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
534 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
562 { |
535 { |
563 return (float) $match[1]; |
536 return (float) $match[1]; |
564 } |
537 } |
565 else |
538 |
566 { |
539 return null; |
567 return null; |
|
568 } |
|
569 } |
540 } |
570 |
541 |
571 public function get_longitude() |
542 public function get_longitude() |
572 { |
543 { |
573 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
544 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) |
580 } |
551 } |
581 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
552 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) |
582 { |
553 { |
583 return (float) $match[2]; |
554 return (float) $match[2]; |
584 } |
555 } |
585 else |
556 |
586 { |
557 return null; |
587 return null; |
|
588 } |
|
589 } |
558 } |
590 |
559 |
591 public function get_image_url() |
560 public function get_image_url() |
592 { |
561 { |
593 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) |
562 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) |
600 } |
569 } |
601 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
570 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) |
602 { |
571 { |
603 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
572 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); |
604 } |
573 } |
605 else |
574 |
606 { |
575 return null; |
607 return null; |
|
608 } |
|
609 } |
576 } |
610 } |
577 } |
611 |
|