This commit is contained in:
gRoussac
2013-11-27 19:21:57 +01:00
parent 76f115ac22
commit 65106c6a24
+27 -27
View File
@@ -124,36 +124,36 @@ class Blockrss extends Module
$url = strval(Configuration::get('RSS_FEED_URL')); $url = strval(Configuration::get('RSS_FEED_URL'));
$nb = (int)(Configuration::get('RSS_FEED_NBR')); $nb = (int)(Configuration::get('RSS_FEED_NBR'));
// Getting data $cacheId = $this->getCacheId($this->name.'-'.date("YmdH"));
$rss_links = array(); if (!$this->isCached('blockrss.tpl', $cacheId))
if ($url && ($contents = Tools::file_get_contents($url))) {
try // Getting data
{ $rss_links = array();
if (@$src = new XML_Feed_Parser($contents)) { if ($url && ($contents = Tools::file_get_contents($url)))
for ($i = 0; $i < ($nb ? $nb : 5); $i++) { try
if (@$item = $src->getEntryByOffset($i)) { {
if (@$src = new XML_Feed_Parser($contents))
$xmlValues = array(); for ($i = 0; $i < ($nb ? $nb : 5); $i++)
foreach(self::$xmlFields as $xmlField) { if (@$item = $src->getEntryByOffset($i))
$xmlValues[$xmlField] = $item->__get($xmlField); {
$xmlValues = array();
foreach(self::$xmlFields as $xmlField)
$xmlValues[$xmlField] = $item->__get($xmlField);
$xmlValues['enclosure'] = $item->getEnclosure();
# Compatibility
$xmlValues['url'] = $xmlValues['link'];
$rss_links[] = $xmlValues;
} }
$xmlValues['enclosure'] = $item->getEnclosure();
# Compatibility
$xmlValues['url'] = $xmlValues['link'];
$rss_links[] = $xmlValues;
}
}
} }
} catch (XML_Feed_Parser_Exception $e)
catch (XML_Feed_Parser_Exception $e) {
{ Tools::dieOrLog(sprintf($this->l('Error: invalid RSS feed in "blockrss" module: %s'), $e->getMessage()), false);
Tools::dieOrLog(sprintf($this->l('Error: invalid RSS feed in "blockrss" module: %s'), $e->getMessage()), false); }
} // Display smarty
$this->smarty->assign(array('title' => ($title ? $title : $this->l('RSS feed')), 'rss_links' => $rss_links));
}
// Display smarty return $this->display(__FILE__, 'blockrss.tpl', $cacheId);
$this->smarty->assign(array('title' => ($title ? $title : $this->l('RSS feed')), 'rss_links' => $rss_links));
return $this->display(__FILE__, 'blockrss.tpl');
} }
function hookRightColumn($params) function hookRightColumn($params)