diff options
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed')
8 files changed, 63 insertions, 36 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php index e8012dd98..ae77ff714 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php @@ -215,7 +215,8 @@ class Attribute * @var array */ private $add_attributes = array( - 'a' => array('rel' => 'noreferrer', 'target' => '_blank') + 'a' => array('rel' => 'noreferrer', 'target' => '_blank'), + 'video' => array('controls' => 'true'), ); /** diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php index 1585131c7..d891ef41c 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php @@ -100,6 +100,47 @@ class Item public $language = ''; /** + * Raw XML + * + * @access public + * @var \SimpleXMLElement + */ + public $xml; + + /** + * List of namespaces + * + * @access public + * @var array + */ + public $namespaces = array(); + + /** + * Get specific XML tag or attribute value + * + * @access public + * @param string $tag Tag name (examples: guid, media:content) + * @param string $attribute Tag attribute + * @return string + */ + public function getTag($tag, $attribute = '') + { + // Get namespaced value + if (strpos($tag, ':') !== false) { + list(,$tag) = explode(':', $tag); + return XmlParser::getNamespaceValue($this->xml, $this->namespaces, $tag, $attribute); + } + + // Return attribute value + if (! empty($attribute)) { + return (string) $this->xml->{$tag}[$attribute]; + } + + // Return tag content + return (string) $this->xml->$tag; + } + + /** * Return item information * * @access public diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php index 4d45f539c..7ef904f0a 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php @@ -153,6 +153,9 @@ abstract class Parser foreach ($this->getItemsTree($xml) as $entry) { $item = new Item; + $item->xml = $entry; + $item->namespaces = $this->namespaces; + $this->findItemAuthor($xml, $entry, $item); $this->findItemUrl($entry, $item); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php index 2c68c50a5..feda8c254 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php @@ -212,21 +212,7 @@ class XmlParser } /** - * Extract charset from meta tag - * - * @static - * @access public - * @param string $data meta tag content - * @return string - */ - public static function findCharset($data) - { - $result = explode('charset=', $data); - return isset($result[1]) ? $result[1] : $data; - } - - /** - * Get the encoding from a xml tag + * Get the charset from a meta tag * * @static * @access public @@ -237,18 +223,8 @@ class XmlParser { $encoding = ''; - $dom = static::getHtmlDocument($data); - $xpath = new DOMXPath($dom); - - $tags = array( - '/html/head/meta[translate(@http-equiv, "CENOPTY", "cenopty")="content-type"]/@content', //HTML4, convert upper to lower-case - '/html/head/meta/@charset', //HTML5 - ); - - $nodes = $xpath->query(implode(' | ', $tags)); - - foreach ($nodes as $node) { - $encoding = static::findCharset($node->nodeValue); + if (preg_match('/<meta.*?charset\s*=\s*["\']?\s*([^"\'\s\/>;]+)/i', $data, $match) === 1) { + $encoding = strtolower($match[1]); } return $encoding; diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Reader/Reader.php b/vendor/fguillot/picofeed/lib/PicoFeed/Reader/Reader.php index fd629f094..ea3c4f299 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Reader/Reader.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Reader/Reader.php @@ -58,9 +58,11 @@ class Reader * @param string $url Feed url * @param string $last_modified Last modified HTTP header * @param string $etag Etag HTTP header + * @param string $username HTTP basic auth username + * @param string $password HTTP basic auth password * @return \PicoFeed\Client\Client */ - public function download($url, $last_modified = '', $etag = '') + public function download($url, $last_modified = '', $etag = '', $username = '', $password = '') { $url = $this->prependScheme($url); @@ -68,6 +70,8 @@ class Reader ->setConfig($this->config) ->setLastModified($last_modified) ->setEtag($etag) + ->setUsername($username) + ->setPassword($password) ->execute($url); } @@ -78,11 +82,13 @@ class Reader * @param string $url Feed or website url * @param string $last_modified Last modified HTTP header * @param string $etag Etag HTTP header + * @param string $username HTTP basic auth username + * @param string $password HTTP basic auth password * @return \PicoFeed\Client\Client */ - public function discover($url, $last_modified = '', $etag = '') + public function discover($url, $last_modified = '', $etag = '', $username = '', $password = '') { - $client = $this->download($url, $last_modified, $etag); + $client = $this->download($url, $last_modified, $etag, $username, $password); // It's already a feed or the feed was not modified if (! $client->isModified() || $this->detectFormat($client->getContent())) { @@ -96,7 +102,7 @@ class Reader throw new SubscriptionNotFoundException('Unable to find a subscription'); } - return $this->download($links[0], $last_modified, $etag); + return $this->download($links[0], $last_modified, $etag, $username, $password); } /** diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.phoronix.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.phoronix.com.php index 0d10eff28..0fd99f7b6 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.phoronix.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.phoronix.com.php @@ -2,7 +2,7 @@ return array( 'test_url' => 'http://www.phoronix.com/scan.php?page=article&item=amazon_ec2_bare&num=1', 'body' => array( - '//article[@class="KonaBody"]', + '//div[@class="KonaBody"]', ), 'strip' => array( ) diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lesjoiesducode.fr.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lesjoiesducode.fr.php index 3ade94b94..68e097ab3 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lesjoiesducode.fr.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lesjoiesducode.fr.php @@ -2,7 +2,7 @@ return array( 'test_url' => 'http://lesjoiesducode.fr/post/75576211207/quand-lappli-ne-fonctionne-plus-sans-aucune-raison', 'body' => array( - '//div[@class="post"]//img', + '//div[@class="blog-post-content"]', ), 'strip' => array( ) diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/monwindowsphone.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/monwindowsphone.com.php index be7f208a3..cfc4b2d08 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/monwindowsphone.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/monwindowsphone.com.php @@ -2,8 +2,8 @@ return array( 'test_url' => 'http://www.monwindowsphone.com/tout-savoir-sur-le-centre-d-action-de-windows-phone-8-1-t40574.html', 'body' => array( - '//div[@class="postmessage"]' + '//div[@class="blog-post-body"]' ), 'strip' => array( ), -);
\ No newline at end of file +); |