1 Author: Roland Mas <lolando@debian.org>
2 Description: Use SimplePie as provided by the libphp-simplepie Debian package
3 Index: src/common/widget/Widget_Rss.class.php
4 ===================================================================
5 --- src.orig/common/widget/Widget_Rss.class.php
6 +++ src/common/widget/Widget_Rss.class.php
8 return idn_to_unicode($param);
11 - require_once 'common/rss/simplepie.inc';
12 + require_once '/usr/share/php/simplepie/simplepie.inc';
13 if (!is_dir(forge_get_config('data_path') .'/rss')) {
14 mkdir(forge_get_config('data_path') .'/rss');
17 $vTitle = new Valid_String('title');
19 if (!$request->validInArray('rss', $vTitle)) {
20 - if (function_exists('idn_to_utf8()')) {
21 - require_once 'simplepie/simplepie.inc';
24 - require_once 'common/rss/simplepie.inc';
26 + require_once '/usr/share/php/simplepie/simplepie.inc';
27 if (!is_dir(forge_get_config('data_path') .'/rss')) {
28 mkdir(forge_get_config('data_path') .'/rss');
30 Index: src/common/rss/simplepie.inc
31 ===================================================================
32 --- src.orig/common/rss/simplepie.inc
39 - * A PHP-Based RSS and Atom Feed Framework.
40 - * Takes the hard work out of managing a complete RSS/Atom solution.
42 - * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
43 - * All rights reserved.
45 - * Redistribution and use in source and binary forms, with or without modification, are
46 - * permitted provided that the following conditions are met:
48 - * * Redistributions of source code must retain the above copyright notice, this list of
49 - * conditions and the following disclaimer.
51 - * * Redistributions in binary form must reproduce the above copyright notice, this list
52 - * of conditions and the following disclaimer in the documentation and/or other materials
53 - * provided with the distribution.
55 - * * Neither the name of the SimplePie Team nor the names of its contributors may be used
56 - * to endorse or promote products derived from this software without specific prior
57 - * written permission.
59 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
60 - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
61 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
62 - * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
64 - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65 - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
66 - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67 - * POSSIBILITY OF SUCH DAMAGE.
69 - * @package SimplePie
71 - * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon
72 - * @author Ryan Parman
73 - * @author Geoffrey Sneddon
74 - * @link http://simplepie.org/ SimplePie
75 - * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
76 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
77 - * @todo phpDoc comments
83 -define('SIMPLEPIE_NAME', 'SimplePie');
88 -define('SIMPLEPIE_VERSION', '1.1.3');
93 -define('SIMPLEPIE_BUILD', 20081219);
96 - * SimplePie Website URL
98 -define('SIMPLEPIE_URL', 'http://simplepie.org');
101 - * SimplePie Useragent
102 - * @see SimplePie::set_useragent()
104 -define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
107 - * SimplePie Linkback
109 -define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
113 - * @see SimplePie::set_autodiscovery_level()
115 -define('SIMPLEPIE_LOCATOR_NONE', 0);
118 - * Feed Link Element Autodiscovery
119 - * @see SimplePie::set_autodiscovery_level()
121 -define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
124 - * Local Feed Extension Autodiscovery
125 - * @see SimplePie::set_autodiscovery_level()
127 -define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
130 - * Local Feed Body Autodiscovery
131 - * @see SimplePie::set_autodiscovery_level()
133 -define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
136 - * Remote Feed Extension Autodiscovery
137 - * @see SimplePie::set_autodiscovery_level()
139 -define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
142 - * Remote Feed Body Autodiscovery
143 - * @see SimplePie::set_autodiscovery_level()
145 -define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
148 - * All Feed Autodiscovery
149 - * @see SimplePie::set_autodiscovery_level()
151 -define('SIMPLEPIE_LOCATOR_ALL', 31);
154 - * No known feed type
156 -define('SIMPLEPIE_TYPE_NONE', 0);
161 -define('SIMPLEPIE_TYPE_RSS_090', 1);
164 - * RSS 0.91 (Netscape)
166 -define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
169 - * RSS 0.91 (Userland)
171 -define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
174 - * RSS 0.91 (both Netscape and Userland)
176 -define('SIMPLEPIE_TYPE_RSS_091', 6);
181 -define('SIMPLEPIE_TYPE_RSS_092', 8);
186 -define('SIMPLEPIE_TYPE_RSS_093', 16);
191 -define('SIMPLEPIE_TYPE_RSS_094', 32);
196 -define('SIMPLEPIE_TYPE_RSS_10', 64);
201 -define('SIMPLEPIE_TYPE_RSS_20', 128);
206 -define('SIMPLEPIE_TYPE_RSS_RDF', 65);
209 - * Non-RDF-based RSS (truly intended as syndication format)
211 -define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
216 -define('SIMPLEPIE_TYPE_RSS_ALL', 255);
221 -define('SIMPLEPIE_TYPE_ATOM_03', 256);
226 -define('SIMPLEPIE_TYPE_ATOM_10', 512);
231 -define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
236 -define('SIMPLEPIE_TYPE_ALL', 1023);
241 -define('SIMPLEPIE_CONSTRUCT_NONE', 0);
246 -define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
251 -define('SIMPLEPIE_CONSTRUCT_HTML', 2);
256 -define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
259 - * base64-encoded construct
261 -define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
266 -define('SIMPLEPIE_CONSTRUCT_IRI', 16);
269 - * A construct that might be HTML
271 -define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
276 -define('SIMPLEPIE_CONSTRUCT_ALL', 63);
279 - * PCRE for HTML attributes
281 -define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
284 - * PCRE for XML attributes
286 -define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
291 -define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
294 - * Atom 1.0 Namespace
296 -define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
299 - * Atom 0.3 Namespace
301 -define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
306 -define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
309 - * RSS 0.90 Namespace
311 -define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
314 - * RSS 1.0 Namespace
316 -define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
319 - * RSS 1.0 Content Module Namespace
321 -define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
324 - * RSS 2.0 Namespace
325 - * (Stupid, I know, but I'm certain it will confuse people less with support.)
327 -define('SIMPLEPIE_NAMESPACE_RSS_20', '');
332 -define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
337 -define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
340 - * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
342 -define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
347 -define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
350 - * Media RSS Namespace
352 -define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
355 - * Wrong Media RSS Namespace
357 -define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
360 - * iTunes RSS Namespace
362 -define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
367 -define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
370 - * IANA Link Relations Registry
372 -define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
375 - * Whether we're running on PHP5
377 -define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
382 -define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
385 - * Remote file source
387 -define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
390 - * Local file source
392 -define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
395 - * fsockopen() file source
397 -define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
402 -define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
405 - * file_get_contents() file source
407 -define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
412 - * @package SimplePie
413 - * @version "Razzleberry"
414 - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
415 - * @author Ryan Parman
416 - * @author Geoffrey Sneddon
417 - * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
422 - * @var array Raw data
425 - var $data = array();
428 - * @var mixed Error string
434 - * @var object Instance of SimplePie_Sanitize (or other class)
435 - * @see SimplePie::set_sanitize_class()
441 - * @var string SimplePie Useragent
442 - * @see SimplePie::set_useragent()
445 - var $useragent = SIMPLEPIE_USERAGENT;
448 - * @var string Feed URL
449 - * @see SimplePie::set_feed_url()
455 - * @var object Instance of SimplePie_File to use as a feed
456 - * @see SimplePie::set_file()
462 - * @var string Raw feed data
463 - * @see SimplePie::set_raw_data()
469 - * @var int Timeout for fetching remote files
470 - * @see SimplePie::set_timeout()
476 - * @var bool Forces fsockopen() to be used for remote files instead
477 - * of cURL, even if a new enough version is installed
478 - * @see SimplePie::force_fsockopen()
481 - var $force_fsockopen = false;
484 - * @var bool Force the given data/URL to be treated as a feed no matter what
486 - * @see SimplePie::force_feed()
489 - var $force_feed = false;
492 - * @var bool Enable/Disable XML dump
493 - * @see SimplePie::enable_xml_dump()
496 - var $xml_dump = false;
499 - * @var bool Enable/Disable Caching
500 - * @see SimplePie::enable_cache()
506 - * @var int Cache duration (in seconds)
507 - * @see SimplePie::set_cache_duration()
510 - var $cache_duration = 3600;
513 - * @var int Auto-discovery cache duration (in seconds)
514 - * @see SimplePie::set_autodiscovery_cache_duration()
517 - var $autodiscovery_cache_duration = 604800; // 7 Days.
520 - * @var string Cache location (relative to executing script)
521 - * @see SimplePie::set_cache_location()
524 - var $cache_location = './cache';
527 - * @var string Function that creates the cache filename
528 - * @see SimplePie::set_cache_name_function()
531 - var $cache_name_function = 'md5';
534 - * @var bool Reorder feed by date descending
535 - * @see SimplePie::enable_order_by_date()
538 - var $order_by_date = true;
541 - * @var mixed Force input encoding to be set to the follow value
542 - * (false, or anything type-cast to false, disables this feature)
543 - * @see SimplePie::set_input_encoding()
546 - var $input_encoding = false;
549 - * @var int Feed Autodiscovery Level
550 - * @see SimplePie::set_autodiscovery_level()
553 - var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
556 - * @var string Class used for caching feeds
557 - * @see SimplePie::set_cache_class()
560 - var $cache_class = 'SimplePie_Cache';
563 - * @var string Class used for locating feeds
564 - * @see SimplePie::set_locator_class()
567 - var $locator_class = 'SimplePie_Locator';
570 - * @var string Class used for parsing feeds
571 - * @see SimplePie::set_parser_class()
574 - var $parser_class = 'SimplePie_Parser';
577 - * @var string Class used for fetching feeds
578 - * @see SimplePie::set_file_class()
581 - var $file_class = 'SimplePie_File';
584 - * @var string Class used for items
585 - * @see SimplePie::set_item_class()
588 - var $item_class = 'SimplePie_Item';
591 - * @var string Class used for authors
592 - * @see SimplePie::set_author_class()
595 - var $author_class = 'SimplePie_Author';
598 - * @var string Class used for categories
599 - * @see SimplePie::set_category_class()
602 - var $category_class = 'SimplePie_Category';
605 - * @var string Class used for enclosures
606 - * @see SimplePie::set_enclosures_class()
609 - var $enclosure_class = 'SimplePie_Enclosure';
612 - * @var string Class used for Media RSS <media:text> captions
613 - * @see SimplePie::set_caption_class()
616 - var $caption_class = 'SimplePie_Caption';
619 - * @var string Class used for Media RSS <media:copyright>
620 - * @see SimplePie::set_copyright_class()
623 - var $copyright_class = 'SimplePie_Copyright';
626 - * @var string Class used for Media RSS <media:credit>
627 - * @see SimplePie::set_credit_class()
630 - var $credit_class = 'SimplePie_Credit';
633 - * @var string Class used for Media RSS <media:rating>
634 - * @see SimplePie::set_rating_class()
637 - var $rating_class = 'SimplePie_Rating';
640 - * @var string Class used for Media RSS <media:restriction>
641 - * @see SimplePie::set_restriction_class()
644 - var $restriction_class = 'SimplePie_Restriction';
647 - * @var string Class used for content-type sniffing
648 - * @see SimplePie::set_content_type_sniffer_class()
651 - var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
654 - * @var string Class used for item sources.
655 - * @see SimplePie::set_source_class()
658 - var $source_class = 'SimplePie_Source';
661 - * @var mixed Set javascript query string parameter (false, or
662 - * anything type-cast to false, disables this feature)
663 - * @see SimplePie::set_javascript()
666 - var $javascript = 'js';
669 - * @var int Maximum number of feeds to check with autodiscovery
670 - * @see SimplePie::set_max_checked_feeds()
673 - var $max_checked_feeds = 10;
676 - * @var string Web-accessible path to the handler_favicon.php file.
677 - * @see SimplePie::set_favicon_handler()
680 - var $favicon_handler = '';
683 - * @var string Web-accessible path to the handler_image.php file.
684 - * @see SimplePie::set_image_handler()
687 - var $image_handler = '';
690 - * @var array Stores the URLs when multiple feeds are being initialized.
691 - * @see SimplePie::set_feed_url()
694 - var $multifeed_url = array();
697 - * @var array Stores SimplePie objects when multiple feeds initialized.
700 - var $multifeed_objects = array();
703 - * @var array Stores the get_object_vars() array for use with multifeeds.
704 - * @see SimplePie::set_feed_url()
707 - var $config_settings = null;
710 - * @var integer Stores the number of items to return per-feed with multifeeds.
711 - * @see SimplePie::set_item_limit()
714 - var $item_limit = 0;
717 - * @var array Stores the default attributes to be stripped by strip_attributes().
718 - * @see SimplePie::strip_attributes()
721 - var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
724 - * @var array Stores the default tags to be stripped by strip_htmltags().
725 - * @see SimplePie::strip_htmltags()
728 - var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
731 - * @var string proxy used to fetch feeds
732 - * @see SimplePie::set_proxy()
738 - * The SimplePie class contains feed level data and options
740 - * There are two ways that you can create a new SimplePie object. The first
741 - * is by passing a feed URL as a parameter to the SimplePie constructor
742 - * (as well as optionally setting the cache location and cache expiry). This
743 - * will initialise the whole feed with all of the default settings, and you
744 - * can begin accessing methods and properties immediately.
746 - * The second way is to create the SimplePie object with no parameters
747 - * at all. This will enable you to set configuration options. After setting
748 - * them, you must initialise the feed using $feed->init(). At that point the
749 - * object's methods and properties will be available to you. This format is
750 - * what is used throughout this documentation.
753 - * @since 1.0 Preview Release
754 - * @param string $feed_url This is the URL you want to parse.
755 - * @param string $cache_location This is where you want the cache to be stored.
756 - * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
757 - * @param string $proxy This is the proxy "host:port" used to fetch feeds
759 - function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null, $proxy = null)
761 - // Other objects, instances created here so we can set options on them
762 - $this->sanitize = new SimplePie_Sanitize;
764 - // Set options if they're passed to the constructor
765 - if ($cache_location !== null)
767 - $this->set_cache_location($cache_location);
770 - if ($cache_duration !== null)
772 - $this->set_cache_duration($cache_duration);
775 - if ($proxy !== null)
777 - $this->set_proxy($proxy);
780 - // Only init the script if we're passed a feed URL
781 - if ($feed_url !== null)
783 - $this->set_feed_url($feed_url);
789 - * Used for converting object to a string
791 - function __toString()
793 - return md5(serialize($this->data));
797 - * Remove items that link back to this before destroying this object
799 - function __destruct()
801 - if (!empty($this->data['items']))
803 - foreach ($this->data['items'] as $item)
805 - $item->__destruct();
807 - unset($this->data['items']);
809 - if (!empty($this->data['ordered_items']))
811 - foreach ($this->data['ordered_items'] as $item)
813 - $item->__destruct();
815 - unset($this->data['ordered_items']);
820 - * Force the given data/URL to be treated as a feed no matter what it
825 - * @param bool $enable Force the given data/URL to be treated as a feed
827 - function force_feed($enable = false)
829 - $this->force_feed = (bool) $enable;
833 - * This is the URL of the feed you want to parse.
835 - * This allows you to enter the URL of the feed you want to parse, or the
836 - * website you want to try to use auto-discovery on. This takes priority
837 - * over any set raw data.
839 - * You can set multiple feeds to mash together by passing an array instead
840 - * of a string for the $url. Remember that with each additional feed comes
841 - * additional processing and resources.
844 - * @since 1.0 Preview Release
845 - * @param mixed $url This is the URL (or array of URLs) that you want to parse.
846 - * @see SimplePie::set_raw_data()
848 - function set_feed_url($url)
850 - if (is_array($url))
852 - $this->multifeed_url = array();
853 - foreach ($url as $value)
855 - $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
860 - $this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
865 - * This is the proxy used to fetch feeds
868 - * @param string $proxy This is the URL of the proxy "host:port"
870 - function set_proxy($proxy)
872 - $this->proxy = $proxy;
873 - $this->sanitize->proxy = $proxy;
877 - * Provides an instance of SimplePie_File to use as a feed
880 - * @param object &$file Instance of SimplePie_File (or subclass)
881 - * @return bool True on success, false on failure
883 - function set_file(&$file)
885 - if (is_a($file, 'SimplePie_File'))
887 - $this->feed_url = $file->url;
888 - $this->file =& $file;
895 - * Allows you to use a string of RSS/Atom data instead of a remote feed.
897 - * If you have a feed available as a string in PHP, you can tell SimplePie
898 - * to parse that data string instead of a remote feed. Any set feed URL
899 - * takes precedence.
902 - * @since 1.0 Beta 3
903 - * @param string $data RSS or Atom data as a string.
904 - * @see SimplePie::set_feed_url()
906 - function set_raw_data($data)
908 - $this->raw_data = $data;
912 - * Allows you to override the default timeout for fetching remote feeds.
914 - * This allows you to change the maximum time the feed's server to respond
915 - * and send the feed back.
918 - * @since 1.0 Beta 3
919 - * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
921 - function set_timeout($timeout = 10)
923 - $this->timeout = (int) $timeout;
927 - * Forces SimplePie to use fsockopen() instead of the preferred cURL
931 - * @since 1.0 Beta 3
932 - * @param bool $enable Force fsockopen() to be used
934 - function force_fsockopen($enable = false)
936 - $this->force_fsockopen = (bool) $enable;
940 - * Outputs the raw XML content of the feed, after it has gone through
941 - * SimplePie's filters.
943 - * Used only for debugging, this function will output the XML content as
944 - * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
945 - * before trying to parse it. Many parts of the feed are re-written in
946 - * memory, and in the end, you have a parsable feed. XML dump shows you the
947 - * actual XML that SimplePie tries to parse, which may or may not be very
948 - * different from the original feed.
951 - * @since 1.0 Preview Release
952 - * @param bool $enable Enable XML dump
954 - function enable_xml_dump($enable = false)
956 - $this->xml_dump = (bool) $enable;
960 - * Enables/disables caching in SimplePie.
962 - * This option allows you to disable caching all-together in SimplePie.
963 - * However, disabling the cache can lead to longer load times.
966 - * @since 1.0 Preview Release
967 - * @param bool $enable Enable caching
969 - function enable_cache($enable = true)
971 - $this->cache = (bool) $enable;
975 - * Set the length of time (in seconds) that the contents of a feed
979 - * @param int $seconds The feed content cache duration.
981 - function set_cache_duration($seconds = 3600)
983 - $this->cache_duration = (int) $seconds;
987 - * Set the length of time (in seconds) that the autodiscovered feed
988 - * URL will be cached.
991 - * @param int $seconds The autodiscovered feed URL cache duration.
993 - function set_autodiscovery_cache_duration($seconds = 604800)
995 - $this->autodiscovery_cache_duration = (int) $seconds;
999 - * Set the file system location where the cached files should be stored.
1002 - * @param string $location The file system location.
1004 - function set_cache_location($location = './cache')
1006 - $this->cache_location = (string) $location;
1010 - * Determines whether feed items should be sorted into reverse chronological order.
1013 - * @param bool $enable Sort as reverse chronological order.
1015 - function enable_order_by_date($enable = true)
1017 - $this->order_by_date = (bool) $enable;
1021 - * Allows you to override the character encoding reported by the feed.
1024 - * @param string $encoding Character encoding.
1026 - function set_input_encoding($encoding = false)
1030 - $this->input_encoding = (string) $encoding;
1034 - $this->input_encoding = false;
1039 - * Set how much feed autodiscovery to do
1042 - * @see SIMPLEPIE_LOCATOR_NONE
1043 - * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
1044 - * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
1045 - * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
1046 - * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
1047 - * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
1048 - * @see SIMPLEPIE_LOCATOR_ALL
1049 - * @param int $level Feed Autodiscovery Level (level can be a
1050 - * combination of the above constants, see bitwise OR operator)
1052 - function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
1054 - $this->autodiscovery = (int) $level;
1058 - * Allows you to change which class SimplePie uses for caching.
1059 - * Useful when you are overloading or extending SimplePie's default classes.
1062 - * @param string $class Name of custom class.
1063 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1064 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1066 - function set_cache_class($class = 'SimplePie_Cache')
1068 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
1070 - $this->cache_class = $class;
1077 - * Allows you to change which class SimplePie uses for auto-discovery.
1078 - * Useful when you are overloading or extending SimplePie's default classes.
1081 - * @param string $class Name of custom class.
1082 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1083 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1085 - function set_locator_class($class = 'SimplePie_Locator')
1087 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
1089 - $this->locator_class = $class;
1096 - * Allows you to change which class SimplePie uses for XML parsing.
1097 - * Useful when you are overloading or extending SimplePie's default classes.
1100 - * @param string $class Name of custom class.
1101 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1102 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1104 - function set_parser_class($class = 'SimplePie_Parser')
1106 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
1108 - $this->parser_class = $class;
1115 - * Allows you to change which class SimplePie uses for remote file fetching.
1116 - * Useful when you are overloading or extending SimplePie's default classes.
1119 - * @param string $class Name of custom class.
1120 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1121 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1123 - function set_file_class($class = 'SimplePie_File')
1125 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
1127 - $this->file_class = $class;
1134 - * Allows you to change which class SimplePie uses for data sanitization.
1135 - * Useful when you are overloading or extending SimplePie's default classes.
1138 - * @param string $class Name of custom class.
1139 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1140 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1142 - function set_sanitize_class($class = 'SimplePie_Sanitize')
1144 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
1146 - $this->sanitize = new $class;
1147 - $this->sanitize->proxy = $this->proxy;
1154 - * Allows you to change which class SimplePie uses for handling feed items.
1155 - * Useful when you are overloading or extending SimplePie's default classes.
1158 - * @param string $class Name of custom class.
1159 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1160 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1162 - function set_item_class($class = 'SimplePie_Item')
1164 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
1166 - $this->item_class = $class;
1173 - * Allows you to change which class SimplePie uses for handling author data.
1174 - * Useful when you are overloading or extending SimplePie's default classes.
1177 - * @param string $class Name of custom class.
1178 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1179 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1181 - function set_author_class($class = 'SimplePie_Author')
1183 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
1185 - $this->author_class = $class;
1192 - * Allows you to change which class SimplePie uses for handling category data.
1193 - * Useful when you are overloading or extending SimplePie's default classes.
1196 - * @param string $class Name of custom class.
1197 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1198 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1200 - function set_category_class($class = 'SimplePie_Category')
1202 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
1204 - $this->category_class = $class;
1211 - * Allows you to change which class SimplePie uses for feed enclosures.
1212 - * Useful when you are overloading or extending SimplePie's default classes.
1215 - * @param string $class Name of custom class.
1216 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1217 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1219 - function set_enclosure_class($class = 'SimplePie_Enclosure')
1221 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
1223 - $this->enclosure_class = $class;
1230 - * Allows you to change which class SimplePie uses for <media:text> captions
1231 - * Useful when you are overloading or extending SimplePie's default classes.
1234 - * @param string $class Name of custom class.
1235 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1236 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1238 - function set_caption_class($class = 'SimplePie_Caption')
1240 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
1242 - $this->caption_class = $class;
1249 - * Allows you to change which class SimplePie uses for <media:copyright>
1250 - * Useful when you are overloading or extending SimplePie's default classes.
1253 - * @param string $class Name of custom class.
1254 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1255 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1257 - function set_copyright_class($class = 'SimplePie_Copyright')
1259 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
1261 - $this->copyright_class = $class;
1268 - * Allows you to change which class SimplePie uses for <media:credit>
1269 - * Useful when you are overloading or extending SimplePie's default classes.
1272 - * @param string $class Name of custom class.
1273 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1274 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1276 - function set_credit_class($class = 'SimplePie_Credit')
1278 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
1280 - $this->credit_class = $class;
1287 - * Allows you to change which class SimplePie uses for <media:rating>
1288 - * Useful when you are overloading or extending SimplePie's default classes.
1291 - * @param string $class Name of custom class.
1292 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1293 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1295 - function set_rating_class($class = 'SimplePie_Rating')
1297 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
1299 - $this->rating_class = $class;
1306 - * Allows you to change which class SimplePie uses for <media:restriction>
1307 - * Useful when you are overloading or extending SimplePie's default classes.
1310 - * @param string $class Name of custom class.
1311 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1312 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1314 - function set_restriction_class($class = 'SimplePie_Restriction')
1316 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
1318 - $this->restriction_class = $class;
1325 - * Allows you to change which class SimplePie uses for content-type sniffing.
1326 - * Useful when you are overloading or extending SimplePie's default classes.
1329 - * @param string $class Name of custom class.
1330 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1331 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1333 - function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
1335 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
1337 - $this->content_type_sniffer_class = $class;
1344 - * Allows you to change which class SimplePie uses item sources.
1345 - * Useful when you are overloading or extending SimplePie's default classes.
1348 - * @param string $class Name of custom class.
1349 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1350 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1352 - function set_source_class($class = 'SimplePie_Source')
1354 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
1356 - $this->source_class = $class;
1363 - * Allows you to override the default user agent string.
1366 - * @param string $ua New user agent string.
1368 - function set_useragent($ua = SIMPLEPIE_USERAGENT)
1370 - $this->useragent = (string) $ua;
1374 - * Set callback function to create cache filename with
1377 - * @param mixed $function Callback function
1379 - function set_cache_name_function($function = 'md5')
1381 - if (is_callable($function))
1383 - $this->cache_name_function = $function;
1388 - * Set javascript query string parameter
1391 - * @param mixed $get Javascript query string parameter
1393 - function set_javascript($get = 'js')
1397 - $this->javascript = (string) $get;
1401 - $this->javascript = false;
1406 - * Set options to make SP as fast as possible. Forgoes a
1407 - * substantial amount of data sanitization in favor of speed.
1410 - * @param bool $set Whether to set them or not
1412 - function set_stupidly_fast($set = false)
1416 - $this->enable_order_by_date(false);
1417 - $this->remove_div(false);
1418 - $this->strip_comments(false);
1419 - $this->strip_htmltags(false);
1420 - $this->strip_attributes(false);
1421 - $this->set_image_handler(false);
1426 - * Set maximum number of feeds to check with autodiscovery
1429 - * @param int $max Maximum number of feeds to check
1431 - function set_max_checked_feeds($max = 10)
1433 - $this->max_checked_feeds = (int) $max;
1436 - function remove_div($enable = true)
1438 - $this->sanitize->remove_div($enable);
1441 - function strip_htmltags($tags = '', $encode = null)
1445 - $tags = $this->strip_htmltags;
1447 - $this->sanitize->strip_htmltags($tags);
1448 - if ($encode !== null)
1450 - $this->sanitize->encode_instead_of_strip($tags);
1454 - function encode_instead_of_strip($enable = true)
1456 - $this->sanitize->encode_instead_of_strip($enable);
1459 - function strip_attributes($attribs = '')
1461 - if ($attribs === '')
1463 - $attribs = $this->strip_attributes;
1465 - $this->sanitize->strip_attributes($attribs);
1468 - function set_output_encoding($encoding = 'UTF-8')
1470 - $this->sanitize->set_output_encoding($encoding);
1473 - function strip_comments($strip = false)
1475 - $this->sanitize->strip_comments($strip);
1479 - * Set element/attribute key/value pairs of HTML attributes
1480 - * containing URLs that need to be resolved relative to the feed
1484 - * @param array $element_attribute Element/attribute key/value pairs
1486 - function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
1488 - $this->sanitize->set_url_replacements($element_attribute);
1492 - * Set the handler to enable the display of cached favicons.
1495 - * @param str $page Web-accessible path to the handler_favicon.php file.
1496 - * @param str $qs The query string that the value should be passed to.
1498 - function set_favicon_handler($page = false, $qs = 'i')
1500 - if ($page != false)
1502 - $this->favicon_handler = $page . '?' . $qs . '=';
1506 - $this->favicon_handler = '';
1511 - * Set the handler to enable the display of cached images.
1514 - * @param str $page Web-accessible path to the handler_image.php file.
1515 - * @param str $qs The query string that the value should be passed to.
1517 - function set_image_handler($page = false, $qs = 'i')
1519 - if ($page != false)
1521 - $this->sanitize->set_image_handler($page . '?' . $qs . '=');
1525 - $this->image_handler = '';
1530 - * Set the limit for items returned per-feed with multifeeds.
1533 - * @param integer $limit The maximum number of items to return.
1535 - function set_item_limit($limit = 0)
1537 - $this->item_limit = (int) $limit;
1542 - if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
1546 - if (isset($_GET[$this->javascript]))
1548 - if (function_exists('ob_gzhandler'))
1550 - ob_start('ob_gzhandler');
1552 - header('Content-type: text/javascript; charset: UTF-8');
1553 - header('Cache-Control: must-revalidate');
1554 - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
1556 -function embed_odeo(link) {
1557 - document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
1560 -function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
1561 - if (placeholder != '') {
1562 - document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
1565 - document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
1569 -function embed_flash(bgcolor, width, height, link, loop, type) {
1570 - document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
1573 -function embed_flv(width, height, link, placeholder, loop, player) {
1574 - document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
1577 -function embed_wmedia(width, height, link) {
1578 - document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
1584 - // Pass whatever was set with config options over to the sanitizer.
1585 - $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
1586 - $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
1588 - if ($this->feed_url !== null || $this->raw_data !== null)
1590 - $this->data = array();
1591 - $this->multifeed_objects = array();
1594 - if ($this->feed_url !== null)
1596 - $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
1597 - // Decide whether to enable caching
1598 - if ($this->cache && $parsed_feed_url['scheme'] !== '')
1600 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
1602 - // If it's enabled and we don't want an XML dump, use the cache
1603 - if ($cache && !$this->xml_dump)
1606 - $this->data = $cache->load();
1607 - if (!empty($this->data))
1609 - // If the cache is for an outdated build of SimplePie
1610 - if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
1613 - $this->data = array();
1615 - // If we've hit a collision just rerun it with caching disabled
1616 - elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
1619 - $this->data = array();
1621 - // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
1622 - elseif (isset($this->data['feed_url']))
1624 - // If the autodiscovery cache is still valid use it.
1625 - if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
1627 - // Do not need to do feed autodiscovery yet.
1628 - if ($this->data['feed_url'] == $this->data['url'])
1631 - $this->data = array();
1635 - $this->set_feed_url($this->data['feed_url']);
1636 - return $this->init();
1640 - // Check if the cache has been updated
1641 - elseif ($cache->mtime() + $this->cache_duration < time())
1643 - // If we have last-modified and/or etag set
1644 - if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
1646 - $headers = array();
1647 - if (isset($this->data['headers']['last-modified']))
1649 - $headers['if-modified-since'] = $this->data['headers']['last-modified'];
1651 - if (isset($this->data['headers']['etag']))
1653 - $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
1655 - $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->proxy);
1656 - if ($file->success)
1658 - if ($file->status_code == 304)
1665 - $headers = $file->headers;
1674 - // If the cache is still valid, just return true
1680 - // If the cache is empty, delete it
1684 - $this->data = array();
1687 - // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
1688 - if (!isset($file))
1690 - if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
1692 - $file =& $this->file;
1696 - $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->proxy);
1699 - // If the file connection has an error, set SimplePie::error to that and quit
1700 - if (!$file->success)
1702 - $this->error = $file->error;
1703 - if (!empty($this->data))
1713 - if (!$this->force_feed)
1715 - // Check if the supplied URL is a feed, if it isn't, look for it.
1716 - $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
1717 - if (!$locate->is_feed($file))
1719 - // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1721 - if ($file = $locate->find($this->autodiscovery))
1725 - $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
1726 - if (!$cache->save($this))
1728 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
1730 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
1732 - $this->feed_url = $file->url;
1736 - $this->error = "A feed could not be found at $this->feed_url";
1737 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1744 - $headers = $file->headers;
1745 - $data = $file->body;
1746 - $sniffer = new $this->content_type_sniffer_class($file);
1747 - $sniffed = $sniffer->get_type();
1751 - $data = $this->raw_data;
1754 - // Set up array of possible encodings
1755 - $encodings = array();
1757 - // First check to see if input has been overridden.
1758 - if ($this->input_encoding !== false)
1760 - $encodings[] = $this->input_encoding;
1763 - $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
1764 - $text_types = array('text/xml', 'text/xml-external-parsed-entity');
1766 - // RFC 3023 (only applies to sniffed content)
1767 - if (isset($sniffed))
1769 - if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
1771 - if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1773 - $encodings[] = strtoupper($charset[1]);
1775 - $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1776 - $encodings[] = 'UTF-8';
1778 - elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
1780 - if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1782 - $encodings[] = $charset[1];
1784 - $encodings[] = 'US-ASCII';
1786 - // Text MIME-type default
1787 - elseif (substr($sniffed, 0, 5) === 'text/')
1789 - $encodings[] = 'US-ASCII';
1793 - // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
1794 - $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1795 - $encodings[] = 'UTF-8';
1796 - $encodings[] = 'ISO-8859-1';
1798 - // There's no point in trying an encoding twice
1799 - $encodings = array_unique($encodings);
1801 - // If we want the XML, just output that with the most likely encoding and quit
1802 - if ($this->xml_dump)
1804 - header('Content-type: text/xml; charset=' . $encodings[0]);
1809 - // Loop through each possible encoding, till we return something, or run out of possibilities
1810 - foreach ($encodings as $encoding)
1812 - // Change the encoding to UTF-8 (as we always use UTF-8 internally)
1813 - if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
1815 - // Create new parser
1816 - $parser = new $this->parser_class();
1818 - // If it's parsed fine
1819 - if ($parser->parse($utf8_data, 'UTF-8'))
1821 - $this->data = $parser->get_data();
1822 - if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
1824 - if (isset($headers))
1826 - $this->data['headers'] = $headers;
1828 - $this->data['build'] = SIMPLEPIE_BUILD;
1830 - // Cache the file if caching is enabled
1831 - if ($cache && !$cache->save($this))
1833 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
1839 - $this->error = "A feed could not be found at $this->feed_url";
1840 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1846 - // We have an error, just set SimplePie::error to it and quit
1847 - $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
1848 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1851 - elseif (!empty($this->multifeed_url))
1855 - $this->multifeed_objects = array();
1856 - foreach ($this->multifeed_url as $url)
1858 - if (SIMPLEPIE_PHP5)
1860 - // This keyword needs to defy coding standards for PHP4 compatibility
1861 - $this->multifeed_objects[$i] = clone($this);
1865 - $this->multifeed_objects[$i] = $this;
1867 - $this->multifeed_objects[$i]->set_feed_url($url);
1868 - $success |= $this->multifeed_objects[$i]->init();
1871 - return (bool) $success;
1880 - * Return the error message for the occured error
1883 - * @return string Error message
1887 - return $this->error;
1890 - function get_encoding()
1892 - return $this->sanitize->output_encoding;
1895 - function handle_content_type($mime = 'text/html')
1897 - if (!headers_sent())
1899 - $header = "Content-type: $mime;";
1900 - if ($this->get_encoding())
1902 - $header .= ' charset=' . $this->get_encoding();
1906 - $header .= ' charset=UTF-8';
1912 - function get_type()
1914 - if (!isset($this->data['type']))
1916 - $this->data['type'] = SIMPLEPIE_TYPE_ALL;
1917 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
1919 - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
1921 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
1923 - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
1925 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
1927 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
1928 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
1929 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
1930 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
1932 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
1934 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
1935 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
1936 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
1937 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
1939 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
1942 - elseif (isset($this->data['child']['']['rss']))
1944 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
1945 - if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
1947 - switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
1950 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
1951 - if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1953 - switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1956 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
1960 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
1967 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
1971 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
1975 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
1979 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
1986 - $this->data['type'] = SIMPLEPIE_TYPE_NONE;
1989 - return $this->data['type'];
1993 - * Returns the URL for the favicon of the feed's website.
1995 - * @todo Cache atom:icon
1999 - function get_favicon()
2001 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
2003 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2005 - elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
2007 - $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
2009 - if ($this->cache && $this->favicon_handler)
2011 - $favicon_filename = call_user_func($this->cache_name_function, $favicon);
2012 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
2014 - if ($cache->load())
2016 - return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
2020 - $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen, $this->proxy);
2022 - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
2024 - $sniffer = new $this->content_type_sniffer_class($file);
2025 - if (substr($sniffer->get_type(), 0, 6) === 'image/')
2027 - if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
2029 - return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
2033 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
2034 - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2042 - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2049 - * @todo If we have a perm redirect we should return the new URL
2050 - * @todo When we make the above change, let's support <itunes:new-feed-url> as well
2051 - * @todo Also, |atom:link|@rel=self
2053 - function subscribe_url()
2055 - if ($this->feed_url !== null)
2057 - return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
2065 - function subscribe_feed()
2067 - if ($this->feed_url !== null)
2069 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2077 - function subscribe_outlook()
2079 - if ($this->feed_url !== null)
2081 - return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2089 - function subscribe_podcast()
2091 - if ($this->feed_url !== null)
2093 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
2101 - function subscribe_itunes()
2103 - if ($this->feed_url !== null)
2105 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
2114 - * Creates the subscribe_* methods' return data
2117 - * @param string $feed_url String to prefix to the feed URL
2118 - * @param string $site_url String to prefix to the site URL (and
2119 - * suffix to the feed URL)
2120 - * @return mixed URL if feed exists, false otherwise
2122 - function subscribe_service($feed_url, $site_url = null)
2124 - if ($this->subscribe_url())
2126 - $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
2127 - if ($site_url !== null && $this->get_link() !== null)
2129 - $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
2139 - function subscribe_aol()
2141 - return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
2144 - function subscribe_bloglines()
2146 - return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
2149 - function subscribe_eskobo()
2151 - return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
2154 - function subscribe_feedfeeds()
2156 - return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
2159 - function subscribe_feedster()
2161 - return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
2164 - function subscribe_google()
2166 - return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
2169 - function subscribe_gritwire()
2171 - return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
2174 - function subscribe_msn()
2176 - return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
2179 - function subscribe_netvibes()
2181 - return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
2184 - function subscribe_newsburst()
2186 - return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
2189 - function subscribe_newsgator()
2191 - return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
2194 - function subscribe_odeo()
2196 - return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
2199 - function subscribe_podnova()
2201 - return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
2204 - function subscribe_rojo()
2206 - return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
2209 - function subscribe_yahoo()
2211 - return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
2214 - function get_feed_tags($namespace, $tag)
2216 - $type = $this->get_type();
2217 - if ($type & SIMPLEPIE_TYPE_ATOM_10)
2219 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
2221 - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
2224 - if ($type & SIMPLEPIE_TYPE_ATOM_03)
2226 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
2228 - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
2231 - if ($type & SIMPLEPIE_TYPE_RSS_RDF)
2233 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
2235 - return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
2238 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2240 - if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
2242 - return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
2248 - function get_channel_tags($namespace, $tag)
2250 - $type = $this->get_type();
2251 - if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
2253 - if ($return = $this->get_feed_tags($namespace, $tag))
2258 - if ($type & SIMPLEPIE_TYPE_RSS_10)
2260 - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
2262 - if (isset($channel[0]['child'][$namespace][$tag]))
2264 - return $channel[0]['child'][$namespace][$tag];
2268 - if ($type & SIMPLEPIE_TYPE_RSS_090)
2270 - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
2272 - if (isset($channel[0]['child'][$namespace][$tag]))
2274 - return $channel[0]['child'][$namespace][$tag];
2278 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2280 - if ($channel = $this->get_feed_tags('', 'channel'))
2282 - if (isset($channel[0]['child'][$namespace][$tag]))
2284 - return $channel[0]['child'][$namespace][$tag];
2291 - function get_image_tags($namespace, $tag)
2293 - $type = $this->get_type();
2294 - if ($type & SIMPLEPIE_TYPE_RSS_10)
2296 - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
2298 - if (isset($image[0]['child'][$namespace][$tag]))
2300 - return $image[0]['child'][$namespace][$tag];
2304 - if ($type & SIMPLEPIE_TYPE_RSS_090)
2306 - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
2308 - if (isset($image[0]['child'][$namespace][$tag]))
2310 - return $image[0]['child'][$namespace][$tag];
2314 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2316 - if ($image = $this->get_channel_tags('', 'image'))
2318 - if (isset($image[0]['child'][$namespace][$tag]))
2320 - return $image[0]['child'][$namespace][$tag];
2327 - function get_base($element = array())
2329 - if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
2331 - return $element['xml_base'];
2333 - elseif ($this->get_link() !== null)
2335 - return $this->get_link();
2339 - return $this->subscribe_url();
2343 - function sanitize($data, $type, $base = '')
2345 - return $this->sanitize->sanitize($data, $type, $base);
2348 - function get_title()
2350 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
2352 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2354 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
2356 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2358 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2360 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2362 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2364 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2366 - elseif ($return = $this->get_channel_tags('', 'title'))
2368 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2370 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2372 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2374 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2376 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2384 - function get_category($key = 0)
2386 - $categories = $this->get_categories();
2387 - if (isset($categories[$key]))
2389 - return $categories[$key];
2397 - function get_categories()
2399 - $categories = array();
2401 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
2406 - if (isset($category['attribs']['']['term']))
2408 - $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
2410 - if (isset($category['attribs']['']['scheme']))
2412 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2414 - if (isset($category['attribs']['']['label']))
2416 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2418 - $categories[] = new $this->category_class($term, $scheme, $label);
2420 - foreach ((array) $this->get_channel_tags('', 'category') as $category)
2422 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2424 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2426 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2428 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
2430 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2433 - if (!empty($categories))
2435 - return SimplePie_Misc::array_unique($categories);
2443 - function get_author($key = 0)
2445 - $authors = $this->get_authors();
2446 - if (isset($authors[$key]))
2448 - return $authors[$key];
2456 - function get_authors()
2458 - $authors = array();
2459 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
2464 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2466 - $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2468 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2470 - $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]));
2472 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2474 - $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2476 - if ($name !== null || $email !== null || $uri !== null)
2478 - $authors[] = new $this->author_class($name, $uri, $email);
2481 - if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
2486 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2488 - $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2490 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2492 - $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]));
2494 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2496 - $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2498 - if ($name !== null || $email !== null || $url !== null)
2500 - $authors[] = new $this->author_class($name, $url, $email);
2503 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
2505 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2507 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
2509 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2511 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
2513 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2516 - if (!empty($authors))
2518 - return SimplePie_Misc::array_unique($authors);
2526 - function get_contributor($key = 0)
2528 - $contributors = $this->get_contributors();
2529 - if (isset($contributors[$key]))
2531 - return $contributors[$key];
2539 - function get_contributors()
2541 - $contributors = array();
2542 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
2547 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2549 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2551 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2553 - $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]));
2555 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2557 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2559 - if ($name !== null || $email !== null || $uri !== null)
2561 - $contributors[] = new $this->author_class($name, $uri, $email);
2564 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
2569 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2571 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2573 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2575 - $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]));
2577 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2579 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2581 - if ($name !== null || $email !== null || $url !== null)
2583 - $contributors[] = new $this->author_class($name, $url, $email);
2587 - if (!empty($contributors))
2589 - return SimplePie_Misc::array_unique($contributors);
2597 - function get_link($key = 0, $rel = 'alternate')
2599 - $links = $this->get_links($rel);
2600 - if (isset($links[$key]))
2602 - return $links[$key];
2611 - * Added for parity between the parent-level and the item/entry-level.
2613 - function get_permalink()
2615 - return $this->get_link(0);
2618 - function get_links($rel = 'alternate')
2620 - if (!isset($this->data['links']))
2622 - $this->data['links'] = array();
2623 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
2625 - foreach ($links as $link)
2627 - if (isset($link['attribs']['']['href']))
2629 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2630 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2634 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
2636 - foreach ($links as $link)
2638 - if (isset($link['attribs']['']['href']))
2640 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2641 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2646 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2648 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2650 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2652 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2654 - if ($links = $this->get_channel_tags('', 'link'))
2656 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2659 - $keys = array_keys($this->data['links']);
2660 - foreach ($keys as $key)
2662 - if (SimplePie_Misc::is_isegment_nz_nc($key))
2664 - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
2666 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
2667 - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
2671 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2674 - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2676 - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2678 - $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2682 - if (isset($this->data['links'][$rel]))
2684 - return $this->data['links'][$rel];
2692 - function get_description()
2694 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
2696 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2698 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
2700 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2702 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
2704 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2706 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
2708 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2710 - elseif ($return = $this->get_channel_tags('', 'description'))
2712 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2714 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
2716 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2718 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
2720 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2722 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
2724 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2726 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
2728 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
2736 - function get_copyright()
2738 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
2740 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2742 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
2744 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2746 - elseif ($return = $this->get_channel_tags('', 'copyright'))
2748 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2750 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
2752 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2754 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
2756 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2764 - function get_language()
2766 - if ($return = $this->get_channel_tags('', 'language'))
2768 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2770 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
2772 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2774 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
2776 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2778 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
2780 - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2782 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
2784 - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2786 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
2788 - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
2790 - elseif (isset($this->data['headers']['content-language']))
2792 - return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
2800 - function get_latitude()
2802 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
2804 - return (float) $return[0]['data'];
2806 - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
2808 - return (float) $match[1];
2816 - function get_longitude()
2818 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
2820 - return (float) $return[0]['data'];
2822 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
2824 - return (float) $return[0]['data'];
2826 - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
2828 - return (float) $match[2];
2836 - function get_image_title()
2838 - if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2840 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2842 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2844 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2846 - elseif ($return = $this->get_image_tags('', 'title'))
2848 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2850 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2852 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2854 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2856 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2864 - function get_image_url()
2866 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
2868 - return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
2870 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
2872 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2874 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
2876 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2878 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
2880 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2882 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
2884 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2886 - elseif ($return = $this->get_image_tags('', 'url'))
2888 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2896 - function get_image_link()
2898 - if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2900 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2902 - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2904 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2906 - elseif ($return = $this->get_image_tags('', 'link'))
2908 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
2916 - function get_image_width()
2918 - if ($return = $this->get_image_tags('', 'width'))
2920 - return round($return[0]['data']);
2922 - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
2932 - function get_image_height()
2934 - if ($return = $this->get_image_tags('', 'height'))
2936 - return round($return[0]['data']);
2938 - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url'))
2948 - function get_item_quantity($max = 0)
2950 - $qty = count($this->get_items());
2957 - return ($qty > $max) ? $max : $qty;
2961 - function get_item($key = 0)
2963 - $items = $this->get_items();
2964 - if (isset($items[$key]))
2966 - return $items[$key];
2974 - function get_items($start = 0, $end = 0)
2976 - if (!empty($this->multifeed_objects))
2978 - return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
2980 - elseif (!isset($this->data['items']))
2982 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
2984 - $keys = array_keys($items);
2985 - foreach ($keys as $key)
2987 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
2990 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
2992 - $keys = array_keys($items);
2993 - foreach ($keys as $key)
2995 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
2998 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
3000 - $keys = array_keys($items);
3001 - foreach ($keys as $key)
3003 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
3006 - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
3008 - $keys = array_keys($items);
3009 - foreach ($keys as $key)
3011 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
3014 - if ($items = $this->get_channel_tags('', 'item'))
3016 - $keys = array_keys($items);
3017 - foreach ($keys as $key)
3019 - $this->data['items'][] = new $this->item_class($this, $items[$key]);
3024 - if (!empty($this->data['items']))
3026 - // If we want to order it by date, check if all items have a date, and then sort it
3027 - if ($this->order_by_date)
3029 - if (!isset($this->data['ordered_items']))
3032 - foreach ($this->data['items'] as $item)
3034 - if (!$item->get_date('U'))
3041 - $this->data['ordered_items'] = $this->data['items'];
3044 - usort($this->data['ordered_items'], array(&$this, 'sort_items'));