[*] Front: move front controllers in controllers/front/ directory

// Refactoring of front controllers part 1

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8721 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-09-22 15:19:42 +00:00
parent 2dbea99b61
commit 69db63f26c
94 changed files with 771 additions and 939 deletions
+82 -82
View File
@@ -252,9 +252,9 @@
'DbMySQLiCore' => 'classes/db/DbMySQLi.php', 'DbMySQLiCore' => 'classes/db/DbMySQLi.php',
'DbMySQLi' => 'override/classes/db/DbMySQLi.php', 'DbMySQLi' => 'override/classes/db/DbMySQLi.php',
'DbPDOCore' => 'classes/db/DbPDO.php', 'DbPDOCore' => 'classes/db/DbPDO.php',
'DbPDO' => '', 'DbPDO' => 'override/classes/db/DbPDO.php',
'DbQueryCore' => 'classes/db/DbQuery.php', 'DbQueryCore' => 'classes/db/DbQuery.php',
'DbQuery' => '', 'DbQuery' => 'override/classes/db/DbQuery.php',
'MySQLCore' => 'classes/db/MySQL.php', 'MySQLCore' => 'classes/db/MySQL.php',
'MySQL' => 'override/classes/db/MySQL.php', 'MySQL' => 'override/classes/db/MySQL.php',
'GroupShopCore' => 'classes/shop/GroupShop.php', 'GroupShopCore' => 'classes/shop/GroupShop.php',
@@ -279,84 +279,84 @@
'TaxRulesTaxManagerCore' => 'classes/tax/TaxRulesTaxManager.php', 'TaxRulesTaxManagerCore' => 'classes/tax/TaxRulesTaxManager.php',
'TaxRulesTaxManager' => 'override/classes/tax/TaxRulesTaxManager.php', 'TaxRulesTaxManager' => 'override/classes/tax/TaxRulesTaxManager.php',
'FB' => 'override/classes/fb.php', 'FB' => 'override/classes/fb.php',
'AddressControllerCore' => 'controllers/AddressController.php', 'AddressControllerCore' => 'controllers/front/AddressController.php',
'AddressController' => 'override/controllers/AddressController.php', 'AddressController' => 'override/controllers/front/AddressController.php',
'AddressesControllerCore' => 'controllers/AddressesController.php', 'AddressesControllerCore' => 'controllers/front/AddressesController.php',
'AddressesController' => 'override/controllers/AddressesController.php', 'AddressesController' => 'override/controllers/front/AddressesController.php',
'AttachmentControllerCore' => 'controllers/AttachmentController.php', 'AttachmentControllerCore' => 'controllers/front/AttachmentController.php',
'AttachmentController' => 'override/controllers/AttachmentController.php', 'AttachmentController' => 'override/controllers/front/AttachmentController.php',
'AuthControllerCore' => 'controllers/AuthController.php', 'AuthControllerCore' => 'controllers/front/AuthController.php',
'AuthController' => 'override/controllers/AuthController.php', 'AuthController' => 'override/controllers/front/AuthController.php',
'BestSalesControllerCore' => 'controllers/BestSalesController.php', 'BestSalesControllerCore' => 'controllers/front/BestSalesController.php',
'BestSalesController' => 'override/controllers/BestSalesController.php', 'BestSalesController' => 'override/controllers/front/BestSalesController.php',
'CartControllerCore' => 'controllers/CartController.php', 'CartControllerCore' => 'controllers/front/CartController.php',
'CartController' => 'override/controllers/CartController.php', 'CartController' => 'override/controllers/front/CartController.php',
'CategoryControllerCore' => 'controllers/CategoryController.php', 'CategoryControllerCore' => 'controllers/front/CategoryController.php',
'CategoryController' => 'override/controllers/CategoryController.php', 'CategoryController' => 'override/controllers/front/CategoryController.php',
'ChangeCurrencyControllerCore' => 'controllers/ChangeCurrencyController.php', 'ChangeCurrencyControllerCore' => 'controllers/front/ChangeCurrencyController.php',
'ChangeCurrencyController' => 'override/controllers/ChangeCurrencyController.php', 'ChangeCurrencyController' => 'override/controllers/front/ChangeCurrencyController.php',
'CmsControllerCore' => 'controllers/CmsController.php', 'CmsControllerCore' => 'controllers/front/CmsController.php',
'CmsController' => 'override/controllers/CmsController.php', 'CmsController' => 'override/controllers/front/CmsController.php',
'CompareControllerCore' => 'controllers/CompareController.php', 'CompareControllerCore' => 'controllers/front/CompareController.php',
'CompareController' => 'override/controllers/CompareController.php', 'CompareController' => 'override/controllers/front/CompareController.php',
'ContactControllerCore' => 'controllers/ContactController.php', 'ContactControllerCore' => 'controllers/front/ContactController.php',
'ContactController' => 'override/controllers/ContactController.php', 'ContactController' => 'override/controllers/front/ContactController.php',
'DiscountControllerCore' => 'controllers/DiscountController.php', 'DiscountControllerCore' => 'controllers/front/DiscountController.php',
'DiscountController' => 'override/controllers/DiscountController.php', 'DiscountController' => 'override/controllers/front/DiscountController.php',
'GetFileControllerCore' => 'controllers/GetFileController.php', 'GetFileControllerCore' => 'controllers/front/GetFileController.php',
'GetFileController' => 'override/controllers/GetFileController.php', 'GetFileController' => 'override/controllers/front/GetFileController.php',
'GuestTrackingControllerCore' => 'controllers/GuestTrackingController.php', 'GuestTrackingControllerCore' => 'controllers/front/GuestTrackingController.php',
'GuestTrackingController' => 'override/controllers/GuestTrackingController.php', 'GuestTrackingController' => 'override/controllers/front/GuestTrackingController.php',
'HistoryControllerCore' => 'controllers/HistoryController.php', 'HistoryControllerCore' => 'controllers/front/HistoryController.php',
'HistoryController' => 'override/controllers/HistoryController.php', 'HistoryController' => 'override/controllers/front/HistoryController.php',
'IdentityControllerCore' => 'controllers/IdentityController.php', 'IdentityControllerCore' => 'controllers/front/IdentityController.php',
'IdentityController' => 'override/controllers/IdentityController.php', 'IdentityController' => 'override/controllers/front/IdentityController.php',
'IndexControllerCore' => 'controllers/IndexController.php', 'IndexControllerCore' => 'controllers/front/IndexController.php',
'IndexController' => 'override/controllers/IndexController.php', 'IndexController' => 'override/controllers/front/IndexController.php',
'ManufacturerControllerCore' => 'controllers/ManufacturerController.php', 'ManufacturerControllerCore' => 'controllers/front/ManufacturerController.php',
'ManufacturerController' => 'override/controllers/ManufacturerController.php', 'ManufacturerController' => 'override/controllers/front/ManufacturerController.php',
'MyAccountControllerCore' => 'controllers/MyAccountController.php', 'MyAccountControllerCore' => 'controllers/front/MyAccountController.php',
'MyAccountController' => 'override/controllers/MyAccountController.php', 'MyAccountController' => 'override/controllers/front/MyAccountController.php',
'NewProductsControllerCore' => 'controllers/NewProductsController.php', 'NewProductsControllerCore' => 'controllers/front/NewProductsController.php',
'NewProductsController' => 'override/controllers/NewProductsController.php', 'NewProductsController' => 'override/controllers/front/NewProductsController.php',
'OrderConfirmationControllerCore' => 'controllers/OrderConfirmationController.php', 'OrderConfirmationControllerCore' => 'controllers/front/OrderConfirmationController.php',
'OrderConfirmationController' => 'override/controllers/OrderConfirmationController.php', 'OrderConfirmationController' => 'override/controllers/front/OrderConfirmationController.php',
'OrderControllerCore' => 'controllers/OrderController.php', 'OrderControllerCore' => 'controllers/front/OrderController.php',
'OrderController' => 'override/controllers/OrderController.php', 'OrderController' => 'override/controllers/front/OrderController.php',
'OrderDetailControllerCore' => 'controllers/OrderDetailController.php', 'OrderDetailControllerCore' => 'controllers/front/OrderDetailController.php',
'OrderDetailController' => 'override/controllers/OrderDetailController.php', 'OrderDetailController' => 'override/controllers/front/OrderDetailController.php',
'OrderFollowControllerCore' => 'controllers/OrderFollowController.php', 'OrderFollowControllerCore' => 'controllers/front/OrderFollowController.php',
'OrderFollowController' => 'override/controllers/OrderFollowController.php', 'OrderFollowController' => 'override/controllers/front/OrderFollowController.php',
'OrderOpcControllerCore' => 'controllers/OrderOpcController.php', 'OrderOpcControllerCore' => 'controllers/front/OrderOpcController.php',
'OrderOpcController' => 'override/controllers/OrderOpcController.php', 'OrderOpcController' => 'override/controllers/front/OrderOpcController.php',
'OrderReturnControllerCore' => 'controllers/OrderReturnController.php', 'OrderReturnControllerCore' => 'controllers/front/OrderReturnController.php',
'OrderReturnController' => 'override/controllers/OrderReturnController.php', 'OrderReturnController' => 'override/controllers/front/OrderReturnController.php',
'OrderSlipControllerCore' => 'controllers/OrderSlipController.php', 'OrderSlipControllerCore' => 'controllers/front/OrderSlipController.php',
'OrderSlipController' => 'override/controllers/OrderSlipController.php', 'OrderSlipController' => 'override/controllers/front/OrderSlipController.php',
'PageNotFoundControllerCore' => 'controllers/PageNotFoundController.php', 'PageNotFoundControllerCore' => 'controllers/front/PageNotFoundController.php',
'PageNotFoundController' => 'override/controllers/PageNotFoundController.php', 'PageNotFoundController' => 'override/controllers/front/PageNotFoundController.php',
'ParentOrderControllerCore' => 'controllers/ParentOrderController.php', 'ParentOrderControllerCore' => 'controllers/front/ParentOrderController.php',
'ParentOrderController' => 'override/controllers/ParentOrderController.php', 'ParentOrderController' => 'override/controllers/front/ParentOrderController.php',
'PasswordControllerCore' => 'controllers/PasswordController.php', 'PasswordControllerCore' => 'controllers/front/PasswordController.php',
'PasswordController' => 'override/controllers/PasswordController.php', 'PasswordController' => 'override/controllers/front/PasswordController.php',
'PdfInvoiceControllerCore' => 'controllers/PdfInvoiceController.php', 'PdfInvoiceControllerCore' => 'controllers/front/PdfInvoiceController.php',
'PdfInvoiceController' => 'override/controllers/PdfInvoiceController.php', 'PdfInvoiceController' => 'override/controllers/front/PdfInvoiceController.php',
'PdfOrderReturnControllerCore' => 'controllers/PdfOrderReturnController.php', 'PdfOrderReturnControllerCore' => 'controllers/front/PdfOrderReturnController.php',
'PdfOrderReturnController' => 'override/controllers/pdfOrderReturnController.php', 'PdfOrderReturnController' => 'override/controllers/front/pdfOrderReturnController.php',
'PdfOrderSlipControllerCore' => 'controllers/PdfOrderSlipController.php', 'PdfOrderSlipControllerCore' => 'controllers/front/PdfOrderSlipController.php',
'PdfOrderSlipController' => 'override/controllers/pdfOrderSlipController.php', 'PdfOrderSlipController' => 'override/controllers/front/pdfOrderSlipController.php',
'PricesDropControllerCore' => 'controllers/PricesDropController.php', 'PricesDropControllerCore' => 'controllers/front/PricesDropController.php',
'PricesDropController' => 'override/controllers/PricesDropController.php', 'PricesDropController' => 'override/controllers/front/PricesDropController.php',
'ProductControllerCore' => 'controllers/ProductController.php', 'ProductControllerCore' => 'controllers/front/ProductController.php',
'ProductController' => 'override/controllers/ProductController.php', 'ProductController' => 'override/controllers/front/ProductController.php',
'SearchControllerCore' => 'controllers/SearchController.php', 'SearchControllerCore' => 'controllers/front/SearchController.php',
'SearchController' => 'override/controllers/SearchController.php', 'SearchController' => 'override/controllers/front/SearchController.php',
'SitemapControllerCore' => 'controllers/SitemapController.php', 'SitemapControllerCore' => 'controllers/front/SitemapController.php',
'SitemapController' => 'override/controllers/SitemapController.php', 'SitemapController' => 'override/controllers/front/SitemapController.php',
'StatisticsControllerCore' => 'controllers/StatisticsController.php', 'StatisticsControllerCore' => 'controllers/front/StatisticsController.php',
'StatisticsController' => 'override/controllers/StatisticsController.php', 'StatisticsController' => 'override/controllers/front/StatisticsController.php',
'StoresControllerCore' => 'controllers/StoresController.php', 'StoresControllerCore' => 'controllers/front/StoresController.php',
'StoresController' => 'override/controllers/StoresController.php', 'StoresController' => 'override/controllers/front/StoresController.php',
'SupplierControllerCore' => 'controllers/SupplierController.php', 'SupplierControllerCore' => 'controllers/front/SupplierController.php',
'SupplierController' => 'override/controllers/SupplierController.php', 'SupplierController' => 'override/controllers/front/SupplierController.php',
); );
+56
View File
@@ -42,6 +42,37 @@ abstract class ControllerCore
*/ */
public $js_files = array(); public $js_files = array();
/**
* @var bool check if header will be displayed
*/
protected $displayHeader = false;
/**
* @var string template name for page content
*/
protected $template;
/**
* @var string check if footer will be displayed
*/
protected $displayFooter = false;
/**
* Initialize the page
*/
abstract public function init();
/**
* Do the page treatment : post process, ajax process, etc.
* Enter description here ...
*/
abstract public function action();
/**
* Display page view
*/
abstract public function display();
/** /**
* Set default media list for controller * Set default media list for controller
*/ */
@@ -64,6 +95,31 @@ abstract class ControllerCore
$this->context = Context::getContext(); $this->context = Context::getContext();
} }
/**
* Start controller process
*/
public function run()
{
$this->init();
$this->action();
$this->display();
}
public function displayHeader($display = true)
{
$this->displayHeader = $display;
}
public function displayFooter($display = true)
{
$this->displayFooter = $display;
}
public function setTemplate($template)
{
$this->template = $template;
}
/** /**
* Add a new stylesheet in page header. * Add a new stylesheet in page header.
* *
+17 -7
View File
@@ -188,7 +188,7 @@ class DispatcherCore
} }
// Get and instantiate controller // Get and instantiate controller
$this->getController(); $this->getController();
$controllers = Dispatcher::getControllers(); $controllers = Dispatcher::getControllers(_PS_CONTROLLER_DIR_);
if (!$this->controller) if (!$this->controller)
$this->controller = 'index'; $this->controller = 'index';
if (!isset($controllers[$this->controller])) if (!isset($controllers[$this->controller]))
@@ -423,18 +423,28 @@ class DispatcherCore
* *
* @return array * @return array
*/ */
public static function getControllers() public static function getControllers($dir)
{ {
$controller_files = scandir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'controllers'); static $controllers;
$controllers = array();
$controller_files = scandir($dir);
foreach ($controller_files as $controller_filename) foreach ($controller_files as $controller_filename)
if (substr($controller_filename, -14, 14) == 'Controller.php') {
if (!in_array($controller_filename, array('.','..','.svn')) AND is_dir($dir.$controller_filename))
$controllers = self::getControllers($dir.$controller_filename.DIRECTORY_SEPARATOR);
else if (substr($controller_filename, -14, 14) == 'Controller.php')
{
$subdir = str_replace(_PS_CONTROLLER_DIR_,'',$dir);
$controllers[strtolower(substr($controller_filename, 0, -14))] = basename($controller_filename, '.php'); $controllers[strtolower(substr($controller_filename, 0, -14))] = basename($controller_filename, '.php');
}
}
// add default controller // add default controller
$controllers['index'] = 'IndexController'; $controllers['index'] = 'IndexController';
$controllers['authentication'] = $controllers['auth']; if (isset($controllers['auth']))
$controllers['productscomparison'] = $controllers['compare']; $controllers['authentication'] = $controllers['auth'];
if (isset($controllers['compare']))
$controllers['productscomparison'] = $controllers['compare'];
return $controllers; return $controllers;
} }
+92 -93
View File
@@ -29,11 +29,10 @@ class FrontControllerCore extends ControllerCore
{ {
public $errors = array(); public $errors = array();
/* Deprecated shortcuts as of 1.5 - Use $context->var instead */ /**
protected static $smarty; * @deprecated Deprecated shortcuts as of 1.5 - Use $context->var instead
protected static $cookie; */
protected static $link; protected static $smarty, $cookie, $link, $cart;
protected static $cart;
public $iso; public $iso;
@@ -49,15 +48,11 @@ class FrontControllerCore extends ControllerCore
protected $restrictedCountry = false; protected $restrictedCountry = false;
protected $maintenance = false; protected $maintenance = false;
protected $id_current_shop;
protected $id_current_group_shop;
public static $initialized = false; public static $initialized = false;
protected static $currentCustomerGroups; protected static $currentCustomerGroups;
public $css_files;
public $js_files;
public $nb_items_per_page; public $nb_items_per_page;
public function __construct() public function __construct()
@@ -68,16 +63,6 @@ class FrontControllerCore extends ControllerCore
$useSSL = $this->ssl; $useSSL = $this->ssl;
} }
public function run()
{
$this->init();
$this->preProcess();
$this->displayHeader();
$this->process();
$this->displayContent();
$this->displayFooter();
}
public function init() public function init()
{ {
/* /*
@@ -91,12 +76,6 @@ class FrontControllerCore extends ControllerCore
return; return;
self::$initialized = true; self::$initialized = true;
$this->id_current_shop = Context::getContext()->shop->getID();
$this->id_current_group_shop = Context::getContext()->shop->getGroupID();
$this->css_files = array();
$this->js_files = array();
// For compatibility with globals, DEPRECATED as of version 1.5 // For compatibility with globals, DEPRECATED as of version 1.5
$css_files = $this->css_files; $css_files = $this->css_files;
$js_files = $this->js_files; $js_files = $this->js_files;
@@ -201,8 +180,8 @@ class FrontControllerCore extends ControllerCore
$cart->id_lang = (int)($this->context->cookie->id_lang); $cart->id_lang = (int)($this->context->cookie->id_lang);
$cart->id_currency = (int)($this->context->cookie->id_currency); $cart->id_currency = (int)($this->context->cookie->id_currency);
$cart->id_guest = (int)($this->context->cookie->id_guest); $cart->id_guest = (int)($this->context->cookie->id_guest);
$cart->id_group_shop = (int)$this->id_current_group_shop; $cart->id_group_shop = (int)$this->context->shop->getGroupID();
$cart->id_shop = $this->id_current_shop; $cart->id_shop = $this->context->shop->getID(true);
if ($this->context->cookie->id_customer) if ($this->context->cookie->id_customer)
{ {
$cart->id_customer = (int)($this->context->cookie->id_customer); $cart->id_customer = (int)($this->context->cookie->id_customer);
@@ -247,7 +226,9 @@ class FrontControllerCore extends ControllerCore
if (!defined('_PS_BASE_URL_SSL_')) if (!defined('_PS_BASE_URL_SSL_'))
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true)); define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
$this->canonicalRedirection(); // Automatically redirect to the canonical URL if needed
if (isset($this->php_self) && !empty($this->php_self) && !Tools::getValue('ajax'))
$this->canonicalRedirection($this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id));
Product::initPricesComputation(); Product::initPricesComputation();
@@ -259,6 +240,7 @@ class FrontControllerCore extends ControllerCore
if (Validate::isLoadedObject($country)) if (Validate::isLoadedObject($country))
$display_tax_label = $country->display_tax_label; $display_tax_label = $country->display_tax_label;
} }
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'link' => $link, 'link' => $link,
'cart' => $cart, 'cart' => $cart,
@@ -351,6 +333,64 @@ class FrontControllerCore extends ControllerCore
$this->context->cart = $cart; $this->context->cart = $cart;
$this->context->currency = $currency; $this->context->currency = $currency;
$this->context->controller = $this; $this->context->controller = $this;
$this->displayHeader();
$this->displayFooter();
}
public function action()
{
// For retrocompatibility
if (method_exists($this, 'preProcess'))
{
Tools::displayAsDeprecated('Method preProcess() is deprecated in controllers, use method postProcess() instead');
$this->preProcess();
}
if (Tools::getValue('ajax') == 'true')
{
$this->displayHeader(false);
$this->displayFooter(false);
$this->ajaxProcess();
}
else
$this->postProcess();
// Prepare generation of page display
$this->processHeader();
$this->process();
$this->processFooter();
}
public function ajaxProcess()
{
}
public function postProcess()
{
}
public function process()
{
}
public function display()
{
if ($this->displayHeader)
$this->context->smarty->display(_PS_THEME_DIR_.'header.tpl');
if ($this->template)
$this->context->smarty->display($this->template);
if ($this->displayFooter)
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
// live edit
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
{
$this->context->smarty->assign(array('ad' => $ad, 'live_edit' => true));
$this->context->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
}
} }
/* Display a maintenance page if shop is closed */ /* Display a maintenance page if shop is closed */
@@ -372,31 +412,28 @@ class FrontControllerCore extends ControllerCore
exit; exit;
} }
protected function canonicalRedirection() protected function canonicalRedirection($canonicalURL)
{ {
// Automatically redirect to the canonical URL if needed if (!Configuration::get('PS_CANONICAL_REDIRECT'))
if (isset($this->php_self) AND !empty($this->php_self)) return;
$matchUrl = (($this->ssl && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', $matchUrl))
{ {
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain $params = array();
$excludedKey = array('isolang', 'id_lang', 'controller');
foreach ($_GET as $key => $value)
if (!in_array($key, $excludedKey))
$params[] = $key.'='.$value;
$canonicalURL = $this->context->link->getPageLink($this->php_self, $this->ssl, $this->context->language->id); $strParams = '';
if (!Tools::getValue('ajax') && !preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', (($this->ssl AND Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) if ($params)
{ $strParams = ((strpos($canonicalURL, '?') === false) ? '?' : '&').implode('&', $params);
header('HTTP/1.0 301 Moved');
$params = array();
$excludedKey = array('isolang', 'id_lang', 'controller');
foreach ($_GET as $key => $value)
if (!in_array($key, $excludedKey))
$params[] = $key.'='.$value;
if ($params)
$params = ((strpos($canonicalURL, '?') === false) ? '?' : '&').implode('&', $params);
else
$params = '';
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ AND $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) header('HTTP/1.0 301 Moved');
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.$params.'">'.$canonicalURL.$params.'</a>'); if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ AND $_SERVER['REQUEST_URI'] != __PS_BASE_URI__)
Tools::redirectLink($canonicalURL.$params); die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.$strParams.'">'.$canonicalURL.$strParams.'</a>');
} Tools::redirectLink($canonicalURL.$strParams);
} }
} }
@@ -459,10 +496,6 @@ class FrontControllerCore extends ControllerCore
return false; return false;
} }
public function preProcess()
{
}
public function setMedia() public function setMedia()
{ {
$this->addCSS(_THEME_CSS_DIR_.'global.css', 'all'); $this->addCSS(_THEME_CSS_DIR_.'global.css', 'all');
@@ -480,27 +513,14 @@ class FrontControllerCore extends ControllerCore
$this->addCSS(_THEME_CSS_DIR_.'rtl.css'); $this->addCSS(_THEME_CSS_DIR_.'rtl.css');
} }
public function process() public function processHeader()
{ {
}
public function displayContent()
{
Tools::safePostVars();
$this->context->smarty->assign('errors', $this->errors);
}
public function displayHeader()
{
if (!self::$initialized)
$this->init();
// if this function is called from a module, do a fast init
else if (!$this->context)
$this->context = Context::getContext();
// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
Tools::safePostVars();
$this->context->smarty->assign('errors', $this->errors);
/* Hooks are volontary out the initialize array (need those variables already assigned) */ /* Hooks are volontary out the initialize array (need those variables already assigned) */
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'time' => time(), 'time' => time(),
@@ -531,39 +551,18 @@ class FrontControllerCore extends ControllerCore
$this->context->smarty->assign('css_files', $this->css_files); $this->context->smarty->assign('css_files', $this->css_files);
$this->context->smarty->assign('js_files', array_unique($this->js_files)); $this->context->smarty->assign('js_files', array_unique($this->js_files));
$this->context->smarty->display(_PS_THEME_DIR_.'header.tpl');
} }
public function displayFooter() public function processFooter()
{ {
if (!self::$initialized)
$this->init();
// if this function is called from a module, do a fast init
else if (!$this->context)
$this->context = Context::getContext();
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => $this->context->cart)), 'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => $this->context->cart)),
'HOOK_FOOTER' => Module::hookExec('footer'), 'HOOK_FOOTER' => Module::hookExec('footer'),
'content_only' => (int)(Tools::getValue('content_only')))); ));
$this->context->smarty->display(_PS_THEME_DIR_.'footer.tpl');
//live edit
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
{
$this->context->smarty->assign(array('ad' => $ad, 'live_edit' => true));
$this->context->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
}
else
Tools::displayError();
} }
public function productSort() public function productSort()
{ {
if (!self::$initialized)
$this->init();
elseif (!$this->context)
$this->context = Context::getContext();
// $this->orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby')); // $this->orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
// $this->orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway')); // $this->orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
// 'orderbydefault' => Tools::getProductsOrder('by'), // 'orderbydefault' => Tools::getProductsOrder('by'),
@@ -38,9 +38,10 @@ class AddressControllerCore extends FrontController
protected $_address; protected $_address;
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
if ($back = Tools::getValue('back')) if ($back = Tools::getValue('back'))
$this->context->smarty->assign('back', Tools::safeOutput($back)); $this->context->smarty->assign('back', Tools::safeOutput($back));
if ($mod = Tools::getValue('mod')) if ($mod = Tools::getValue('mod'))
@@ -267,6 +268,8 @@ class AddressControllerCore extends FrontController
'token' => Tools::getToken(false), 'token' => Tools::getToken(false),
'select_address' => (int)(Tools::getValue('select_address')) 'select_address' => (int)(Tools::getValue('select_address'))
)); ));
$this->setTemplate(_PS_THEME_DIR_.'address.tpl');
} }
protected function _processAddressFormat() protected function _processAddressFormat()
@@ -284,14 +287,6 @@ class AddressControllerCore extends FrontController
parent::displayHeader(); parent::displayHeader();
} }
public function displayContent()
{
parent::displayContent();
$this->_processAddressFormat();
$this->context->smarty->display(_PS_THEME_DIR_.'address.tpl');
}
public function displayFooter() public function displayFooter()
{ {
if (Tools::getValue('ajax') != 'true') if (Tools::getValue('ajax') != 'true')
@@ -41,7 +41,6 @@ class AddressesControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$multipleAddressesFormated = array(); $multipleAddressesFormated = array();
$ordered_fields = array(); $ordered_fields = array();
$customer = $this->context->customer; $customer = $this->context->customer;
@@ -88,12 +87,8 @@ class AddressesControllerCore extends FrontController
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'multipleAddresses' => $multipleAddressesFormated, 'multipleAddresses' => $multipleAddressesFormated,
'ordered_fields' => $ordered_fields)); 'ordered_fields' => $ordered_fields));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'addresses.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'addresses.tpl');
} }
} }
@@ -29,8 +29,6 @@ class AttachmentControllerCore extends FrontController
{ {
public function process() public function process()
{ {
parent::process();
$a = new Attachment(Tools::getValue('id_attachment'), $this->context->language->id); $a = new Attachment(Tools::getValue('id_attachment'), $this->context->language->id);
if (!$a->id) if (!$a->id)
Tools::redirect('index.php'); Tools::redirect('index.php');
@@ -30,9 +30,9 @@ class AuthControllerCore extends FrontController
public $ssl = true; public $ssl = true;
public $php_self = 'authentication'; public $php_self = 'authentication';
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
if ($this->context->customer->isLogged() AND !Tools::isSubmit('ajax')) if ($this->context->customer->isLogged() AND !Tools::isSubmit('ajax'))
Tools::redirect('index.php?controller=my-account'); Tools::redirect('index.php?controller=my-account');
@@ -381,14 +381,9 @@ class AuthControllerCore extends FrontController
)); ));
} }
} }
}
public function displayContent()
{
$this->processAddressFormat(); $this->processAddressFormat();
$this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'authentication.tpl');
} }
protected function processAddressFormat() protected function processAddressFormat()
@@ -41,6 +41,8 @@ class BestSalesControllerCore extends FrontController
'nbProducts' => $nbProducts, 'nbProducts' => $nbProducts,
'homeSize' => Image::getSize('home') 'homeSize' => Image::getSize('home')
)); ));
$this->setTemplate(_PS_THEME_DIR_.'best-sales.tpl');
} }
public function setMedia() public function setMedia()
@@ -48,11 +50,5 @@ class BestSalesControllerCore extends FrontController
parent::setMedia(); parent::setMedia();
$this->addCSS(_THEME_CSS_DIR_.'product_list.css'); $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'best-sales.tpl');
}
} }
@@ -32,46 +32,32 @@ class CartControllerCore extends FrontController
// This is not a public page, so the canonical redirection is disabled // This is not a public page, so the canonical redirection is disabled
public function canonicalRedirection(){} public function canonicalRedirection(){}
public function run() public function ajaxProcess()
{ {
$this->init(); if (Tools::getIsset('summary'))
$this->preProcess();
if (Tools::getValue('ajax') == 'true')
{ {
if (Tools::getIsset('summary')) if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
{ {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) if (Validate::isLoadedObject($this->context->customer))
{ $groups = $this->context->customer->getGroups();
if (Validate::isLoadedObject($this->context->customer)) else
$groups = $this->context->customer->getGroups(); $groups = array(1);
else if ($this->context->cart->id_address_delivery)
$groups = array(1); $deliveryAddress = new Address($this->context->cart->id_address_delivery);
if ($this->context->cart->id_address_delivery) $result = array('carriers' => Carrier::getCarriersForOrder(Country::getIdZone((isset($deliveryAddress) AND (int)$deliveryAddress->id) ? (int)$deliveryAddress->id_country : (int)Configuration::get('PS_COUNTRY_DEFAULT')), $groups));
$deliveryAddress = new Address($this->context->cart->id_address_delivery);
$result = array('carriers' => Carrier::getCarriersForOrder(Country::getIdZone((isset($deliveryAddress) AND (int)$deliveryAddress->id) ? (int)$deliveryAddress->id_country : (int)Configuration::get('PS_COUNTRY_DEFAULT')), $groups));
}
$result['summary'] = $this->context->cart->getSummaryDetails();
$result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true);
$result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']);
$result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
// Display reduced price (or not) without quantity discount
if (Tools::getIsset('getproductprice'))
foreach ($result['summary']['products'] as $key => $product)
$result['summary']['products'][$key]['price_without_quantity_discount'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute']);
die(Tools::jsonEncode($result));
} }
else $result['summary'] = $this->context->cart->getSummaryDetails();
$this->includeCartModule(); $result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true);
$result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']);
$result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
// Display reduced price (or not) without quantity discount
if (Tools::getIsset('getproductprice'))
foreach ($result['summary']['products'] as $key => $product)
$result['summary']['products'][$key]['price_without_quantity_discount'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute']);
die(Tools::jsonEncode($result));
} }
else else
{ $this->includeCartModule();
$this->setMedia();
$this->displayHeader();
$this->process();
$this->displayContent();
$this->displayFooter();
}
} }
public function includeCartModule() public function includeCartModule()
@@ -79,9 +65,10 @@ class CartControllerCore extends FrontController
require_once(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php'); require_once(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php');
} }
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
$orderTotal = $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS); $orderTotal = $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
$this->cartDiscounts = $this->context->cart->getDiscounts(); $this->cartDiscounts = $this->context->cart->getDiscounts();
foreach ($this->cartDiscounts AS $k => $this->cartDiscount) foreach ($this->cartDiscounts AS $k => $this->cartDiscount)
@@ -254,11 +241,7 @@ class CartControllerCore extends FrontController
} }
} }
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'errors.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'errors.tpl');
} }
} }
@@ -51,27 +51,14 @@ class CategoryControllerCore extends FrontController
public function canonicalRedirection() public function canonicalRedirection()
{ {
if (Configuration::get('PS_CANONICAL_REDIRECT') && !Tools::getValue('noredirect')) if (!Tools::getValue('noredirect') && Validate::isLoadedObject($this->category))
{ parent::canonicalRedirection($this->context->link->getCategoryLink($this->category));
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if (Validate::isLoadedObject($this->category))
{
$currentURL = $this->context->link->getCategoryLink($this->category);
$currentURL = preg_replace('/[?&].*$/', '', $currentURL);
if (!preg_match('/^'.Tools::pRegexp($currentURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ )
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$currentURL.'">'.$currentURL.'</a>');
Tools::redirectLink($currentURL);
}
}
}
} }
public function preProcess() public function init()
{ {
parent::init();
if ($id_category = (int)Tools::getValue('id_category')) if ($id_category = (int)Tools::getValue('id_category'))
$this->category = new Category($id_category, $this->context->language->id); $this->category = new Category($id_category, $this->context->language->id);
if (!Validate::isLoadedObject($this->category)) if (!Validate::isLoadedObject($this->category))
@@ -81,8 +68,6 @@ class CategoryControllerCore extends FrontController
} }
else else
$this->canonicalRedirection(); $this->canonicalRedirection();
parent::preProcess();
} }
public function process() public function process()
@@ -163,6 +148,8 @@ class CategoryControllerCore extends FrontController
'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')), 'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')),
'suppliers' => Supplier::getSuppliers() 'suppliers' => Supplier::getSuppliers()
)); ));
$this->setTemplate(_PS_THEME_DIR_.'category.tpl');
} }
public function productListAssign() public function productListAssign()
@@ -180,11 +167,5 @@ class CategoryControllerCore extends FrontController
$this->pagination((int)$this->nbProducts); $this->pagination((int)$this->nbProducts);
self::$smarty->assign('nb_products', (int)$this->nbProducts); self::$smarty->assign('nb_products', (int)$this->nbProducts);
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'category.tpl');
}
} }
@@ -29,8 +29,6 @@ class ChangeCurrencyControllerCore extends FrontController
{ {
public function process() public function process()
{ {
parent::process();
$currency = new Currency((int)Tools::getValue('id_currency')); $currency = new Currency((int)Tools::getValue('id_currency'));
if (Validate::isLoadedObject($currency) AND !$currency->deleted) if (Validate::isLoadedObject($currency) AND !$currency->deleted)
{ {
@@ -39,10 +37,4 @@ class ChangeCurrencyControllerCore extends FrontController
} }
die('0'); die('0');
} }
public function run()
{
$this->init();
$this->process();
}
} }
@@ -34,40 +34,22 @@ class CmsControllerCore extends FrontController
public function canonicalRedirection() public function canonicalRedirection()
{ {
// Automatically redirect to the canonical URL if the current in is the right one if (Validate::isLoadedObject($this->cms) && ($canonicalURL = $this->context->link->getCMSLink($this->cms)))
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain parent::canonicalRedirection($canonicalURL);
else if (Validate::isLoadedObject($this->cms_category) && ($canonicalURL = $this->context->link->getCMSCategoryLink($this->cms_category)))
if (Configuration::get('PS_CANONICAL_REDIRECT')) parent::canonicalRedirection($canonicalURL);
{
if (Validate::isLoadedObject($this->cms) AND $canonicalURL = $this->context->link->getCMSLink($this->cms))
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
if (_PS_MODE_DEV_)
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
Tools::redirectLink($canonicalURL);
}
if (Validate::isLoadedObject($this->cms_category) AND $canonicalURL = $this->context->link->getCMSCategoryLink($this->cms_category))
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
if (_PS_MODE_DEV_ )
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
Tools::redirectLink($canonicalURL);
}
}
} }
public function preProcess() public function init()
{ {
parent::init();
if ($id_cms = (int)Tools::getValue('id_cms')) if ($id_cms = (int)Tools::getValue('id_cms'))
$this->cms = new CMS($id_cms, $this->context->language->id); $this->cms = new CMS($id_cms, $this->context->language->id);
elseif ($id_cms_category = (int)Tools::getValue('id_cms_category')) elseif ($id_cms_category = (int)Tools::getValue('id_cms_category'))
$this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id); $this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id);
$this->canonicalRedirection(); $this->canonicalRedirection();
parent::preProcess();
/* assignCase (1 = CMS page, 2 = CMS category) */ /* assignCase (1 = CMS page, 2 = CMS category) */
if (Validate::isLoadedObject($this->cms) AND ($this->cms->isAssociatedToShop() AND $this->cms->active OR (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) AND file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php')))) if (Validate::isLoadedObject($this->cms) AND ($this->cms->isAssociatedToShop() AND $this->cms->active OR (Tools::getValue('adtoken') == Tools::encrypt('PreviewCMS'.$this->cms->id) AND file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php'))))
$this->assignCase = 1; $this->assignCase = 1;
@@ -111,11 +93,7 @@ class CmsControllerCore extends FrontController
'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '', 'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '',
)); ));
} }
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'cms.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'cms.tpl');
} }
} }
@@ -38,9 +38,9 @@ class CompareControllerCore extends FrontController
$this->addJS(_THEME_JS_DIR_.'products-comparison.js'); $this->addJS(_THEME_JS_DIR_.'products-comparison.js');
} }
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
//Add or remove product with Ajax //Add or remove product with Ajax
if (Tools::getValue('ajax') AND Tools::getValue('id_product') AND Tools::getValue('action')) if (Tools::getValue('ajax') AND Tools::getValue('id_product') AND Tools::getValue('action'))
@@ -80,8 +80,6 @@ class CompareControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
//Clean compare product table //Clean compare product table
CompareProduct::cleanCompareProducts('week'); CompareProduct::cleanCompareProducts('week');
@@ -161,12 +159,8 @@ class CompareControllerCore extends FrontController
} }
} }
$this->context->smarty->assign('hasProduct', $hasProduct); $this->context->smarty->assign('hasProduct', $hasProduct);
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'products-comparison.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'products-comparison.tpl');
} }
} }
@@ -27,16 +27,12 @@
class ContactControllerCore extends FrontController class ContactControllerCore extends FrontController
{ {
public function __construct() public $php_self = 'contact';
{ public $ssl = true;
$this->php_self = 'contact';
$this->ssl = true;
parent::__construct();
}
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
if ($this->context->customer->isLogged()) if ($this->context->customer->isLogged())
{ {
@@ -105,7 +101,7 @@ class ContactControllerCore extends FrontController
$id_customer_thread = (int)Tools::getValue('id_customer_thread') $id_customer_thread = (int)Tools::getValue('id_customer_thread')
AND (int)Db::getInstance()->getValue(' AND (int)Db::getInstance()->getValue('
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->id_current_shop.' AND token = \''.pSQL(Tools::getValue('token')).'\'') WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND token = \''.pSQL(Tools::getValue('token')).'\'')
) OR ( ) OR (
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int)Tools::getValue('id_order')) $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int)Tools::getValue('id_order'))
))) )))
@@ -113,7 +109,7 @@ class ContactControllerCore extends FrontController
$fields = Db::getInstance()->ExecuteS(' $fields = Db::getInstance()->ExecuteS('
SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
FROM '._DB_PREFIX_.'customer_thread cm FROM '._DB_PREFIX_.'customer_thread cm
WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->id_current_shop.' AND ('. WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND ('.
($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').' ($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').'
id_order = '.(int)(Tools::getValue('id_order')).')'); id_order = '.(int)(Tools::getValue('id_order')).')');
$score = 0; $score = 0;
@@ -140,7 +136,7 @@ class ContactControllerCore extends FrontController
$old_message = Db::getInstance()->getValue(' $old_message = Db::getInstance()->getValue('
SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm
LEFT JOIN '._DB_PREFIX_.'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread) LEFT JOIN '._DB_PREFIX_.'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->id_current_shop.' WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->context->shop->getID(true).'
ORDER BY cm.date_add DESC'); ORDER BY cm.date_add DESC');
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8')) if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
{ {
@@ -176,7 +172,7 @@ class ContactControllerCore extends FrontController
$ct = new CustomerThread(); $ct = new CustomerThread();
if (isset($customer->id)) if (isset($customer->id))
$ct->id_customer = (int)($customer->id); $ct->id_customer = (int)($customer->id);
$ct->id_shop = (int)$this->id_current_shop; $ct->id_shop = (int)$this->context->shop->getID(true);
if ($id_order = (int)Tools::getValue('id_order')) if ($id_order = (int)Tools::getValue('id_order'))
$ct->id_order = $id_order; $ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product')) if ($id_product = (int)Tools::getValue('id_product'))
@@ -224,8 +220,6 @@ class ContactControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$email = Tools::safeOutput(Tools::getValue('from', ((isset($this->context->cookie) AND isset($this->context->cookie->email) AND Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : ''))); $email = Tools::safeOutput(Tools::getValue('from', ((isset($this->context->cookie) AND isset($this->context->cookie->email) AND Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : '')));
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'errors' => $this->errors, 'errors' => $this->errors,
@@ -238,19 +232,17 @@ class ContactControllerCore extends FrontController
{ {
$customerThread = Db::getInstance()->getRow(' $customerThread = Db::getInstance()->getRow('
SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->id_current_shop.' AND token = \''.pSQL($token).'\''); WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND token = \''.pSQL($token).'\'');
$this->context->smarty->assign('customerThread', $customerThread); $this->context->smarty->assign('customerThread', $customerThread);
} }
$this->context->smarty->assign(array('contacts' => Contact::getContacts($this->context->language->id), $this->context->smarty->assign(array('contacts' => Contact::getContacts($this->context->language->id),
'message' => html_entity_decode(Tools::getValue('message')) 'message' => html_entity_decode(Tools::getValue('message'))
)); ));
}
public function displayContent() // @todo I don't know who did this code, but it's not me
{
$_POST = array_merge($_POST, $_GET);
parent::displayContent(); $this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl');
$this->context->smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
} }
} }
@@ -34,8 +34,6 @@ class DiscountControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$discounts = Discount::getCustomerDiscounts($this->context->language->id, $this->context->customer->id, true, false); $discounts = Discount::getCustomerDiscounts($this->context->language->id, $this->context->customer->id, true, false);
$nbDiscounts = 0; $nbDiscounts = 0;
foreach ($discounts AS $discount) foreach ($discounts AS $discount)
@@ -43,12 +41,7 @@ class DiscountControllerCore extends FrontController
$nbDiscounts++; $nbDiscounts++;
$this->context->smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts)); $this->context->smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts));
} $this->setTemplate(_PS_THEME_DIR_.'discount.tpl');
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'discount.tpl');
} }
} }
@@ -27,15 +27,11 @@
class GetFileControllerCore extends FrontController class GetFileControllerCore extends FrontController
{ {
public function run()
{
$this->init();
$this->preProcess();
$this->process();
}
public function process() public function process()
{ {
$this->displayHeader(false);
$this->displayFooter(false);
if (isset($this->context->employee) && $this->context->employee->isLoggedBack() AND Tools::getValue('file')) if (isset($this->context->employee) && $this->context->employee->isLoggedBack() AND Tools::getValue('file'))
{ {
/* Admin can directly access to file */ /* Admin can directly access to file */
@@ -29,9 +29,9 @@ class GuestTrackingControllerCore extends FrontController
{ {
public $php_self = 'guest-tracking'; public $php_self = 'guest-tracking';
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
if ($this->context->customer->isLogged()) if ($this->context->customer->isLogged())
Tools::redirect('index.php?controller=history'); Tools::redirect('index.php?controller=history');
@@ -39,10 +39,6 @@ class GuestTrackingControllerCore extends FrontController
public function process() public function process()
{ {
global $link;
parent::process();
if ($id_order = Tools::getValue('id_order') AND $email = Tools::getValue('email')) if ($id_order = Tools::getValue('id_order') AND $email = Tools::getValue('email'))
{ {
$order = new Order((int)$id_order); $order = new Order((int)$id_order);
@@ -118,9 +114,11 @@ class GuestTrackingControllerCore extends FrontController
} }
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'action' => $link->getPageLink('guest-tracking.php'), 'action' => $this->context->link->getPageLink('guest-tracking.php'),
'errors' => $this->errors 'errors' => $this->errors
)); ));
$this->setTemplate(_PS_THEME_DIR_.'guest-tracking.tpl');
} }
public function setMedia() public function setMedia()
@@ -131,13 +129,6 @@ class GuestTrackingControllerCore extends FrontController
$this->addCSS(_THEME_CSS_DIR_.'addresses.css'); $this->addCSS(_THEME_CSS_DIR_.'addresses.css');
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'guest-tracking.tpl');
}
private function processAddressFormat(Address $delivery, Address $invoice) private function processAddressFormat(Address $delivery, Address $invoice)
{ {
$inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country, false, true); $inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country, false, true);
@@ -45,8 +45,6 @@ class HistoryControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
if ($orders = Order::getCustomerOrders($this->context->customer->id)) if ($orders = Order::getCustomerOrders($this->context->customer->id))
foreach ($orders AS &$order) foreach ($orders AS &$order)
{ {
@@ -59,12 +57,8 @@ class HistoryControllerCore extends FrontController
'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')),
'slowValidation' => Tools::isSubmit('slowvalidation') 'slowValidation' => Tools::isSubmit('slowvalidation')
)); ));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'history.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'history.tpl');
} }
} }
@@ -32,10 +32,8 @@ class IdentityControllerCore extends FrontController
public $authRedirection = 'identity'; public $authRedirection = 'identity';
public $ssl = true; public $ssl = true;
public function preProcess() public function process()
{ {
parent::preProcess();
$customer = $this->context->customer; $customer = $this->context->customer;
if (sizeof($_POST)) if (sizeof($_POST))
@@ -107,6 +105,8 @@ class IdentityControllerCore extends FrontController
)); ));
$this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); $this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
$this->setTemplate(_PS_THEME_DIR_.'identity.tpl');
} }
public function setMedia() public function setMedia()
@@ -115,11 +115,4 @@ class IdentityControllerCore extends FrontController
$this->addCSS(_THEME_CSS_DIR_.'identity.css'); $this->addCSS(_THEME_CSS_DIR_.'identity.css');
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'identity.tpl');
}
} }
@@ -27,22 +27,11 @@
class IndexControllerCore extends FrontController class IndexControllerCore extends FrontController
{ {
public function __construct() public $php_self = 'index';
{
$this->php_self = 'index';
parent::__construct();
}
public function process() public function process()
{ {
parent::process();
$this->context->smarty->assign('HOOK_HOME', Module::hookExec('home')); $this->context->smarty->assign('HOOK_HOME', Module::hookExec('home'));
} $this->setTemplate(_PS_THEME_DIR_.'index.tpl');
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'index.tpl');
} }
} }
@@ -39,20 +39,13 @@ class ManufacturerControllerCore extends FrontController
public function canonicalRedirection() public function canonicalRedirection()
{ {
if (Validate::isLoadedObject($this->manufacturer)) if (Validate::isLoadedObject($this->manufacturer))
{ parent::canonicalRedirection($this->context->link->getManufacturerLink($this->manufacturer));
$canonicalURL = $this->context->link->getManufacturerLink($this->manufacturer);
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
Tools::redirectLink($canonicalURL);
}
}
} }
public function preProcess() public function init()
{ {
parent::init();
if ($id_manufacturer = Tools::getValue('id_manufacturer')) if ($id_manufacturer = Tools::getValue('id_manufacturer'))
{ {
$this->manufacturer = new Manufacturer((int)$id_manufacturer, $this->context->language->id); $this->manufacturer = new Manufacturer((int)$id_manufacturer, $this->context->language->id);
@@ -65,8 +58,6 @@ class ManufacturerControllerCore extends FrontController
else else
$this->canonicalRedirection(); $this->canonicalRedirection();
} }
parent::preProcess();
} }
public function process() public function process()
@@ -80,6 +71,8 @@ class ManufacturerControllerCore extends FrontController
'products' => $this->manufacturer->getProducts($this->manufacturer->id, $this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay), 'products' => $this->manufacturer->getProducts($this->manufacturer->id, $this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''), 'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
'manufacturer' => $this->manufacturer)); 'manufacturer' => $this->manufacturer));
$this->setTemplate(_PS_THEME_DIR_.'manufacturer.tpl');
} }
else else
{ {
@@ -105,6 +98,8 @@ class ManufacturerControllerCore extends FrontController
} }
else else
$this->context->smarty->assign('nbManufacturers', 0); $this->context->smarty->assign('nbManufacturers', 0);
$this->setTemplate(_PS_THEME_DIR_.'manufacturer-list.tpl');
} }
} }
@@ -113,14 +108,4 @@ class ManufacturerControllerCore extends FrontController
parent::displayHeader(); parent::displayHeader();
$this->productSort(); $this->productSort();
} }
public function displayContent()
{
parent::displayContent();
if ($this->manufacturer)
$this->context->smarty->display(_PS_THEME_DIR_.'manufacturer.tpl');
else
$this->context->smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl');
}
} }
@@ -40,19 +40,13 @@ class MyAccountControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')), 'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')),
'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN')) 'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN'))
)); ));
$this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount')); $this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount'));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'my-account.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'my-account.tpl');
} }
} }
@@ -37,8 +37,6 @@ class NewProductsControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$this->productSort(); $this->productSort();
$nbProducts = (int)Product::getNewProducts($this->context->language->id, (isset($this->p) ? (int)($this->p) - 1 : NULL), (isset($this->n) ? (int)($this->n) : NULL), true); $nbProducts = (int)Product::getNewProducts($this->context->language->id, (isset($this->p) ? (int)($this->p) - 1 : NULL), (isset($this->n) ? (int)($this->n) : NULL), true);
@@ -50,12 +48,8 @@ class NewProductsControllerCore extends FrontController
'nbProducts' => (int)($nbProducts), 'nbProducts' => (int)($nbProducts),
'homeSize' => Image::getSize('home') 'homeSize' => Image::getSize('home')
)); ));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'new-products.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'new-products.tpl');
} }
} }
@@ -34,9 +34,9 @@ class OrderConfirmationControllerCore extends FrontController
public $id_order; public $id_order;
public $secure_key; public $secure_key;
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
$this->id_cart = (int)(Tools::getValue('id_cart', 0)); $this->id_cart = (int)(Tools::getValue('id_cart', 0));
@@ -62,7 +62,6 @@ class OrderConfirmationControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'is_guest' => $this->context->customer->is_guest, 'is_guest' => $this->context->customer->is_guest,
'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)), 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)),
@@ -78,12 +77,8 @@ class OrderConfirmationControllerCore extends FrontController
/* If guest we clear the cookie for security reason */ /* If guest we clear the cookie for security reason */
$this->context->customer->mylogout(); $this->context->customer->mylogout();
} }
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl');
} }
} }
@@ -31,18 +31,13 @@ class OrderControllerCore extends ParentOrderController
public function init() public function init()
{ {
global $isVirtualCart, $orderTotal;
parent::init(); parent::init();
$this->step = (int)(Tools::getValue('step')); $this->step = (int)(Tools::getValue('step'));
if (!$this->nbProducts) if (!$this->nbProducts)
$this->step = -1; $this->step = -1;
}
public function preProcess()
{
global $isVirtualCart, $orderTotal;
parent::preProcess();
/* If some products have disappear */ /* If some products have disappear */
if (!$this->context->cart->checkQuantities()) if (!$this->context->cart->checkQuantities())
@@ -78,23 +73,28 @@ class OrderControllerCore extends ParentOrderController
public function process() public function process()
{ {
parent::process();
/* 4 steps to the order */ /* 4 steps to the order */
switch ((int)$this->step) switch ((int)$this->step)
{ {
case -1; case -1;
$this->context->smarty->assign('empty', 1); $this->context->smarty->assign('empty', 1);
break; $this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');
break;
case 1: case 1:
$this->_assignAddress(); $this->_assignAddress();
break; $this->processAddressFormat();
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
break;
case 2: case 2:
if(Tools::isSubmit('processAddress')) if(Tools::isSubmit('processAddress'))
$this->processAddress(); $this->processAddress();
$this->autoStep(); $this->autoStep();
$this->_assignCarrier(); $this->_assignCarrier();
break; $this->setTemplate(_PS_THEME_DIR_.'order-carrier.tpl');
break;
case 3: 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'); $cgv = Tools::getValue('cgv');
@@ -119,11 +119,21 @@ class OrderControllerCore extends ParentOrderController
$this->_assignPayment(); $this->_assignPayment();
// assign some informations to display cart // assign some informations to display cart
$this->_assignSummaryInformations(); $this->_assignSummaryInformations();
break; $this->setTemplate(_PS_THEME_DIR_.'order-payment.tpl');
break;
default: default:
$this->_assignSummaryInformations(); $this->_assignSummaryInformations();
break; $this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');
break;
} }
$this->context->smarty->assign(array(
'currencySign' => $this->context->currency->sign,
'currencyRate' => $this->context->currency->conversion_rate,
'currencyFormat' => $this->context->currency->format,
'currencyBlank' => $this->context->currency->blank,
));
} }
private function processAddressFormat() private function processAddressFormat()
@@ -139,38 +149,6 @@ class OrderControllerCore extends ParentOrderController
'dlv_adr_fields' => $deliveryAddressFields)); 'dlv_adr_fields' => $deliveryAddressFields));
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->assign(array(
'currencySign' => $this->context->currency->sign,
'currencyRate' => $this->context->currency->conversion_rate,
'currencyFormat' => $this->context->currency->format,
'currencyBlank' => $this->context->currency->blank,
));
switch ((int)$this->step)
{
case -1:
$this->context->smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
break;
case 1:
$this->processAddressFormat();
$this->context->smarty->display(_PS_THEME_DIR_.'order-address.tpl');
break;
case 2:
$this->context->smarty->display(_PS_THEME_DIR_.'order-carrier.tpl');
break;
case 3:
$this->context->smarty->display(_PS_THEME_DIR_.'order-payment.tpl');
break;
default:
$this->context->smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
break;
}
}
public function displayFooter() public function displayFooter()
{ {
if (!Tools::getValue('ajax')) if (!Tools::getValue('ajax'))
@@ -39,9 +39,9 @@ class OrderDetailControllerCore extends FrontController
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
} }
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
if (Tools::isSubmit('submitMessage')) if (Tools::isSubmit('submitMessage'))
{ {
@@ -180,6 +180,8 @@ class OrderDetailControllerCore extends FrontController
$this->errors[] = Tools::displayError('Cannot find this order'); $this->errors[] = Tools::displayError('Cannot find this order');
unset($order); unset($order);
} }
$this->setTemplate(_PS_THEME_DIR_.'order-detail.tpl');
} }
public function setMedia() public function setMedia()
@@ -198,12 +200,6 @@ class OrderDetailControllerCore extends FrontController
parent::displayHeader(); parent::displayHeader();
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'order-detail.tpl');
}
public function displayFooter() public function displayFooter()
{ {
if (Tools::getValue('ajax') != 'true') if (Tools::getValue('ajax') != 'true')
@@ -32,10 +32,8 @@ class OrderFollowControllerCore extends FrontController
public $authRedirection = 'order-follow'; public $authRedirection = 'order-follow';
public $ssl = true; public $ssl = true;
public function preProcess() public function process()
{ {
parent::preProcess();
if (Tools::isSubmit('submitReturnMerchandise')) if (Tools::isSubmit('submitReturnMerchandise'))
{ {
$customizationQtyInput = Tools::getValue('customization_qty_input'); $customizationQtyInput = Tools::getValue('customization_qty_input');
@@ -82,6 +80,8 @@ class OrderFollowControllerCore extends FrontController
$this->context->smarty->assign('errorNotReturnable',true); $this->context->smarty->assign('errorNotReturnable',true);
$this->context->smarty->assign('ordersReturn', $ordersReturn); $this->context->smarty->assign('ordersReturn', $ordersReturn);
$this->setTemplate(_PS_THEME_DIR_.'order-follow.tpl');
} }
public function setMedia() public function setMedia()
@@ -91,11 +91,4 @@ class OrderFollowControllerCore extends FrontController
$this->addCSS(_THEME_CSS_DIR_.'addresses.css'); $this->addCSS(_THEME_CSS_DIR_.'addresses.css');
$this->addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js', _THEME_JS_DIR_.'history.js')); $this->addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js', _THEME_JS_DIR_.'history.js'));
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'order-follow.tpl');
}
} }
@@ -30,9 +30,10 @@ class OrderOpcControllerCore extends ParentOrderController
public $php_self = 'order-opc'; public $php_self = 'order-opc';
public $isLogged; public $isLogged;
public function preProcess() public function init()
{ {
parent::preProcess(); parent::init();
if ($this->nbProducts) if ($this->nbProducts)
$this->context->smarty->assign('virtual_cart', false); $this->context->smarty->assign('virtual_cart', false);
$this->isLogged = (bool)($this->context->customer->id AND Customer::customerIdExistsStatic((int)($this->context->cookie->id_customer))); $this->isLogged = (bool)($this->context->customer->id AND Customer::customerIdExistsStatic((int)($this->context->cookie->id_customer)));
@@ -272,6 +273,9 @@ class OrderOpcControllerCore extends ParentOrderController
Tools::safePostVars(); Tools::safePostVars();
$this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active); $this->context->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
$this->_processAddressFormat();
$this->setTemplate(_PS_THEME_DIR_.'order-opc.tpl');
} }
public function displayHeader() public function displayHeader()
@@ -280,14 +284,6 @@ class OrderOpcControllerCore extends ParentOrderController
parent::displayHeader(); parent::displayHeader();
} }
public function displayContent()
{
parent::displayContent();
$this->_processAddressFormat();
$this->context->smarty->display(_PS_THEME_DIR_.'order-opc.tpl');
}
public function displayFooter() public function displayFooter()
{ {
if (Tools::getValue('ajax') != 'true') if (Tools::getValue('ajax') != 'true')
@@ -40,10 +40,8 @@ class OrderReturnControllerCore extends FrontController
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
} }
public function preProcess() public function process()
{ {
parent::preProcess();
if (!isset($_GET['id_order_return']) OR !Validate::isUnsignedId($_GET['id_order_return'])) if (!isset($_GET['id_order_return']) OR !Validate::isUnsignedId($_GET['id_order_return']))
$this->errors[] = Tools::displayError('Order ID required'); $this->errors[] = Tools::displayError('Order ID required');
else else
@@ -76,6 +74,8 @@ class OrderReturnControllerCore extends FrontController
'errors' => $this->errors, 'errors' => $this->errors,
'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS')) 'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))
)); ));
$this->setTemplate(_PS_THEME_DIR_.'order-return.tpl');
} }
public function displayHeader() public function displayHeader()
@@ -84,12 +84,6 @@ class OrderReturnControllerCore extends FrontController
parent::displayHeader(); parent::displayHeader();
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'order-return.tpl');
}
public function displayFooter() public function displayFooter()
{ {
if (Tools::getValue('ajax') != 'true') if (Tools::getValue('ajax') != 'true')
@@ -42,14 +42,8 @@ class OrderSlipControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$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');
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'order-slip.tpl');
} }
} }
@@ -29,9 +29,9 @@ class PageNotFoundControllerCore extends FrontController
{ {
public $php_self = '404'; public $php_self = '404';
public function displayContent() public function process()
{ {
$this->context->smarty->display(_PS_THEME_DIR_.'404.tpl'); $this->setTemplate(_PS_THEME_DIR_.'404.tpl');
} }
} }
@@ -48,12 +48,8 @@ class ParentOrderControllerCore extends FrontController
{ {
parent::init(); parent::init();
$this->nbProducts = $this->context->cart->nbProducts(); $this->nbProducts = $this->context->cart->nbProducts();
}
public function preProcess()
{
global $isVirtualCart; global $isVirtualCart;
parent::preProcess();
// Redirect to the good order process // Redirect to the good order process
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 AND Dispatcher::getInstance()->getController() != 'order') if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 AND Dispatcher::getInstance()->getController() != 'order')
@@ -33,8 +33,6 @@ class PasswordControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
if (Tools::isSubmit('email')) if (Tools::isSubmit('email'))
{ {
if (!($email = Tools::getValue('email')) OR !Validate::isEmail($email)) if (!($email = Tools::getValue('email')) OR !Validate::isEmail($email))
@@ -100,12 +98,8 @@ class PasswordControllerCore extends FrontController
} }
elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer'))) elseif (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer')))
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted'); $this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'password.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'password.tpl');
} }
} }
@@ -27,16 +27,11 @@
class PdfInvoiceControllerCore extends FrontController class PdfInvoiceControllerCore extends FrontController
{ {
public function run()
{
$this->init();
$this->preProcess();
$this->process();
}
public function process() public function process()
{ {
parent::process(); $this->displayHeader(false);
$this->displayFooter(false);
if (!$this->context->customer->isLogged() AND !Tools::getValue('secure_key')) if (!$this->context->customer->isLogged() AND !Tools::getValue('secure_key'))
Tools::redirect('index.php?controller=authentication&back=pdf-invoice'); Tools::redirect('index.php?controller=authentication&back=pdf-invoice');
if (!(int)(Configuration::get('PS_INVOICE'))) if (!(int)(Configuration::get('PS_INVOICE')))
@@ -27,16 +27,10 @@
class PdfOrderReturnControllerCore extends FrontController class PdfOrderReturnControllerCore extends FrontController
{ {
public function run()
{
$this->init();
$this->preProcess();
$this->process();
}
public function process() public function process()
{ {
parent::process(); $this->displayHeader(false);
$this->displayFooter(false);
if (!$this->context->customer->isLogged()) if (!$this->context->customer->isLogged())
Tools::redirect('index.php?controller=authentication&back=order-follow'); Tools::redirect('index.php?controller=authentication&back=order-follow');
@@ -27,16 +27,10 @@
class PdfOrderSlipControllerCore extends FrontController class PdfOrderSlipControllerCore extends FrontController
{ {
public function run()
{
$this->init();
$this->preProcess();
$this->process();
}
public function process() public function process()
{ {
parent::process(); $this->displayHeader(false);
$this->displayFooter(false);
if (!$this->context->customer->isLogged()) if (!$this->context->customer->isLogged())
Tools::redirect('index.php?controller=authentication&back=order-follow'); Tools::redirect('index.php?controller=authentication&back=order-follow');
@@ -37,8 +37,6 @@ class PricesDropControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$this->productSort(); $this->productSort();
$nbProducts = Product::getPricesDrop($this->context->language->id, NULL, NULL, true); $nbProducts = Product::getPricesDrop($this->context->language->id, NULL, NULL, true);
$this->pagination($nbProducts); $this->pagination($nbProducts);
@@ -49,12 +47,8 @@ class PricesDropControllerCore extends FrontController
'nbProducts' => $nbProducts, 'nbProducts' => $nbProducts,
'homeSize' => Image::getSize('home') 'homeSize' => Image::getSize('home')
)); ));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'prices-drop.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'prices-drop.tpl');
} }
} }
@@ -52,23 +52,14 @@ class ProductControllerCore extends FrontController
public function canonicalRedirection() public function canonicalRedirection()
{ {
// Automatically redirect to the canonical URL if the current in is the right one
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if (Validate::isLoadedObject($this->product)) if (Validate::isLoadedObject($this->product))
{ parent::canonicalRedirection($this->context->link->getProductLink($this->product));
$canonicalURL = $this->context->link->getProductLink($this->product);
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
Tools::redirectLink($canonicalURL);
}
}
} }
public function preProcess() public function init()
{ {
parent::init();
if ($id_product = (int)Tools::getValue('id_product')) if ($id_product = (int)Tools::getValue('id_product'))
$this->product = new Product($id_product, true, $this->context->language->id); $this->product = new Product($id_product, true, $this->context->language->id);
@@ -79,8 +70,6 @@ class ProductControllerCore extends FrontController
} }
else else
$this->canonicalRedirection(); $this->canonicalRedirection();
parent::preProcess();
} }
public function process() public function process()
@@ -203,7 +192,7 @@ class ProductControllerCore extends FrontController
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2); $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)$this->product->id, $this->id_current_shop, (int)$this->context->cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)$tax), 'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)$this->product->id, $this->context->shop->getID(true), (int)$this->context->cookie->id_currency, $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)$tax),
'product' => $this->product, 'product' => $this->product,
'ecotax_tax_inc' => $ecotaxTaxAmount, 'ecotax_tax_inc' => $ecotaxTaxAmount,
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2),
@@ -361,12 +350,8 @@ class ProductControllerCore extends FrontController
'currencyBlank' => $this->context->currency->blank, 'currencyBlank' => $this->context->currency->blank,
'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM') 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')
)); ));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'product.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'product.tpl');
} }
public function transformDescriptionWithImg($desc) public function transformDescriptionWithImg($desc)
@@ -39,10 +39,8 @@ class SearchControllerCore extends FrontController
$this->ajaxSearch = Tools::getValue('ajaxSearch'); $this->ajaxSearch = Tools::getValue('ajaxSearch');
} }
public function preProcess() public function process()
{ {
parent::preProcess();
$query = urldecode(Tools::getValue('q')); $query = urldecode(Tools::getValue('q'));
if ($this->ajaxSearch) if ($this->ajaxSearch)
{ {
@@ -107,6 +105,8 @@ class SearchControllerCore extends FrontController
'nbProducts' => 0)); 'nbProducts' => 0));
} }
$this->context->smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')); $this->context->smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'));
$this->setTemplate(_PS_THEME_DIR_.'search.tpl');
} }
public function displayHeader() public function displayHeader()
@@ -117,12 +117,6 @@ class SearchControllerCore extends FrontController
$this->context->smarty->assign('static_token', Tools::getToken(false)); $this->context->smarty->assign('static_token', Tools::getToken(false));
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'search.tpl');
}
public function displayFooter() public function displayFooter()
{ {
if (!$this->instantSearch AND !$this->ajaxSearch) if (!$this->instantSearch AND !$this->ajaxSearch)
@@ -38,8 +38,6 @@ class SitemapControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
$this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1));
$this->context->smarty->assign('voucherAllowed', (int)Configuration::get('PS_VOUCHERS')); $this->context->smarty->assign('voucherAllowed', (int)Configuration::get('PS_VOUCHERS'));
@@ -50,11 +48,7 @@ class SitemapControllerCore extends FrontController
$this->context->smarty->assign('display_supplier_link', (((int)$blocksupplier->id) ? true : false)); $this->context->smarty->assign('display_supplier_link', (((int)$blocksupplier->id) ? true : false));
$this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
$this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
}
public function displayContent() $this->setTemplate(_PS_THEME_DIR_.'sitemap.tpl');
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'sitemap.tpl');
} }
} }
@@ -29,7 +29,8 @@ class StatisticsControllerCore extends FrontController
{ {
public function process() public function process()
{ {
parent::process(); $this->displayHeader(false);
$this->displayFooter(false);
if (!isset($_POST['token']) OR !isset($_POST['type'])) if (!isset($_POST['token']) OR !isset($_POST['type']))
die; die;
@@ -29,9 +29,11 @@ class StoresControllerCore extends FrontController
{ {
public $php_self = 'stores'; public $php_self = 'stores';
public function preProcess() public function init()
{ {
if(!extension_loaded('Dom')) parent::init();
if (!extension_loaded('Dom'))
{ {
$this->errors[] = Tools::displayError('Dom extension is not loaded.'); $this->errors[] = Tools::displayError('Dom extension is not loaded.');
$smarty->assign('errors', $this->errors); $smarty->assign('errors', $this->errors);
@@ -46,11 +48,11 @@ class StoresControllerCore extends FrontController
{ {
$stores = Db::getInstance()->ExecuteS(' $stores = Db::getInstance()->ExecuteS('
SELECT s.*, cl.name country, st.iso_code state SELECT s.*, cl.name country, st.iso_code state
FROM '._DB_PREFIX_.'store_shop ss FROM '._DB_PREFIX_.'store s
LEFT JOIN '._DB_PREFIX_.'store s ON (ss.id_store = s.id_store) '.$this->context->shop->sqlAsso('shop', 's').'
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id.' AND ss.id_shop = '.(int)$this->id_current_shop); WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id);
foreach ($stores AS &$store) foreach ($stores AS &$store)
$store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'); $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');
@@ -61,11 +63,11 @@ class StoresControllerCore extends FrontController
{ {
$stores = Db::getInstance()->ExecuteS(' $stores = Db::getInstance()->ExecuteS('
SELECT s.*, cl.name country, st.iso_code state SELECT s.*, cl.name country, st.iso_code state
FROM '._DB_PREFIX_.'store_shop ss FROM '._DB_PREFIX_.'store s
LEFT JOIN '._DB_PREFIX_.'store s ON (ss.id_store = s.id_store) '.$this->context->shop->sqlAsso('shop', 's').'
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id.' AND ss.id_shop = '.(int)$this->id_current_shop); WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id);
} }
else else
{ {
@@ -75,11 +77,11 @@ class StoresControllerCore extends FrontController
$stores = Db::getInstance()->ExecuteS(' $stores = Db::getInstance()->ExecuteS('
SELECT s.*, cl.name country, st.iso_code state, SELECT s.*, cl.name country, st.iso_code state,
('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country ('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country
FROM '._DB_PREFIX_.'store_shop ss FROM '._DB_PREFIX_.'store s
LEFT JOIN '._DB_PREFIX_.'store s ON (ss.id_store = s.id_store) '.$this->context->shop->sqlAsso('shop', 's').'
LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id.' AND ss.id_shop = '.(int)$this->id_current_shop.' WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id.'
HAVING distance < '.(int)($distance).' HAVING distance < '.(int)($distance).'
ORDER BY distance ASC ORDER BY distance ASC
LIMIT 0,20'); LIMIT 0,20');
@@ -188,13 +190,13 @@ class StoresControllerCore extends FrontController
public function process() public function process()
{ {
parent::process();
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'defaultLat' => (float)Configuration::get('PS_STORES_CENTER_LAT'), 'defaultLat' => (float)Configuration::get('PS_STORES_CENTER_LAT'),
'defaultLong' => (float)Configuration::get('PS_STORES_CENTER_LONG'), 'defaultLong' => (float)Configuration::get('PS_STORES_CENTER_LONG'),
'searchUrl' => $this->context->link->getPageLink('stores') 'searchUrl' => $this->context->link->getPageLink('stores')
)); ));
$this->setTemplate(_PS_THEME_DIR_.'stores.tpl');
} }
public function setMedia() public function setMedia()
@@ -205,10 +207,4 @@ class StoresControllerCore extends FrontController
$this->addJS(_THEME_JS_DIR_.'stores.js'); $this->addJS(_THEME_JS_DIR_.'stores.js');
$this->addJS('http://maps.google.com/maps/api/js?sensor=true'); $this->addJS('http://maps.google.com/maps/api/js?sensor=true');
} }
public function displayContent()
{
parent::displayContent();
$this->context->smarty->display(_PS_THEME_DIR_.'stores.tpl');
}
} }
@@ -39,24 +39,14 @@ class SupplierControllerCore extends FrontController
public function canonicalRedirection() public function canonicalRedirection()
{ {
if (Configuration::get('PS_CANONICAL_REDIRECT'))
{
if (Validate::isLoadedObject($this->supplier)) if (Validate::isLoadedObject($this->supplier))
{ parent::canonicalRedirection($this->context->link->getSupplierLink($this->supplier))
$canonicalURL = $this->context->link->getSupplierLink($this->supplier);
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$canonicalURL.'">'.$canonicalURL.'</a>');
Tools::redirectLink($canonicalURL);
}
}
}
} }
public function preProcess() public function init()
{ {
parent::init();
if ($id_supplier = (int)Tools::getValue('id_supplier')) if ($id_supplier = (int)Tools::getValue('id_supplier'))
{ {
$this->supplier = new Supplier($id_supplier, $this->context->language->id); $this->supplier = new Supplier($id_supplier, $this->context->language->id);
@@ -70,8 +60,6 @@ class SupplierControllerCore extends FrontController
else else
$this->canonicalRedirection(); $this->canonicalRedirection();
} }
parent::preProcess();
} }
public function process() public function process()
@@ -79,13 +67,13 @@ class SupplierControllerCore extends FrontController
if (Validate::isLoadedObject($this->supplier) AND $this->supplier->active AND $this->supplier->isAssociatedToGroupShop()) if (Validate::isLoadedObject($this->supplier) AND $this->supplier->active AND $this->supplier->isAssociatedToGroupShop())
{ {
$nbProducts = $this->supplier->getProducts($this->supplier->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $nbProducts = $this->supplier->getProducts($this->supplier->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int)$nbProducts); $this->pagination((int)$nbProducts);
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'nb_products' => $nbProducts, 'nb_products' => $nbProducts,
'products' => $this->supplier->getProducts($this->supplier->id, $this->context->cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay), 'products' => $this->supplier->getProducts($this->supplier->id, $this->context->cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
'path' => ($this->supplier->active ? Tools::safeOutput($this->supplier->name) : ''), 'path' => ($this->supplier->active ? Tools::safeOutput($this->supplier->name) : ''),
'supplier' => $this->supplier, 'supplier' => $this->supplier,
)); ));
} }
elseif (!Tools::getValue('id_supplier')) elseif (!Tools::getValue('id_supplier'))
{ {
@@ -110,6 +98,11 @@ class SupplierControllerCore extends FrontController
else else
$this->context->smarty->assign('nbSuppliers', 0); $this->context->smarty->assign('nbSuppliers', 0);
} }
if ($this->supplier)
$this->setTemplate(_PS_THEME_DIR_.'supplier.tpl');
else
$this->setTemplate(_PS_THEME_DIR_.'supplier-list.tpl');
} }
public function displayHeader() public function displayHeader()
@@ -117,14 +110,4 @@ class SupplierControllerCore extends FrontController
parent::displayHeader(); parent::displayHeader();
$this->productSort(); $this->productSort();
} }
public function displayContent()
{
parent::displayContent();
if ($this->supplier)
$this->context->smarty->display(_PS_THEME_DIR_.'supplier.tpl');
else
$this->context->smarty->display(_PS_THEME_DIR_.'supplier-list.tpl');
}
} }
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
@@ -55,7 +55,7 @@ class BlockManufacturer extends Module
function hookLeftColumn($params) function hookLeftColumn($params)
{ {
$this->context->smarty->assign(array( $this->smartyAssign(array(
'manufacturers' => Manufacturer::getManufacturers(), 'manufacturers' => Manufacturer::getManufacturers(),
'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'),
'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'), 'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'),
@@ -26,24 +26,24 @@
<!-- Block manufacturers module --> <!-- Block manufacturers module -->
<div id="manufacturers_block_left" class="block blockmanufacturer"> <div id="manufacturers_block_left" class="block blockmanufacturer">
<h4>{if $display_link_manufacturer}<a href="{$link->getPageLink('manufacturer')}" title="{l s='Manufacturers' mod='blockmanufacturer'}">{/if}{l s='Manufacturers' mod='blockmanufacturer'}{if $display_link_manufacturer}</a>{/if}</h4> <h4>{if $blockmanufacturer_display_link_manufacturer}<a href="{$link->getPageLink('manufacturer')}" title="{l s='Manufacturers' mod='blockmanufacturer'}">{/if}{l s='Manufacturers' mod='blockmanufacturer'}{if $blockmanufacturer_display_link_manufacturer}</a>{/if}</h4>
<div class="block_content"> <div class="block_content">
{if $manufacturers} {if $blockmanufacturer_manufacturers}
{if $text_list} {if $blockmanufacturer_text_list}
<ul class="bullet"> <ul class="bullet">
{foreach from=$manufacturers item=manufacturer name=manufacturer_list} {foreach from=$blockmanufacturer_manufacturers item=manufacturer name=manufacturer_list}
{if $smarty.foreach.manufacturer_list.iteration <= $text_list_nb} {if $smarty.foreach.manufacturer_list.iteration <= $blockmanufacturer_text_list_nb}
<li class="{if $smarty.foreach.manufacturer_list.last}last_item{elseif $smarty.foreach.manufacturer_list.first}first_item{else}item{/if}"><a href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}" title="{l s='More about' mod='blockmanufacturer'} {$manufacturer.name}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</a></li> <li class="{if $smarty.foreach.manufacturer_list.last}last_item{elseif $smarty.foreach.manufacturer_list.first}first_item{else}item{/if}"><a href="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}" title="{l s='More about' mod='blockmanufacturer'} {$manufacturer.name}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</a></li>
{/if} {/if}
{/foreach} {/foreach}
</ul> </ul>
{/if} {/if}
{if $form_list} {if $blockmanufacturer_form_list}
<form action="{$smarty.server.SCRIPT_NAME}" method="get"> <form action="{$smarty.server.SCRIPT_NAME}" method="get">
<p> <p>
<select id="manufacturer_list" onchange="autoUrl('manufacturer_list', '');"> <select id="manufacturer_list" onchange="autoUrl('manufacturer_list', '');">
<option value="0">{l s='All manufacturers' mod='blockmanufacturer'}</option> <option value="0">{l s='All manufacturers' mod='blockmanufacturer'}</option>
{foreach from=$manufacturers item=manufacturer} {foreach from=$blockmanufacturer_manufacturers item=manufacturer}
<option value="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</option> <option value="{$link->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}">{$manufacturer.name|escape:'htmlall':'UTF-8'}</option>
{/foreach} {/foreach}
</select> </select>
+5 -4
View File
@@ -60,10 +60,11 @@ class BlockMyAccount extends Module
{ {
if (!$this->context->customer->isLogged()) if (!$this->context->customer->isLogged())
return false; return false;
$this->context->smarty->assign(array(
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')), $this->smartyAssign(array(
'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN')), 'voucherAllowed' => (int)Configuration::get('PS_VOUCHERS'),
'HOOK_BLOCK_MY_ACCOUNT' => Module::hookExec('myAccountBlock') 'returnAllowed' => (int)Configuration::get('PS_ORDER_RETURN'),
'HOOK_BLOCK_MY_ACCOUNT' => Module::hookExec('myAccountBlock'),
)); ));
return $this->display(__FILE__, $this->name.'.tpl'); return $this->display(__FILE__, $this->name.'.tpl');
} }
+3 -3
View File
@@ -30,12 +30,12 @@
<div class="block_content"> <div class="block_content">
<ul class="bullet"> <ul class="bullet">
<li><a href="{$link->getPageLink('history', true)}" title="">{l s='My orders' mod='blockmyaccount'}</a></li> <li><a href="{$link->getPageLink('history', true)}" title="">{l s='My orders' mod='blockmyaccount'}</a></li>
{if $returnAllowed}<li><a href="{$link->getPageLink('order-follow', true)}" title="">{l s='My merchandise returns' mod='blockmyaccount'}</a></li>{/if} {if $blockmyaccount_returnAllowed}<li><a href="{$link->getPageLink('order-follow', true)}" title="">{l s='My merchandise returns' mod='blockmyaccount'}</a></li>{/if}
<li><a href="{$link->getPageLink('order-slip', true)}" title="">{l s='My credit slips' mod='blockmyaccount'}</a></li> <li><a href="{$link->getPageLink('order-slip', true)}" title="">{l s='My credit slips' mod='blockmyaccount'}</a></li>
<li><a href="{$link->getPageLink('addresses', true)}" title="">{l s='My addresses' mod='blockmyaccount'}</a></li> <li><a href="{$link->getPageLink('addresses', true)}" title="">{l s='My addresses' mod='blockmyaccount'}</a></li>
<li><a href="{$link->getPageLink('identity', true)}" title="">{l s='My personal info' mod='blockmyaccount'}</a></li> <li><a href="{$link->getPageLink('identity', true)}" title="">{l s='My personal info' mod='blockmyaccount'}</a></li>
{if $voucherAllowed}<li><a href="{$link->getPageLink('discount', true)}" title="">{l s='My vouchers' mod='blockmyaccount'}</a></li>{/if} {if $blockmyaccount_voucherAllowed}<li><a href="{$link->getPageLink('discount', true)}" title="">{l s='My vouchers' mod='blockmyaccount'}</a></li>{/if}
{$HOOK_BLOCK_MY_ACCOUNT} {$blockmyaccount_HOOK_BLOCK_MY_ACCOUNT}
</ul> </ul>
<p class="logout"><a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Sign out' mod='blockmyaccount'}">{l s='Sign out' mod='blockmyaccount'}</a></p> <p class="logout"><a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Sign out' mod='blockmyaccount'}">{l s='Sign out' mod='blockmyaccount'}</a></p>
</div> </div>
+1 -1
View File
@@ -166,7 +166,7 @@ class BlockViewed extends Module
if (!sizeof($productsViewedObj)) if (!sizeof($productsViewedObj))
return ; return ;
$this->context->smarty->assign(array( $this->smartyAssign(array(
'productsViewedObj' => $productsViewedObj, 'productsViewedObj' => $productsViewedObj,
'mediumSize' => Image::getSize('medium'))); 'mediumSize' => Image::getSize('medium')));
+2 -2
View File
@@ -29,9 +29,9 @@
<h4>{l s='Viewed products' mod='blockviewed'}</h4> <h4>{l s='Viewed products' mod='blockviewed'}</h4>
<div class="block_content"> <div class="block_content">
<ul class="products clearfix"> <ul class="products clearfix">
{foreach from=$productsViewedObj item=viewedProduct name=myLoop} {foreach from=$blockviewed_productsViewedObj item=viewedProduct name=myLoop}
<li class="clearfix{if $smarty.foreach.myLoop.last} last_item{elseif $smarty.foreach.myLoop.first} first_item{else} item{/if}"> <li class="clearfix{if $smarty.foreach.myLoop.last} last_item{elseif $smarty.foreach.myLoop.first} first_item{else} item{/if}">
<a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($viewedProduct->link_rewrite, $viewedProduct->cover, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$viewedProduct->legend|escape:html:'UTF-8'}" /></a> <a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($viewedProduct->link_rewrite, $viewedProduct->cover, 'medium')}" height="{$blockviewed_mediumSize.height}" width="{$blockviewed_mediumSize.width}" alt="{$viewedProduct->legend|escape:html:'UTF-8'}" /></a>
<h5><a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}">{$viewedProduct->name|truncate:14:'...'|escape:html:'UTF-8'}</a></h5> <h5><a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}">{$viewedProduct->name|truncate:14:'...'|escape:html:'UTF-8'}</a></h5>
<p>{$viewedProduct->description_short|strip_tags:'UTF-8'|truncate:44}<a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}"><img src="{$img_dir}bullet.gif" alt="&gt;&gt;" width="10" height="7" /></a></p> <p>{$viewedProduct->description_short|strip_tags:'UTF-8'|truncate:44}<a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}"><img src="{$img_dir}bullet.gif" alt="&gt;&gt;" width="10" height="7" /></a></p>
</li> </li>
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;