diff options
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php')
-rw-r--r-- | vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php | 108 |
1 files changed, 51 insertions, 57 deletions
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php index 80e09e016..de73504e4 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php @@ -141,6 +141,9 @@ abstract class Parser $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); @@ -185,10 +188,27 @@ abstract class Parser */ public function checkFeedUrl(Feed $feed) { - $url = new Url($feed->getUrl()); + if ($feed->getFeedUrl() === '') { + $feed->feed_url = $this->fallback_url; + } + else { + $feed->feed_url = Url::resolve($feed->getFeedUrl(), $this->fallback_url); + } + } - if ($url->isRelativeUrl()) { - $feed->url = $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); } } @@ -201,11 +221,7 @@ abstract class Parser */ public function checkItemUrl(Feed $feed, Item $item) { - $url = new Url($item->getUrl()); - - if ($url->isRelativeUrl()) { - $item->url = Url::resolve($item->getUrl(), $feed->getUrl()); - } + $item->url = Url::resolve($item->getUrl(), $feed->getSiteUrl()); } /** @@ -238,7 +254,7 @@ abstract class Parser public function filterItemContent(Feed $feed, Item $item) { if ($this->isFilteringEnabled()) { - $filter = Filter::html($item->getContent(), $feed->getUrl()); + $filter = Filter::html($item->getContent(), $feed->getSiteUrl()); $filter->setConfig($this->config); $item->content = $filter->execute(); } @@ -283,6 +299,7 @@ abstract class Parser '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, @@ -340,38 +357,6 @@ 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 @@ -464,16 +449,25 @@ abstract class Parser * Find the feed url * * @access public - * @param SimpleXMLElement $xml Feed xml + * @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 SimpleXMLElement $xml Feed xml * @param \PicoFeed\Parser\Feed $feed Feed object */ public abstract function findFeedTitle(SimpleXMLElement $xml, Feed $feed); @@ -482,7 +476,7 @@ abstract class Parser * Find the feed description * * @access public - * @param SimpleXMLElement $xml Feed xml + * @param SimpleXMLElement $xml Feed xml * @param \PicoFeed\Parser\Feed $feed Feed object */ public abstract function findFeedDescription(SimpleXMLElement $xml, Feed $feed); @@ -491,7 +485,7 @@ abstract class Parser * Find the feed language * * @access public - * @param SimpleXMLElement $xml Feed xml + * @param SimpleXMLElement $xml Feed xml * @param \PicoFeed\Parser\Feed $feed Feed object */ public abstract function findFeedLanguage(SimpleXMLElement $xml, Feed $feed); @@ -500,7 +494,7 @@ abstract class Parser * Find the feed id * * @access public - * @param SimpleXMLElement $xml Feed xml + * @param SimpleXMLElement $xml Feed xml * @param \PicoFeed\Parser\Feed $feed Feed object */ public abstract function findFeedId(SimpleXMLElement $xml, Feed $feed); @@ -509,7 +503,7 @@ abstract class Parser * Find the feed date * * @access public - * @param SimpleXMLElement $xml Feed xml + * @param SimpleXMLElement $xml Feed xml * @param \PicoFeed\Parser\Feed $feed Feed object */ public abstract function findFeedDate(SimpleXMLElement $xml, Feed $feed); @@ -518,7 +512,7 @@ abstract class Parser * Find the feed logo url * * @access public - * @param SimpleXMLElement $xml Feed xml + * @param SimpleXMLElement $xml Feed xml * @param \PicoFeed\Parser\Feed $feed Feed object */ public abstract function findFeedLogo(SimpleXMLElement $xml, Feed $feed); @@ -536,8 +530,8 @@ abstract class Parser * Find the item author * * @access public - * @param SimpleXMLElement $xml Feed - * @param SimpleXMLElement $entry Feed item + * @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); @@ -546,7 +540,7 @@ abstract class Parser * Find the item URL * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object */ public abstract function findItemUrl(SimpleXMLElement $entry, Item $item); @@ -555,7 +549,7 @@ abstract class Parser * Find the item title * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object */ public abstract function findItemTitle(SimpleXMLElement $entry, Item $item); @@ -564,7 +558,7 @@ abstract class Parser * Genereate the item id * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ @@ -574,7 +568,7 @@ abstract class Parser * Find the item date * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object */ public abstract function findItemDate(SimpleXMLElement $entry, Item $item); @@ -583,7 +577,7 @@ abstract class Parser * Find the item content * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object */ public abstract function findItemContent(SimpleXMLElement $entry, Item $item); @@ -592,7 +586,7 @@ abstract class Parser * Find the item enclosure * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ @@ -602,7 +596,7 @@ abstract class Parser * Find the item language * * @access public - * @param SimpleXMLElement $entry Feed item + * @param SimpleXMLElement $entry Feed item * @param \PicoFeed\Parser\Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ |