From e69a9bd03efc759f5a11a6b217db734340a36972 Mon Sep 17 00:00:00 2001 From: Artur Kyryliuk Date: Fri, 2 Dec 2022 04:56:13 +0100 Subject: [PATCH] Fixed RSS --- core/functions/rss.php | 2 +- manager/views/page/2.blade.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/functions/rss.php b/core/functions/rss.php index 1bcc8dba58..5529f2bad3 100644 --- a/core/functions/rss.php +++ b/core/functions/rss.php @@ -10,7 +10,7 @@ function fetchCacheableRss($url, $xpath = null, Closure $callback = null) if (!$content) { return $items; } - + $content = str_replace('xmlns=', 'ns=', $content); $xml = new SimpleXmlElement($content); if ($xpath) { diff --git a/manager/views/page/2.blade.php b/manager/views/page/2.blade.php index 847c02de11..1e5e20c863 100644 --- a/manager/views/page/2.blade.php +++ b/manager/views/page/2.blade.php @@ -201,12 +201,13 @@ // create Feed foreach ($urls as $section => $url) { $output = ''; - $items = fetchCacheableRss($url, 'channel/item', function(SimpleXMLElement $entry){ + $items = fetchCacheableRss($url, '//entry', function(SimpleXMLElement $entry){ $props = []; foreach ($entry as $prop) { - if (mb_strtolower($prop->getName()) === 'pubdate' && ($time = @strtotime($prop->__toString())) > 0) { - $props['date_timestamp'] = $time; - $props['pubdate'] = $prop->__toString(); + if (mb_strtolower($prop->getName()) === 'updated' && ($time = @strtotime($prop->__toString())) > 0) { + $props['updated'] = $prop->__toString(); + } elseif (mb_strtolower($prop->getName()) === 'link') { + $props['link'] = $prop->attributes()['href']->__toString(); } else { $props[$prop->getName()] = $prop->__toString(); } @@ -222,11 +223,11 @@ $items = array_slice($items, 0, $itemsNumber); foreach ($items as $item) { - $href = rel2abs($item['link'], 'https://github.com'); + $href = $item['link']; $title = $item['title']; - $pubdate = $item['pubdate']; + $pubdate = $item['updated']; $pubdate = EvolutionCMS()->toDateFormat(strtotime($pubdate)); - $description = strip_tags($item['description']); + $description = strip_tags($item['content']); if (strlen($description) > 199) { $description = substr($description, 0, 200); $description .= '...
Read more.';