All fields available in the RSS

Not just link & title but all available fields
This commit is contained in:
Axome
2013-08-05 17:58:49 +02:00
parent cf9d20f83b
commit 9dfeb1d528
+19 -5
View File
@@ -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');
}
}
}