From 9dfeb1d5284cc8ffc9c86ead66b17557fd790f2f Mon Sep 17 00:00:00 2001 From: Axome Date: Mon, 5 Aug 2013 17:58:49 +0200 Subject: [PATCH] All fields available in the RSS Not just link & title but all available fields --- modules/blockrss/blockrss.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/blockrss/blockrss.php b/modules/blockrss/blockrss.php index 9cf3d2f6a..102b1fbb8 100644 --- a/modules/blockrss/blockrss.php +++ b/modules/blockrss/blockrss.php @@ -32,6 +32,9 @@ include_once(_PS_PEAR_XML_PARSER_PATH_.'Parser.php'); class Blockrss extends Module { + + private static $xmlFields = array('title', 'guid', 'description', 'author', 'comments', 'pubDate', 'source', 'link', 'content'); + function __construct() { $this->name = 'blockrss'; @@ -154,10 +157,21 @@ class Blockrss extends Module if ($url && ($contents = Tools::file_get_contents($url))) try { - if (@$src = new XML_Feed_Parser($contents)) - for ($i = 0; $i < ($nb ? $nb : 5); $i++) - if (@$item = $src->getEntryByOffset($i)) - $rss_links[] = array('title' => $item->title, 'url' => $item->link); + if (@$src = new XML_Feed_Parser($contents)) { + for ($i = 0; $i < ($nb ? $nb : 5); $i++) { + if (@$item = $src->getEntryByOffset($i)) { + + $xmlValues = array(); + foreach(self::$xmlFields as $xmlField) { + $xmlValues[$xmlField] = $item->__get($xmlField); + } + $xmlValues['enclosure'] = $item->getEnclosure(); + # Compatibility + $xmlValues['url'] = $xmlValues['link']; + $rss_links[] = $xmlValues; + } + } + } } catch (XML_Feed_Parser_Exception $e) { @@ -179,4 +193,4 @@ class Blockrss extends Module { $this->context->controller->addCSS(($this->_path).'blockrss.css', 'all'); } -} \ No newline at end of file +}