1 Author: Roland Mas <lolando@debian.org>
2 Description: Use SimplePie as provided by the libphp-simplepie Debian package
3 --- src.orig/common/rss/simplepie.inc
10 - * A PHP-Based RSS and Atom Feed Framework.
11 - * Takes the hard work out of managing a complete RSS/Atom solution.
13 - * Copyright (c) 2004-2008, Ryan Parman and Geoffrey Sneddon
14 - * All rights reserved.
16 - * Redistribution and use in source and binary forms, with or without modification, are
17 - * permitted provided that the following conditions are met:
19 - * * Redistributions of source code must retain the above copyright notice, this list of
20 - * conditions and the following disclaimer.
22 - * * Redistributions in binary form must reproduce the above copyright notice, this list
23 - * of conditions and the following disclaimer in the documentation and/or other materials
24 - * provided with the distribution.
26 - * * Neither the name of the SimplePie Team nor the names of its contributors may be used
27 - * to endorse or promote products derived from this software without specific prior
28 - * written permission.
30 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
31 - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
32 - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
33 - * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37 - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 - * POSSIBILITY OF SUCH DAMAGE.
40 - * @package SimplePie
42 - * @copyright 2004-2008 Ryan Parman, Geoffrey Sneddon
43 - * @author Ryan Parman
44 - * @author Geoffrey Sneddon
45 - * @link http://simplepie.org/ SimplePie
46 - * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
47 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
48 - * @todo phpDoc comments
54 -define('SIMPLEPIE_NAME', 'SimplePie');
59 -define('SIMPLEPIE_VERSION', '1.1.3');
64 -define('SIMPLEPIE_BUILD', 20081219);
67 - * SimplePie Website URL
69 -define('SIMPLEPIE_URL', 'http://simplepie.org');
72 - * SimplePie Useragent
73 - * @see SimplePie::set_useragent()
75 -define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
78 - * SimplePie Linkback
80 -define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
84 - * @see SimplePie::set_autodiscovery_level()
86 -define('SIMPLEPIE_LOCATOR_NONE', 0);
89 - * Feed Link Element Autodiscovery
90 - * @see SimplePie::set_autodiscovery_level()
92 -define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
95 - * Local Feed Extension Autodiscovery
96 - * @see SimplePie::set_autodiscovery_level()
98 -define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
101 - * Local Feed Body Autodiscovery
102 - * @see SimplePie::set_autodiscovery_level()
104 -define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
107 - * Remote Feed Extension Autodiscovery
108 - * @see SimplePie::set_autodiscovery_level()
110 -define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
113 - * Remote Feed Body Autodiscovery
114 - * @see SimplePie::set_autodiscovery_level()
116 -define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
119 - * All Feed Autodiscovery
120 - * @see SimplePie::set_autodiscovery_level()
122 -define('SIMPLEPIE_LOCATOR_ALL', 31);
125 - * No known feed type
127 -define('SIMPLEPIE_TYPE_NONE', 0);
132 -define('SIMPLEPIE_TYPE_RSS_090', 1);
135 - * RSS 0.91 (Netscape)
137 -define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
140 - * RSS 0.91 (Userland)
142 -define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
145 - * RSS 0.91 (both Netscape and Userland)
147 -define('SIMPLEPIE_TYPE_RSS_091', 6);
152 -define('SIMPLEPIE_TYPE_RSS_092', 8);
157 -define('SIMPLEPIE_TYPE_RSS_093', 16);
162 -define('SIMPLEPIE_TYPE_RSS_094', 32);
167 -define('SIMPLEPIE_TYPE_RSS_10', 64);
172 -define('SIMPLEPIE_TYPE_RSS_20', 128);
177 -define('SIMPLEPIE_TYPE_RSS_RDF', 65);
180 - * Non-RDF-based RSS (truly intended as syndication format)
182 -define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
187 -define('SIMPLEPIE_TYPE_RSS_ALL', 255);
192 -define('SIMPLEPIE_TYPE_ATOM_03', 256);
197 -define('SIMPLEPIE_TYPE_ATOM_10', 512);
202 -define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
207 -define('SIMPLEPIE_TYPE_ALL', 1023);
212 -define('SIMPLEPIE_CONSTRUCT_NONE', 0);
217 -define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
222 -define('SIMPLEPIE_CONSTRUCT_HTML', 2);
227 -define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
230 - * base64-encoded construct
232 -define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
237 -define('SIMPLEPIE_CONSTRUCT_IRI', 16);
240 - * A construct that might be HTML
242 -define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
247 -define('SIMPLEPIE_CONSTRUCT_ALL', 63);
250 - * PCRE for HTML attributes
252 -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]*');
255 - * PCRE for XML attributes
257 -define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
262 -define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
265 - * Atom 1.0 Namespace
267 -define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
270 - * Atom 0.3 Namespace
272 -define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
277 -define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
280 - * RSS 0.90 Namespace
282 -define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
285 - * RSS 1.0 Namespace
287 -define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
290 - * RSS 1.0 Content Module Namespace
292 -define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
295 - * RSS 2.0 Namespace
296 - * (Stupid, I know, but I'm certain it will confuse people less with support.)
298 -define('SIMPLEPIE_NAMESPACE_RSS_20', '');
303 -define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
308 -define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
311 - * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
313 -define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
318 -define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
321 - * Media RSS Namespace
323 -define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
326 - * Wrong Media RSS Namespace
328 -define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
331 - * iTunes RSS Namespace
333 -define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
338 -define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
341 - * IANA Link Relations Registry
343 -define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
346 - * Whether we're running on PHP5
348 -define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
353 -define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
356 - * Remote file source
358 -define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
361 - * Local file source
363 -define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
366 - * fsockopen() file source
368 -define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
373 -define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
376 - * file_get_contents() file source
378 -define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
383 - * @package SimplePie
384 - * @version "Razzleberry"
385 - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon
386 - * @author Ryan Parman
387 - * @author Geoffrey Sneddon
388 - * @todo Option for type of fetching (cache, not modified header, fetch, etc.)
393 - * @var array Raw data
396 - var $data = array();
399 - * @var mixed Error string
405 - * @var object Instance of SimplePie_Sanitize (or other class)
406 - * @see SimplePie::set_sanitize_class()
412 - * @var string SimplePie Useragent
413 - * @see SimplePie::set_useragent()
416 - var $useragent = SIMPLEPIE_USERAGENT;
419 - * @var string Feed URL
420 - * @see SimplePie::set_feed_url()
426 - * @var object Instance of SimplePie_File to use as a feed
427 - * @see SimplePie::set_file()
433 - * @var string Raw feed data
434 - * @see SimplePie::set_raw_data()
440 - * @var int Timeout for fetching remote files
441 - * @see SimplePie::set_timeout()
447 - * @var bool Forces fsockopen() to be used for remote files instead
448 - * of cURL, even if a new enough version is installed
449 - * @see SimplePie::force_fsockopen()
452 - var $force_fsockopen = false;
455 - * @var bool Force the given data/URL to be treated as a feed no matter what
457 - * @see SimplePie::force_feed()
460 - var $force_feed = false;
463 - * @var bool Enable/Disable XML dump
464 - * @see SimplePie::enable_xml_dump()
467 - var $xml_dump = false;
470 - * @var bool Enable/Disable Caching
471 - * @see SimplePie::enable_cache()
477 - * @var int Cache duration (in seconds)
478 - * @see SimplePie::set_cache_duration()
481 - var $cache_duration = 3600;
484 - * @var int Auto-discovery cache duration (in seconds)
485 - * @see SimplePie::set_autodiscovery_cache_duration()
488 - var $autodiscovery_cache_duration = 604800; // 7 Days.
491 - * @var string Cache location (relative to executing script)
492 - * @see SimplePie::set_cache_location()
495 - var $cache_location = './cache';
498 - * @var string Function that creates the cache filename
499 - * @see SimplePie::set_cache_name_function()
502 - var $cache_name_function = 'md5';
505 - * @var bool Reorder feed by date descending
506 - * @see SimplePie::enable_order_by_date()
509 - var $order_by_date = true;
512 - * @var mixed Force input encoding to be set to the follow value
513 - * (false, or anything type-cast to false, disables this feature)
514 - * @see SimplePie::set_input_encoding()
517 - var $input_encoding = false;
520 - * @var int Feed Autodiscovery Level
521 - * @see SimplePie::set_autodiscovery_level()
524 - var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
527 - * @var string Class used for caching feeds
528 - * @see SimplePie::set_cache_class()
531 - var $cache_class = 'SimplePie_Cache';
534 - * @var string Class used for locating feeds
535 - * @see SimplePie::set_locator_class()
538 - var $locator_class = 'SimplePie_Locator';
541 - * @var string Class used for parsing feeds
542 - * @see SimplePie::set_parser_class()
545 - var $parser_class = 'SimplePie_Parser';
548 - * @var string Class used for fetching feeds
549 - * @see SimplePie::set_file_class()
552 - var $file_class = 'SimplePie_File';
555 - * @var string Class used for items
556 - * @see SimplePie::set_item_class()
559 - var $item_class = 'SimplePie_Item';
562 - * @var string Class used for authors
563 - * @see SimplePie::set_author_class()
566 - var $author_class = 'SimplePie_Author';
569 - * @var string Class used for categories
570 - * @see SimplePie::set_category_class()
573 - var $category_class = 'SimplePie_Category';
576 - * @var string Class used for enclosures
577 - * @see SimplePie::set_enclosures_class()
580 - var $enclosure_class = 'SimplePie_Enclosure';
583 - * @var string Class used for Media RSS <media:text> captions
584 - * @see SimplePie::set_caption_class()
587 - var $caption_class = 'SimplePie_Caption';
590 - * @var string Class used for Media RSS <media:copyright>
591 - * @see SimplePie::set_copyright_class()
594 - var $copyright_class = 'SimplePie_Copyright';
597 - * @var string Class used for Media RSS <media:credit>
598 - * @see SimplePie::set_credit_class()
601 - var $credit_class = 'SimplePie_Credit';
604 - * @var string Class used for Media RSS <media:rating>
605 - * @see SimplePie::set_rating_class()
608 - var $rating_class = 'SimplePie_Rating';
611 - * @var string Class used for Media RSS <media:restriction>
612 - * @see SimplePie::set_restriction_class()
615 - var $restriction_class = 'SimplePie_Restriction';
618 - * @var string Class used for content-type sniffing
619 - * @see SimplePie::set_content_type_sniffer_class()
622 - var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
625 - * @var string Class used for item sources.
626 - * @see SimplePie::set_source_class()
629 - var $source_class = 'SimplePie_Source';
632 - * @var mixed Set javascript query string parameter (false, or
633 - * anything type-cast to false, disables this feature)
634 - * @see SimplePie::set_javascript()
637 - var $javascript = 'js';
640 - * @var int Maximum number of feeds to check with autodiscovery
641 - * @see SimplePie::set_max_checked_feeds()
644 - var $max_checked_feeds = 10;
647 - * @var string Web-accessible path to the handler_favicon.php file.
648 - * @see SimplePie::set_favicon_handler()
651 - var $favicon_handler = '';
654 - * @var string Web-accessible path to the handler_image.php file.
655 - * @see SimplePie::set_image_handler()
658 - var $image_handler = '';
661 - * @var array Stores the URLs when multiple feeds are being initialized.
662 - * @see SimplePie::set_feed_url()
665 - var $multifeed_url = array();
668 - * @var array Stores SimplePie objects when multiple feeds initialized.
671 - var $multifeed_objects = array();
674 - * @var array Stores the get_object_vars() array for use with multifeeds.
675 - * @see SimplePie::set_feed_url()
678 - var $config_settings = null;
681 - * @var integer Stores the number of items to return per-feed with multifeeds.
682 - * @see SimplePie::set_item_limit()
685 - var $item_limit = 0;
688 - * @var array Stores the default attributes to be stripped by strip_attributes().
689 - * @see SimplePie::strip_attributes()
692 - var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
695 - * @var array Stores the default tags to be stripped by strip_htmltags().
696 - * @see SimplePie::strip_htmltags()
699 - var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
702 - * @var string proxy used to fetch feeds
703 - * @see SimplePie::set_proxy()
709 - * The SimplePie class contains feed level data and options
711 - * There are two ways that you can create a new SimplePie object. The first
712 - * is by passing a feed URL as a parameter to the SimplePie constructor
713 - * (as well as optionally setting the cache location and cache expiry). This
714 - * will initialise the whole feed with all of the default settings, and you
715 - * can begin accessing methods and properties immediately.
717 - * The second way is to create the SimplePie object with no parameters
718 - * at all. This will enable you to set configuration options. After setting
719 - * them, you must initialise the feed using $feed->init(). At that point the
720 - * object's methods and properties will be available to you. This format is
721 - * what is used throughout this documentation.
724 - * @since 1.0 Preview Release
725 - * @param string $feed_url This is the URL you want to parse.
726 - * @param string $cache_location This is where you want the cache to be stored.
727 - * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
728 - * @param string $proxy This is the proxy "host:port" used to fetch feeds
730 - function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null, $proxy = null)
732 - // Other objects, instances created here so we can set options on them
733 - $this->sanitize = new SimplePie_Sanitize;
735 - // Set options if they're passed to the constructor
736 - if ($cache_location !== null)
738 - $this->set_cache_location($cache_location);
741 - if ($cache_duration !== null)
743 - $this->set_cache_duration($cache_duration);
746 - if ($proxy !== null)
748 - $this->set_proxy($proxy);
751 - // Only init the script if we're passed a feed URL
752 - if ($feed_url !== null)
754 - $this->set_feed_url($feed_url);
760 - * Used for converting object to a string
762 - function __toString()
764 - return md5(serialize($this->data));
768 - * Remove items that link back to this before destroying this object
770 - function __destruct()
772 - if (!empty($this->data['items']))
774 - foreach ($this->data['items'] as $item)
776 - $item->__destruct();
778 - unset($this->data['items']);
780 - if (!empty($this->data['ordered_items']))
782 - foreach ($this->data['ordered_items'] as $item)
784 - $item->__destruct();
786 - unset($this->data['ordered_items']);
791 - * Force the given data/URL to be treated as a feed no matter what it
796 - * @param bool $enable Force the given data/URL to be treated as a feed
798 - function force_feed($enable = false)
800 - $this->force_feed = (bool) $enable;
804 - * This is the URL of the feed you want to parse.
806 - * This allows you to enter the URL of the feed you want to parse, or the
807 - * website you want to try to use auto-discovery on. This takes priority
808 - * over any set raw data.
810 - * You can set multiple feeds to mash together by passing an array instead
811 - * of a string for the $url. Remember that with each additional feed comes
812 - * additional processing and resources.
815 - * @since 1.0 Preview Release
816 - * @param mixed $url This is the URL (or array of URLs) that you want to parse.
817 - * @see SimplePie::set_raw_data()
819 - function set_feed_url($url)
821 - if (is_array($url))
823 - $this->multifeed_url = array();
824 - foreach ($url as $value)
826 - $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
831 - $this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
836 - * This is the proxy used to fetch feeds
839 - * @param string $proxy This is the URL of the proxy "host:port"
841 - function set_proxy($proxy)
843 - $this->proxy = $proxy;
844 - $this->sanitize->proxy = $proxy;
848 - * Provides an instance of SimplePie_File to use as a feed
851 - * @param object &$file Instance of SimplePie_File (or subclass)
852 - * @return bool True on success, false on failure
854 - function set_file(&$file)
856 - if (is_a($file, 'SimplePie_File'))
858 - $this->feed_url = $file->url;
859 - $this->file =& $file;
866 - * Allows you to use a string of RSS/Atom data instead of a remote feed.
868 - * If you have a feed available as a string in PHP, you can tell SimplePie
869 - * to parse that data string instead of a remote feed. Any set feed URL
870 - * takes precedence.
873 - * @since 1.0 Beta 3
874 - * @param string $data RSS or Atom data as a string.
875 - * @see SimplePie::set_feed_url()
877 - function set_raw_data($data)
879 - $this->raw_data = $data;
883 - * Allows you to override the default timeout for fetching remote feeds.
885 - * This allows you to change the maximum time the feed's server to respond
886 - * and send the feed back.
889 - * @since 1.0 Beta 3
890 - * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
892 - function set_timeout($timeout = 10)
894 - $this->timeout = (int) $timeout;
898 - * Forces SimplePie to use fsockopen() instead of the preferred cURL
902 - * @since 1.0 Beta 3
903 - * @param bool $enable Force fsockopen() to be used
905 - function force_fsockopen($enable = false)
907 - $this->force_fsockopen = (bool) $enable;
911 - * Outputs the raw XML content of the feed, after it has gone through
912 - * SimplePie's filters.
914 - * Used only for debugging, this function will output the XML content as
915 - * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
916 - * before trying to parse it. Many parts of the feed are re-written in
917 - * memory, and in the end, you have a parsable feed. XML dump shows you the
918 - * actual XML that SimplePie tries to parse, which may or may not be very
919 - * different from the original feed.
922 - * @since 1.0 Preview Release
923 - * @param bool $enable Enable XML dump
925 - function enable_xml_dump($enable = false)
927 - $this->xml_dump = (bool) $enable;
931 - * Enables/disables caching in SimplePie.
933 - * This option allows you to disable caching all-together in SimplePie.
934 - * However, disabling the cache can lead to longer load times.
937 - * @since 1.0 Preview Release
938 - * @param bool $enable Enable caching
940 - function enable_cache($enable = true)
942 - $this->cache = (bool) $enable;
946 - * Set the length of time (in seconds) that the contents of a feed
950 - * @param int $seconds The feed content cache duration.
952 - function set_cache_duration($seconds = 3600)
954 - $this->cache_duration = (int) $seconds;
958 - * Set the length of time (in seconds) that the autodiscovered feed
959 - * URL will be cached.
962 - * @param int $seconds The autodiscovered feed URL cache duration.
964 - function set_autodiscovery_cache_duration($seconds = 604800)
966 - $this->autodiscovery_cache_duration = (int) $seconds;
970 - * Set the file system location where the cached files should be stored.
973 - * @param string $location The file system location.
975 - function set_cache_location($location = './cache')
977 - $this->cache_location = (string) $location;
981 - * Determines whether feed items should be sorted into reverse chronological order.
984 - * @param bool $enable Sort as reverse chronological order.
986 - function enable_order_by_date($enable = true)
988 - $this->order_by_date = (bool) $enable;
992 - * Allows you to override the character encoding reported by the feed.
995 - * @param string $encoding Character encoding.
997 - function set_input_encoding($encoding = false)
1001 - $this->input_encoding = (string) $encoding;
1005 - $this->input_encoding = false;
1010 - * Set how much feed autodiscovery to do
1013 - * @see SIMPLEPIE_LOCATOR_NONE
1014 - * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
1015 - * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
1016 - * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
1017 - * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
1018 - * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
1019 - * @see SIMPLEPIE_LOCATOR_ALL
1020 - * @param int $level Feed Autodiscovery Level (level can be a
1021 - * combination of the above constants, see bitwise OR operator)
1023 - function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
1025 - $this->autodiscovery = (int) $level;
1029 - * Allows you to change which class SimplePie uses for caching.
1030 - * Useful when you are overloading or extending SimplePie's default classes.
1033 - * @param string $class Name of custom class.
1034 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1035 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1037 - function set_cache_class($class = 'SimplePie_Cache')
1039 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
1041 - $this->cache_class = $class;
1048 - * Allows you to change which class SimplePie uses for auto-discovery.
1049 - * Useful when you are overloading or extending SimplePie's default classes.
1052 - * @param string $class Name of custom class.
1053 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1054 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1056 - function set_locator_class($class = 'SimplePie_Locator')
1058 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
1060 - $this->locator_class = $class;
1067 - * Allows you to change which class SimplePie uses for XML parsing.
1068 - * Useful when you are overloading or extending SimplePie's default classes.
1071 - * @param string $class Name of custom class.
1072 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1073 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1075 - function set_parser_class($class = 'SimplePie_Parser')
1077 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
1079 - $this->parser_class = $class;
1086 - * Allows you to change which class SimplePie uses for remote file fetching.
1087 - * Useful when you are overloading or extending SimplePie's default classes.
1090 - * @param string $class Name of custom class.
1091 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1092 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1094 - function set_file_class($class = 'SimplePie_File')
1096 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
1098 - $this->file_class = $class;
1105 - * Allows you to change which class SimplePie uses for data sanitization.
1106 - * Useful when you are overloading or extending SimplePie's default classes.
1109 - * @param string $class Name of custom class.
1110 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1111 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1113 - function set_sanitize_class($class = 'SimplePie_Sanitize')
1115 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
1117 - $this->sanitize = new $class;
1118 - $this->sanitize->proxy = $this->proxy;
1125 - * Allows you to change which class SimplePie uses for handling feed items.
1126 - * Useful when you are overloading or extending SimplePie's default classes.
1129 - * @param string $class Name of custom class.
1130 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1131 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1133 - function set_item_class($class = 'SimplePie_Item')
1135 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
1137 - $this->item_class = $class;
1144 - * Allows you to change which class SimplePie uses for handling author data.
1145 - * Useful when you are overloading or extending SimplePie's default classes.
1148 - * @param string $class Name of custom class.
1149 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1150 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1152 - function set_author_class($class = 'SimplePie_Author')
1154 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
1156 - $this->author_class = $class;
1163 - * Allows you to change which class SimplePie uses for handling category data.
1164 - * Useful when you are overloading or extending SimplePie's default classes.
1167 - * @param string $class Name of custom class.
1168 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1169 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1171 - function set_category_class($class = 'SimplePie_Category')
1173 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
1175 - $this->category_class = $class;
1182 - * Allows you to change which class SimplePie uses for feed enclosures.
1183 - * Useful when you are overloading or extending SimplePie's default classes.
1186 - * @param string $class Name of custom class.
1187 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1188 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1190 - function set_enclosure_class($class = 'SimplePie_Enclosure')
1192 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
1194 - $this->enclosure_class = $class;
1201 - * Allows you to change which class SimplePie uses for <media:text> captions
1202 - * Useful when you are overloading or extending SimplePie's default classes.
1205 - * @param string $class Name of custom class.
1206 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1207 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1209 - function set_caption_class($class = 'SimplePie_Caption')
1211 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
1213 - $this->caption_class = $class;
1220 - * Allows you to change which class SimplePie uses for <media:copyright>
1221 - * Useful when you are overloading or extending SimplePie's default classes.
1224 - * @param string $class Name of custom class.
1225 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1226 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1228 - function set_copyright_class($class = 'SimplePie_Copyright')
1230 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
1232 - $this->copyright_class = $class;
1239 - * Allows you to change which class SimplePie uses for <media:credit>
1240 - * Useful when you are overloading or extending SimplePie's default classes.
1243 - * @param string $class Name of custom class.
1244 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1245 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1247 - function set_credit_class($class = 'SimplePie_Credit')
1249 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
1251 - $this->credit_class = $class;
1258 - * Allows you to change which class SimplePie uses for <media:rating>
1259 - * Useful when you are overloading or extending SimplePie's default classes.
1262 - * @param string $class Name of custom class.
1263 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1264 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1266 - function set_rating_class($class = 'SimplePie_Rating')
1268 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
1270 - $this->rating_class = $class;
1277 - * Allows you to change which class SimplePie uses for <media:restriction>
1278 - * Useful when you are overloading or extending SimplePie's default classes.
1281 - * @param string $class Name of custom class.
1282 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1283 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1285 - function set_restriction_class($class = 'SimplePie_Restriction')
1287 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
1289 - $this->restriction_class = $class;
1296 - * Allows you to change which class SimplePie uses for content-type sniffing.
1297 - * Useful when you are overloading or extending SimplePie's default classes.
1300 - * @param string $class Name of custom class.
1301 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1302 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1304 - function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
1306 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
1308 - $this->content_type_sniffer_class = $class;
1315 - * Allows you to change which class SimplePie uses item sources.
1316 - * Useful when you are overloading or extending SimplePie's default classes.
1319 - * @param string $class Name of custom class.
1320 - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
1321 - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
1323 - function set_source_class($class = 'SimplePie_Source')
1325 - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
1327 - $this->source_class = $class;
1334 - * Allows you to override the default user agent string.
1337 - * @param string $ua New user agent string.
1339 - function set_useragent($ua = SIMPLEPIE_USERAGENT)
1341 - $this->useragent = (string) $ua;
1345 - * Set callback function to create cache filename with
1348 - * @param mixed $function Callback function
1350 - function set_cache_name_function($function = 'md5')
1352 - if (is_callable($function))
1354 - $this->cache_name_function = $function;
1359 - * Set javascript query string parameter
1362 - * @param mixed $get Javascript query string parameter
1364 - function set_javascript($get = 'js')
1368 - $this->javascript = (string) $get;
1372 - $this->javascript = false;
1377 - * Set options to make SP as fast as possible. Forgoes a
1378 - * substantial amount of data sanitization in favor of speed.
1381 - * @param bool $set Whether to set them or not
1383 - function set_stupidly_fast($set = false)
1387 - $this->enable_order_by_date(false);
1388 - $this->remove_div(false);
1389 - $this->strip_comments(false);
1390 - $this->strip_htmltags(false);
1391 - $this->strip_attributes(false);
1392 - $this->set_image_handler(false);
1397 - * Set maximum number of feeds to check with autodiscovery
1400 - * @param int $max Maximum number of feeds to check
1402 - function set_max_checked_feeds($max = 10)
1404 - $this->max_checked_feeds = (int) $max;
1407 - function remove_div($enable = true)
1409 - $this->sanitize->remove_div($enable);
1412 - function strip_htmltags($tags = '', $encode = null)
1416 - $tags = $this->strip_htmltags;
1418 - $this->sanitize->strip_htmltags($tags);
1419 - if ($encode !== null)
1421 - $this->sanitize->encode_instead_of_strip($tags);
1425 - function encode_instead_of_strip($enable = true)
1427 - $this->sanitize->encode_instead_of_strip($enable);
1430 - function strip_attributes($attribs = '')
1432 - if ($attribs === '')
1434 - $attribs = $this->strip_attributes;
1436 - $this->sanitize->strip_attributes($attribs);
1439 - function set_output_encoding($encoding = 'UTF-8')
1441 - $this->sanitize->set_output_encoding($encoding);
1444 - function strip_comments($strip = false)
1446 - $this->sanitize->strip_comments($strip);
1450 - * Set element/attribute key/value pairs of HTML attributes
1451 - * containing URLs that need to be resolved relative to the feed
1455 - * @param array $element_attribute Element/attribute key/value pairs
1457 - 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'))
1459 - $this->sanitize->set_url_replacements($element_attribute);
1463 - * Set the handler to enable the display of cached favicons.
1466 - * @param str $page Web-accessible path to the handler_favicon.php file.
1467 - * @param str $qs The query string that the value should be passed to.
1469 - function set_favicon_handler($page = false, $qs = 'i')
1471 - if ($page != false)
1473 - $this->favicon_handler = $page . '?' . $qs . '=';
1477 - $this->favicon_handler = '';
1482 - * Set the handler to enable the display of cached images.
1485 - * @param str $page Web-accessible path to the handler_image.php file.
1486 - * @param str $qs The query string that the value should be passed to.
1488 - function set_image_handler($page = false, $qs = 'i')
1490 - if ($page != false)
1492 - $this->sanitize->set_image_handler($page . '?' . $qs . '=');
1496 - $this->image_handler = '';
1501 - * Set the limit for items returned per-feed with multifeeds.
1504 - * @param integer $limit The maximum number of items to return.
1506 - function set_item_limit($limit = 0)
1508 - $this->item_limit = (int) $limit;
1513 - if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
1517 - if (isset($_GET[$this->javascript]))
1519 - if (function_exists('ob_gzhandler'))
1521 - ob_start('ob_gzhandler');
1523 - header('Content-type: text/javascript; charset: UTF-8');
1524 - header('Cache-Control: must-revalidate');
1525 - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
1527 -function embed_odeo(link) {
1528 - 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>');
1531 -function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
1532 - if (placeholder != '') {
1533 - 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>');
1536 - 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>');
1540 -function embed_flash(bgcolor, width, height, link, loop, type) {
1541 - 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>');
1544 -function embed_flv(width, height, link, placeholder, loop, player) {
1545 - 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>');
1548 -function embed_wmedia(width, height, link) {
1549 - document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
1555 - // Pass whatever was set with config options over to the sanitizer.
1556 - $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
1557 - $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
1559 - if ($this->feed_url !== null || $this->raw_data !== null)
1561 - $this->data = array();
1562 - $this->multifeed_objects = array();
1565 - if ($this->feed_url !== null)
1567 - $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
1568 - // Decide whether to enable caching
1569 - if ($this->cache && $parsed_feed_url['scheme'] !== '')
1571 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
1573 - // If it's enabled and we don't want an XML dump, use the cache
1574 - if ($cache && !$this->xml_dump)
1577 - $this->data = $cache->load();
1578 - if (!empty($this->data))
1580 - // If the cache is for an outdated build of SimplePie
1581 - if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD)
1584 - $this->data = array();
1586 - // If we've hit a collision just rerun it with caching disabled
1587 - elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url)
1590 - $this->data = array();
1592 - // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
1593 - elseif (isset($this->data['feed_url']))
1595 - // If the autodiscovery cache is still valid use it.
1596 - if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
1598 - // Do not need to do feed autodiscovery yet.
1599 - if ($this->data['feed_url'] == $this->data['url'])
1602 - $this->data = array();
1606 - $this->set_feed_url($this->data['feed_url']);
1607 - return $this->init();
1611 - // Check if the cache has been updated
1612 - elseif ($cache->mtime() + $this->cache_duration < time())
1614 - // If we have last-modified and/or etag set
1615 - if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
1617 - $headers = array();
1618 - if (isset($this->data['headers']['last-modified']))
1620 - $headers['if-modified-since'] = $this->data['headers']['last-modified'];
1622 - if (isset($this->data['headers']['etag']))
1624 - $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
1626 - $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->proxy);
1627 - if ($file->success)
1629 - if ($file->status_code == 304)
1636 - $headers = $file->headers;
1645 - // If the cache is still valid, just return true
1651 - // If the cache is empty, delete it
1655 - $this->data = array();
1658 - // 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.
1659 - if (!isset($file))
1661 - if (is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url)
1663 - $file =& $this->file;
1667 - $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->proxy);
1670 - // If the file connection has an error, set SimplePie::error to that and quit
1671 - if (!$file->success)
1673 - $this->error = $file->error;
1674 - if (!empty($this->data))
1684 - if (!$this->force_feed)
1686 - // Check if the supplied URL is a feed, if it isn't, look for it.
1687 - $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
1688 - if (!$locate->is_feed($file))
1690 - // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
1692 - if ($file = $locate->find($this->autodiscovery))
1696 - $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
1697 - if (!$cache->save($this))
1699 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
1701 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
1703 - $this->feed_url = $file->url;
1707 - $this->error = "A feed could not be found at $this->feed_url";
1708 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1715 - $headers = $file->headers;
1716 - $data = $file->body;
1717 - $sniffer = new $this->content_type_sniffer_class($file);
1718 - $sniffed = $sniffer->get_type();
1722 - $data = $this->raw_data;
1725 - // Set up array of possible encodings
1726 - $encodings = array();
1728 - // First check to see if input has been overridden.
1729 - if ($this->input_encoding !== false)
1731 - $encodings[] = $this->input_encoding;
1734 - $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
1735 - $text_types = array('text/xml', 'text/xml-external-parsed-entity');
1737 - // RFC 3023 (only applies to sniffed content)
1738 - if (isset($sniffed))
1740 - if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
1742 - if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1744 - $encodings[] = strtoupper($charset[1]);
1746 - $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1747 - $encodings[] = 'UTF-8';
1749 - elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
1751 - if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
1753 - $encodings[] = $charset[1];
1755 - $encodings[] = 'US-ASCII';
1757 - // Text MIME-type default
1758 - elseif (substr($sniffed, 0, 5) === 'text/')
1760 - $encodings[] = 'US-ASCII';
1764 - // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
1765 - $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
1766 - $encodings[] = 'UTF-8';
1767 - $encodings[] = 'ISO-8859-1';
1769 - // There's no point in trying an encoding twice
1770 - $encodings = array_unique($encodings);
1772 - // If we want the XML, just output that with the most likely encoding and quit
1773 - if ($this->xml_dump)
1775 - header('Content-type: text/xml; charset=' . $encodings[0]);
1780 - // Loop through each possible encoding, till we return something, or run out of possibilities
1781 - foreach ($encodings as $encoding)
1783 - // Change the encoding to UTF-8 (as we always use UTF-8 internally)
1784 - if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
1786 - // Create new parser
1787 - $parser = new $this->parser_class();
1789 - // If it's parsed fine
1790 - if ($parser->parse($utf8_data, 'UTF-8'))
1792 - $this->data = $parser->get_data();
1793 - if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
1795 - if (isset($headers))
1797 - $this->data['headers'] = $headers;
1799 - $this->data['build'] = SIMPLEPIE_BUILD;
1801 - // Cache the file if caching is enabled
1802 - if ($cache && !$cache->save($this))
1804 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
1810 - $this->error = "A feed could not be found at $this->feed_url";
1811 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1817 - // We have an error, just set SimplePie::error to it and quit
1818 - $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
1819 - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
1822 - elseif (!empty($this->multifeed_url))
1826 - $this->multifeed_objects = array();
1827 - foreach ($this->multifeed_url as $url)
1829 - if (SIMPLEPIE_PHP5)
1831 - // This keyword needs to defy coding standards for PHP4 compatibility
1832 - $this->multifeed_objects[$i] = clone($this);
1836 - $this->multifeed_objects[$i] = $this;
1838 - $this->multifeed_objects[$i]->set_feed_url($url);
1839 - $success |= $this->multifeed_objects[$i]->init();
1842 - return (bool) $success;
1851 - * Return the error message for the occured error
1854 - * @return string Error message
1858 - return $this->error;
1861 - function get_encoding()
1863 - return $this->sanitize->output_encoding;
1866 - function handle_content_type($mime = 'text/html')
1868 - if (!headers_sent())
1870 - $header = "Content-type: $mime;";
1871 - if ($this->get_encoding())
1873 - $header .= ' charset=' . $this->get_encoding();
1877 - $header .= ' charset=UTF-8';
1883 - function get_type()
1885 - if (!isset($this->data['type']))
1887 - $this->data['type'] = SIMPLEPIE_TYPE_ALL;
1888 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
1890 - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
1892 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
1894 - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
1896 - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
1898 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
1899 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
1900 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
1901 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
1903 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
1905 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
1906 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
1907 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
1908 - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
1910 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
1913 - elseif (isset($this->data['child']['']['rss']))
1915 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
1916 - if (isset($this->data['child']['']['rss'][0]['attribs']['']['version']))
1918 - switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version']))
1921 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
1922 - if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1924 - switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data']))
1927 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
1931 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
1938 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
1942 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
1946 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
1950 - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
1957 - $this->data['type'] = SIMPLEPIE_TYPE_NONE;
1960 - return $this->data['type'];
1964 - * Returns the URL for the favicon of the feed's website.
1966 - * @todo Cache atom:icon
1970 - function get_favicon()
1972 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
1974 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
1976 - elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
1978 - $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
1980 - if ($this->cache && $this->favicon_handler)
1982 - $favicon_filename = call_user_func($this->cache_name_function, $favicon);
1983 - $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
1985 - if ($cache->load())
1987 - return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
1991 - $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen, $this->proxy);
1993 - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
1995 - $sniffer = new $this->content_type_sniffer_class($file);
1996 - if (substr($sniffer->get_type(), 0, 6) === 'image/')
1998 - if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
2000 - return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
2004 - trigger_error("$cache->name is not writeable", E_USER_WARNING);
2005 - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2013 - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
2020 - * @todo If we have a perm redirect we should return the new URL
2021 - * @todo When we make the above change, let's support <itunes:new-feed-url> as well
2022 - * @todo Also, |atom:link|@rel=self
2024 - function subscribe_url()
2026 - if ($this->feed_url !== null)
2028 - return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
2036 - function subscribe_feed()
2038 - if ($this->feed_url !== null)
2040 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2048 - function subscribe_outlook()
2050 - if ($this->feed_url !== null)
2052 - return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
2060 - function subscribe_podcast()
2062 - if ($this->feed_url !== null)
2064 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
2072 - function subscribe_itunes()
2074 - if ($this->feed_url !== null)
2076 - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
2085 - * Creates the subscribe_* methods' return data
2088 - * @param string $feed_url String to prefix to the feed URL
2089 - * @param string $site_url String to prefix to the site URL (and
2090 - * suffix to the feed URL)
2091 - * @return mixed URL if feed exists, false otherwise
2093 - function subscribe_service($feed_url, $site_url = null)
2095 - if ($this->subscribe_url())
2097 - $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->feed_url);
2098 - if ($site_url !== null && $this->get_link() !== null)
2100 - $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link());
2110 - function subscribe_aol()
2112 - return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
2115 - function subscribe_bloglines()
2117 - return urldecode($this->subscribe_service('http://www.bloglines.com/sub/'));
2120 - function subscribe_eskobo()
2122 - return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
2125 - function subscribe_feedfeeds()
2127 - return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
2130 - function subscribe_feedster()
2132 - return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
2135 - function subscribe_google()
2137 - return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
2140 - function subscribe_gritwire()
2142 - return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
2145 - function subscribe_msn()
2147 - return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
2150 - function subscribe_netvibes()
2152 - return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
2155 - function subscribe_newsburst()
2157 - return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
2160 - function subscribe_newsgator()
2162 - return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
2165 - function subscribe_odeo()
2167 - return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
2170 - function subscribe_podnova()
2172 - return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
2175 - function subscribe_rojo()
2177 - return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
2180 - function subscribe_yahoo()
2182 - return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
2185 - function get_feed_tags($namespace, $tag)
2187 - $type = $this->get_type();
2188 - if ($type & SIMPLEPIE_TYPE_ATOM_10)
2190 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
2192 - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
2195 - if ($type & SIMPLEPIE_TYPE_ATOM_03)
2197 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
2199 - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
2202 - if ($type & SIMPLEPIE_TYPE_RSS_RDF)
2204 - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
2206 - return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
2209 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2211 - if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag]))
2213 - return $this->data['child']['']['rss'][0]['child'][$namespace][$tag];
2219 - function get_channel_tags($namespace, $tag)
2221 - $type = $this->get_type();
2222 - if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
2224 - if ($return = $this->get_feed_tags($namespace, $tag))
2229 - if ($type & SIMPLEPIE_TYPE_RSS_10)
2231 - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
2233 - if (isset($channel[0]['child'][$namespace][$tag]))
2235 - return $channel[0]['child'][$namespace][$tag];
2239 - if ($type & SIMPLEPIE_TYPE_RSS_090)
2241 - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
2243 - if (isset($channel[0]['child'][$namespace][$tag]))
2245 - return $channel[0]['child'][$namespace][$tag];
2249 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2251 - if ($channel = $this->get_feed_tags('', 'channel'))
2253 - if (isset($channel[0]['child'][$namespace][$tag]))
2255 - return $channel[0]['child'][$namespace][$tag];
2262 - function get_image_tags($namespace, $tag)
2264 - $type = $this->get_type();
2265 - if ($type & SIMPLEPIE_TYPE_RSS_10)
2267 - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
2269 - if (isset($image[0]['child'][$namespace][$tag]))
2271 - return $image[0]['child'][$namespace][$tag];
2275 - if ($type & SIMPLEPIE_TYPE_RSS_090)
2277 - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
2279 - if (isset($image[0]['child'][$namespace][$tag]))
2281 - return $image[0]['child'][$namespace][$tag];
2285 - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
2287 - if ($image = $this->get_channel_tags('', 'image'))
2289 - if (isset($image[0]['child'][$namespace][$tag]))
2291 - return $image[0]['child'][$namespace][$tag];
2298 - function get_base($element = array())
2300 - if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
2302 - return $element['xml_base'];
2304 - elseif ($this->get_link() !== null)
2306 - return $this->get_link();
2310 - return $this->subscribe_url();
2314 - function sanitize($data, $type, $base = '')
2316 - return $this->sanitize->sanitize($data, $type, $base);
2319 - function get_title()
2321 - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
2323 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2325 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
2327 - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
2329 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
2331 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2333 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
2335 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2337 - elseif ($return = $this->get_channel_tags('', 'title'))
2339 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
2341 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
2343 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2345 - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
2347 - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2355 - function get_category($key = 0)
2357 - $categories = $this->get_categories();
2358 - if (isset($categories[$key]))
2360 - return $categories[$key];
2368 - function get_categories()
2370 - $categories = array();
2372 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
2377 - if (isset($category['attribs']['']['term']))
2379 - $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
2381 - if (isset($category['attribs']['']['scheme']))
2383 - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
2385 - if (isset($category['attribs']['']['label']))
2387 - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
2389 - $categories[] = new $this->category_class($term, $scheme, $label);
2391 - foreach ((array) $this->get_channel_tags('', 'category') as $category)
2393 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2395 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
2397 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2399 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
2401 - $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2404 - if (!empty($categories))
2406 - return SimplePie_Misc::array_unique($categories);
2414 - function get_author($key = 0)
2416 - $authors = $this->get_authors();
2417 - if (isset($authors[$key]))
2419 - return $authors[$key];
2427 - function get_authors()
2429 - $authors = array();
2430 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
2435 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2437 - $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2439 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2441 - $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]));
2443 - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2445 - $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2447 - if ($name !== null || $email !== null || $uri !== null)
2449 - $authors[] = new $this->author_class($name, $uri, $email);
2452 - if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
2457 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2459 - $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2461 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2463 - $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]));
2465 - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2467 - $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2469 - if ($name !== null || $email !== null || $url !== null)
2471 - $authors[] = new $this->author_class($name, $url, $email);
2474 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
2476 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2478 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
2480 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2482 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
2484 - $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
2487 - if (!empty($authors))
2489 - return SimplePie_Misc::array_unique($authors);
2497 - function get_contributor($key = 0)
2499 - $contributors = $this->get_contributors();
2500 - if (isset($contributors[$key]))
2502 - return $contributors[$key];
2510 - function get_contributors()
2512 - $contributors = array();
2513 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
2518 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
2520 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2522 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
2524 - $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]));
2526 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
2528 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2530 - if ($name !== null || $email !== null || $uri !== null)
2532 - $contributors[] = new $this->author_class($name, $uri, $email);
2535 - foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
2540 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
2542 - $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2544 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
2546 - $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]));
2548 - if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
2550 - $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
2552 - if ($name !== null || $email !== null || $url !== null)
2554 - $contributors[] = new $this->author_class($name, $url, $email);
2558 - if (!empty($contributors))
2560 - return SimplePie_Misc::array_unique($contributors);
2568 - function get_link($key = 0, $rel = 'alternate')
2570 - $links = $this->get_links($rel);
2571 - if (isset($links[$key]))
2573 - return $links[$key];
2582 - * Added for parity between the parent-level and the item/entry-level.
2584 - function get_permalink()
2586 - return $this->get_link(0);
2589 - function get_links($rel = 'alternate')
2591 - if (!isset($this->data['links']))
2593 - $this->data['links'] = array();
2594 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
2596 - foreach ($links as $link)
2598 - if (isset($link['attribs']['']['href']))
2600 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2601 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2605 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
2607 - foreach ($links as $link)
2609 - if (isset($link['attribs']['']['href']))
2611 - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
2612 - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
2617 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
2619 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2621 - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
2623 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2625 - if ($links = $this->get_channel_tags('', 'link'))
2627 - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
2630 - $keys = array_keys($this->data['links']);
2631 - foreach ($keys as $key)
2633 - if (SimplePie_Misc::is_isegment_nz_nc($key))
2635 - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
2637 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
2638 - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
2642 - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
2645 - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
2647 - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
2649 - $this->data['links'][$key] = array_unique($this->data['links'][$key]);
2653 - if (isset($this->data['links'][$rel]))
2655 - return $this->data['links'][$rel];