From 84f7fe24feefd6774f77374afc1db59808d94c0f Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 16 Apr 2020 10:49:39 +0200 Subject: [PATCH] Adress feedback --- htdocs/core/class/rssparser.class.php | 148 +++++++++++++------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 94bcb4b3b5d..dd02bf365c1 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -364,7 +364,7 @@ class RssParser if (!empty($rss->channel['title'])) $this->_title = (string) $rss->channel['title']; //if (!empty($rss->channel['rss_description'])) $this->_description = (string) $rss->channel['rss_description']; - $this->_imageurl = _getAtomImageUrl($rss->channel); + $this->_imageurl = $this->getAtomImageUrl($rss->channel); } if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { $tmprss = xml2php($rss); $items = $tmprss['entry']; @@ -418,7 +418,7 @@ class RssParser { $itemLink = (isset($item['link']) ? (string) $item['link'] : ''); $itemTitle = (string) $item['title']; - $itemDescription = _getAtomItemDescription($item); + $itemDescription = $this->getAtomItemDescription($item); $itemPubDate = (string) $item['created']; $itemId = (string) $item['id']; $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']); @@ -427,7 +427,7 @@ class RssParser { $itemLink = (isset($item['link']) ? (string) $item['link'] : ''); $itemTitle = (string) $item['title']; - $itemDescription = _getAtomItemDescription($item); + $itemDescription = $this->getAtomItemDescription($item); $itemPubDate = (string) $item['created']; $itemId = (string) $item['id']; $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']); @@ -741,6 +741,77 @@ class RssParser } } } + + /** + * Return a description/summary for one item from a ATOM feed + * + * @param array $item A parsed item of a ATOM feed + * @param int $maxlength (optional) The maximum length for the description + * @return string A summary description + */ + private function getAtomItemDescription(array $item, $maxlength = 500) + { + $result = ""; + + if (isset($item['summary'])) + { + $result = $item['summary']; + } + elseif (isset($item['atom_content'])) + { + $result = $item['atom_content']; + } + + // remove all HTML elements that can possible break the maximum size of a tooltip, + // like headings, image, video etc. and allow only simple style elements + $result = strip_tags($result, "