From 73f65c8fbadbdd2098448e77b6d3f0464ad8613e Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 27 Jan 2015 09:29:09 +0100 Subject: update picofeed --- vendor/fguillot/picofeed | 1 + .../fguillot/picofeed/lib/PicoFeed/Parser/Atom.php | 324 ----------- .../fguillot/picofeed/lib/PicoFeed/Parser/Feed.php | 219 ------- .../fguillot/picofeed/lib/PicoFeed/Parser/Item.php | 231 -------- .../lib/PicoFeed/Parser/MalformedXmlException.php | 13 - .../picofeed/lib/PicoFeed/Parser/Parser.php | 635 --------------------- .../lib/PicoFeed/Parser/ParserException.php | 16 - .../picofeed/lib/PicoFeed/Parser/Rss10.php | 77 --- .../picofeed/lib/PicoFeed/Parser/Rss20.php | 287 ---------- .../picofeed/lib/PicoFeed/Parser/Rss91.php | 13 - .../picofeed/lib/PicoFeed/Parser/Rss92.php | 13 - .../picofeed/lib/PicoFeed/Parser/XmlParser.php | 257 --------- 12 files changed, 1 insertion(+), 2085 deletions(-) create mode 160000 vendor/fguillot/picofeed delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/ParserException.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss10.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss91.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss92.php delete mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Parser') diff --git a/vendor/fguillot/picofeed b/vendor/fguillot/picofeed new file mode 160000 index 000000000..0a1d0d395 --- /dev/null +++ b/vendor/fguillot/picofeed @@ -0,0 +1 @@ +Subproject commit 0a1d0d3950f7f047dc8fb1d80aa6296e15f306d0 diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php deleted file mode 100644 index 154ed3cfb..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php +++ /dev/null @@ -1,324 +0,0 @@ -entry; - } - - /** - * Find the feed url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedUrl(SimpleXMLElement $xml, Feed $feed) - { - $feed->feed_url = $this->getUrl($xml, 'self'); - } - - /** - * Find the site url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findSiteUrl(SimpleXMLElement $xml, Feed $feed) - { - $feed->site_url = $this->getUrl($xml, 'alternate', true); - } - - /** - * Find the feed description - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedDescription(SimpleXMLElement $xml, Feed $feed) - { - $feed->description = (string) $xml->subtitle; - } - - /** - * Find the feed logo url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedLogo(SimpleXMLElement $xml, Feed $feed) - { - $feed->logo = (string) $xml->logo; - } - - /** - * Find the feed title - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedTitle(SimpleXMLElement $xml, Feed $feed) - { - $feed->title = Filter::stripWhiteSpace((string) $xml->title) ?: $feed->getSiteUrl(); - } - - /** - * Find the feed language - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed) - { - $feed->language = XmlParser::getXmlLang($this->content); - } - - /** - * Find the feed id - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedId(SimpleXMLElement $xml, Feed $feed) - { - $feed->id = (string) $xml->id; - } - - /** - * Find the feed date - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedDate(SimpleXMLElement $xml, Feed $feed) - { - $feed->date = $this->parseDate((string) $xml->updated); - } - - /** - * Find the item date - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param Item $item Item object - */ - public function findItemDate(SimpleXMLElement $entry, Item $item) - { - $published = isset($entry->published) ? $this->parseDate((string) $entry->published) : 0; - $updated = isset($entry->updated) ? $this->parseDate((string) $entry->updated) : 0; - - $item->date = max($published, $updated) ?: time(); - } - - /** - * Find the item title - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param Item $item Item object - */ - public function findItemTitle(SimpleXMLElement $entry, Item $item) - { - $item->title = Filter::stripWhiteSpace((string) $entry->title); - - if (empty($item->title)) { - $item->title = $item->url; - } - } - - /** - * Find the item author - * - * @access public - * @param SimpleXMLElement $xml Feed - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item) - { - if (isset($entry->author->name)) { - $item->author = (string) $entry->author->name; - } - else { - $item->author = (string) $xml->author->name; - } - } - - /** - * Find the item content - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemContent(SimpleXMLElement $entry, Item $item) - { - $item->content = $this->getContent($entry); - } - - /** - * Find the item URL - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemUrl(SimpleXMLElement $entry, Item $item) - { - $item->url = $this->getUrl($entry, 'alternate', true); - } - - /** - * Genereate the item id - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed) - { - $id = (string) $entry->id; - - if ($id) { - $item->id = $this->generateId($id); - } - else { - $item->id = $this->generateId( - $item->getTitle(), $item->getUrl(), $item->getContent() - ); - } - } - - /** - * Find the item enclosure - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed) - { - $enclosure = $this->findLink($entry, 'enclosure'); - - if ($enclosure) { - $item->enclosure_url = Url::resolve((string) $enclosure['href'], $feed->getSiteUrl()); - $item->enclosure_type = (string) $enclosure['type']; - } - } - - /** - * Find the item language - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed) - { - $language = (string) $entry->attributes('xml', true)->{'lang'}; - - if ($language === '') { - $language = $feed->language; - } - - $item->language = $language; - } - - /** - * Get the URL from a link tag - * - * @access private - * @param SimpleXMLElement $xml XML tag - * @param string $rel Link relationship: alternate, enclosure, related, self, via - * @return string - */ - private function getUrl(SimpleXMLElement $xml, $rel, $fallback = false) - { - $link = $this->findLink($xml, $rel); - - if ($link) { - return (string) $link['href']; - } - - if ($fallback) { - $link = $this->findLink($xml, ''); - return $link ? (string) $link['href'] : ''; - } - - return ''; - } - - /** - * Get a link tag that match a relationship - * - * @access private - * @param SimpleXMLElement $xml XML tag - * @param string $rel Link relationship: alternate, enclosure, related, self, via - * @return SimpleXMLElement|null - */ - private function findLink(SimpleXMLElement $xml, $rel) - { - foreach ($xml->link as $link) { - if ($rel === (string) $link['rel']) { - return $link; - } - } - - return null; - } - - /** - * Get the entry content - * - * @access private - * @param SimpleXMLElement $entry XML Entry - * @return string - */ - private function getContent(SimpleXMLElement $entry) - { - if (isset($entry->content) && ! empty($entry->content)) { - - if (count($entry->content->children())) { - return (string) $entry->content->asXML(); - } - else { - return (string) $entry->content; - } - } - else if (isset($entry->summary) && ! empty($entry->summary)) { - return (string) $entry->summary; - } - - return ''; - } -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php deleted file mode 100644 index 99fc27e8e..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php +++ /dev/null @@ -1,219 +0,0 @@ -$property.PHP_EOL; - } - - $output .= 'Feed::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL; - $output .= 'Feed::items = '.count($this->items).' items'.PHP_EOL; - - foreach ($this->items as $item) { - $output .= '----'.PHP_EOL; - $output .= $item; - } - - return $output; - } - - /** - * Get title - * - * @access public - * $return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get description - * - * @access public - * $return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the logo url - * - * @access public - * $return string - */ - public function getLogo() - { - return $this->logo; - } - - /** - * Get feed url - * - * @access public - * $return string - */ - public function getFeedUrl() - { - return $this->feed_url; - } - - /** - * Get site url - * - * @access public - * $return string - */ - public function getSiteUrl() - { - return $this->site_url; - } - - /** - * Get date - * - * @access public - * $return integer - */ - public function getDate() - { - return $this->date; - } - - /** - * Get language - * - * @access public - * $return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * Get id - * - * @access public - * $return string - */ - public function getId() - { - return $this->id; - } - - /** - * Get feed items - * - * @access public - * $return array - */ - public function getItems() - { - return $this->items; - } - - /** - * Return true if the feed is "Right to Left" - * - * @access public - * @return bool - */ - public function isRTL() - { - return Parser::isLanguageRTL($this->language); - } -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php deleted file mode 100644 index 3642cccea..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php +++ /dev/null @@ -1,231 +0,0 @@ -$property.PHP_EOL; - } - - $output .= 'Item::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL; - $output .= 'Item::content = '.strlen($this->content).' bytes'.PHP_EOL; - - return $output; - } - - /** - * Get title - * - * @access public - * $return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get url - * - * @access public - * $return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * Get id - * - * @access public - * $return string - */ - public function getId() - { - return $this->id; - } - - /** - * Get date - * - * @access public - * $return integer - */ - public function getDate() - { - return $this->date; - } - - /** - * Get content - * - * @access public - * $return string - */ - public function getContent() - { - return $this->content; - } - - /** - * Get enclosure url - * - * @access public - * $return string - */ - public function getEnclosureUrl() - { - return $this->enclosure_url; - } - - /** - * Get enclosure type - * - * @access public - * $return string - */ - public function getEnclosureType() - { - return $this->enclosure_type; - } - - /** - * Get language - * - * @access public - * $return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * Get author - * - * @access public - * $return string - */ - public function getAuthor() - { - return $this->author; - } - - /** - * Return true if the item is "Right to Left" - * - * @access public - * @return bool - */ - public function isRTL() - { - return Parser::isLanguageRTL($this->language); - } -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php deleted file mode 100644 index 8464e9cac..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php +++ /dev/null @@ -1,13 +0,0 @@ -fallback_url = $fallback_url; - $xml_encoding = XmlParser::getEncodingFromXmlTag($content); - - // Strip XML tag to avoid multiple encoding/decoding in the next XML processing - $this->content = Filter::stripXmlTag($content); - - // Encode everything in UTF-8 - Logger::setMessage(get_called_class().': HTTP Encoding "'.$http_encoding.'" ; XML Encoding "'.$xml_encoding.'"'); - $this->content = Encoding::convert($this->content, $xml_encoding ?: $http_encoding); - - // Workarounds - $this->content = Filter::normalizeData($this->content); - } - - /** - * Parse the document - * - * @access public - * @return \PicoFeed\Parser\Feed - */ - public function execute() - { - Logger::setMessage(get_called_class().': begin parsing'); - - $xml = XmlParser::getSimpleXml($this->content); - - if ($xml === false) { - Logger::setMessage(get_called_class().': XML parsing error'); - Logger::setMessage(XmlParser::getErrors()); - throw new MalformedXmlException('XML parsing error'); - } - - $this->namespaces = $xml->getNamespaces(true); - - $feed = new Feed; - - $this->findFeedUrl($xml, $feed); - $this->checkFeedUrl($feed); - - $this->findSiteUrl($xml, $feed); - $this->checkSiteUrl($feed); - - $this->findFeedTitle($xml, $feed); - $this->findFeedDescription($xml, $feed); - $this->findFeedLanguage($xml, $feed); - $this->findFeedId($xml, $feed); - $this->findFeedDate($xml, $feed); - $this->findFeedLogo($xml, $feed); - - foreach ($this->getItemsTree($xml) as $entry) { - - $item = new Item; - $this->findItemAuthor($xml, $entry, $item); - - $this->findItemUrl($entry, $item); - $this->checkItemUrl($feed, $item); - - $this->findItemTitle($entry, $item); - $this->findItemContent($entry, $item); - - // Id generation can use the item url/title/content (order is important) - $this->findItemId($entry, $item, $feed); - - $this->findItemDate($entry, $item); - $this->findItemEnclosure($entry, $item, $feed); - $this->findItemLanguage($entry, $item, $feed); - - $this->scrapWebsite($item); - $this->filterItemContent($feed, $item); - - $feed->items[] = $item; - } - - Logger::setMessage(get_called_class().PHP_EOL.$feed); - - return $feed; - } - - /** - * Check if the feed url is correct - * - * @access public - * @param Feed $feed Feed object - */ - public function checkFeedUrl(Feed $feed) - { - if ($feed->getFeedUrl() === '') { - $feed->feed_url = $this->fallback_url; - } - else { - $feed->feed_url = Url::resolve($feed->getFeedUrl(), $this->fallback_url); - } - } - - /** - * Check if the site url is correct - * - * @access public - * @param Feed $feed Feed object - */ - public function checkSiteUrl(Feed $feed) - { - if ($feed->getSiteUrl() === '') { - $feed->site_url = Url::base($feed->getFeedUrl()); - } - else { - $feed->site_url = Url::resolve($feed->getSiteUrl(), $this->fallback_url); - } - } - - /** - * Check if the item url is correct - * - * @access public - * @param Feed $feed Feed object - * @param Item $item Item object - */ - public function checkItemUrl(Feed $feed, Item $item) - { - $item->url = Url::resolve($item->getUrl(), $feed->getSiteUrl()); - } - - /** - * Fetch item content with the content grabber - * - * @access public - * @param Item $item Item object - */ - public function scrapWebsite(Item $item) - { - if ($this->enable_grabber && ! in_array($item->getUrl(), $this->grabber_ignore_urls)) { - - $grabber = new Grabber($item->getUrl()); - $grabber->setConfig($this->config); - $grabber->download(); - - if ($grabber->parse()) { - $item->content = $grabber->getContent() ?: $item->content; - } - } - } - - /** - * Filter HTML for entry content - * - * @access public - * @param Feed $feed Feed object - * @param Item $item Item object - */ - public function filterItemContent(Feed $feed, Item $item) - { - if ($this->isFilteringEnabled()) { - $filter = Filter::html($item->getContent(), $feed->getSiteUrl()); - $filter->setConfig($this->config); - $item->content = $filter->execute(); - } - else { - Logger::setMessage(get_called_class().': Content filtering disabled'); - } - } - - /** - * Generate a unique id for an entry (hash all arguments) - * - * @access public - * @param string $args Pieces of data to hash - * @return string - */ - public function generateId() - { - return hash($this->hash_algo, implode(func_get_args())); - } - - /** - * Try to parse all date format for broken feeds - * - * @access public - * @param string $value Original date format - * @return integer Timestamp - */ - public function parseDate($value) - { - // Format => truncate to this length if not null - $formats = array( - DATE_ATOM => null, - DATE_RSS => null, - DATE_COOKIE => null, - DATE_ISO8601 => null, - DATE_RFC822 => null, - DATE_RFC850 => null, - DATE_RFC1036 => null, - DATE_RFC1123 => null, - DATE_RFC2822 => null, - DATE_RFC3339 => null, - 'D, d M Y H:i:s' => 25, - 'D, d M Y h:i:s' => 25, - 'D M d Y H:i:s' => 24, - 'j M Y H:i:s' => 20, - 'Y-m-d H:i:s' => 19, - 'Y-m-d\TH:i:s' => 19, - 'd/m/Y H:i:s' => 19, - 'D, d M Y' => 16, - 'Y-m-d' => 10, - 'd-m-Y' => 10, - 'm-d-Y' => 10, - 'd.m.Y' => 10, - 'm.d.Y' => 10, - 'd/m/Y' => 10, - 'm/d/Y' => 10, - ); - - $value = trim($value); - - foreach ($formats as $format => $length) { - - $truncated_value = $value; - if ($length !== null) { - $truncated_value = substr($truncated_value, 0, $length); - } - - $timestamp = $this->getValidDate($format, $truncated_value); - if ($timestamp > 0) { - return $timestamp; - } - } - - $date = new DateTime('now', new DateTimeZone($this->timezone)); - return $date->getTimestamp(); - } - - /** - * Get a valid date from a given format - * - * @access public - * @param string $format Date format - * @param string $value Original date value - * @return integer Timestamp - */ - public function getValidDate($format, $value) - { - $date = DateTime::createFromFormat($format, $value, new DateTimeZone($this->timezone)); - - if ($date !== false) { - - $errors = DateTime::getLastErrors(); - - if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { - return $date->getTimestamp(); - } - } - - return 0; - } - - /** - * Return true if the given language is "Right to Left" - * - * @static - * @access public - * @param string $language Language: fr-FR, en-US - * @return bool - */ - public static function isLanguageRTL($language) - { - $language = strtolower($language); - - $rtl_languages = array( - 'ar', // Arabic (ar-**) - 'fa', // Farsi (fa-**) - 'ur', // Urdu (ur-**) - 'ps', // Pashtu (ps-**) - 'syr', // Syriac (syr-**) - 'dv', // Divehi (dv-**) - 'he', // Hebrew (he-**) - 'yi', // Yiddish (yi-**) - ); - - foreach ($rtl_languages as $prefix) { - if (strpos($language, $prefix) === 0) { - return true; - } - } - - return false; - } - - /** - * Set Hash algorithm used for id generation - * - * @access public - * @param string $algo Algorithm name - * @return \PicoFeed\Parser\Parser - */ - public function setHashAlgo($algo) - { - $this->hash_algo = $algo ?: $this->hash_algo; - return $this; - } - - /** - * Set a different timezone - * - * @see http://php.net/manual/en/timezones.php - * @access public - * @param string $timezone Timezone - * @return \PicoFeed\Parser\Parser - */ - public function setTimezone($timezone) - { - $this->timezone = $timezone ?: $this->timezone; - return $this; - } - - /** - * Set config object - * - * @access public - * @param \PicoFeed\Config\Config $config Config instance - * @return \PicoFeed\Parser\Parser - */ - public function setConfig($config) - { - $this->config = $config; - return $this; - } - - /** - * Enable the content grabber - * - * @access public - * @return \PicoFeed\Parser\Parser - */ - public function disableContentFiltering() - { - $this->enable_filter = false; - } - - /** - * Return true if the content filtering is enabled - * - * @access public - * @return boolean - */ - public function isFilteringEnabled() - { - if ($this->config === null) { - return $this->enable_filter; - } - - return $this->config->getContentFiltering($this->enable_filter); - } - - /** - * Enable the content grabber - * - * @access public - * @return \PicoFeed\Parser\Parser - */ - public function enableContentGrabber() - { - $this->enable_grabber = true; - } - - /** - * Set ignored URLs for the content grabber - * - * @access public - * @param array $urls URLs - * @return \PicoFeed\Parser\Parser - */ - public function setGrabberIgnoreUrls(array $urls) - { - $this->grabber_ignore_urls = $urls; - } - - /** - * Find the feed url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedUrl(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the site url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findSiteUrl(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the feed title - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedTitle(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the feed description - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedDescription(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the feed language - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedLanguage(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the feed id - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedId(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the feed date - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedDate(SimpleXMLElement $xml, Feed $feed); - - /** - * Find the feed logo url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findFeedLogo(SimpleXMLElement $xml, Feed $feed); - - /** - * Get the path to the items XML tree - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @return SimpleXMLElement - */ - public abstract function getItemsTree(SimpleXMLElement $xml); - - /** - * Find the item author - * - * @access public - * @param SimpleXMLElement $xml Feed - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public abstract function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item); - - /** - * Find the item URL - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public abstract function findItemUrl(SimpleXMLElement $entry, Item $item); - - /** - * Find the item title - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public abstract function findItemTitle(SimpleXMLElement $entry, Item $item); - - /** - * Genereate the item id - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed); - - /** - * Find the item date - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public abstract function findItemDate(SimpleXMLElement $entry, Item $item); - - /** - * Find the item content - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public abstract function findItemContent(SimpleXMLElement $entry, Item $item); - - /** - * Find the item enclosure - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed); - - /** - * Find the item language - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public abstract function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed); -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/ParserException.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/ParserException.php deleted file mode 100644 index 40e48abc0..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/ParserException.php +++ /dev/null @@ -1,16 +0,0 @@ -item; - } - - /** - * Find the feed date - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedDate(SimpleXMLElement $xml, Feed $feed) - { - $feed->date = $this->parseDate(XmlParser::getNamespaceValue($xml->channel, $this->namespaces, 'date')); - } - - /** - * Find the feed language - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed) - { - $feed->language = XmlParser::getNamespaceValue($xml->channel, $this->namespaces, 'language'); - } - - /** - * Genereate the item id - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed) - { - $item->id = $this->generateId( - $item->getTitle(), $item->getUrl(), $item->getContent() - ); - } - - /** - * Find the item enclosure - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed) - { - } -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php deleted file mode 100644 index c0417f9ac..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php +++ /dev/null @@ -1,287 +0,0 @@ -channel->item; - } - - /** - * Find the feed url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedUrl(SimpleXMLElement $xml, Feed $feed) - { - $feed->feed_url = ''; - } - - /** - * Find the site url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findSiteUrl(SimpleXMLElement $xml, Feed $feed) - { - $feed->site_url = (string) $xml->channel->link; - } - - /** - * Find the feed description - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedDescription(SimpleXMLElement $xml, Feed $feed) - { - $feed->description = (string) $xml->channel->description; - } - - /** - * Find the feed logo url - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedLogo(SimpleXMLElement $xml, Feed $feed) - { - if (isset($xml->channel->image->url)) { - $feed->logo = (string) $xml->channel->image->url; - } - } - - /** - * Find the feed title - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedTitle(SimpleXMLElement $xml, Feed $feed) - { - $feed->title = Filter::stripWhiteSpace((string) $xml->channel->title) ?: $feed->getSiteUrl(); - } - - /** - * Find the feed language - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedLanguage(SimpleXMLElement $xml, Feed $feed) - { - $feed->language = isset($xml->channel->language) ? (string) $xml->channel->language : ''; - } - - /** - * Find the feed id - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedId(SimpleXMLElement $xml, Feed $feed) - { - $feed->id = $feed->getFeedUrl() ?: $feed->getSiteUrl(); - } - - /** - * Find the feed date - * - * @access public - * @param SimpleXMLElement $xml Feed xml - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findFeedDate(SimpleXMLElement $xml, Feed $feed) - { - $date = isset($xml->channel->pubDate) ? $xml->channel->pubDate : $xml->channel->lastBuildDate; - $feed->date = $this->parseDate((string) $date); - } - - /** - * Find the item date - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemDate(SimpleXMLElement $entry, Item $item) - { - $date = XmlParser::getNamespaceValue($entry, $this->namespaces, 'date'); - - if (empty($date)) { - $date = XmlParser::getNamespaceValue($entry, $this->namespaces, 'updated'); - } - - if (empty($date)) { - $date = (string) $entry->pubDate; - } - - $item->date = $this->parseDate($date); - } - - /** - * Find the item title - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemTitle(SimpleXMLElement $entry, Item $item) - { - $item->title = Filter::stripWhiteSpace((string) $entry->title); - - if (empty($item->title)) { - $item->title = $item->url; - } - } - - /** - * Find the item author - * - * @access public - * @param SimpleXMLElement $xml Feed - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemAuthor(SimpleXMLElement $xml, SimpleXMLElement $entry, Item $item) - { - $item->author = XmlParser::getNamespaceValue($entry, $this->namespaces, 'creator'); - - if (empty($item->author)) { - if (isset($entry->author)) { - $item->author = (string) $entry->author; - } - else if (isset($xml->channel->webMaster)) { - $item->author = (string) $xml->channel->webMaster; - } - } - } - - /** - * Find the item content - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemContent(SimpleXMLElement $entry, Item $item) - { - $content = XmlParser::getNamespaceValue($entry, $this->namespaces, 'encoded'); - - if (empty($content) && $entry->description->count() > 0) { - $content = (string) $entry->description; - } - - $item->content = $content; - } - - /** - * Find the item URL - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - */ - public function findItemUrl(SimpleXMLElement $entry, Item $item) - { - $links = array( - XmlParser::getNamespaceValue($entry, $this->namespaces, 'origLink'), - isset($entry->link) ? (string) $entry->link : '', - XmlParser::getNamespaceValue($entry, $this->namespaces, 'link', 'href'), - isset($entry->guid) ? (string) $entry->guid : '', - ); - - foreach ($links as $link) { - if (! empty($link) && filter_var($link, FILTER_VALIDATE_URL) !== false) { - $item->url = $link; - break; - } - } - } - - /** - * Genereate the item id - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemId(SimpleXMLElement $entry, Item $item, Feed $feed) - { - $id = (string) $entry->guid; - - if ($id) { - $item->id = $this->generateId($id); - } - else { - $item->id = $this->generateId( - $item->getTitle(), $item->getUrl(), $item->getContent() - ); - } - } - - /** - * Find the item enclosure - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemEnclosure(SimpleXMLElement $entry, Item $item, Feed $feed) - { - if (isset($entry->enclosure)) { - - $item->enclosure_url = XmlParser::getNamespaceValue($entry->enclosure, $this->namespaces, 'origEnclosureLink'); - - if (empty($item->enclosure_url)) { - $item->enclosure_url = isset($entry->enclosure['url']) ? (string) $entry->enclosure['url'] : ''; - } - - $item->enclosure_type = isset($entry->enclosure['type']) ? (string) $entry->enclosure['type'] : ''; - $item->enclosure_url = Url::resolve($item->enclosure_url, $feed->getSiteUrl()); - } - } - - /** - * Find the item language - * - * @access public - * @param SimpleXMLElement $entry Feed item - * @param \PicoFeed\Parser\Item $item Item object - * @param \PicoFeed\Parser\Feed $feed Feed object - */ - public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed) - { - $item->language = $feed->language; - } -} diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss91.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss91.php deleted file mode 100644 index 69f175313..000000000 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss91.php +++ /dev/null @@ -1,13 +0,0 @@ -childNodes as $child) { - if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { - if ($child->entities->length > 0) { - return false; - } - } - } - - return $dom; - } - - /** - * Get a DomDocument instance or return false - * - * @static - * @access public - * @param string $input XML content - * @return \DOMNode - */ - public static function getDomDocument($input) - { - $dom = self::scanInput($input, function ($in) { - $dom = new DomDocument; - $dom->loadXml($in, LIBXML_NONET); - return $dom; - }); - - // The document is empty, there is probably some parsing errors - if ($dom && $dom->childNodes->length === 0) { - return false; - } - - return $dom; - } - - /** - * Load HTML document by using a DomDocument instance or return false on failure - * - * @static - * @access public - * @param string $input XML content - * @return \DOMDocument - */ - public static function getHtmlDocument($input) - { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - $callback = function ($in) { - $dom = new DomDocument; - $dom->loadHTML($in, LIBXML_NONET); - return $dom; - }; - } - else { - $callback = function ($in) { - $dom = new DomDocument; - $dom->loadHTML($in); - return $dom; - }; - } - - return self::scanInput($input, $callback); - } - - /** - * Convert a HTML document to XML - * - * @static - * @access public - * @param string $html HTML document - * @return string - */ - public static function HtmlToXml($html) - { - $dom = self::getHtmlDocument(''.$html); - return $dom->saveXML($dom->getElementsByTagName('body')->item(0)); - } - - /** - * Get XML parser errors - * - * @static - * @access public - * @return string - */ - public static function getErrors() - { - $errors = array(); - - foreach(libxml_get_errors() as $error) { - - $errors[] = sprintf('XML error: %s (Line: %d - Column: %d - Code: %d)', - $error->message, - $error->line, - $error->column, - $error->code - ); - } - - return implode(', ', $errors); - } - - /** - * Get the encoding from a xml tag - * - * @static - * @access public - * @param string $data Input data - * @return string - */ - public static function getEncodingFromXmlTag($data) - { - $encoding = ''; - - if (strpos($data, '')); - $data = str_replace("'", '"', $data); - - $p1 = strpos($data, 'encoding='); - $p2 = strpos($data, '"', $p1 + 10); - - $encoding = substr($data, $p1 + 10, $p2 - $p1 - 10); - $encoding = strtolower($encoding); - } - - return $encoding; - } - - /** - * Get xml:lang value - * - * @static - * @access public - * @param string $xml XML string - * @return string Language - */ - public static function getXmlLang($xml) - { - $dom = self::getDomDocument($xml); - - if ($dom === false) { - return ''; - } - - $xpath = new DOMXPath($dom); - return $xpath->evaluate('string(//@xml:lang[1])') ?: ''; - } - - /** - * Get a value from a XML namespace - * - * @static - * @access public - * @param \SimpleXMLElement $xml XML element - * @param array $namespaces XML namespaces - * @param string $property XML tag name - * @param string $attribute XML attribute name - * @return string - */ - public static function getNamespaceValue(SimpleXMLElement $xml, array $namespaces, $property, $attribute = '') - { - foreach ($namespaces as $name => $url) { - $namespace = $xml->children($namespaces[$name]); - - if ($namespace->$property->count() > 0) { - - if ($attribute) { - - foreach ($namespace->$property->attributes() as $xml_attribute => $xml_value) { - if ($xml_attribute === $attribute && $xml_value) { - return (string) $xml_value; - } - } - } - - return (string) $namespace->$property; - } - } - - return ''; - } -} -- cgit v1.2.3