75 lines
2.7 KiB
PHP
Executable File
75 lines
2.7 KiB
PHP
Executable File
<?php
|
|
class ProductController extends ProductControllerCore {
|
|
public function preProcess() {
|
|
parent::preProcess();
|
|
|
|
if(Module::isInstalled('privatesales')) {
|
|
$id_category = $this->product->id_category_default;
|
|
$sale = Sale::getSaleFromCategory($id_category);
|
|
|
|
/* Find out the good Category for thumb*/
|
|
$found_category = false;
|
|
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]))
|
|
{
|
|
if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[2])))))
|
|
$found_category = (int)$regs[2];
|
|
}
|
|
elseif (isset($regs[5]) AND is_numeric($regs[5]))
|
|
{
|
|
if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)($regs[5])))))
|
|
$found_category = (int)$regs[5];
|
|
}
|
|
}
|
|
|
|
if ($found_category && file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$found_category.'_thumb_vp.jpg') && $found_category != $sale->id_category) {
|
|
$id_category_thumb = $found_category;
|
|
} elseif (file_exists(_PS_ROOT_DIR_.'/img/c/'.(int)$id_category.'_thumb_vp.jpg') && $id_category != $sale->id_category) {
|
|
$id_category_thumb = $id_category;
|
|
} else {
|
|
$id_category_thumb = $sale->id_category;
|
|
}
|
|
|
|
self::$smarty->assign(array(
|
|
'sale' => $sale,
|
|
'HOOK_PRIVATESALES_PRODUCT' => Module::hookExec('privatesales_product', array('sale' => $sale)),
|
|
'is_sale_home' => ($sale? $sale->id_category == $id_category: FALSE),
|
|
'is_thumb_vp' => (file_exists(_PS_ROOT_DIR_.'/img/c/'.$id_category_thumb.'_thumb_vp.jpg')),
|
|
'id_category_thumb' => $id_category_thumb,
|
|
));
|
|
|
|
// assign date estimation from sale delay
|
|
if (Module::isInstalled('privatesales_delay')) {
|
|
if (!class_exists('SaleDelay')) {
|
|
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
|
|
}
|
|
$date = new DateTime();
|
|
$delivery_date = SaleDelay::getDeliveryDate(array($sale->delivery_delay), null, $date, true);
|
|
}
|
|
}
|
|
|
|
$bestSaleCart = Module::hookExec('bestSaleCart');
|
|
self::$smarty->assign(array(
|
|
'bestSaleCart' => $bestSaleCart,
|
|
'product' => $this->product,
|
|
'coverImage' => Product::getCover($this->product->id),
|
|
'delivery_date' => (!empty($delivery_date)?$delivery_date:null),
|
|
));
|
|
}
|
|
|
|
public function setMedia() {
|
|
parent::setMedia();
|
|
|
|
global $css_files;
|
|
$css_files = array_slice($css_files, 0, 1);
|
|
|
|
if(!_PS_MOBILE_) {
|
|
Tools::addJS(array(
|
|
_THEME_JS_DIR_.'jquery.mousewheel.js',
|
|
_THEME_JS_DIR_.'jquery.jscrollpane.min.js'
|
|
));
|
|
}
|
|
}
|
|
}
|