// Norm on controllers

This commit is contained in:
rMalie
2011-09-30 13:50:55 +00:00
parent 8d19f130d7
commit f65df2f2ae
38 changed files with 252 additions and 272 deletions
+12 -8
View File
@@ -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)
+4 -4
View File
@@ -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
+1 -1
View File
@@ -362,7 +362,7 @@ class AuthControllerCore extends FrontController
$this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
}
public function process()
public function initContent()
{
parent::process();
+1 -1
View File
@@ -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)
+2 -3
View File
@@ -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);
+2 -2
View File
@@ -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');
+4 -4
View File
@@ -193,12 +193,12 @@ 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();
$email = Tools::safeOutput(Tools::getValue('from',
((isset($this->context->cookie) && isset($this->context->cookie->email) && Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : '')));
$this->context->smarty->assign(array(
@@ -221,7 +221,7 @@ class ContactControllerCore extends FrontController
$this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl');
}
/**
* Assign template vars related to order list and product list ordered by the customer
*/
+2 -2
View File
@@ -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;
+5 -9
View File
@@ -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());
@@ -39,7 +39,7 @@ class GuestTrackingControllerCore extends FrontController
if ($this->context->customer->isLogged())
Tools::redirect('history.php');
}
/**
* Start forms process
* @see FrontController::postProcess()
@@ -51,7 +51,7 @@ class GuestTrackingControllerCore extends FrontController
$id_order = (int)Tools::getValue('id_order');
$email = Tools::getValue('email');
$order = new Order((int)$id_order);
if (empty($id_order))
$this->errors[] = Tools::displayError('Please provide your Order ID');
else if (empty($email))
@@ -92,20 +92,21 @@ 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');
}
/**
* Assign template vars related to order tracking informations
*/
+2 -2
View File
@@ -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)
+5 -5
View File
@@ -31,13 +31,13 @@ class IdentityControllerCore extends FrontController
public $php_self = 'identity';
public $authRedirection = 'identity';
public $ssl = true;
public function init()
{
parent::init();
$this->customer = $this->context->customer;
}
/**
* Start forms process
* @see FrontController::postProcess()
@@ -94,14 +94,14 @@ class IdentityControllerCore extends FrontController
}
else
$_POST = array_map('stripslashes', $this->customer->getFields());
return $this->customer;
}
/**
* 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);
+2 -2
View File
@@ -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');
+5 -5
View File
@@ -41,7 +41,7 @@ class ManufacturerControllerCore extends FrontController
if (Validate::isLoadedObject($this->manufacturer))
parent::canonicalRedirection($this->context->link->getManufacturerLink($this->manufacturer));
}
/**
* Initialize manufaturer controller
* @see FrontController::init()
@@ -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())
{
@@ -82,7 +82,7 @@ class ManufacturerControllerCore extends FrontController
$this->setTemplate(_PS_THEME_DIR_.'manufacturer-list.tpl');
}
}
/**
* Assign template vars if displaying one manufacturer
*/
@@ -96,7 +96,7 @@ class ManufacturerControllerCore extends FrontController
'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
'manufacturer' => $this->manufacturer));
}
/**
* Assign template vars if displaying the manufacturer list
*/
+2 -2
View File
@@ -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');
+2 -2
View File
@@ -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')),
+2 -2
View File
@@ -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,
+41 -38
View File
@@ -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;
+4 -16
View File
@@ -41,7 +41,7 @@ class OrderDetailControllerCore extends FrontController
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
}
/**
* Start forms process
* @see FrontController::postProcess()
@@ -118,12 +118,12 @@ 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();
}
}
+3 -3
View File
@@ -71,12 +71,12 @@ class OrderFollowControllerCore extends FrontController
Tools::redirect('index.php?controller=order-follow');
}
}
/**
* 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'))
+2 -14
View File
@@ -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;
+3 -16
View File
@@ -71,31 +71,18 @@ class OrderReturnControllerCore extends FrontController
$this->errors[] = Tools::displayError('Cannot find this order return');
}
}
/**
* 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();
}
}
+3 -3
View File
@@ -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');
}
}
+2 -2
View File
@@ -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');
}
+3 -3
View File
@@ -105,12 +105,12 @@ class PasswordControllerCore extends FrontController
else if (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer')))
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
/**
* 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');
}
+9 -10
View File
@@ -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)
+10 -11
View File
@@ -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);
}
+2 -2
View File
@@ -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);
+14 -16
View File
@@ -74,7 +74,7 @@ class ProductControllerCore extends FrontController
if (Pack::isPack((int)$this->product->id) && !Pack::isInStock((int)$this->product->id))
$this->product->quantity = 0;
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
if (!Validate::isLoadedObject($this->product))
@@ -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)));
@@ -153,7 +151,7 @@ class ProductControllerCore extends FrontController
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
// Assign template vars related to the images
$this->assignImages();
@@ -197,7 +195,7 @@ class ProductControllerCore extends FrontController
$this->setTemplate(_PS_THEME_DIR_.'product.tpl');
}
/**
* Assign price and tax to the template
*/
@@ -223,9 +221,9 @@ class ProductControllerCore extends FrontController
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
$quantityDiscounts = SpecificPrice::getQuantityDiscounts((int)$this->product->id, $this->context->shop->getID(true), (int)$this->context->cookie->id_currency, $id_country, $id_group);
$productPrice = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
$this->context->smarty->assign(array(
'quantity_discounts' => $this->formatQuantityDiscounts($quantityDiscounts, $productPrice, (float)$tax),
'ecotax_tax_inc' => $ecotaxTaxAmount,
@@ -238,7 +236,7 @@ class ProductControllerCore extends FrontController
'tax_enabled' => Configuration::get('PS_TAX')
));
}
/**
* Assign template vars related to images
*/
@@ -271,7 +269,7 @@ class ProductControllerCore extends FrontController
if (count($productImages))
$this->context->smarty->assign('images', $productImages);
}
/**
* Assign template vars related to attribute groups and colors
*/
@@ -301,7 +299,7 @@ class ProductControllerCore extends FrontController
'group_type' => $row['group_type'],
'default' => -1,
);
$groups = array();
$combinationImages = $this->product->getCombinationImages($this->context->language->id);
foreach ($attributesGroups AS $k => $row)
@@ -388,7 +386,7 @@ class ProductControllerCore extends FrontController
$availableDate = Tools::displayDate($row['available_date'], $this->context->language->id);
else
$availableDate = $row['available_date'];
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
$combinations[$row['id_product_attribute']]['attributes'][] = (int)($row['id_attribute']);
$combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);
@@ -433,7 +431,7 @@ class ProductControllerCore extends FrontController
'combinationImages' => $combinationImages));
}
}
/**
* Assign template vars related to category
*/
@@ -474,7 +472,7 @@ class ProductControllerCore extends FrontController
}
else
$this->context->smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name));
$this->context->smarty->assign('categories', Category::getHomeCategories($this->context->language->id));
$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category)));
}
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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));
+54 -33
View File
@@ -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);
}
}
+20 -20
View File
@@ -99,20 +99,20 @@ class StoresControllerCore extends FrontController
foreach ($stores as &$store)
$store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');
$this->context->smarty->assign(array(
'simplifiedStoresDiplay' => true,
'stores' => $stores
));
}
public function getStores()
{
$distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
if (!in_array($distanceUnit, array('km', 'mi')))
$distanceUnit = 'km';
if (Tools::getValue('all') == 1)
{
$stores = Db::getInstance()->ExecuteS('
@@ -149,10 +149,10 @@ class StoresControllerCore extends FrontController
ORDER BY distance ASC
LIMIT 0,20');
}
return $stores;
}
/**
* Assign template vars for classical stores
*/
@@ -163,25 +163,25 @@ class StoresControllerCore extends FrontController
$distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
if (!in_array($distanceUnit, array('km', 'mi')))
$distanceUnit = 'km';
$this->context->smarty->assign(array(
'distance_unit' => $distanceUnit,
'simplifiedStoresDiplay' => false,
'stores' => $this->getStores()
));
}
/**
* Display the Xml for showing the nodes in the google map
*/
protected function displayAjax()
{
$stores = $this->getStores();
$dom = new DOMDocument('1.0');
$node = $dom->createElement('markers');
$parnode = $dom->appendChild($node);
$days[1] = 'Monday';
$days[2] = 'Tuesday';
$days[3] = 'Wednesday';
@@ -189,7 +189,7 @@ class StoresControllerCore extends FrontController
$days[5] = 'Friday';
$days[6] = 'Saturday';
$days[7] = 'Sunday';
foreach ($stores as $store)
{
$days_datas = array();
@@ -197,12 +197,12 @@ class StoresControllerCore extends FrontController
$newnode = $parnode->appendChild($node);
$newnode->setAttribute('name', $store['name']);
$address = $this->processStoreAddress($store);
$other = '';
if (!empty($store['hours']))
{
$hours = unserialize($store['hours']);
for ($i = 1; $i < 8; $i++)
{
$hours_datas = array();
@@ -212,10 +212,10 @@ class StoresControllerCore extends FrontController
}
$this->context->smarty->assign('days_datas', $days_datas);
$this->context->smarty->assign('id_country', $store['id_country']);
$other .= $this->context->smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
}
$newnode->setAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));
$newnode->setAttribute('address', $address);
$newnode->setAttribute('other', $other);
@@ -224,20 +224,20 @@ class StoresControllerCore extends FrontController
$newnode->setAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'));
$newnode->setAttribute('lat', (float)($store['latitude']));
$newnode->setAttribute('lng', (float)($store['longitude']));
if (isset($store['distance']))
$newnode->setAttribute('distance', (int)($store['distance']));
}
header('Content-type: text/xml');
die($dom->saveXML());
}
/**
* 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();
@@ -250,7 +250,7 @@ class StoresControllerCore extends FrontController
'defaultLong' => (float)Configuration::get('PS_STORES_CENTER_LONG'),
'searchUrl' => $this->context->link->getPageLink('stores')
));
$this->setTemplate(_PS_THEME_DIR_.'stores.tpl');
}
+4 -4
View File
@@ -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())
{
@@ -84,7 +84,7 @@ class SupplierControllerCore extends FrontController
$this->setTemplate(_PS_THEME_DIR_.'supplier-list.tpl');
}
}
/**
* Assign template vars if displaying one supplier
*/
@@ -99,7 +99,7 @@ class SupplierControllerCore extends FrontController
'supplier' => $this->supplier,
));
}
/**
* Assign template vars if displaying the supplier list
*/
+2 -2
View File
@@ -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();