* @copyright 2007-2012 PrestaShop SA * @version Release: $Revision: 14011 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; class Feeder extends Module { private $_postErrors = array(); public function __construct() { $this->name = 'feeder'; $this->tab = 'front_office_features'; $this->version = 0.2; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->_directory = dirname(__FILE__).'/../../'; parent::__construct(); $this->displayName = $this->l('RSS products feed'); $this->description = $this->l('Generate a RSS products feed'); } function install() { if (!parent::install()) return false; if (!$this->registerHook('header')) return false; return true; } function hookHeader($params) { global $smarty, $cookie; $id_category = (int)(Tools::getValue('id_category')); if (!$id_category) { if (isset($_SERVER['HTTP_REFERER']) AND preg_match('!^(.*)\/([0-9]+)\-(.*[^\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) AND !strstr($_SERVER['HTTP_REFERER'], '.html')) { if (isset($regs[2]) AND is_numeric($regs[2])) $id_category = (int)($regs[2]); elseif (isset($regs[5]) AND is_numeric($regs[5])) $id_category = (int)($regs[5]); } elseif ($id_product = (int)(Tools::getValue('id_product'))) { $product = new Product($id_product); $id_category = $product->id_category_default; } } $category = new Category($id_category); $orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby')); $orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway')); $smarty->assign(array( 'feedUrl' => Tools::getShopDomain(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/rss.php?id_category='.$id_category.'&orderby='.$orderBy.'&orderway='.$orderWay, )); return $this->display(__FILE__, 'feederHeader.tpl'); } public function getContent() { /* display the module name */ $this->_html = '

'.$this->displayName.'


'; $this->_html .= $this->l('Url for example:').'
'; $orderBy = Tools::getProductsOrder('by'); $orderWay = Tools::getProductsOrder('way'); $this->_html .= Tools::getShopDomain(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/rss.php?id_category={id_category}&orderby='.$orderBy.'&orderway='.$orderWay; $this->_html .= '

'.$this->l('Replace').' {id_category} '.$this->l('by the id category current or "0"'); return $this->_html; } }