diff options
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Parser')
5 files changed, 61 insertions, 20 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php index 5bb930b22..154ed3cfb 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php @@ -192,7 +192,7 @@ class Atom extends Parser */ public function findItemUrl(SimpleXMLElement $entry, Item $item) { - $item->url = $this->getUrl($entry, 'alternate'); + $item->url = $this->getUrl($entry, 'alternate', true); } /** @@ -245,7 +245,13 @@ class Atom extends Parser */ public function findItemLanguage(SimpleXMLElement $entry, Item $item, Feed $feed) { - $item->language = $feed->language; + $language = (string) $entry->attributes('xml', true)->{'lang'}; + + if ($language === '') { + $language = $feed->language; + } + + $item->language = $language; } /** @@ -283,7 +289,7 @@ class Atom extends Parser private function findLink(SimpleXMLElement $xml, $rel) { foreach ($xml->link as $link) { - if (empty($rel) || $rel === (string) $link['rel']) { + if ($rel === (string) $link['rel']) { return $link; } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php index b8edbd6f8..99fc27e8e 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php @@ -96,6 +96,7 @@ class Feed $output .= 'Feed::'.$property.' = '.$this->$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) { @@ -204,4 +205,15 @@ class Feed { 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 index 6b2864ba7..3642cccea 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php @@ -226,14 +226,6 @@ class Item */ public function isRTL() { - $language = strtolower($this->language); - - foreach ($this->rtl as $prefix) { - if (strpos($language, $prefix) === 0) { - return true; - } - } - - return false; + return Parser::isLanguageRTL($this->language); } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php index de73504e4..44f0c8e38 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php @@ -5,7 +5,6 @@ namespace PicoFeed\Parser; use SimpleXMLElement; use DateTime; use DateTimeZone; - use PicoFeed\Encoding\Encoding; use PicoFeed\Filter\Filter; use PicoFeed\Logging\Logger; @@ -96,9 +95,9 @@ abstract class Parser * Constructor * * @access public - * @param string $content Feed content - * @param string $http_encoding HTTP encoding (headers) - * @param string $base_url Fallback url when the feed provide relative or broken url + * @param string $content Feed content + * @param string $http_encoding HTTP encoding (headers) + * @param string $fallback_url Fallback url when the feed provide relative or broken url */ public function __construct($content, $http_encoding = '', $fallback_url = '') { @@ -268,7 +267,7 @@ abstract class Parser * * @access public * @param string $args Pieces of data to hash - * @return string Id + * @return string */ public function generateId() { @@ -357,6 +356,38 @@ abstract class Parser } /** + * 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 diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php index 2b007e199..0afc89d5d 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php @@ -90,7 +90,7 @@ class XmlParser * @static * @access public * @param string $input XML content - * @return mixed + * @return \DOMNode */ public static function getDomDocument($input) { @@ -114,7 +114,7 @@ class XmlParser * @static * @access public * @param string $input XML content - * @return mixed + * @return \DOMDocument */ public static function getHtmlDocument($input) { @@ -226,7 +226,7 @@ class XmlParser * * @static * @access public - * @param SimpleXMLElement $xml XML element + * @param \SimpleXMLElement $xml XML element * @param array $namespaces XML namespaces * @param string $property XML tag name * @param string $attribute XML attribute name |