changeset 16 | a86126ab1dd4 |
parent 0 | d970ebf37754 |
child 19 | 3d72ae0968f4 |
15:3d4e9c994f10 | 16:a86126ab1dd4 |
---|---|
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 |
281 { |
280 { |
282 if ($this->bitrate !== null) |
281 if ($this->bitrate !== null) |
283 { |
282 { |
284 return $this->bitrate; |
283 return $this->bitrate; |
285 } |
284 } |
286 else |
285 |
287 { |
286 return null; |
288 return null; |
|
289 } |
|
290 } |
287 } |
291 |
288 |
292 /** |
289 /** |
293 * Get a single caption |
290 * Get a single caption |
294 * |
291 * |
300 $captions = $this->get_captions(); |
297 $captions = $this->get_captions(); |
301 if (isset($captions[$key])) |
298 if (isset($captions[$key])) |
302 { |
299 { |
303 return $captions[$key]; |
300 return $captions[$key]; |
304 } |
301 } |
305 else |
302 |
306 { |
303 return null; |
307 return null; |
|
308 } |
|
309 } |
304 } |
310 |
305 |
311 /** |
306 /** |
312 * Get all captions |
307 * Get all captions |
313 * |
308 * |
317 { |
312 { |
318 if ($this->captions !== null) |
313 if ($this->captions !== null) |
319 { |
314 { |
320 return $this->captions; |
315 return $this->captions; |
321 } |
316 } |
322 else |
317 |
323 { |
318 return null; |
324 return null; |
|
325 } |
|
326 } |
319 } |
327 |
320 |
328 /** |
321 /** |
329 * Get a single category |
322 * Get a single category |
330 * |
323 * |
336 $categories = $this->get_categories(); |
329 $categories = $this->get_categories(); |
337 if (isset($categories[$key])) |
330 if (isset($categories[$key])) |
338 { |
331 { |
339 return $categories[$key]; |
332 return $categories[$key]; |
340 } |
333 } |
341 else |
334 |
342 { |
335 return null; |
343 return null; |
|
344 } |
|
345 } |
336 } |
346 |
337 |
347 /** |
338 /** |
348 * Get all categories |
339 * Get all categories |
349 * |
340 * |
353 { |
344 { |
354 if ($this->categories !== null) |
345 if ($this->categories !== null) |
355 { |
346 { |
356 return $this->categories; |
347 return $this->categories; |
357 } |
348 } |
358 else |
349 |
359 { |
350 return null; |
360 return null; |
|
361 } |
|
362 } |
351 } |
363 |
352 |
364 /** |
353 /** |
365 * Get the number of audio channels |
354 * Get the number of audio channels |
366 * |
355 * |
370 { |
359 { |
371 if ($this->channels !== null) |
360 if ($this->channels !== null) |
372 { |
361 { |
373 return $this->channels; |
362 return $this->channels; |
374 } |
363 } |
375 else |
364 |
376 { |
365 return null; |
377 return null; |
|
378 } |
|
379 } |
366 } |
380 |
367 |
381 /** |
368 /** |
382 * Get the copyright information |
369 * Get the copyright information |
383 * |
370 * |
387 { |
374 { |
388 if ($this->copyright !== null) |
375 if ($this->copyright !== null) |
389 { |
376 { |
390 return $this->copyright; |
377 return $this->copyright; |
391 } |
378 } |
392 else |
379 |
393 { |
380 return null; |
394 return null; |
|
395 } |
|
396 } |
381 } |
397 |
382 |
398 /** |
383 /** |
399 * Get a single credit |
384 * Get a single credit |
400 * |
385 * |
406 $credits = $this->get_credits(); |
391 $credits = $this->get_credits(); |
407 if (isset($credits[$key])) |
392 if (isset($credits[$key])) |
408 { |
393 { |
409 return $credits[$key]; |
394 return $credits[$key]; |
410 } |
395 } |
411 else |
396 |
412 { |
397 return null; |
413 return null; |
|
414 } |
|
415 } |
398 } |
416 |
399 |
417 /** |
400 /** |
418 * Get all credits |
401 * Get all credits |
419 * |
402 * |
423 { |
406 { |
424 if ($this->credits !== null) |
407 if ($this->credits !== null) |
425 { |
408 { |
426 return $this->credits; |
409 return $this->credits; |
427 } |
410 } |
428 else |
411 |
429 { |
412 return null; |
430 return null; |
|
431 } |
|
432 } |
413 } |
433 |
414 |
434 /** |
415 /** |
435 * Get the description of the enclosure |
416 * Get the description of the enclosure |
436 * |
417 * |
440 { |
421 { |
441 if ($this->description !== null) |
422 if ($this->description !== null) |
442 { |
423 { |
443 return $this->description; |
424 return $this->description; |
444 } |
425 } |
445 else |
426 |
446 { |
427 return null; |
447 return null; |
|
448 } |
|
449 } |
428 } |
450 |
429 |
451 /** |
430 /** |
452 * Get the duration of the enclosure |
431 * Get the duration of the enclosure |
453 * |
432 * |
454 * @param string $convert Convert seconds into hh:mm:ss |
433 * @param bool $convert Convert seconds into hh:mm:ss |
455 * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) |
434 * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) |
456 */ |
435 */ |
457 public function get_duration($convert = false) |
436 public function get_duration($convert = false) |
458 { |
437 { |
459 if ($this->duration !== null) |
438 if ($this->duration !== null) |
461 if ($convert) |
440 if ($convert) |
462 { |
441 { |
463 $time = SimplePie_Misc::time_hms($this->duration); |
442 $time = SimplePie_Misc::time_hms($this->duration); |
464 return $time; |
443 return $time; |
465 } |
444 } |
466 else |
445 |
467 { |
446 return $this->duration; |
468 return $this->duration; |
447 } |
469 } |
448 |
470 } |
449 return null; |
471 else |
|
472 { |
|
473 return null; |
|
474 } |
|
475 } |
450 } |
476 |
451 |
477 /** |
452 /** |
478 * Get the expression |
453 * Get the expression |
479 * |
454 * |
483 { |
458 { |
484 if ($this->expression !== null) |
459 if ($this->expression !== null) |
485 { |
460 { |
486 return $this->expression; |
461 return $this->expression; |
487 } |
462 } |
488 else |
463 |
489 { |
464 return 'full'; |
490 return 'full'; |
|
491 } |
|
492 } |
465 } |
493 |
466 |
494 /** |
467 /** |
495 * Get the file extension |
468 * Get the file extension |
496 * |
469 * |
518 { |
491 { |
519 if ($this->framerate !== null) |
492 if ($this->framerate !== null) |
520 { |
493 { |
521 return $this->framerate; |
494 return $this->framerate; |
522 } |
495 } |
523 else |
496 |
524 { |
497 return null; |
525 return null; |
|
526 } |
|
527 } |
498 } |
528 |
499 |
529 /** |
500 /** |
530 * Get the preferred handler |
501 * Get the preferred handler |
531 * |
502 * |
548 $hashes = $this->get_hashes(); |
519 $hashes = $this->get_hashes(); |
549 if (isset($hashes[$key])) |
520 if (isset($hashes[$key])) |
550 { |
521 { |
551 return $hashes[$key]; |
522 return $hashes[$key]; |
552 } |
523 } |
553 else |
524 |
554 { |
525 return null; |
555 return null; |
|
556 } |
|
557 } |
526 } |
558 |
527 |
559 /** |
528 /** |
560 * Get all credits |
529 * Get all credits |
561 * |
530 * |
565 { |
534 { |
566 if ($this->hashes !== null) |
535 if ($this->hashes !== null) |
567 { |
536 { |
568 return $this->hashes; |
537 return $this->hashes; |
569 } |
538 } |
570 else |
539 |
571 { |
540 return null; |
572 return null; |
|
573 } |
|
574 } |
541 } |
575 |
542 |
576 /** |
543 /** |
577 * Get the height |
544 * Get the height |
578 * |
545 * |
582 { |
549 { |
583 if ($this->height !== null) |
550 if ($this->height !== null) |
584 { |
551 { |
585 return $this->height; |
552 return $this->height; |
586 } |
553 } |
587 else |
554 |
588 { |
555 return null; |
589 return null; |
|
590 } |
|
591 } |
556 } |
592 |
557 |
593 /** |
558 /** |
594 * Get the language |
559 * Get the language |
595 * |
560 * |
600 { |
565 { |
601 if ($this->lang !== null) |
566 if ($this->lang !== null) |
602 { |
567 { |
603 return $this->lang; |
568 return $this->lang; |
604 } |
569 } |
605 else |
570 |
606 { |
571 return null; |
607 return null; |
|
608 } |
|
609 } |
572 } |
610 |
573 |
611 /** |
574 /** |
612 * Get a single keyword |
575 * Get a single keyword |
613 * |
576 * |
619 $keywords = $this->get_keywords(); |
582 $keywords = $this->get_keywords(); |
620 if (isset($keywords[$key])) |
583 if (isset($keywords[$key])) |
621 { |
584 { |
622 return $keywords[$key]; |
585 return $keywords[$key]; |
623 } |
586 } |
624 else |
587 |
625 { |
588 return null; |
626 return null; |
|
627 } |
|
628 } |
589 } |
629 |
590 |
630 /** |
591 /** |
631 * Get all keywords |
592 * Get all keywords |
632 * |
593 * |
636 { |
597 { |
637 if ($this->keywords !== null) |
598 if ($this->keywords !== null) |
638 { |
599 { |
639 return $this->keywords; |
600 return $this->keywords; |
640 } |
601 } |
641 else |
602 |
642 { |
603 return null; |
643 return null; |
|
644 } |
|
645 } |
604 } |
646 |
605 |
647 /** |
606 /** |
648 * Get length |
607 * Get length |
649 * |
608 * |
653 { |
612 { |
654 if ($this->length !== null) |
613 if ($this->length !== null) |
655 { |
614 { |
656 return $this->length; |
615 return $this->length; |
657 } |
616 } |
658 else |
617 |
659 { |
618 return null; |
660 return null; |
|
661 } |
|
662 } |
619 } |
663 |
620 |
664 /** |
621 /** |
665 * Get the URL |
622 * Get the URL |
666 * |
623 * |
670 { |
627 { |
671 if ($this->link !== null) |
628 if ($this->link !== null) |
672 { |
629 { |
673 return urldecode($this->link); |
630 return urldecode($this->link); |
674 } |
631 } |
675 else |
632 |
676 { |
633 return null; |
677 return null; |
|
678 } |
|
679 } |
634 } |
680 |
635 |
681 /** |
636 /** |
682 * Get the medium |
637 * Get the medium |
683 * |
638 * |
688 { |
643 { |
689 if ($this->medium !== null) |
644 if ($this->medium !== null) |
690 { |
645 { |
691 return $this->medium; |
646 return $this->medium; |
692 } |
647 } |
693 else |
648 |
694 { |
649 return null; |
695 return null; |
|
696 } |
|
697 } |
650 } |
698 |
651 |
699 /** |
652 /** |
700 * Get the player URL |
653 * Get the player URL |
701 * |
654 * |
706 { |
659 { |
707 if ($this->player !== null) |
660 if ($this->player !== null) |
708 { |
661 { |
709 return $this->player; |
662 return $this->player; |
710 } |
663 } |
711 else |
664 |
712 { |
665 return null; |
713 return null; |
|
714 } |
|
715 } |
666 } |
716 |
667 |
717 /** |
668 /** |
718 * Get a single rating |
669 * Get a single rating |
719 * |
670 * |
725 $ratings = $this->get_ratings(); |
676 $ratings = $this->get_ratings(); |
726 if (isset($ratings[$key])) |
677 if (isset($ratings[$key])) |
727 { |
678 { |
728 return $ratings[$key]; |
679 return $ratings[$key]; |
729 } |
680 } |
730 else |
681 |
731 { |
682 return null; |
732 return null; |
|
733 } |
|
734 } |
683 } |
735 |
684 |
736 /** |
685 /** |
737 * Get all ratings |
686 * Get all ratings |
738 * |
687 * |
742 { |
691 { |
743 if ($this->ratings !== null) |
692 if ($this->ratings !== null) |
744 { |
693 { |
745 return $this->ratings; |
694 return $this->ratings; |
746 } |
695 } |
747 else |
696 |
748 { |
697 return null; |
749 return null; |
|
750 } |
|
751 } |
698 } |
752 |
699 |
753 /** |
700 /** |
754 * Get a single restriction |
701 * Get a single restriction |
755 * |
702 * |
761 $restrictions = $this->get_restrictions(); |
708 $restrictions = $this->get_restrictions(); |
762 if (isset($restrictions[$key])) |
709 if (isset($restrictions[$key])) |
763 { |
710 { |
764 return $restrictions[$key]; |
711 return $restrictions[$key]; |
765 } |
712 } |
766 else |
713 |
767 { |
714 return null; |
768 return null; |
|
769 } |
|
770 } |
715 } |
771 |
716 |
772 /** |
717 /** |
773 * Get all restrictions |
718 * Get all restrictions |
774 * |
719 * |
778 { |
723 { |
779 if ($this->restrictions !== null) |
724 if ($this->restrictions !== null) |
780 { |
725 { |
781 return $this->restrictions; |
726 return $this->restrictions; |
782 } |
727 } |
783 else |
728 |
784 { |
729 return null; |
785 return null; |
|
786 } |
|
787 } |
730 } |
788 |
731 |
789 /** |
732 /** |
790 * Get the sampling rate (in kHz) |
733 * Get the sampling rate (in kHz) |
791 * |
734 * |
795 { |
738 { |
796 if ($this->samplingrate !== null) |
739 if ($this->samplingrate !== null) |
797 { |
740 { |
798 return $this->samplingrate; |
741 return $this->samplingrate; |
799 } |
742 } |
800 else |
743 |
801 { |
744 return null; |
802 return null; |
|
803 } |
|
804 } |
745 } |
805 |
746 |
806 /** |
747 /** |
807 * Get the file size (in MiB) |
748 * Get the file size (in MiB) |
808 * |
749 * |
813 $length = $this->get_length(); |
754 $length = $this->get_length(); |
814 if ($length !== null) |
755 if ($length !== null) |
815 { |
756 { |
816 return round($length/1048576, 2); |
757 return round($length/1048576, 2); |
817 } |
758 } |
818 else |
759 |
819 { |
760 return null; |
820 return null; |
|
821 } |
|
822 } |
761 } |
823 |
762 |
824 /** |
763 /** |
825 * Get a single thumbnail |
764 * Get a single thumbnail |
826 * |
765 * |
832 $thumbnails = $this->get_thumbnails(); |
771 $thumbnails = $this->get_thumbnails(); |
833 if (isset($thumbnails[$key])) |
772 if (isset($thumbnails[$key])) |
834 { |
773 { |
835 return $thumbnails[$key]; |
774 return $thumbnails[$key]; |
836 } |
775 } |
837 else |
776 |
838 { |
777 return null; |
839 return null; |
|
840 } |
|
841 } |
778 } |
842 |
779 |
843 /** |
780 /** |
844 * Get all thumbnails |
781 * Get all thumbnails |
845 * |
782 * |
849 { |
786 { |
850 if ($this->thumbnails !== null) |
787 if ($this->thumbnails !== null) |
851 { |
788 { |
852 return $this->thumbnails; |
789 return $this->thumbnails; |
853 } |
790 } |
854 else |
791 |
855 { |
792 return null; |
856 return null; |
|
857 } |
|
858 } |
793 } |
859 |
794 |
860 /** |
795 /** |
861 * Get the title |
796 * Get the title |
862 * |
797 * |
866 { |
801 { |
867 if ($this->title !== null) |
802 if ($this->title !== null) |
868 { |
803 { |
869 return $this->title; |
804 return $this->title; |
870 } |
805 } |
871 else |
806 |
872 { |
807 return null; |
873 return null; |
|
874 } |
|
875 } |
808 } |
876 |
809 |
877 /** |
810 /** |
878 * Get mimetype of the enclosure |
811 * Get mimetype of the enclosure |
879 * |
812 * |
884 { |
817 { |
885 if ($this->type !== null) |
818 if ($this->type !== null) |
886 { |
819 { |
887 return $this->type; |
820 return $this->type; |
888 } |
821 } |
889 else |
822 |
890 { |
823 return null; |
891 return null; |
|
892 } |
|
893 } |
824 } |
894 |
825 |
895 /** |
826 /** |
896 * Get the width |
827 * Get the width |
897 * |
828 * |
901 { |
832 { |
902 if ($this->width !== null) |
833 if ($this->width !== null) |
903 { |
834 { |
904 return $this->width; |
835 return $this->width; |
905 } |
836 } |
906 else |
837 |
907 { |
838 return null; |
908 return null; |
|
909 } |
|
910 } |
839 } |
911 |
840 |
912 /** |
841 /** |
913 * Embed the enclosure using `<embed>` |
842 * Embed the enclosure using `<embed>` |
914 * |
843 * |
940 * - `bgcolor` (string): The background color for the media, if not |
869 * - `bgcolor` (string): The background color for the media, if not |
941 * already transparent. Defaults to `#ffffff`. |
870 * already transparent. Defaults to `#ffffff`. |
942 * - `height` (integer): The height of the embedded media. Accepts any |
871 * - `height` (integer): The height of the embedded media. Accepts any |
943 * numeric pixel value (such as `360`) or `auto`. Defaults to `auto`, |
872 * numeric pixel value (such as `360`) or `auto`. Defaults to `auto`, |
944 * and it is recommended that you use this default. |
873 * and it is recommended that you use this default. |
945 * - `loop` (boolean): Do you want the media to loop when its done? |
874 * - `loop` (boolean): Do you want the media to loop when it's done? |
946 * Defaults to `false`. |
875 * Defaults to `false`. |
947 * - `mediaplayer` (string): The location of the included |
876 * - `mediaplayer` (string): The location of the included |
948 * `mediaplayer.swf` file. This allows for the playback of Flash Video |
877 * `mediaplayer.swf` file. This allows for the playback of Flash Video |
949 * (`.flv`) files, and is the default handler for non-Odeo MP3's. |
878 * (`.flv`) files, and is the default handler for non-Odeo MP3's. |
950 * Defaults to blank. |
879 * Defaults to blank. |
1364 } |
1293 } |
1365 elseif (in_array($type, $types_mp3)) |
1294 elseif (in_array($type, $types_mp3)) |
1366 { |
1295 { |
1367 return 'mp3'; |
1296 return 'mp3'; |
1368 } |
1297 } |
1369 else |
1298 |
1370 { |
1299 return null; |
1371 return null; |
1300 } |
1372 } |
1301 |
1373 } |
1302 return $type; |
1374 else |
|
1375 { |
|
1376 return $type; |
|
1377 } |
|
1378 } |
1303 } |
1379 } |
1304 } |
1380 |