Marion Muszynski 52a3477a1e fix //static
2017-03-09 11:07:11 +01:00

96 lines
3.4 KiB
PHP
Executable File

<?php
require_once(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
require_once(dirname(__FILE__).'/Sale.php');
$controller->preProcess();
$sale = new Sale((int) Tools::getValue('id_sale'));
if($sale->id === NULL) {
Tools::redirect('/');
}
$langs = Language::getLanguages();
$lang = (int) $cookie->id_lang;
$isolang = Language::getIsoById($lang);
$trailers_i18n = array(
'fr' => 'bande-annonce',
'en' => 'trailer',
);
$ps_i18n = array(
'fr' => 'Vente Privée',
'en' => 'Private Sale of',
);
$on_i18n = array(
'fr' => 'sur',
'en' => 'on',
);
if(Configuration::get('PS_REWRITING_SETTINGS')) {
if(count($langs) > 1) {
$canonical_url = Tools::getShopDomain(TRUE, TRUE).__PS_BASE_URI__.$iso_code.'/'.(isset($trailers_i18n[$iso_code])? $trailers_i18n[$isolang]: $trailers_i18n['en']).'/'.$sale->id.'-'.Tools::str2url($sale->title[$lang]);
} else {
$canonical_url = Tools::getShopDomain(TRUE, TRUE).__PS_BASE_URI__.(isset($trailers_i18n[$isolang])? $trailers_i18n[$isolang]: $trailers_i18n['en']).'/'.$sale->id.'-'.Tools::str2url($sale->title[$lang]);
}
} else {
$canonical_url = Tools::getShopDomain(TRUE, TRUE).__PS_BASE_URI__.'modules/privatesales/trailer.php?id_sale='.$sale->id;
}
$current_url = explode('?', $_SERVER['REQUEST_URI'], 1);
if(Tools::getShopDomain(TRUE, TRUE).$current_url[0] != $canonical_url) {
Tools::redirectLink($canonical_url.(count($current_url) > 1? '?'.$current_url[1]: ''));
}
$smarty->assign('sale', $sale);
$smarty->assign(array(
'meta_title' => (isset($ps_i18n[$isolang])? $ps_i18n[$isolang]: $ps_i18n['en']).' '.$sale->title[(int) $cookie->id_lang].' '.(isset($on_i18n[$isolang])? $on_i18n[$isolang]: $on_i18n['en']).' '.Configuration::get('PS_SHOP_NAME'),
'meta_description' => substr(strip_tags($sale->description[(int) $cookie->id_lang]), 0, 120),
'meta_fb_img' => '//static.bebeboutik.com'.__PS_BASE_URI__.'modules/privatesales/img/'.$sale->id.'/liston_'.(int) $cookie->id_lang.'.jpg'
// 'meta_keywords' => '', // TODO: Handle keywords
));
require_once(dirname(__FILE__).'/../../header.php');
$subscribed = Tools::getValue('notify_email')? $sale->isSubscribed(Tools::getValue('notify_email')): ($cookie->isLogged()? $sale->isSubscribed($cookie->email): FALSE);
if(Tools::getValue('notify_del') && Tools::getValue('notify_email')) {
$sale->unsubscribe(Tools::getValue('notify_email'));
$smarty->assign(array(
'notify' => 3,
));
$subscribed = FALSE;
} elseif(Tools::getValue('notify_add') && Tools::getValue('notify_email')) {
if($subscribed) {
$smarty->assign(array(
'notify' => 2,
));
} else {
$sale->subscribe(Tools::getValue('notify_email'));
$smarty->assign(array(
'notify' => 1,
));
$subscribed = TRUE;
}
} else {
$smarty->assign(array(
'notify' => FALSE,
));
}
$smarty->assign(array(
'subscribed' => $subscribed,
'bgColumns' => is_file(dirname(__FILE__).'/img/'.$sale->id.'/trailerbg_'.$cookie->id_lang.'.png'),
'bgCenter' => is_file(dirname(__FILE__).'/img/'.$sale->id.'/trailercenter_'.$cookie->id_lang.'.png'),
'path' => dirname(__FILE__).'/img/'.$sale->id.'/',
'path_uri'=> 'modules/privatesales/img/'.$sale->id.'/',
'page_url' => $canonical_url,
'shop_name' => Configuration::get('PS_SHOP_NAME'),
'show_notification' => Configuration::get('PRIVATESALES_TRAILER_NOTIFY'),
'show_signin' => Configuration::get('PRIVATESALES_TRAILER_SIGNIN'),
));
echo Module::display(dirname(__FILE__), 'trailer.tpl');
require_once(dirname(__FILE__).'/../../footer.php');