bebeboutik/modules/privatesales/feed.php

50 lines
1.7 KiB
PHP
Raw Normal View History

2016-01-04 12:49:26 +01:00
<?php
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/Sale.php');
$controller->preProcess();
if($format = Tools::getValue('format', 'atom')) {
$langs = Language::getLanguages();
$lang = (int) Tools::getValue('id_lang', Configuration::get('PS_LANG_DEFAULT'));
$isolang = Language::getIsoById($lang);
$feed_i18n = array(
'fr' => 'flux',
'en' => 'feed',
);
$trailer_i18n = array(
'fr' => 'bande-annonce',
'en' => 'trailer',
);
smartyRegisterFunction($smarty, 'modifier', 'str2url', array('Tools', 'str2url'));
if(Configuration::get('PS_REWRITING_SETTINGS')) {
$smarty->assign(array(
'rewriting' => TRUE,
'feed_url' => (count($langs) > 1? (isset($feed_i18n[$isolang])? $isolang.'/'.$feed_i18n[$isolang]: $isolang.'/'.$feed_i18n['en']): (isset($feed_i18n[$isolang])? $feed_i18n[$isolang]: $feed_i18n['en'])),
'base_url' => (count($langs) > 1? (isset($trailer_i18n[$isolang])? $isolang.'/'.$trailer_i18n[$isolang]: $isolang.'/'.$trailer_i18n['en']): (isset($trailer_i18n[$isolang])? $trailer_i18n[$isolang]: $trailer_i18n['en'])),
));
} else {
$smarty->assign('rewriting', FALSE);
}
$smarty->assign(array(
'shop_name' => Configuration::get('PS_SHOP_NAME'),
'lang' => $lang,
'language' => Language::getIsoById($lang),
'date' => date('Y-m-d\TH:i:sP'),
'sales' => Sale::getSales(TRUE, NULL, NULL, 'today', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC')),
));
header('content-type: application/xml');
if($format == 'atom') {
$smarty->assign('format', 'atom');
$smarty->display('atom.tpl', __FILE__);
} else {
$smarty->assign('format', 'rss');
$smarty->display('rss.tpl', __FILE__);
}
}