// Norm on controllers
This commit is contained in:
1 parent
8d19f130d7
commit
f65df2f2ae
38 files changed
+205
-225
No files matched your search
+12
-8
@@ -48,7 +48,7 @@ abstract class ControllerCore
|
||||
/**
|
||||
* @var bool check if header will be displayed
|
||||
*/
|
||||
protected $displayHeader = false;
|
||||
protected $display_header;
|
||||
|
||||
/**
|
||||
* @var string template name for page content
|
||||
@@ -58,7 +58,7 @@ abstract class ControllerCore
|
||||
/**
|
||||
* @var string check if footer will be displayed
|
||||
*/
|
||||
protected $displayFooter = false;
|
||||
protected $display_footer;
|
||||
|
||||
/**
|
||||
* @var bool If ajax parameter is detected in request, set this flag to true
|
||||
@@ -99,8 +99,12 @@ abstract class ControllerCore
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->displayHeader(true);
|
||||
$this->displayFooter(true);
|
||||
if (is_null($this->display_header))
|
||||
$this->display_header = true;
|
||||
|
||||
if (is_null($this->display_footer))
|
||||
$this->display_footer = true;
|
||||
|
||||
$this->context = Context::getContext();
|
||||
$this->ajax = Tools::getValue('ajax') || Tools::isSubmit('ajax');
|
||||
}
|
||||
@@ -117,14 +121,14 @@ abstract class ControllerCore
|
||||
else
|
||||
$this->postProcess();
|
||||
|
||||
if ($this->displayHeader)
|
||||
if ($this->display_header)
|
||||
{
|
||||
$this->setMedia();
|
||||
$this->initHeader();
|
||||
}
|
||||
|
||||
$this->initContent();
|
||||
if ($this->displayFooter)
|
||||
if ($this->display_footer)
|
||||
$this->initFooter();
|
||||
|
||||
if ($this->ajax && method_exists($this, 'displayAjax'))
|
||||
@@ -135,12 +139,12 @@ abstract class ControllerCore
|
||||
|
||||
public function displayHeader($display = true)
|
||||
{
|
||||
$this->displayHeader = $display;
|
||||
$this->display_header = $display;
|
||||
}
|
||||
|
||||
public function displayFooter($display = true)
|
||||
{
|
||||
$this->displayFooter = $display;
|
||||
$this->display_footer = $display;
|
||||
}
|
||||
|
||||
public function setTemplate($template)
|
||||
|
||||
@@ -89,8 +89,8 @@ class FrontControllerCore extends Controller
|
||||
|
||||
if ($this->ajax)
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
$this->display_header = false;
|
||||
$this->display_footer = false;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
@@ -375,13 +375,13 @@ class FrontControllerCore extends Controller
|
||||
Tools::safePostVars();
|
||||
$this->context->smarty->assign('errors', $this->errors);
|
||||
|
||||
if ($this->displayHeader)
|
||||
if ($this->display_header)
|
||||
$this->context->smarty->display(_PS_THEME_DIR_.'header.tpl');
|
||||
|
||||
if ($this->template)
|
||||
$this->context->smarty->display($this->template);
|
||||
|
||||
if ($this->displayFooter)
|
||||
if ($this->display_footer)
|
||||
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
|
||||
|
||||
// live edit
|
||||
|
||||
@@ -362,7 +362,7 @@ class AuthControllerCore extends FrontController
|
||||
$this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
|
||||
}
|
||||
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class BestSalesControllerCore extends FrontController
|
||||
{
|
||||
public $php_self = 'best-sales';
|
||||
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->productSort();
|
||||
$nbProducts = (int)ProductSale::getNbSales();
|
||||
|
||||
@@ -29,9 +29,9 @@ class ChangeCurrencyControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$currency = new Currency((int)Tools::getValue('id_currency'));
|
||||
if (Validate::isLoadedObject($currency) && !$currency->deleted)
|
||||
|
||||
@@ -76,11 +76,10 @@ class CmsControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
parent::process();
|
||||
$parent_cat = new CMSCategory(1, $this->context->language->id);
|
||||
$this->context->smarty->assign('id_current_lang', $this->context->language->id);
|
||||
$this->context->smarty->assign('home_title', $parent_cat->name);
|
||||
|
||||
@@ -81,9 +81,9 @@ class CompareControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
//Clean compare product table
|
||||
CompareProduct::cleanCompareProducts('week');
|
||||
|
||||
@@ -193,9 +193,9 @@ class ContactControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->assignOrderList();
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ class DiscountControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$discounts = Discount::getCustomerDiscounts($this->context->language->id, $this->context->customer->id, true, false);
|
||||
$nbDiscounts = 0;
|
||||
|
||||
@@ -27,18 +27,14 @@
|
||||
|
||||
class GetFileControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
protected $display_header = false;
|
||||
protected $display_footer = false;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($this->context->employee) && $this->context->employee->isLoggedBack() && Tools::getValue('file'))
|
||||
{
|
||||
/* Admin can directly access to file */
|
||||
// Admin can directly access to file
|
||||
$filename = Tools::getValue('file');
|
||||
if (!Validate::isSha1($filename))
|
||||
die(Tools::displayError());
|
||||
|
||||
@@ -92,17 +92,18 @@ class GuestTrackingControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
/* Handle brute force attacks */
|
||||
if (count($this->errors))
|
||||
sleep(1);
|
||||
|
||||
$this->context->smarty->assign(array('action' => $this->context->link->getPageLink('guest-tracking.php'), 'errors' => $this->errors));
|
||||
$this->context->smarty->assign(array(
|
||||
'action' => $this->context->link->getPageLink('guest-tracking.php'),
|
||||
'errors' => $this->errors,
|
||||
));
|
||||
$this->setTemplate(_PS_THEME_DIR_.'guest-tracking.tpl');
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ class HistoryControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
if ($orders = Order::getCustomerOrders($this->context->customer->id))
|
||||
foreach ($orders as &$order)
|
||||
|
||||
@@ -99,9 +99,9 @@ class IdentityControllerCore extends FrontController
|
||||
}
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
if ($this->customer->birthday)
|
||||
$birthday = explode('-', $this->customer->birthday);
|
||||
|
||||
@@ -31,9 +31,9 @@ class IndexControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->smarty->assign('HOOK_HOME', Module::hookExec('home'));
|
||||
$this->setTemplate(_PS_THEME_DIR_.'index.tpl');
|
||||
|
||||
@@ -66,9 +66,9 @@ class ManufacturerControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
if (Validate::isLoadedObject($this->manufacturer) && $this->manufacturer->active && $this->manufacturer->isAssociatedToGroupShop())
|
||||
{
|
||||
|
||||
@@ -35,9 +35,9 @@ class ModuleControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
// Check module existence
|
||||
$name = Tools::getValue('module');
|
||||
|
||||
@@ -40,9 +40,9 @@ class MyAccountControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')),
|
||||
|
||||
@@ -37,9 +37,9 @@ class NewProductsControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->productSort();
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'is_guest' => $this->context->customer->is_guest,
|
||||
|
||||
@@ -43,45 +43,41 @@ class OrderControllerCore extends ParentOrderController
|
||||
if (!$this->nbProducts)
|
||||
$this->step = -1;
|
||||
|
||||
/* If some products have disappear */
|
||||
// If some products have disappear
|
||||
if (!$this->context->cart->checkQuantities())
|
||||
{
|
||||
$this->step = 0;
|
||||
$this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.');
|
||||
}
|
||||
|
||||
/* Check minimal amount */
|
||||
// Check minimal amount
|
||||
$currency = Currency::getCurrency((int)$this->context->cart->id_currency);
|
||||
|
||||
$orderTotal = $this->context->cart->getOrderTotal();
|
||||
$minimalPurchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
|
||||
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase && $this->step != -1)
|
||||
$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
|
||||
if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step != -1)
|
||||
{
|
||||
$this->step = 0;
|
||||
$this->errors[] = Tools::displayError('A minimum purchase total of').' '.Tools::displayPrice($minimalPurchase, $currency).
|
||||
$this->errors[] = Tools::displayError('A minimum purchase total of').' '.Tools::displayPrice($minimal_purchase, $currency).
|
||||
' '.Tools::displayError('is required in order to validate your order.');
|
||||
}
|
||||
|
||||
if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3)))
|
||||
Tools::redirect('index.php?controller=authentication&back='.urlencode('order.php&step='.$this->step));
|
||||
|
||||
if ($this->nbProducts)
|
||||
$this->context->smarty->assign('virtual_cart', $isVirtualCart);
|
||||
}
|
||||
|
||||
public function displayHeader($display = true)
|
||||
{
|
||||
if (!Tools::getValue('ajax'))
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
/* 4 steps to the order */
|
||||
global $isVirtualCart;
|
||||
|
||||
if ($this->nbProducts)
|
||||
$this->context->smarty->assign('virtual_cart', $isVirtualCart);
|
||||
|
||||
// 4 steps to the order
|
||||
switch ((int)$this->step)
|
||||
{
|
||||
case -1;
|
||||
@@ -104,7 +100,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
break;
|
||||
|
||||
case 3:
|
||||
//Test that the conditions (so active) were accepted by the customer
|
||||
// Test that the conditions (so active) were accepted by the customer
|
||||
$cgv = Tools::getValue('cgv');
|
||||
if (Configuration::get('PS_CONDITIONS') && (!Validate::isBool($cgv)))
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
@@ -112,7 +108,8 @@ class OrderControllerCore extends ParentOrderController
|
||||
if (Tools::isSubmit('processCarrier'))
|
||||
$this->processCarrier();
|
||||
$this->autoStep();
|
||||
/* Bypass payment step if total is 0 */
|
||||
|
||||
// Bypass payment step if total is 0
|
||||
if (($id_order = $this->_checkFreeOrder()) && $id_order)
|
||||
{
|
||||
if ($this->context->customer->is_guest)
|
||||
@@ -146,8 +143,8 @@ class OrderControllerCore extends ParentOrderController
|
||||
|
||||
private function processAddressFormat()
|
||||
{
|
||||
$addressDelivery = new Address((int)($this->context->cart->id_address_delivery));
|
||||
$addressInvoice = new Address((int)($this->context->cart->id_address_invoice));
|
||||
$addressDelivery = new Address((int)$this->context->cart->id_address_delivery);
|
||||
$addressInvoice = new Address((int)$this->context->cart->id_address_invoice);
|
||||
|
||||
$invoiceAddressFields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country, false, true);
|
||||
$deliveryAddressFields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country, false, true);
|
||||
@@ -157,21 +154,17 @@ class OrderControllerCore extends ParentOrderController
|
||||
'dlv_adr_fields' => $deliveryAddressFields));
|
||||
}
|
||||
|
||||
public function displayFooter($display = true)
|
||||
{
|
||||
if (!Tools::getValue('ajax'))
|
||||
parent::displayFooter();
|
||||
}
|
||||
|
||||
/* Order process controller */
|
||||
/**
|
||||
* Order process controller
|
||||
*/
|
||||
public function autoStep()
|
||||
{
|
||||
global $isVirtualCart;
|
||||
|
||||
if ($this->step >= 2 && (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice))
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
$delivery = new Address((int)($this->context->cart->id_address_delivery));
|
||||
$invoice = new Address((int)($this->context->cart->id_address_invoice));
|
||||
$delivery = new Address((int)$this->context->cart->id_address_delivery);
|
||||
$invoice = new Address((int)$this->context->cart->id_address_invoice);
|
||||
|
||||
if ($delivery->deleted || $invoice->deleted)
|
||||
{
|
||||
@@ -194,25 +187,29 @@ class OrderControllerCore extends ParentOrderController
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
else
|
||||
{
|
||||
$this->context->cart->id_address_delivery = (int)(Tools::getValue('id_address_delivery'));
|
||||
$this->context->cart->id_address_invoice = Tools::isSubmit('same') ? $this->context->cart->id_address_delivery : (int)(Tools::getValue('id_address_invoice'));
|
||||
$this->context->cart->id_address_delivery = (int)Tools::getValue('id_address_delivery');
|
||||
$this->context->cart->id_address_invoice = Tools::isSubmit('same') ? $this->context->cart->id_address_delivery : (int)Tools::getValue('id_address_invoice');
|
||||
if (!$this->context->cart->update())
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your cart.');
|
||||
|
||||
if (Tools::isSubmit('message'))
|
||||
$this->_updateMessage(Tools::getValue('message'));
|
||||
}
|
||||
if (count($this->errors))
|
||||
|
||||
if ($this->errors)
|
||||
{
|
||||
if (Tools::getValue('ajax'))
|
||||
die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
|
||||
$this->step = 1;
|
||||
}
|
||||
if (Tools::getValue('ajax'))
|
||||
|
||||
if ($this->ajax)
|
||||
die(true);
|
||||
}
|
||||
|
||||
/* Carrier step */
|
||||
/**
|
||||
* Carrier step
|
||||
*/
|
||||
protected function processCarrier()
|
||||
{
|
||||
global $orderTotal;
|
||||
@@ -231,7 +228,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
$orderTotal = $this->context->cart->getOrderTotal();
|
||||
}
|
||||
|
||||
/* Address step */
|
||||
/**
|
||||
* Address step
|
||||
*/
|
||||
protected function _assignAddress()
|
||||
{
|
||||
parent::_assignAddress();
|
||||
@@ -241,7 +240,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
}
|
||||
|
||||
/* Carrier step */
|
||||
/**
|
||||
* Carrier step
|
||||
*/
|
||||
protected function _assignCarrier()
|
||||
{
|
||||
if (!isset($this->context->customer->id))
|
||||
@@ -254,7 +255,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
$this->context->smarty->assign('is_guest', (isset($this->context->customer->is_guest) ? $this->context->customer->is_guest : 0));
|
||||
}
|
||||
|
||||
/* Payment step */
|
||||
/**
|
||||
* Payment step
|
||||
*/
|
||||
protected function _assignPayment()
|
||||
{
|
||||
global $orderTotal;
|
||||
|
||||
@@ -121,9 +121,9 @@ class OrderDetailControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
if (!$id_order = (int)(Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order))
|
||||
$this->errors[] = Tools::displayError('Order ID required');
|
||||
@@ -204,16 +204,4 @@ class OrderDetailControllerCore extends FrontController
|
||||
$this->addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayHeader($display = true)
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayFooter($display = true)
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
}
|
||||
@@ -74,9 +74,9 @@ class OrderFollowControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$ordersReturn = OrderReturn::getOrdersReturn($this->context->customer->id);
|
||||
if (Tools::isSubmit('errorQuantity'))
|
||||
|
||||
@@ -227,9 +227,9 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
// SHOPPING CART
|
||||
$this->_assignSummaryInformations();
|
||||
@@ -286,18 +286,6 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-opc.tpl');
|
||||
}
|
||||
|
||||
public function displayHeader($display = true)
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayFooter($display = true)
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
|
||||
protected function _getGuestInformations()
|
||||
{
|
||||
$customer = $this->context->customer;
|
||||
|
||||
@@ -74,28 +74,15 @@ class OrderReturnControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
parent::process();
|
||||
$this->context->smarty->assign(array(
|
||||
'errors' => $this->errors,
|
||||
'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))
|
||||
));
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-return.tpl');
|
||||
}
|
||||
|
||||
public function displayHeader($display = true)
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayHeader();
|
||||
}
|
||||
|
||||
public function displayFooter($display = true)
|
||||
{
|
||||
if (Tools::getValue('ajax') != 'true')
|
||||
parent::displayFooter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,11 +43,11 @@ class OrderSlipControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)($this->context->cookie->id_customer)));
|
||||
$this->context->smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)$this->context->cookie->id_customer));
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-slip.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ class PageNotFoundControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->setTemplate(_PS_THEME_DIR_.'404.tpl');
|
||||
}
|
||||
|
||||
@@ -108,9 +108,9 @@ class PasswordControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->setTemplate(_PS_THEME_DIR_.'password.tpl');
|
||||
}
|
||||
|
||||
@@ -27,21 +27,20 @@
|
||||
|
||||
class PdfInvoiceControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
protected $display_header = false;
|
||||
protected $display_footer = false;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key'))
|
||||
Tools::redirect('index.php?controller=authentication&back=pdf-invoice');
|
||||
if (!(int)(Configuration::get('PS_INVOICE')))
|
||||
|
||||
if (!(int)Configuration::get('PS_INVOICE'))
|
||||
die(Tools::displayError('Invoices are disabled in this shop.'));
|
||||
|
||||
if (isset($_GET['id_order']) && Validate::isUnsignedId($_GET['id_order']))
|
||||
$order = new Order((int)($_GET['id_order']));
|
||||
$order = new Order($_GET['id_order']);
|
||||
|
||||
if (!isset($order) || !Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Invoice not found'));
|
||||
else if ((isset($this->context->customer->id) && $order->id_customer != $this->context->customer->id) || (Tools::isSubmit('secure_key') && $order->secure_key != Tools::getValue('secure_key')))
|
||||
|
||||
@@ -27,20 +27,17 @@
|
||||
|
||||
class PdfOrderReturnControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
protected $display_header = false;
|
||||
protected $display_footer = false;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->context->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&back=order-follow');
|
||||
|
||||
if (isset($_GET['id_order_return']) && Validate::isUnsignedId($_GET['id_order_return']))
|
||||
$orderReturn = new OrderReturn((int)($_GET['id_order_return']));
|
||||
$orderReturn = new OrderReturn($_GET['id_order_return']);
|
||||
|
||||
if (!isset($orderReturn) || !Validate::isLoadedObject($orderReturn))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderReturn->id_customer != $this->context->customer->id)
|
||||
|
||||
@@ -27,28 +27,27 @@
|
||||
|
||||
class PdfOrderSlipControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
protected $display_header = false;
|
||||
protected $display_footer = false;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!$this->context->customer->isLogged())
|
||||
Tools::redirect('index.php?controller=authentication&back=order-follow');
|
||||
|
||||
if (isset($_GET['id_order_slip']) && Validate::isUnsignedId($_GET['id_order_slip']))
|
||||
$orderSlip = new OrderSlip((int)($_GET['id_order_slip']));
|
||||
$orderSlip = new OrderSlip($_GET['id_order_slip']);
|
||||
|
||||
if (!isset($orderSlip) || !Validate::isLoadedObject($orderSlip))
|
||||
die(Tools::displayError('Order return not found'));
|
||||
else if ($orderSlip->id_customer != $this->context->customer->id)
|
||||
die(Tools::displayError('Order return not found'));
|
||||
$order = new Order((int)($orderSlip->id_order));
|
||||
|
||||
$order = new Order($orderSlip->id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Order not found'));
|
||||
$order->products = OrderSlip::getOrdersSlipProducts((int)($orderSlip->id), $order);
|
||||
|
||||
$order->products = OrderSlip::getOrdersSlipProducts((int)$orderSlip->id, $order);
|
||||
$ref = null;
|
||||
PDF::invoice($order, 'D', false, $ref, $orderSlip);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ class PricesDropControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->productSort();
|
||||
$nbProducts = Product::getPricesDrop($this->context->language->id, null, null, true);
|
||||
|
||||
@@ -101,13 +101,11 @@ class ProductControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
parent::process();
|
||||
|
||||
if (!count($this->errors))
|
||||
if (!$this->errors)
|
||||
{
|
||||
// Assign to the tempate the id of the virtuale product. "0" if the product is not downloadable.
|
||||
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id)));
|
||||
|
||||
@@ -45,9 +45,9 @@ class SearchControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$query = urldecode(Tools::getValue('q'));
|
||||
if ($this->ajax_search)
|
||||
|
||||
@@ -38,9 +38,9 @@ class SitemapControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
$this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
|
||||
$this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1));
|
||||
|
||||
@@ -27,43 +27,64 @@
|
||||
|
||||
class StatisticsControllerCore extends FrontController
|
||||
{
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
$this->displayHeader(false);
|
||||
$this->displayFooter(false);
|
||||
public $display_header = false;
|
||||
public $display_footer = false;
|
||||
|
||||
if (!isset($_POST['token']) || !isset($_POST['type']))
|
||||
protected $param_token;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$this->param_token = Tools::getValue('token');
|
||||
if (!$this->param_token)
|
||||
die;
|
||||
|
||||
if ($_POST['type'] == 'navinfo')
|
||||
{
|
||||
if (sha1($_POST['id_guest']._COOKIE_KEY_) != $_POST['token'])
|
||||
die;
|
||||
|
||||
$guest = new Guest((int)$_POST['id_guest']);
|
||||
$guest->javascript = true;
|
||||
$guest->screen_resolution_x = (int)($_POST['screen_resolution_x']);
|
||||
$guest->screen_resolution_y = (int)($_POST['screen_resolution_y']);
|
||||
$guest->screen_color = (int)($_POST['screen_color']);
|
||||
$guest->sun_java = (int)($_POST['sun_java']);
|
||||
$guest->adobe_flash = (int)($_POST['adobe_flash']);
|
||||
$guest->adobe_director = (int)($_POST['adobe_director']);
|
||||
$guest->apple_quicktime = (int)($_POST['apple_quicktime']);
|
||||
$guest->real_player = (int)($_POST['real_player']);
|
||||
$guest->windows_media = (int)($_POST['windows_media']);
|
||||
$guest->update();
|
||||
}
|
||||
$this->processNavigationStats();
|
||||
else if ($_POST['type'] == 'pagetime')
|
||||
{
|
||||
if (sha1($_POST['id_connections'].$_POST['id_page'].$_POST['time_start']._COOKIE_KEY_) != $_POST['token'])
|
||||
die;
|
||||
if (!Validate::isInt($_POST['time']) || $_POST['time'] <= 0)
|
||||
die;
|
||||
Connection::setPageTime((int)$_POST['id_connections'], (int)$_POST['id_page'], substr($_POST['time_start'], 0, 19), intval($_POST['time']));
|
||||
}
|
||||
$this->processPageTime();
|
||||
else
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log statistics on navigation (resolution, plugins, etc.)
|
||||
*/
|
||||
protected function processNavigationStats()
|
||||
{
|
||||
$id_guest = (int)Tools::getValue('id_guest');
|
||||
if (sha1($id_guest._COOKIE_KEY_) != $this->param_token)
|
||||
die;
|
||||
|
||||
$guest = new Guest($id_guest);
|
||||
$guest->javascript = true;
|
||||
$guest->screen_resolution_x = (int)Tools::getValue('screen_resolution_x');
|
||||
$guest->screen_resolution_y = (int)Tools::getValue('screen_resolution_y');
|
||||
$guest->screen_color = (int)Tools::getValue('screen_color');
|
||||
$guest->sun_java = (int)Tools::getValue('sun_java');
|
||||
$guest->adobe_flash = (int)Tools::getValue('adobe_flash');
|
||||
$guest->adobe_director = (int)Tools::getValue('adobe_director');
|
||||
$guest->apple_quicktime = (int)Tools::getValue('apple_quicktime');
|
||||
$guest->real_player = (int)Tools::getValue('real_player');
|
||||
$guest->windows_media = (int)Tools::getValue('windows_media');
|
||||
$guest->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log statistics on time spend on pages
|
||||
*/
|
||||
protected function processPageTime()
|
||||
{
|
||||
$id_connection = (int)Tools::getValue('id_connections');
|
||||
$time = (int)Tools::getValue('time');
|
||||
$time_start = Tools::getValue('time_start');
|
||||
$id_page = (int)Tools::getValue('id_page');
|
||||
|
||||
if (sha1($id_connection.$id_page.$time_start._COOKIE_KEY_) != $this->param_token)
|
||||
die;
|
||||
|
||||
if ($time <= 0)
|
||||
die;
|
||||
|
||||
Connection::setPageTime($id_connection, $id_page, substr($time_start, 0, 19), $time);
|
||||
}
|
||||
}
|
||||
@@ -235,9 +235,9 @@ class StoresControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
if (Configuration::get('PS_STORES_SIMPLIFIED'))
|
||||
$stores = $this->assignStoresSimplified();
|
||||
|
||||
@@ -68,9 +68,9 @@ class SupplierControllerCore extends FrontController
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::process()
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function process()
|
||||
public function initContent()
|
||||
{
|
||||
if (Validate::isLoadedObject($this->supplier) && $this->supplier->active && $this->supplier->isAssociatedToGroupShop())
|
||||
{
|
||||
|
||||
@@ -192,7 +192,7 @@ class FrontController extends FrontControllerCore
|
||||
|
||||
$this->_memory[2] = memory_get_usage();
|
||||
$this->_time[2] = microtime(true);
|
||||
if ($this->displayHeader)
|
||||
if ($this->display_header)
|
||||
{
|
||||
$this->setMedia();
|
||||
$this->initHeader();
|
||||
@@ -205,7 +205,7 @@ class FrontController extends FrontControllerCore
|
||||
|
||||
$this->_memory[4] = memory_get_usage();
|
||||
$this->_time[4] = microtime(true);
|
||||
if ($this->displayFooter)
|
||||
if ($this->display_footer)
|
||||
$this->initFooter();
|
||||
|
||||
$this->_memory[5] = memory_get_usage();
|
||||
|
||||
Reference in new issue
Block a user