diff --git a/admin-dev/init.php b/admin-dev/init.php
index 0d53acdb0..d575ab0a4 100644
--- a/admin-dev/init.php
+++ b/admin-dev/init.php
@@ -35,14 +35,11 @@ if (isset($_GET['logout']))
if (!$cookie->isLoggedBack())
{
-
$destination = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])) + 1);
Tools::redirectAdmin('login.php'.(empty($destination) || ($destination == 'index.php?logout') ? '' : '?redirect='.$destination));
}
else
{
- $link = new Link();
-
$currentIndex = $_SERVER['SCRIPT_NAME'].(($tab = Tools::getValue('tab')) ? '?tab='.$tab : '');
if ($back = Tools::getValue('back'))
$currentIndex .= '&back='.urlencode($back);
@@ -50,12 +47,14 @@ else
/* Server Params */
$protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
$protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
+ $link = new Link($protocol_link, $protocol_content);
define('_PS_BASE_URL_', Tools::getShopDomain(true));
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
$employee = new Employee((int)$cookie->id_employee);
$cookie->id_lang = (int)$employee->id_lang;
- $iso = strtolower(Language::getIsoById($cookie->id_lang ? $cookie->id_lang : Configuration::get('PS_LANG_DEFAULT')));
+ $language = new Language($cookie->id_lang ? $cookie->id_lang : Configuration::get('PS_LANG_DEFAULT'));
+ $iso = $language->iso_code;
include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
@@ -90,4 +89,10 @@ else
unset($parseQuery['setShopContext']);
Tools::redirectAdmin($url['path'] . '?' . http_build_query($parseQuery));
}
+
+ $context = Context::getContext();
+ $context->employee = $employee;
+ $context->cookie = $cookie;
+ $context->link = $link;
+ $context->language = $language;
}
diff --git a/classes/AdminTab.php b/classes/AdminTab.php
index 4e96a2f49..a9862cb46 100644
--- a/classes/AdminTab.php
+++ b/classes/AdminTab.php
@@ -170,7 +170,8 @@ abstract class AdminTabCore
public function __construct()
{
global $cookie;
-
+ $context = Context::getContext();
+ $context->tab = $this;
$this->id = Tab::getCurrentTabId();
$this->_conf = array(
1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'),
@@ -480,10 +481,11 @@ abstract class AdminTabCore
* Overload this method for custom checking
*
* @param integer $id Object id used for deleting images
- * TODO This function will soon be deprecated. Use ObjectModel->deleteImage instead.
+ * @deprecated As of 1.5 use ObjectModel->deleteImage instead.
*/
public function deleteImage($id)
{
+ Tools::displayAsDeprecated();
$dir = null;
/* Deleting object images and thumbnails (cache) */
if (key_exists('dir', $this->fieldImageSettings))
diff --git a/classes/CMS.php b/classes/CMS.php
index 20d248e01..012aaed5e 100644
--- a/classes/CMS.php
+++ b/classes/CMS.php
@@ -104,8 +104,11 @@ class CMSCore extends ObjectModel
return false;
}
- public static function getLinks($id_lang, $selection = NULL, $active = true, $id_shop = false)
+ public static function getLinks($id_lang, $selection = NULL, $active = true, $id_shop = false, $context = null)
{
+ if (!$context)
+ $context = Context::getContext();
+
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.id_cms, cl.link_rewrite, cl.meta_title
FROM '._DB_PREFIX_.'cms c
@@ -114,12 +117,12 @@ class CMSCore extends ObjectModel
'.(($selection !== NULL) ? ' AND c.id_cms IN ('.implode(',', array_map('intval', $selection)).')' : '').
($active ? ' AND c.`active` = 1 ' : '').
'ORDER BY c.`position`');
- $link = new Link();
+
$links = array();
if ($result)
foreach ($result as $row)
{
- $row['link'] = $link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
+ $row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
$links[] = $row;
}
return $links;
diff --git a/classes/CMSCategory.php b/classes/CMSCategory.php
index d0b22319e..460551d72 100644
--- a/classes/CMSCategory.php
+++ b/classes/CMSCategory.php
@@ -177,8 +177,11 @@ class CMSCategoryCore extends ObjectModel
);
}
- static public function getRecurseCategory($id_lang = _USER_ID_LANG_, $current = 1, $active = 1, $links = 0, $id_shop = false)
+ static public function getRecurseCategory($id_lang = _USER_ID_LANG_, $current = 1, $active = 1, $links = 0, $id_shop = false, $context = null)
{
+ if (!$context)
+ $context = Context::getContext();
+
$category = Db::getInstance()->getRow('
SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms_category` c
@@ -203,10 +206,9 @@ class CMSCategoryCore extends ObjectModel
ORDER BY c.`position`');
if ($links == 1)
{
- $link = new Link();
$category['link'] = $link->getCMSCategoryLink($current, $category['link_rewrite']);
foreach($category['cms'] as $key => $cms)
- $category['cms'][$key]['link'] = $link->getCMSLink($cms['id_cms'], $cms['link_rewrite']);
+ $category['cms'][$key]['link'] = $context->link->getCMSLink($cms['id_cms'], $cms['link_rewrite']);
}
return $category;
}
diff --git a/classes/Cart.php b/classes/Cart.php
index 095522247..61ea90cc6 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -72,6 +72,10 @@ class CartCore extends ObjectModel
/** @var string Object last modification date */
public $date_upd;
+ public $checkedTos = false;
+ public $pictures;
+ public $textFields;
+
protected static $_nbProducts = array();
protected static $_isVirtualCart = array();
diff --git a/classes/Context.php b/classes/Context.php
new file mode 100644
index 000000000..71d922a0c
--- /dev/null
+++ b/classes/Context.php
@@ -0,0 +1,95 @@
+cart = $cart;
+ $this->customer = $customer;
+ $this->cookie = $cookie;
+ $this->link = $link;
+ $this->country = $country;
+ $this->employee = $employee;
+ $this->lang = $lang;
+ $this->currency = $currency;
+ $this->tab = $tab;
+ }
+
+ /**
+ * Get a singleton context
+ *
+ * @return Context
+ */
+ public static function getContext()
+ {
+ if (!isset(self::$instance))
+ self::$instance = new self();
+ return self::$instance;
+ }
+
+ public function setData($cart = null,
+ $customer = null,
+ $cookie = null,
+ $link = null,
+ $country = null,
+ $employee = null,
+ $lang = null,
+ $currency = null,
+ $tab = null)
+ {
+ $this->cart = $cart;
+ $this->customer = $customer;
+ $this->cookie = $cookie;
+ $this->link = $link;
+ $this->country = $country;
+ $this->employee = $employee;
+ $this->lang = $lang;
+ $this->currency = $currency;
+ $this->tab = $tab;
+ }
+
+ /*public function __get($var)
+ {
+ return (isset($this->data[$var]) ? $this->data[$var] : null);
+ }
+
+ public function __set($var, $value)
+ {
+ $this->data[$var] = $value;
+ }
+
+ public function __isset($var)
+ {
+ return isset($this->data[$var]);
+ }
+
+ public function __unset($var)
+ {
+ if (isset($this->data[$var]))
+ unset($this->data[$var]);
+ }*/
+}
\ No newline at end of file
diff --git a/classes/Customer.php b/classes/Customer.php
index 6ca696eb1..642d842d9 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -43,7 +43,7 @@ class CustomerCore extends ObjectModel
public $id_gender = 9;
/** @var integer Default group ID */
- public $id_default_group;
+ public $id_default_group = _PS_DEFAULT_CUSTOMER_GROUP_;
/** @var string Lastname */
public $lastname;
@@ -93,7 +93,11 @@ class CustomerCore extends ObjectModel
public $years;
public $days;
public $months;
-
+
+ public $geoloc_id_country;
+ public $geoloc_id_state;
+ public $geoloc_postcode;
+
protected $tables = array ('customer');
protected $fieldsRequired = array('lastname', 'passwd', 'firstname', 'email');
diff --git a/classes/FrontController.php b/classes/FrontController.php
index 68ab2fedf..646d8fd76 100755
--- a/classes/FrontController.php
+++ b/classes/FrontController.php
@@ -28,7 +28,7 @@
class FrontControllerCore
{
public $errors = array();
- protected static $smarty;
+ public $smarty;
protected static $cookie;
protected static $link;
protected static $cart;
@@ -52,6 +52,10 @@ class FrontControllerCore
public static $initialized = false;
protected static $currentCustomerGroups;
+
+ public $css_files;
+ public $js_files;
+ public $nb_items_per_page;
public function __construct()
{
@@ -72,7 +76,7 @@ class FrontControllerCore
public function init()
{
- global $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files;
+ global $link, $cookie, $cart, $smarty, $iso, $defaultCountry;
if (self::$initialized)
return;
@@ -81,8 +85,8 @@ class FrontControllerCore
$this->id_current_shop = (int)Shop::getCurrentShop();
$this->id_current_group_shop = (int)Shop::getCurrentGroupShop();
- $css_files = array();
- $js_files = array();
+ $this->css_files = array();
+ $this->js_files = array();
if ($this->ssl AND (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED'))
{
@@ -97,7 +101,6 @@ class FrontControllerCore
$defaultCountry = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
$cookie = new Cookie('ps');
- $link = new Link();
if ($this->auth AND !$cookie->isLogged($this->guestAllowed))
Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : ''));
@@ -115,7 +118,7 @@ class FrontControllerCore
$_GET['id_lang'] = $id_lang;
Tools::switchLanguage();
- Tools::setCookieLanguage();
+ Tools::setCookieLanguage($cookie);
/* attribute id_lang is often needed, so we create a constant for performance reasons */
if (!defined('_USER_ID_LANG_'))
@@ -133,7 +136,7 @@ class FrontControllerCore
}
global $currency;
- $currency = Tools::setCurrency();
+ $currency = Tools::setCurrency($cookie);
$_MODULES = array();
@@ -224,11 +227,14 @@ class FrontControllerCore
$protocol_link = (Configuration::get('PS_SSL_ENABLED') OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
$protocol_content = ((isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) OR (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';
+
if (!defined('_PS_BASE_URL_'))
define('_PS_BASE_URL_', Tools::getShopDomain(true));
if (!defined('_PS_BASE_URL_SSL_'))
define('_PS_BASE_URL_SSL_', Tools::getShopDomainSsl(true));
+ $link = new Link($protocol_link, $protocol_content);
+
$link->preloadPageLinks();
$this->canonicalRedirection();
@@ -305,7 +311,7 @@ class FrontControllerCore
// setting properties from global var
self::$cookie = $cookie;
self::$cart = $cart;
- self::$smarty = $smarty;
+ $this->smarty = $smarty;
self::$link = $link;
if ($this->maintenance)
@@ -321,6 +327,29 @@ class FrontControllerCore
$this->iso = $iso;
$this->setMedia();
+
+
+ //$defaultCountry
+ if (isset($cookie->id_customer) && (int)$cookie->id_customer)
+ $customer = new Customer($cookie->id_customer);
+ else
+ $customer = new Customer();
+
+ if($cookie->id_country)
+ $customer->geoloc_id_country = (int)$cookie->id_country;
+ if($cookie->id_state)
+ $customer->geoloc_id_state = (int)$cookie->id_state;
+ if($cookie->postcode)
+ $customer->geoloc_postcode = (int)$cookie->postcode;
+
+ $context = Context::getContext();
+ $context->customer = $customer;
+ $context->cart = $cart;
+ $context->link = $link;
+ $context->cookie = $cookie;
+ $context->currency = $currency;
+ $context->controller = $this;
+ $context->language = $ps_language;
}
/* Display a maintenance page if shop is closed */
@@ -329,7 +358,7 @@ class FrontControllerCore
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP'))))
{
header('HTTP/1.1 503 temporarily overloaded');
- self::$smarty->display(_PS_THEME_DIR_.'maintenance.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'maintenance.tpl');
exit;
}
}
@@ -431,16 +460,16 @@ class FrontControllerCore
{
global $cookie;
- Tools::addCSS(_THEME_CSS_DIR_.'global.css', 'all');
- Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery-1.4.4.min.js', _PS_JS_DIR_.'jquery/jquery.easing.1.3.js', _PS_JS_DIR_.'tools.js'));
+ $this->addCSS(_THEME_CSS_DIR_.'global.css', 'all');
+ $this->addJS(array(_PS_JS_DIR_.'jquery/jquery-1.4.4.min.js', _PS_JS_DIR_.'jquery/jquery.easing.1.3.js', _PS_JS_DIR_.'tools.js'));
if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
{
- Tools::addJS(array(
+ $this->addJS(array(
_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js',
_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js',
_PS_JS_DIR_.'hookLiveEdit.js')
);
- Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css');
+ $this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css');
}
}
@@ -451,13 +480,11 @@ class FrontControllerCore
public function displayContent()
{
Tools::safePostVars();
- self::$smarty->assign('errors', $this->errors);
+ $this->smarty->assign('errors', $this->errors);
}
public function displayHeader()
{
- global $css_files, $js_files;
-
if (!self::$initialized)
$this->init();
@@ -465,7 +492,7 @@ class FrontControllerCore
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
/* Hooks are volontary out the initialize array (need those variables already assigned) */
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'time' => time(),
'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
'static_token' => Tools::getToken(false),
@@ -475,7 +502,7 @@ class FrontControllerCore
'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
'content_only' => (int)Tools::getValue('content_only')
));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_HEADER' => Module::hookExec('header'),
'HOOK_TOP' => Module::hookExec('top'),
'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn')
@@ -485,16 +512,16 @@ class FrontControllerCore
{
// CSS compressor management
if (Configuration::get('PS_CSS_THEME_CACHE'))
- Tools::cccCss();
+ $this->css_files = Tools::cccCSS($this->css_files);
//JS compressor management
if (Configuration::get('PS_JS_THEME_CACHE'))
- Tools::cccJs();
+ $this->js_files = Tools::cccJs($this->js_files);
}
- self::$smarty->assign('css_files', $css_files);
- self::$smarty->assign('js_files', array_unique($js_files));
- self::$smarty->display(_PS_THEME_DIR_.'header.tpl');
+ $this->smarty->assign('css_files', $this->css_files);
+ $this->smarty->assign('js_files', array_unique($this->js_files));
+ $this->smarty->display(_PS_THEME_DIR_.'header.tpl');
}
public function displayFooter()
@@ -503,16 +530,16 @@ class FrontControllerCore
if (!self::$initialized)
$this->init();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_RIGHT_COLUMN' => Module::hookExec('rightColumn', array('cart' => self::$cart)),
'HOOK_FOOTER' => Module::hookExec('footer'),
'content_only' => (int)(Tools::getValue('content_only'))));
- self::$smarty->display(_PS_THEME_DIR_.'footer.tpl');
+ $this->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_)))
{
- self::$smarty->assign(array('ad' => $ad, 'live_edit' => true));
- self::$smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
+ $this->smarty->assign(array('ad' => $ad, 'live_edit' => true));
+ $this->smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
}
else
Tools::displayError();
@@ -539,7 +566,7 @@ class FrontControllerCore
if (!in_array($this->orderWay, $orderWayValues))
$this->orderWay = $orderWayValues[0];
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'orderby' => $this->orderBy,
'orderway' => $this->orderWay,
'orderbydefault' => $orderByValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_BY'))],
@@ -575,7 +602,7 @@ class FrontControllerCore
$stop = (int)($this->p + $range);
if ($stop > $pages_nb)
$stop = (int)($pages_nb);
- self::$smarty->assign('nb_products', $nbProducts);
+ $this->smarty->assign('nb_products', $nbProducts);
$pagination_infos = array(
'pages_nb' => (int)($pages_nb),
'p' => (int)($this->p),
@@ -585,7 +612,7 @@ class FrontControllerCore
'start' => (int)($start),
'stop' => (int)($stop)
);
- self::$smarty->assign($pagination_infos);
+ $this->smarty->assign($pagination_infos);
}
public static function getCurrentCustomerGroups()
@@ -613,5 +640,98 @@ class FrontControllerCore
$allowed = true;
return $allowed;
}
+
+ /**
+ * addCSS allows you to add stylesheet at any time.
+ *
+ * @param mixed $css_uri
+ * @param string $css_media_type
+ * @return true
+ */
+ public function addCSS($css_uri, $css_media_type = 'all')
+ {
+ if (is_array($css_uri))
+ {
+ foreach ($css_uri as $file => $media_type)
+ $this->addCSS($file, $media_type);
+ return true;
+ }
+
+ //overriding of modules css files
+ $different = 0;
+ $override_path = str_replace(__PS_BASE_URI__.'modules/', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/css/modules/', $css_uri, $different);
+ if ($different && file_exists($override_path))
+ $css_uri = str_replace(__PS_BASE_URI__.'modules/', __PS_BASE_URI__.'themes/'._THEME_NAME_.'/css/modules/', $css_uri, $different);
+ else
+ {
+ // remove PS_BASE_URI on _PS_ROOT_DIR_ for the following
+ $url_data = parse_url($css_uri);
+ $file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
+ // check if css files exists
+ if (!file_exists($file_uri))
+ return true;
+ }
+
+ // detect mass add
+ $css_uri = array($css_uri => $css_media_type);
+
+ // adding file to the big array...
+ if (is_array($this->css_files))
+ $this->css_files = array_merge($this->css_files, $css_uri);
+ else
+ $this->css_files = $css_uri;
+
+ return true;
+ }
+
+ /**
+ * addJS load a javascript file in the header
+ *
+ * @param mixed $js_uri
+ * @return void
+ */
+ public function addJS($js_uri)
+ {
+ if(!isset($this->js_files))
+ $this->js_files = array();
+ // avoid useless operation...
+ if (in_array($js_uri, $this->js_files))
+ return true;
+
+ // detect mass add
+ if (!is_array($js_uri) && !in_array($js_uri, $this->js_files))
+ $js_uri = array($js_uri);
+ else
+ foreach($js_uri as $key => $js)
+ if (in_array($js, $this->js_files))
+ unset($js_uri[$key]);
+
+ //overriding of modules js files
+ foreach ($js_uri AS $key => &$file)
+ {
+ if (!preg_match('/^http(s?):\/\//i', $file))
+ {
+ $different = 0;
+ $override_path = str_replace(__PS_BASE_URI__.'modules/', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/js/modules/', $file, $different);
+ if ($different && file_exists($override_path))
+ $file = str_replace(__PS_BASE_URI__.'modules/', __PS_BASE_URI__.'themes/'._THEME_NAME_.'/js/modules/', $file, $different);
+ else
+ {
+ // remove PS_BASE_URI on _PS_ROOT_DIR_ for the following
+ $url_data = parse_url($file);
+ $file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
+ // check if js files exists
+ if (!file_exists($file_uri))
+ unset($js_uri[$key]);
+ }
+ }
+ }
+
+ // adding file to the big array...
+ $this->js_files = array_merge($this->js_files, $js_uri);
+
+ return true;
+ }
+
}
diff --git a/classes/Link.php b/classes/Link.php
index 846afebf5..15e80cc85 100644
--- a/classes/Link.php
+++ b/classes/Link.php
@@ -31,14 +31,20 @@ class LinkCore
protected $allow;
protected $url;
public static $cache = array('page' => array());
+
+ public $protocol_link;
+ public $protocol_content;
+ public $useSSL;
/**
* Constructor (initialization only)
*/
- public function __construct()
+ public function __construct($protocol_link = null, $protocol_content = null)
{
$this->allow = (int)Configuration::get('PS_REWRITING_SETTINGS');
$this->url = $_SERVER['SCRIPT_NAME'];
+ $this->protocol_link = $protocol_link;
+ $this->protocol_content = $protocol_content;
}
/**
@@ -146,8 +152,6 @@ class LinkCore
*/
public function getImageLink($name, $ids, $type = NULL)
{
- global $protocol_content;
-
// legacy mode
if (Configuration::get('PS_LEGACY_IMAGES')
&& (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'.jpg')))
@@ -168,7 +172,7 @@ class LinkCore
$uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'.jpg';
}
- return $protocol_content.Tools::getMediaServer($uri_path).$uri_path;
+ return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
}
public function getMediaLink($filepath)
diff --git a/classes/Product.php b/classes/Product.php
index 17cc7cd88..b878a4f32 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -288,19 +288,20 @@ class ProductCore extends ObjectModel
),
);
- public function __construct($id_product = NULL, $full = false, $id_lang = NULL, $id_shop = NULL)
+ public function __construct($id_product = NULL, $full = false, $id_lang = NULL, $id_shop = NULL, $context = NULL)
{
- global $cart;
-
parent::__construct($id_product, $id_lang, $id_shop);
+ if (!$context)
+ $context = Context::getContext();
+
if ($full AND $this->id)
{
$this->tax_name = 'deprecated'; // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode)
$this->manufacturer_name = Manufacturer::getNameById((int)$this->id_manufacturer);
$this->supplier_name = Supplier::getNameById((int)$this->id_supplier);
self::$_tax_rules_group[$this->id] = $this->id_tax_rules_group;
- if (is_object($cart) AND $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != NULL)
- $this->tax_rate = Tax::getProductTaxRate($this->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
+ if (is_object($context->cart) AND $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != NULL)
+ $this->tax_rate = Tax::getProductTaxRate($this->id, $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
else
$this->tax_rate = Tax::getProductTaxRate($this->id, NULL);
$this->new = $this->isNew();
@@ -412,30 +413,22 @@ class ProductCore extends ObjectModel
return $fields;
}
- public static function initPricesComputation($id_customer = NULL)
+ public static function initPricesComputation($customer = NULL)
{
- global $cookie;
-
- if ($id_customer)
+ if ($customer)
{
- $customer = new Customer((int)($id_customer));
if (!Validate::isLoadedObject($customer))
die(Tools::displayError());
self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int)($customer->id_default_group));
}
- elseif ($cookie->id_customer)
- {
- $customer = new Customer((int)($cookie->id_customer));
- self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int)($customer->id_default_group));
- }
else
self::$_taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
}
- public static function getTaxCalculationMethod($id_customer = NULL)
+ public static function getTaxCalculationMethod($customer = NULL)
{
- if ($id_customer)
- self::initPricesComputation((int)($id_customer));
+ if ($customer)
+ self::initPricesComputation((int)($customer));
return (int)(self::$_taxCalculationMethod);
}
@@ -1455,15 +1448,15 @@ class ProductCore extends ObjectModel
return Product::getProductsProperties((int)$id_lang, $result);
}
- static protected function _getProductIdByDate($beginning, $ending)
+ static protected function _getProductIdByDate($beginning, $ending, $context = null)
{
- global $cookie, $cart;
+ if (!$context)
+ $context = Context::getContext();
- $id_group = $cookie->id_customer ? (int)(Customer::getDefaultGroupId((int)($cookie->id_customer))) : _PS_DEFAULT_CUSTOMER_GROUP_;
- $id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
+ $id_address = $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
$ids = Address::getCountryAndState($id_address);
$id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
- return SpecificPrice::getProductIdByDate((int)(Shop::getCurrentShop()), (int)($cookie->id_currency), $id_country, $id_group, $beginning, $ending);
+ return SpecificPrice::getProductIdByDate(Shop::getCurrentShop(), $context->currency->id, $id_country, $context->customer->id_default_group, $beginning, $ending);
}
/**
@@ -1742,10 +1735,13 @@ class ProductCore extends ObjectModel
* @return float Product price
*/
public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = NULL, $decimals = 6, $divisor = NULL, $only_reduc = false,
- $usereduc = true, $quantity = 1, $forceAssociatedTax = false, $id_customer = NULL, $id_cart = NULL, $id_address = NULL, &$specificPriceOutput = NULL, $with_ecotax = TRUE)
+ $usereduc = true, $quantity = 1, $forceAssociatedTax = false, $id_customer = NULL, $id_cart = NULL, $id_address = NULL, &$specificPriceOutput = NULL,
+ $with_ecotax = TRUE, $context = null)
{
- global $cookie, $cart;
- $cur_cart = $cart;
+ if (!$context)
+ $context = Context::getContext();
+
+ $cur_cart = $context->cart;
if (isset($divisor))
Tools::displayParameterAsDeprecated('divisor');
@@ -1753,18 +1749,17 @@ class ProductCore extends ObjectModel
if (!Validate::isBool($usetax) OR !Validate::isUnsignedId($id_product))
die(Tools::displayError());
// Initializations
- if (!$id_customer)
- $id_customer = ((Validate::isCookie($cookie) AND isset($cookie->id_customer) AND $cookie->id_customer) ? (int)($cookie->id_customer) : NULL);
- $id_group = $id_customer ? (int)(Customer::getDefaultGroupId($id_customer)) : _PS_DEFAULT_CUSTOMER_GROUP_;
+ $id_group = (isset($context->customer) ? $context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
if (!is_object($cur_cart) OR (Validate::isUnsignedInt($id_cart) AND $id_cart))
{
/*
* When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php)
* When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
+ * When called from the back office, cart ID can be inexistant
*/
- if (!$id_cart AND !Validate::isCookie($cookie))
+ if (!$id_cart &&!isset($context->tab))
die(Tools::displayError());
- $cur_cart = $id_cart ? new Cart((int)($id_cart)) : new Cart((int)($cookie->id_cart));
+ $cur_cart = new Cart($id_cart);
}
if ((int)($id_cart))
@@ -1778,7 +1773,7 @@ class ProductCore extends ObjectModel
$cart_quantity = self::$_cart_quantity[(int)($id_cart).'_'.(int)($id_product)];
}
$quantity = ($id_cart AND $cart_quantity) ? $cart_quantity : $quantity;
- $id_currency = (int)(Validate::isLoadedObject($cur_cart) ? $cur_cart->id_currency : ((isset($cookie->id_currency) AND (int)($cookie->id_currency)) ? $cookie->id_currency : Configuration::get('PS_CURRENCY_DEFAULT')));
+ $id_currency = (int)(Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT'));
// retrieve address informations
$id_country = (int)Country::getDefaultCountryId();
@@ -1800,12 +1795,11 @@ class ProductCore extends ObjectModel
$id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
}
}
- elseif (isset($cookie->id_country))
+ elseif (isset($context->customer->geoloc_id_country))
{
- // fetch address from cookie
- $id_country = (int)$cookie->id_country;
- $id_state = (int)$cookie->id_state;
- $postcode = (int)$cookie->postcode;
+ $id_country = (int)$context->customer->geoloc_id_country;
+ $id_state = (int)$context->customer->id_state;
+ $postcode = (int)$context->customer->postcode;
$id_county = (int)County::getIdCountyByZipCode($id_state, $postcode);
}
@@ -1952,20 +1946,17 @@ class ProductCore extends ObjectModel
return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
}
- public static function isDiscounted($id_product, $quantity = 1)
+ public static function isDiscounted($id_product, $quantity = 1, $context = null)
{
- global $cookie, $cart;
-
- $id_customer = ((Validate::isCookie($cookie) AND isset($cookie->id_customer) AND $cookie->id_customer) ? (int)($cookie->id_customer) : NULL);
- $id_group = $id_customer ? (int)(Customer::getDefaultGroupId($id_customer)) : _PS_DEFAULT_CUSTOMER_GROUP_;
- $cart_quantity = !$cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
+ $id_group = $context->customer->id_default_group;
+ $cart_quantity = !$context->cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'cart_product`
- WHERE `id_product` = '.(int)($id_product).' AND `id_cart` = '.(int)($cart->id)
+ WHERE `id_product` = '.(int)($id_product).' AND `id_cart` = '.(int)($context->cart->id)
);
$quantity = $cart_quantity ? $cart_quantity : $quantity;
- $id_currency = (int)(Validate::isLoadedObject($cart) ? $cart->id_currency : ((isset($cookie->id_currency) AND (int)($cookie->id_currency)) ? $cookie->id_currency : Configuration::get('PS_CURRENCY_DEFAULT')));
- $ids = Address::getCountryAndState((int)($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
+ $id_currency = (int)$context->currency->id;
+ $ids = Address::getCountryAndState((int)($context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
$id_shop = (int)(Shop::getCurrentShop());
return (bool)SpecificPrice::getSpecificPrice((int)$id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity);
@@ -2203,9 +2194,10 @@ class ProductCore extends ObjectModel
return $productObj->addStockMvt(-(int)$product['cart_quantity'], (int)_STOCK_MOVEMENT_ORDER_REASON_, (int)$product['id_product_attribute'], (int)$id_order, NULL);
}
- public static function reinjectQuantities(&$orderDetail, $quantity)
+ public static function reinjectQuantities(&$orderDetail, $quantity, $context = null)
{
- global $cookie;
+ if (!$context)
+ $context = Context::getContext();
if (!Validate::isLoadedObject($orderDetail))
die(Tools::displayError());
@@ -2213,12 +2205,12 @@ class ProductCore extends ObjectModel
{
$products_pack = Pack::getItems((int)($orderDetail->product_id), (int)(Configuration::get('PS_LANG_DEFAULT')));
foreach($products_pack AS $product_pack)
- if (!$product_pack->addStockMvt((int)($product_pack->pack_quantity * $quantity), _STOCK_MOVEMENT_ORDER_REASON_, (int)$product_pack->id_product_attribute, (int)$orderDetail->id_order, (int)$cookie->id_employee))
+ if (!$product_pack->addStockMvt((int)($product_pack->pack_quantity * $quantity), _STOCK_MOVEMENT_ORDER_REASON_, (int)$product_pack->id_product_attribute, (int)$orderDetail->id_order, (int)$context->employee->id))
return false;
}
$product = new Product((int)$orderDetail->product_id);
- if (!$product->addStockMvt((int)$quantity, _STOCK_MOVEMENT_ORDER_REASON_, (int)$orderDetail->product_attribute_id, (int)$orderDetail->id_order, (int)$cookie->id_employee))
+ if (!$product->addStockMvt((int)$quantity, _STOCK_MOVEMENT_ORDER_REASON_, (int)$orderDetail->product_attribute_id, (int)$orderDetail->id_order, (int)$context->employee->id))
return false;
$orderDetail->product_quantity_reinjected += (int)($quantity);
@@ -2346,9 +2338,7 @@ class ProductCore extends ObjectModel
* @return array Product accessories
*/
public function getAccessories($id_lang, $active = true, $id_shop = false)
- {
- global $link, $cookie;
-
+ {
if (!$id_shop)
$id_shop_lang = (int)Configuration::get('PS_SHOP_DEFAULT');
else
@@ -2751,10 +2741,11 @@ class ProductCore extends ObjectModel
/**
* Get the link of the product page of this product
*/
- public function getLink()
+ public function getLink($context = null)
{
- global $link;
- return $link->getProductLink($this);
+ if (!$context)
+ $context = Context::getContext();
+ return $context->link->getProductLink($this);
}
public function getTags($id_lang)
@@ -2774,11 +2765,12 @@ class ProductCore extends ObjectModel
return Language::getIsoById((int)$id_lang).'-default';
}
- public static function getProductProperties($id_lang, $row)
+ public static function getProductProperties($id_lang, $row, $context = null)
{
if (!$row['id_product'])
return false;
-
+ $context = Context::getContext();
+
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
if ((!isset($row['id_product_attribute']) OR !$row['id_product_attribute'])
@@ -2797,9 +2789,8 @@ class ProductCore extends ObjectModel
return self::$producPropertiesCache[$cacheKey];
// Datas
- $link = new Link();
$row['category'] = Category::getLinkRewrite((int)$row['id_category_default'], (int)($id_lang));
- $row['link'] = $link->getProductLink((int)$row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
+ $row['link'] = $context->link->getProductLink((int)$row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
$row['attribute_price'] = (isset($row['id_product_attribute']) AND $row['id_product_attribute']) ? (float)(Product::getProductAttributePrice($row['id_product_attribute'])) : 0;
$row['price_tax_exc'] = Product::getPriceStatic((int)$row['id_product'], false, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : NULL), (self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6));
if (self::$_taxCalculationMethod == PS_TAX_EXC)
@@ -2890,19 +2881,16 @@ class ProductCore extends ObjectModel
** Customization management
*/
- public static function getAllCustomizedDatas($id_cart, $id_lang = null)
+ public static function getAllCustomizedDatas($id_cart, $id_lang = null, $context = null)
{
- global $cookie;
+ if (!$context)
+ $context = Context::getContext();
+
// No need to query if there isn't any real cart!
if (!$id_cart)
return false;
- if (!$id_lang AND !is_null($cookie) AND $cookie->id_lang)
- $id_lang = $cookie->id_lang;
- else
- {
- $cart = new Cart((int)($id_cart));
- $id_lang = (int)($cart->id_lang);
- }
+ if (!$id_lang)
+ $id_lang = $context->language->id;
if (!$result = Db::getInstance()->ExecuteS('
SELECT cd.`id_customization`, c.`id_product`, cfl.`id_customization_field`, c.`id_product_attribute`, cd.`type`, cd.`index`, cd.`value`, cfl.`name`
@@ -2926,34 +2914,6 @@ class ProductCore extends ObjectModel
return $customizedDatas;
}
-
- /**
- * @param int $id_customization
- * @return bool
- * @deprecated
- */
- public function deleteCustomizedDatas($id_customization)
- {
- Tools::displayAsDeprecated();
- if (Pack::isPack((int)($product['id_product'])))
- {
- $products_pack = Pack::getItems((int)($product['id_product']), (int)(Configuration::get('PS_LANG_DEFAULT')));
- foreach($products_pack AS $product_pack)
- {
- $tab_product_pack['id_product'] = (int)($product_pack->id);
- $tab_product_pack['id_product_attribute'] = self::getDefaultAttribute($tab_product_pack['id_product'], 1);
- $tab_product_pack['cart_quantity'] = (int)($product_pack->pack_quantity * $product['cart_quantity']);
- self::updateQuantity($tab_product_pack);
- }
- }
- if (($result = Db::getInstance()->ExecuteS('SELECT `value` FROM `'._DB_PREFIX_.'customized_data` WHERE `id_customization` = '.(int)($id_customization).' AND `type` = '._CUSTOMIZE_FILE_)) === false)
- return false;
- foreach ($result AS $row)
- if (!@unlink(_PS_UPLOAD_DIR_.$row['value']) OR !@unlink(_PS_UPLOAD_DIR_.$row['value'].'_small'))
- return false;
- return (Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'customization` WHERE `id_customization` = '.(int)($id_customization)) AND Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'customized_data` WHERE `id_customization` = '.(int)($id_customization)));
- }
-
public static function addCustomizationPrice(&$products, &$customizedDatas)
{
foreach ($products AS &$productUpdate)
diff --git a/classes/Tools.php b/classes/Tools.php
index d9919a79e..de09a0788 100644
--- a/classes/Tools.php
+++ b/classes/Tools.php
@@ -268,10 +268,8 @@ class ToolsCore
/**
* Change language in cookie while clicking on a flag
*/
- public static function setCookieLanguage()
+ public static function setCookieLanguage($cookie)
{
- global $cookie;
-
/* If language does not exist or is disabled, erase it */
if ($cookie->id_lang)
{
@@ -309,18 +307,16 @@ class ToolsCore
return $iso;
}
- public static function switchLanguage()
+ public static function switchLanguage($context = null)
{
- global $cookie;
-
+ if (!$context)
+ $context = Context::getContext();
if ($id_lang = (int)(self::getValue('id_lang')) AND Validate::isUnsignedId($id_lang))
- $cookie->id_lang = $id_lang;
+ $context->cookie->id_lang = $id_lang;
}
- public static function setCurrency()
+ public static function setCurrency($cookie)
{
- global $cookie;
-
if (self::isSubmit('SubmitCurrency'))
if (isset($_POST['id_currency']) AND is_numeric($_POST['id_currency']))
{
@@ -1387,108 +1383,42 @@ class ToolsCore
return false;
}
- /**
+ /**
* addJS load a javascript file in the header
*
+ * @deprecated as of 1.5 use FrontController->addJS()
* @param mixed $js_uri
* @return void
*/
public static function addJS($js_uri)
{
- global $js_files;
- if(!isset($js_files))
- $js_files = array();
- // avoid useless operation...
- if (in_array($js_uri, $js_files))
- return true;
-
- // detect mass add
- if (!is_array($js_uri) && !in_array($js_uri, $js_files))
- $js_uri = array($js_uri);
- else
- foreach($js_uri as $key => $js)
- if (in_array($js, $js_files))
- unset($js_uri[$key]);
-
- //overriding of modules js files
- foreach ($js_uri AS $key => &$file)
- {
- if (!preg_match('/^http(s?):\/\//i', $file))
- {
- $different = 0;
- $override_path = str_replace(__PS_BASE_URI__.'modules/', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/js/modules/', $file, $different);
- if ($different && file_exists($override_path))
- $file = str_replace(__PS_BASE_URI__.'modules/', __PS_BASE_URI__.'themes/'._THEME_NAME_.'/js/modules/', $file, $different);
- else
- {
- // remove PS_BASE_URI on _PS_ROOT_DIR_ for the following
- $url_data = parse_url($file);
- $file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
- // check if js files exists
- if (!file_exists($file_uri))
- unset($js_uri[$key]);
- }
- }
- }
-
- // adding file to the big array...
- $js_files = array_merge($js_files, $js_uri);
-
- return true;
+ Tools::displayAsDeprecated();
+ $context = Context::getContext();
+ $context->controller->addJs($js_uri);
}
-
+
/**
* addCSS allows you to add stylesheet at any time.
*
+ * @deprecated as of 1.5 use FrontController->addCSS()
* @param mixed $css_uri
* @param string $css_media_type
* @return true
*/
public static function addCSS($css_uri, $css_media_type = 'all')
{
- global $css_files;
-
- if (is_array($css_uri))
- {
- foreach ($css_uri as $file => $media_type)
- Tools::addCSS($file, $media_type);
- return true;
- }
-
- //overriding of modules css files
- $different = 0;
- $override_path = str_replace(__PS_BASE_URI__.'modules/', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/css/modules/', $css_uri, $different);
- if ($different && file_exists($override_path))
- $css_uri = str_replace(__PS_BASE_URI__.'modules/', __PS_BASE_URI__.'themes/'._THEME_NAME_.'/css/modules/', $css_uri, $different);
- else
- {
- // remove PS_BASE_URI on _PS_ROOT_DIR_ for the following
- $url_data = parse_url($css_uri);
- $file_uri = _PS_ROOT_DIR_.Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
- // check if css files exists
- if (!file_exists($file_uri))
- return true;
- }
-
- // detect mass add
- $css_uri = array($css_uri => $css_media_type);
-
- // adding file to the big array...
- if (is_array($css_files))
- $css_files = array_merge($css_files, $css_uri);
- else
- $css_files = $css_uri;
-
- return true;
+ Tools::displayAsDeprecated();
+ $context = Context::getContext();
+ $context->controller->addCSS($css_uri, $css_media_type);
}
-
/**
* Combine Compress and Cache CSS (ccc) calls
*
+ * @param array css_files
+ * @return array processed css_files
*/
- public static function cccCss() {
- global $css_files;
+ public static function cccCss($css_files) {
//inits
$css_files_by_media = array();
$compressed_css_files = array();
@@ -1562,14 +1492,17 @@ class ToolsCore
$url = str_replace(_PS_THEME_DIR_, _THEMES_DIR_._THEME_NAME_.'/', $filename);
$css_files[$protocolLink.Tools::getMediaServer($url).$url] = $media;
}
+ return $css_files;
}
/**
* Combine Compress and Cache (ccc) JS calls
+ *
+ * @param array js_files
+ * @return array processed js_files
*/
- public static function cccJS() {
- global $js_files;
+ public static function cccJS($js_files) {
//inits
$compressed_js_files_not_found = array();
$js_files_infos = array();
@@ -1632,7 +1565,7 @@ class ToolsCore
// rebuild the original js_files array
$url = str_replace(_PS_ROOT_DIR_.'/', __PS_BASE_URI__, $compressed_js_path);
- $js_files = array_merge(array($protocolLink.Tools::getMediaServer($url).$url), $js_external_files);
+ return array_merge(array($protocolLink.Tools::getMediaServer($url).$url), $js_external_files);
}
diff --git a/controllers/AddressController.php b/controllers/AddressController.php
index 02d8e86c7..765d117a6 100644
--- a/controllers/AddressController.php
+++ b/controllers/AddressController.php
@@ -47,9 +47,9 @@ class AddressControllerCore extends FrontController
parent::preProcess();
if ($back = Tools::getValue('back'))
- self::$smarty->assign('back', Tools::safeOutput($back));
+ $this->smarty->assign('back', Tools::safeOutput($back));
if ($mod = Tools::getValue('mod'))
- self::$smarty->assign('mod', Tools::safeOutput($mod));
+ $this->smarty->assign('mod', Tools::safeOutput($mod));
if (Tools::isSubmit('ajax') AND Tools::isSubmit('type'))
{
@@ -78,7 +78,7 @@ class AddressControllerCore extends FrontController
Tools::redirect('index.php?controller=addresses');
$this->errors[] = Tools::displayError('This address cannot be deleted.');
}
- self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address));
+ $this->smarty->assign(array('address' => $this->_address, 'id_address' => (int)$id_address));
}
elseif (Tools::isSubmit('ajax'))
exit;
@@ -222,7 +222,7 @@ class AddressControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
+ $this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
}
public function process()
@@ -252,17 +252,17 @@ class AddressControllerCore extends FrontController
$countriesList .= '';
if ((Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
- self::$smarty->assign('vat_display', 2);
+ $this->smarty->assign('vat_display', 2);
else if(Configuration::get('VATNUMBER_MANAGEMENT'))
- self::$smarty->assign('vat_display', 1);
+ $this->smarty->assign('vat_display', 1);
else
- self::$smarty->assign('vat_display', 0);
+ $this->smarty->assign('vat_display', 0);
- self::$smarty->assign('ajaxurl', _MODULE_DIR_);
+ $this->smarty->assign('ajaxurl', _MODULE_DIR_);
- self::$smarty->assign('vatnumber_ajax_call', (int)file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'));
+ $this->smarty->assign('vatnumber_ajax_call', (int)file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'countries_list' => $countriesList,
'countries' => $countries,
'errors' => $this->errors,
@@ -277,7 +277,7 @@ class AddressControllerCore extends FrontController
$id_country = is_null($this->_address)? 0 : (int)$this->_address->id_country;
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($id_country, $split_all = true);
- self::$smarty->assign('ordered_adr_fields', $dlv_adr_fields);
+ $this->smarty->assign('ordered_adr_fields', $dlv_adr_fields);
}
public function displayHeader()
@@ -291,7 +291,7 @@ class AddressControllerCore extends FrontController
parent::displayContent();
$this->_processAddressFormat();
- self::$smarty->display(_PS_THEME_DIR_.'address.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'address.tpl');
}
public function displayFooter()
diff --git a/controllers/AddressesController.php b/controllers/AddressesController.php
index 01d1f72ac..25e71e894 100644
--- a/controllers/AddressesController.php
+++ b/controllers/AddressesController.php
@@ -40,8 +40,8 @@ class AddressesControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
- Tools::addJS(_THEME_JS_DIR_.'tools.js');
+ $this->addCSS(_THEME_CSS_DIR_.'addresses.css');
+ $this->addJS(_THEME_JS_DIR_.'tools.js');
}
public function process()
@@ -56,7 +56,7 @@ class AddressesControllerCore extends FrontController
die(Tools::displayError('Customer not found'));
// Retro Compatibility Theme < 1.4.1
- self::$smarty->assign('addresses', $customer->getAddresses((int)(self::$cookie->id_lang)));
+ $this->smarty->assign('addresses', $customer->getAddresses((int)(self::$cookie->id_lang)));
$customerAddressesDetailed = $customer->getAddresses((int)(self::$cookie->id_lang));
@@ -81,7 +81,7 @@ class AddressesControllerCore extends FrontController
if (($key = array_search('Country:name', $ordered_fields)))
$ordered_fields[$key] = 'country';
- self::$smarty->assign('addresses_style', array(
+ $this->smarty->assign('addresses_style', array(
'company' => 'address_company'
,'vat_number' => 'address_company'
,'firstname' => 'address_name'
@@ -95,7 +95,7 @@ class AddressesControllerCore extends FrontController
,'alias' => 'address_title'
));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'multipleAddresses' => $multipleAddressesFormated,
'ordered_fields' => $ordered_fields));
unset($customer);
@@ -104,7 +104,7 @@ class AddressesControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'addresses.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'addresses.tpl');
}
}
diff --git a/controllers/AuthController.php b/controllers/AuthController.php
index 60c00c34f..5a745b1bc 100644
--- a/controllers/AuthController.php
+++ b/controllers/AuthController.php
@@ -45,7 +45,7 @@ class AuthControllerCore extends FrontController
if (Tools::getValue('create_account'))
{
$create_account = 1;
- self::$smarty->assign('email_create', 1);
+ $this->smarty->assign('email_create', 1);
}
if (Tools::isSubmit('SubmitCreate'))
@@ -61,7 +61,7 @@ class AuthControllerCore extends FrontController
else
{
$create_account = 1;
- self::$smarty->assign('email_create', Tools::safeOutput($email));
+ $this->smarty->assign('email_create', Tools::safeOutput($email));
$_POST['email'] = $email;
}
@@ -71,7 +71,7 @@ class AuthControllerCore extends FrontController
{
$create_account = 1;
if (Tools::isSubmit('submitAccount'))
- self::$smarty->assign('email_create', 1);
+ $this->smarty->assign('email_create', 1);
/* New Guest customer */
if (!Tools::getValue('is_new_customer', 1) AND !Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
$this->errors[] = Tools::displayError('You cannot create a guest account.');
@@ -170,7 +170,7 @@ class AuthControllerCore extends FrontController
array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname.' '.$customer->lastname))
$this->errors[] = Tools::displayError('Cannot send email');
}
- self::$smarty->assign('confirmation', 1);
+ $this->smarty->assign('confirmation', 1);
self::$cookie->id_customer = (int)($customer->id);
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
@@ -310,14 +310,14 @@ class AuthControllerCore extends FrontController
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
$countries = Country::getCountries((int)(self::$cookie->id_lang), true, NULL, $this->id_current_shop);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'countries' => $countries,
'sl_country' => (isset($selectedCountry) ? $selectedCountry : 0),
'vat_management' => Configuration::get('VATNUMBER_MANAGEMENT')
));
/* Call a hook to display more information on form */
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'),
'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')
));
@@ -335,7 +335,7 @@ class AuthControllerCore extends FrontController
$selectedDays = (int)($_POST['days']);
$days = Tools::dateDays();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'years' => $years,
'sl_year' => (isset($selectedYears) ? $selectedYears : 0),
'months' => $months,
@@ -343,14 +343,14 @@ class AuthControllerCore extends FrontController
'days' => $days,
'sl_day' => (isset($selectedDays) ? $selectedDays : 0)
));
- self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
+ $this->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
}
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'authentication.css');
- Tools::addJS(array(_THEME_JS_DIR_.'tools/statesManagement.js', _PS_JS_DIR_.'jquery/jquery-typewatch.pack.js'));
+ $this->addCSS(_THEME_CSS_DIR_.'authentication.css');
+ $this->addJS(array(_THEME_JS_DIR_.'tools/statesManagement.js', _PS_JS_DIR_.'jquery/jquery-typewatch.pack.js'));
}
public function process()
@@ -363,11 +363,11 @@ class AuthControllerCore extends FrontController
$back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key;
if (!empty($back))
{
- self::$smarty->assign('back', Tools::safeOutput($back));
+ $this->smarty->assign('back', Tools::safeOutput($back));
if (strpos($back, 'order.php') !== false)
{
$countries = Country::getCountries((int)(self::$cookie->id_lang), true);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'inOrderProcess' => true,
'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
'sl_country' => (int)Tools::getValue('id_country', Configuration::get('PS_COUNTRY_DEFAULT')),
@@ -382,7 +382,7 @@ class AuthControllerCore extends FrontController
$this->processAddressFormat();
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'authentication.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'authentication.tpl');
}
protected function processAddressFormat()
@@ -401,7 +401,7 @@ class AuthControllerCore extends FrontController
$addressItems[] = trim($fieldName);
foreach (array('inv', 'dlv') as $addressType)
- self::$smarty->assign(array($addressType.'_adr_fields' => $addressFormat, $addressType.'_all_fields' => $addressItems));
+ $this->smarty->assign(array($addressType.'_adr_fields' => $addressFormat, $addressType.'_all_fields' => $addressItems));
}
}
diff --git a/controllers/BestSalesController.php b/controllers/BestSalesController.php
index b35fb9ff5..4108d7cea 100644
--- a/controllers/BestSalesController.php
+++ b/controllers/BestSalesController.php
@@ -40,7 +40,7 @@ class BestSalesControllerCore extends FrontController
$nbProducts = (int)(ProductSale::getNbSales((int)$this->id_current_shop));
$this->pagination($nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => ProductSale::getBestSales((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), $this->orderBy, $this->orderWay, (int)$this->id_current_shop),
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'nbProducts' => $nbProducts,
@@ -51,13 +51,13 @@ class BestSalesControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'best-sales.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'best-sales.tpl');
}
}
diff --git a/controllers/CMSController.php b/controllers/CMSController.php
index e6ff2c462..1104bd6b0 100644
--- a/controllers/CMSController.php
+++ b/controllers/CMSController.php
@@ -78,7 +78,7 @@ class CmsControllerCore extends FrontController
self::$link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
$default_rewrite[$infos['id_lang']] = $arr_link;
}
- self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
+ $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
}
}
@@ -87,21 +87,21 @@ class CmsControllerCore extends FrontController
parent::setMedia();
if ($this->assignCase == 1)
- Tools::addJS(_THEME_JS_DIR_.'cms.js');
+ $this->addJS(_THEME_JS_DIR_.'cms.js');
- Tools::addCSS(_THEME_CSS_DIR_.'cms.css');
+ $this->addCSS(_THEME_CSS_DIR_.'cms.css');
}
public function process()
{
parent::process();
$parent_cat = new CMSCategory(1, (int)(self::$cookie->id_lang));
- self::$smarty->assign('id_current_lang', self::$cookie->id_lang);
- self::$smarty->assign('home_title', $parent_cat->name);
- self::$smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
+ $this->smarty->assign('id_current_lang', self::$cookie->id_lang);
+ $this->smarty->assign('home_title', $parent_cat->name);
+ $this->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
if ($this->assignCase == 1)
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'cms' => $this->cms,
'content_only' => (int)(Tools::getValue('content_only')),
'path' => ((isset($this->cms->id_cms_category) AND $this->cms->id_cms_category) ? Tools::getFullPath((int)($this->cms->id_cms_category), $this->cms->meta_title, 'CMS') : Tools::getFullPath(1, $this->cms->meta_title, 'CMS'))
@@ -109,7 +109,7 @@ class CmsControllerCore extends FrontController
}
elseif ($this->assignCase == 2)
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'category' => $this->cms_category,
'sub_category' => $this->cms_category->getSubCategories((int)(self::$cookie->id_lang)),
'cms_pages' => CMS::getCMSPages((int)(self::$cookie->id_lang), (int)($this->cms_category->id) ),
@@ -121,6 +121,6 @@ class CmsControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'cms.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'cms.tpl');
}
}
diff --git a/controllers/CartController.php b/controllers/CartController.php
index f17561767..a766ab01e 100644
--- a/controllers/CartController.php
+++ b/controllers/CartController.php
@@ -253,6 +253,6 @@ class CartControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'errors.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'errors.tpl');
}
}
diff --git a/controllers/CategoryController.php b/controllers/CategoryController.php
index 513c94a17..5ad36d0d4 100644
--- a/controllers/CategoryController.php
+++ b/controllers/CategoryController.php
@@ -32,14 +32,14 @@ class CategoryControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(array(
+ $this->addCSS(array(
_PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
_THEME_CSS_DIR_.'scenes.css' => 'all',
_THEME_CSS_DIR_.'category.css' => 'all',
_THEME_CSS_DIR_.'product_list.css' => 'all'));
if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
- Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
+ $this->addJS(_THEME_JS_DIR_.'products-comparison.js');
}
public function displayHeader()
@@ -83,7 +83,7 @@ class CategoryControllerCore extends FrontController
foreach ($rewrite_infos AS $infos)
$default_rewrite[$infos['id_lang']] = self::$link->getCategoryLink((int)$id_category, $infos['link_rewrite'], $infos['id_lang']);
- self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
+ $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
}
}
@@ -99,13 +99,13 @@ class CategoryControllerCore extends FrontController
elseif (!$this->category->checkAccess((int)(self::$cookie->id_customer)))
$this->errors[] = Tools::displayError('You do not have access to this category.');
elseif (!$this->category->active)
- self::$smarty->assign('category', $this->category);
+ $this->smarty->assign('category', $this->category);
else
{
$rewrited_url = self::$link->getCategoryLink((int)$this->category->id, $this->category->link_rewrite);
/* Scenes (could be externalised to another controler if you need them */
- self::$smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false));
+ $this->smarty->assign('scenes', Scene::getScenes((int)($this->category->id), (int)(self::$cookie->id_lang), true, false));
/* Scenes images formats */
if ($sceneImageTypes = ImageType::getImagesTypes('scenes'))
@@ -117,18 +117,18 @@ class CategoryControllerCore extends FrontController
elseif ($sceneImageType['name'] == 'large_scene')
$largeSceneImageType = $sceneImageType;
}
- self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
- self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
+ $this->smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL);
+ $this->smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL);
}
$this->category->description = nl2br2($this->category->description);
$subCategories = $this->category->getSubCategories((int)(self::$cookie->id_lang));
- self::$smarty->assign('category', $this->category);
+ $this->smarty->assign('category', $this->category);
if (isset($subCategories) AND !empty($subCategories) AND $subCategories)
{
- self::$smarty->assign('subcategories', $subCategories);
- self::$smarty->assign(array(
+ $this->smarty->assign('subcategories', $subCategories);
+ $this->smarty->assign(array(
'subcategories_nb_total' => sizeof($subCategories),
'subcategories_nb_half' => ceil(sizeof($subCategories) / 2)));
}
@@ -136,10 +136,10 @@ class CategoryControllerCore extends FrontController
{
$nbProducts = $this->category->getProducts(NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int)$nbProducts);
- self::$smarty->assign('nb_products', (int)$nbProducts);
+ $this->smarty->assign('nb_products', (int)$nbProducts);
$cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL,
'id_category' => (int)($this->category->id),
'id_category_parent' => (int)($this->category->id_parent),
@@ -154,7 +154,7 @@ class CategoryControllerCore extends FrontController
}
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'allow_oosp' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
'comparator_max_item' => (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')),
'suppliers' => Supplier::getSuppliers()
@@ -164,7 +164,7 @@ class CategoryControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'category.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'category.tpl');
}
}
diff --git a/controllers/CompareController.php b/controllers/CompareController.php
index 2df2ea492..6bd24211f 100644
--- a/controllers/CompareController.php
+++ b/controllers/CompareController.php
@@ -30,7 +30,7 @@ class CompareControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'/comparator.css');
+ $this->addCSS(_THEME_CSS_DIR_.'/comparator.css');
}
public function process()
@@ -96,25 +96,24 @@ class CompareControllerCore extends FrontController
$hasProduct = true;
$ordered_features = Feature::getFeaturesForComparison($ids, self::$cookie->id_lang);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'ordered_features' => $ordered_features,
'product_features' => $listFeatures,
'products' => $listProducts,
- 'link' => new Link(),
'width' => $width,
'homeSize' => Image::getSize('home')
));
- self::$smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
+ $this->smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
}
}
}
- self::$smarty->assign('hasProduct', $hasProduct);
+ $this->smarty->assign('hasProduct', $hasProduct);
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'products-comparison.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'products-comparison.tpl');
}
}
diff --git a/controllers/ContactController.php b/controllers/ContactController.php
index 93a4355b0..76450c88f 100644
--- a/controllers/ContactController.php
+++ b/controllers/ContactController.php
@@ -41,7 +41,7 @@ class ContactControllerCore extends FrontController
if (self::$cookie->isLogged())
{
- self::$smarty->assign('isLogged', 1);
+ $this->smarty->assign('isLogged', 1);
$customer = new Customer((int)(self::$cookie->id_customer));
if (!Validate::isLoadedObject($customer))
die(Tools::displayError('Customer not found'));
@@ -68,8 +68,8 @@ class ContactControllerCore extends FrontController
foreach ($products as $key => $val)
$orderedProductList .= '';
- self::$smarty->assign('orderList', $orderList);
- self::$smarty->assign('orderedProductList', $orderedProductList);
+ $this->smarty->assign('orderList', $orderList);
+ $this->smarty->assign('orderedProductList', $orderedProductList);
}
if (Tools::isSubmit('submitMessage'))
@@ -152,7 +152,7 @@ class ContactControllerCore extends FrontController
ORDER BY date_add DESC');
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
{
- self::$smarty->assign('alreadySent', 1);
+ $this->smarty->assign('alreadySent', 1);
$contact->email = '';
$contact->customer_service = 0;
}
@@ -160,7 +160,7 @@ class ContactControllerCore extends FrontController
{
if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from))
- self::$smarty->assign('confirmation', 1);
+ $this->smarty->assign('confirmation', 1);
else
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
@@ -210,7 +210,7 @@ class ContactControllerCore extends FrontController
{
if (empty($contact->email))
Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
- self::$smarty->assign('confirmation', 1);
+ $this->smarty->assign('confirmation', 1);
}
else
$this->errors[] = Tools::displayError('An error occurred while sending message.');
@@ -227,7 +227,7 @@ class ContactControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'contact-form.css');
+ $this->addCSS(_THEME_CSS_DIR_.'contact-form.css');
}
public function process()
@@ -235,7 +235,7 @@ class ContactControllerCore extends FrontController
parent::process();
$email = Tools::safeOutput(Tools::getValue('from', ((isset(self::$cookie) AND isset(self::$cookie->email) AND Validate::isEmail(self::$cookie->email)) ? self::$cookie->email : '')));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'errors' => $this->errors,
'email' => $email,
'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD')
@@ -247,9 +247,9 @@ class ContactControllerCore extends FrontController
$customerThread = Db::getInstance()->getRow('
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).'\'');
- self::$smarty->assign('customerThread', $customerThread);
+ $this->smarty->assign('customerThread', $customerThread);
}
- self::$smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang, (int)$this->id_current_shop),
+ $this->smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang, (int)$this->id_current_shop),
'message' => html_entity_decode(Tools::getValue('message'))
));
}
@@ -258,7 +258,7 @@ class ContactControllerCore extends FrontController
{
$_POST = array_merge($_POST, $_GET);
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
}
}
diff --git a/controllers/DiscountController.php b/controllers/DiscountController.php
index 9192c7a4a..37d1e8257 100644
--- a/controllers/DiscountController.php
+++ b/controllers/DiscountController.php
@@ -47,13 +47,13 @@ class DiscountControllerCore extends FrontController
if ($discount['quantity_for_user'])
$nbDiscounts++;
- self::$smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts));
+ $this->smarty->assign(array('nbDiscounts' => (int)($nbDiscounts), 'discount' => $discounts));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'discount.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'discount.tpl');
}
}
diff --git a/controllers/GuestTrackingController.php b/controllers/GuestTrackingController.php
index c039c916b..789b0e516 100644
--- a/controllers/GuestTrackingController.php
+++ b/controllers/GuestTrackingController.php
@@ -60,13 +60,13 @@ class GuestTrackingControllerCore extends FrontController
$deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
if ($order->total_discounts > 0)
- self::$smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts));
+ $this->smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts));
$products = $order->getProducts();
$customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
Product::addCustomizationPrice($products, $customizedDatas);
$this->processAddressFormat($addressDelivery, $addressInvoice);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'shop_name' => Configuration::get('PS_SHOP_NAME'),
'order' => $order,
'return_allowed' => false,
@@ -91,8 +91,8 @@ class GuestTrackingControllerCore extends FrontController
'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues,
'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues));
if ($carrier->url AND $order->shipping_number)
- self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
- self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
+ $this->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
+ $this->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
if (Tools::isSubmit('submitTransformGuestToCustomer'))
@@ -105,7 +105,7 @@ class GuestTrackingControllerCore extends FrontController
if (!Tools::getValue('password'))
$this->errors[] = Tools::displayError('Invalid password');
else
- self::$smarty->assign('transformSuccess', true);
+ $this->smarty->assign('transformSuccess', true);
}
}
if (sizeof($this->errors))
@@ -113,7 +113,7 @@ class GuestTrackingControllerCore extends FrontController
sleep(1);
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'action' => 'guest-tracking.php',
'errors' => $this->errors
));
@@ -123,15 +123,15 @@ class GuestTrackingControllerCore extends FrontController
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'history.css');
- Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
+ $this->addCSS(_THEME_CSS_DIR_.'history.css');
+ $this->addCSS(_THEME_CSS_DIR_.'addresses.css');
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'guest-tracking.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'guest-tracking.tpl');
}
private function processAddressFormat(Address $delivery, Address $invoice)
@@ -140,8 +140,8 @@ class GuestTrackingControllerCore extends FrontController
$inv_adr_fields = AddressFormat::getOrderedAddressFields($invoice->id_country);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($delivery->id_country);
- self::$smarty->assign('inv_adr_fields', $inv_adr_fields);
- self::$smarty->assign('dlv_adr_fields', $dlv_adr_fields);
+ $this->smarty->assign('inv_adr_fields', $inv_adr_fields);
+ $this->smarty->assign('dlv_adr_fields', $dlv_adr_fields);
}
}
diff --git a/controllers/HistoryController.php b/controllers/HistoryController.php
index a3d3ec5a6..bf07f799b 100644
--- a/controllers/HistoryController.php
+++ b/controllers/HistoryController.php
@@ -40,9 +40,9 @@ class HistoryControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'history.css');
- Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
- Tools::addJS(array(
+ $this->addCSS(_THEME_CSS_DIR_.'history.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',
_THEME_JS_DIR_.'tools.js'));
@@ -59,7 +59,7 @@ class HistoryControllerCore extends FrontController
if (Validate::isLoadedObject($myOrder))
$order['virtual'] = $myOrder->isVirtual(false);
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'orders' => $orders,
'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')),
'slowValidation' => Tools::isSubmit('slowvalidation')
@@ -69,7 +69,7 @@ class HistoryControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'history.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'history.tpl');
}
}
diff --git a/controllers/IdentityController.php b/controllers/IdentityController.php
index a372d53ea..07f5f705a 100644
--- a/controllers/IdentityController.php
+++ b/controllers/IdentityController.php
@@ -84,7 +84,7 @@ class IdentityControllerCore extends FrontController
{
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
- self::$smarty->assign('confirmation', 1);
+ $this->smarty->assign('confirmation', 1);
}
else
$this->errors[] = Tools::displayError('Cannot update information');
@@ -100,7 +100,7 @@ class IdentityControllerCore extends FrontController
$birthday = array('-', '-', '-');
/* Generate years, months and days */
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'years' => Tools::dateYears(),
'sl_year' => $birthday[0],
'months' => Tools::dateMonths(),
@@ -110,19 +110,19 @@ class IdentityControllerCore extends FrontController
'errors' => $this->errors
));
- self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
+ $this->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
}
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'identity.css');
+ $this->addCSS(_THEME_CSS_DIR_.'identity.css');
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'identity.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'identity.tpl');
}
}
diff --git a/controllers/IndexController.php b/controllers/IndexController.php
index d55c6c912..c4c2a2ae2 100644
--- a/controllers/IndexController.php
+++ b/controllers/IndexController.php
@@ -37,12 +37,12 @@ class IndexControllerCore extends FrontController
public function process()
{
parent::process();
- self::$smarty->assign('HOOK_HOME', Module::hookExec('home'));
+ $this->smarty->assign('HOOK_HOME', Module::hookExec('home'));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'index.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'index.tpl');
}
}
diff --git a/controllers/ManufacturerController.php b/controllers/ManufacturerController.php
index 25bfa99b4..724c42400 100644
--- a/controllers/ManufacturerController.php
+++ b/controllers/ManufacturerController.php
@@ -32,7 +32,7 @@ class ManufacturerControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
public function process()
@@ -44,7 +44,7 @@ class ManufacturerControllerCore extends FrontController
{
$nbProducts = $this->manufacturer->getProducts($id_manufacturer, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int)$nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'nb_products' => $nbProducts,
'products' => $this->manufacturer->getProducts($id_manufacturer, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
@@ -71,7 +71,7 @@ class ManufacturerControllerCore extends FrontController
foreach ($data AS &$item)
$item['image'] = (!file_exists($imgDir.'/'.$item['id_manufacturer'].'-medium.jpg')) ?
Language::getIsoById((int)(self::$cookie->id_lang)).'-default' : $item['id_manufacturer'];
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'pages_nb' => ceil($nbProducts / (int)($this->n)),
'nbManufacturers' => $nbProducts,
'mediumSize' => Image::getSize('medium'),
@@ -80,7 +80,7 @@ class ManufacturerControllerCore extends FrontController
));
}
else
- self::$smarty->assign('nbManufacturers', 0);
+ $this->smarty->assign('nbManufacturers', 0);
}
}
@@ -94,9 +94,9 @@ class ManufacturerControllerCore extends FrontController
{
parent::displayContent();
if ($this->manufacturer)
- self::$smarty->display(_PS_THEME_DIR_.'manufacturer.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'manufacturer.tpl');
else
- self::$smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'manufacturer-list.tpl');
}
}
diff --git a/controllers/MyAccountController.php b/controllers/MyAccountController.php
index f817d98af..3c87eb161 100644
--- a/controllers/MyAccountController.php
+++ b/controllers/MyAccountController.php
@@ -40,24 +40,24 @@ class MyAccountControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'my-account.css');
+ $this->addCSS(_THEME_CSS_DIR_.'my-account.css');
}
public function process()
{
parent::process();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')),
'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN'))
));
- self::$smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount'));
+ $this->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount'));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'my-account.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'my-account.tpl');
}
}
diff --git a/controllers/NewProductsController.php b/controllers/NewProductsController.php
index b7e255f4f..97b14332a 100644
--- a/controllers/NewProductsController.php
+++ b/controllers/NewProductsController.php
@@ -37,7 +37,7 @@ class NewProductsControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
public function process()
@@ -49,7 +49,7 @@ class NewProductsControllerCore extends FrontController
$nbProducts = (int)Product::getNewProducts((int)self::$cookie->id_lang, (isset($this->p) ? (int)($this->p) - 1 : NULL), (isset($this->n) ? (int)($this->n) : NULL), true);
$this->pagination($nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => Product::getNewProducts((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), false, $this->orderBy, $this->orderWay),
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'nbProducts' => (int)($nbProducts),
@@ -60,7 +60,7 @@ class NewProductsControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'new-products.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'new-products.tpl');
}
}
diff --git a/controllers/OrderConfirmationController.php b/controllers/OrderConfirmationController.php
index 41165322e..234210ab3 100644
--- a/controllers/OrderConfirmationController.php
+++ b/controllers/OrderConfirmationController.php
@@ -68,7 +68,7 @@ class OrderConfirmationControllerCore extends FrontController
public function process()
{
parent::process();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'is_guest' => self::$cookie->is_guest,
'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int)($this->id_order)),
'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int)($this->id_order), (int)($this->id_module))
@@ -76,7 +76,7 @@ class OrderConfirmationControllerCore extends FrontController
if (self::$cookie->is_guest)
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'id_order' => $this->id_order,
'id_order_formatted' => sprintf('#%06d', $this->id_order)
));
@@ -88,7 +88,7 @@ class OrderConfirmationControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-confirmation.tpl');
}
}
diff --git a/controllers/OrderController.php b/controllers/OrderController.php
index 1ee6004e2..b83b91c29 100644
--- a/controllers/OrderController.php
+++ b/controllers/OrderController.php
@@ -69,7 +69,7 @@ class OrderControllerCore extends ParentOrderController
Tools::redirect('index.php?controller=authentication&back='.urlencode('order.php&step='.$this->step));
if ($this->nbProducts)
- self::$smarty->assign('virtual_cart', $isVirtualCart);
+ $this->smarty->assign('virtual_cart', $isVirtualCart);
}
public function displayHeader()
@@ -86,7 +86,7 @@ class OrderControllerCore extends ParentOrderController
switch ((int)$this->step)
{
case -1;
- self::$smarty->assign('empty', 1);
+ $this->smarty->assign('empty', 1);
break;
case 1:
$this->_assignAddress();
@@ -134,7 +134,7 @@ class OrderControllerCore extends ParentOrderController
$invoiceAddressFields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
$deliveryAddressFields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'inv_adr_fields' => $invoiceAddressFields,
'dlv_adr_fields' => $deliveryAddressFields));
}
@@ -145,7 +145,7 @@ class OrderControllerCore extends ParentOrderController
parent::displayContent();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'currencySign' => $currency->sign,
'currencyRate' => $currency->conversion_rate,
'currencyFormat' => $currency->format,
@@ -155,20 +155,20 @@ class OrderControllerCore extends ParentOrderController
switch ((int)$this->step)
{
case -1:
- self::$smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
break;
case 1:
$this->processAddressFormat();
- self::$smarty->display(_PS_THEME_DIR_.'order-address.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-address.tpl');
break;
case 2:
- self::$smarty->display(_PS_THEME_DIR_.'order-carrier.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-carrier.tpl');
break;
case 3:
- self::$smarty->display(_PS_THEME_DIR_.'order-payment.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-payment.tpl');
break;
default:
- self::$smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'shopping-cart.tpl');
break;
}
}
@@ -237,7 +237,7 @@ class OrderControllerCore extends ParentOrderController
if (sizeof($this->errors))
{
- self::$smarty->assign('errors', $this->errors);
+ $this->smarty->assign('errors', $this->errors);
$this->_assignCarrier();
$this->step = 2;
$this->displayContent();
@@ -252,7 +252,7 @@ class OrderControllerCore extends ParentOrderController
{
parent::_assignAddress();
- self::$smarty->assign('cart', self::$cart);
+ $this->smarty->assign('cart', self::$cart);
if (self::$cookie->is_guest)
Tools::redirect('index.php?controller=order&step=2');
}
@@ -260,8 +260,6 @@ class OrderControllerCore extends ParentOrderController
/* Carrier step */
protected function _assignCarrier()
{
- global $defaultCountry;
-
if (isset(self::$cookie->id_customer))
$customer = new Customer((int)(self::$cookie->id_customer));
else
@@ -271,7 +269,7 @@ class OrderControllerCore extends ParentOrderController
// Assign wrapping and TOS
$this->_assignWrappingAndTOS();
- self::$smarty->assign('is_guest' ,(isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0));
+ $this->smarty->assign('is_guest' ,(isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0));
}
/* Payment step */
@@ -283,8 +281,8 @@ class OrderControllerCore extends ParentOrderController
Hook::backBeforePayment('order.php?step=3');
/* We may need to display an order summary */
- self::$smarty->assign(self::$cart->getSummaryDetails());
- self::$smarty->assign(array(
+ $this->smarty->assign(self::$cart->getSummaryDetails());
+ $this->smarty->assign(array(
'total_price' => (float)($orderTotal),
'taxes_enabled' => (int)(Configuration::get('PS_TAX'))
));
diff --git a/controllers/OrderDetailController.php b/controllers/OrderDetailController.php
index 1f866fea3..09a04f676 100644
--- a/controllers/OrderDetailController.php
+++ b/controllers/OrderDetailController.php
@@ -114,7 +114,7 @@ class OrderDetailControllerCore extends FrontController
$deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
if ($order->total_discounts > 0)
- self::$smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts));
+ $this->smarty->assign('total_old', (float)($order->total_paid - $order->total_discounts));
$products = $order->getProducts();
$customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
@@ -122,7 +122,7 @@ class OrderDetailControllerCore extends FrontController
$customer = new Customer($order->id_customer);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'shop_name' => strval(Configuration::get('PS_SHOP_NAME')),
'order' => $order,
'return_allowed' => (int)($order->isReturnable()),
@@ -150,8 +150,8 @@ class OrderDetailControllerCore extends FrontController
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
'customizedDatas' => $customizedDatas));
if ($carrier->url AND $order->shipping_number)
- self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
- self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
+ $this->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
+ $this->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
unset($carrier);
@@ -173,7 +173,7 @@ class OrderDetailControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'order-detail.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-detail.tpl');
}
public function displayFooter()
diff --git a/controllers/OrderFollowController.php b/controllers/OrderFollowController.php
index 4cb04de87..691ceab7e 100644
--- a/controllers/OrderFollowController.php
+++ b/controllers/OrderFollowController.php
@@ -76,31 +76,31 @@ class OrderFollowControllerCore extends FrontController
$ordersReturn = OrderReturn::getOrdersReturn((int)(self::$cookie->id_customer));
if (Tools::isSubmit('errorQuantity'))
- self::$smarty->assign('errorQuantity', true);
+ $this->smarty->assign('errorQuantity', true);
elseif (Tools::isSubmit('errorMsg'))
- self::$smarty->assign('errorMsg', true);
+ $this->smarty->assign('errorMsg', true);
elseif (Tools::isSubmit('errorDetail1'))
- self::$smarty->assign('errorDetail1', true);
+ $this->smarty->assign('errorDetail1', true);
elseif (Tools::isSubmit('errorDetail2'))
- self::$smarty->assign('errorDetail2', true);
+ $this->smarty->assign('errorDetail2', true);
elseif (Tools::isSubmit('errorNotReturnable'))
- self::$smarty->assign('errorNotReturnable',true);
+ $this->smarty->assign('errorNotReturnable',true);
- self::$smarty->assign('ordersReturn', $ordersReturn);
+ $this->smarty->assign('ordersReturn', $ordersReturn);
}
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'history.css');
- Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
- Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js', _THEME_JS_DIR_.'history.js'));
+ $this->addCSS(_THEME_CSS_DIR_.'history.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'));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'order-follow.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-follow.tpl');
}
}
diff --git a/controllers/OrderOpcController.php b/controllers/OrderOpcController.php
index a84b9f3b0..9fc708c27 100644
--- a/controllers/OrderOpcController.php
+++ b/controllers/OrderOpcController.php
@@ -35,7 +35,7 @@ class OrderOpcControllerCore extends ParentOrderController
{
parent::preProcess();
if ($this->nbProducts)
- self::$smarty->assign('virtual_cart', false);
+ $this->smarty->assign('virtual_cart', false);
$this->isLogged = (bool)((int)(self::$cookie->id_customer) AND Customer::customerIdExistsStatic((int)(self::$cookie->id_customer)));
if (self::$cart->nbProducts())
@@ -122,7 +122,7 @@ class OrderOpcControllerCore extends ParentOrderController
include_once(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php');
$blockUserInfo = new BlockUserInfo();
}
- self::$smarty->assign('isVirtualCart', self::$cart->isVirtualCart());
+ $this->smarty->assign('isVirtualCart', self::$cart->isVirtualCart());
$this->_processAddressFormat();
$this->_assignAddress();
// Wrapping fees
@@ -131,7 +131,7 @@ class OrderOpcControllerCore extends ParentOrderController
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
$return = array(
'summary' => self::$cart->getSummaryDetails(),
- 'order_opc_adress' => self::$smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'),
+ 'order_opc_adress' => $this->smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'),
'block_user_info' => (isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : ''),
'carrier_list' => $this->_getCarrierList(),
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
@@ -218,11 +218,11 @@ class OrderOpcControllerCore extends ParentOrderController
parent::setMedia();
// Adding CSS style sheet
- Tools::addCSS(_THEME_CSS_DIR_.'order-opc.css');
+ $this->addCSS(_THEME_CSS_DIR_.'order-opc.css');
// Adding JS files
- Tools::addJS(_THEME_JS_DIR_.'order-opc.js');
- Tools::addJs(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js');
- Tools::addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
+ $this->addJS(_THEME_JS_DIR_.'order-opc.js');
+ $this->addJS(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js');
+ $this->addJS(_THEME_JS_DIR_.'tools/statesManagement.js');
}
public function process()
@@ -234,7 +234,7 @@ class OrderOpcControllerCore extends ParentOrderController
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
$countries = Country::getCountries((int)(self::$cookie->id_lang), true);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'isLogged' => $this->isLogged,
'isGuest' => isset(self::$cookie->is_guest) ? self::$cookie->is_guest : 0,
'countries' => $countries,
@@ -247,7 +247,7 @@ class OrderOpcControllerCore extends ParentOrderController
$years = Tools::dateYears();
$months = Tools::dateMonths();
$days = Tools::dateDays();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'years' => $years,
'months' => $months,
'days' => $days,
@@ -255,7 +255,7 @@ class OrderOpcControllerCore extends ParentOrderController
/* Load guest informations */
if ($this->isLogged AND self::$cookie->is_guest)
- self::$smarty->assign('guestInformations', $this->_getGuestInformations());
+ $this->smarty->assign('guestInformations', $this->_getGuestInformations());
if ($this->isLogged)
$this->_assignAddress(); // ADDRESS
@@ -265,7 +265,7 @@ class OrderOpcControllerCore extends ParentOrderController
$this->_assignPayment();
Tools::safePostVars();
- self::$smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
+ $this->smarty->assign('newsletter', (int)Module::getInstanceByName('blocknewsletter')->active);
}
public function displayHeader()
@@ -279,7 +279,7 @@ class OrderOpcControllerCore extends ParentOrderController
parent::displayContent();
$this->_processAddressFormat();
- self::$smarty->display(_PS_THEME_DIR_.'order-opc.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-opc.tpl');
}
public function displayFooter()
@@ -330,7 +330,7 @@ class OrderOpcControllerCore extends ParentOrderController
if (!$this->isLogged)
{
$carriers = Carrier::getCarriersForOrder(Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT')));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'checked' => $this->_setDefaultCarrierSelection($carriers),
'carriers' => $carriers,
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')),
@@ -344,7 +344,7 @@ class OrderOpcControllerCore extends ParentOrderController
protected function _assignPayment()
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_TOP_PAYMENT' => ($this->isLogged ? Module::hookExec('paymentTop') : ''),
'HOOK_PAYMENT' => $this->_getPaymentMethods()
));
@@ -448,8 +448,8 @@ class OrderOpcControllerCore extends ParentOrderController
foreach(explode(' ',$fields_line) as $field_item)
${$adr_type.'_all_fields'}[] = trim($field_item);
- self::$smarty->assign($adr_type.'_adr_fields', ${$adr_type.'_adr_fields'});
- self::$smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'});
+ $this->smarty->assign($adr_type.'_adr_fields', ${$adr_type.'_adr_fields'});
+ $this->smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'});
}
}
diff --git a/controllers/OrderReturnController.php b/controllers/OrderReturnController.php
index 91ff15761..014f286b6 100644
--- a/controllers/OrderReturnController.php
+++ b/controllers/OrderReturnController.php
@@ -55,7 +55,7 @@ class OrderReturnControllerCore extends FrontController
if (Validate::isLoadedObject($order))
{
$state = new OrderReturnState((int)($orderRet->state));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'orderRet' => $orderRet,
'order' => $order,
'state_name' => $state->name[(int)(self::$cookie->id_lang)],
@@ -72,7 +72,7 @@ class OrderReturnControllerCore extends FrontController
$this->errors[] = Tools::displayError('Cannot find this order return');
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'errors' => $this->errors,
'nbdaysreturn' => (int)(Configuration::get('PS_ORDER_RETURN_NB_DAYS'))
));
@@ -87,7 +87,7 @@ class OrderReturnControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'order-return.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-return.tpl');
}
public function displayFooter()
diff --git a/controllers/OrderSlipController.php b/controllers/OrderSlipController.php
index 951a51f7a..b28c65dd4 100644
--- a/controllers/OrderSlipController.php
+++ b/controllers/OrderSlipController.php
@@ -40,21 +40,21 @@ class OrderSlipControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'history.css');
- Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
- Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js',_THEME_JS_DIR_.'history.js'));
+ $this->addCSS(_THEME_CSS_DIR_.'history.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'));
}
public function process()
{
parent::process();
- self::$smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)(self::$cookie->id_customer)));
+ $this->smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)(self::$cookie->id_customer)));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'order-slip.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'order-slip.tpl');
}
}
diff --git a/controllers/PageNotFoundController.php b/controllers/PageNotFoundController.php
index bbcd27c3b..d2dc97e09 100644
--- a/controllers/PageNotFoundController.php
+++ b/controllers/PageNotFoundController.php
@@ -29,7 +29,7 @@ class PageNotFoundControllerCore extends FrontController
{
public function displayContent()
{
- self::$smarty->display(_PS_THEME_DIR_.'404.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'404.tpl');
}
}
diff --git a/controllers/ParentOrderController.php b/controllers/ParentOrderController.php
index 02527ff0a..de4bb6284 100644
--- a/controllers/ParentOrderController.php
+++ b/controllers/ParentOrderController.php
@@ -108,7 +108,7 @@ class ParentOrderControllerCore extends FrontController
Tools::redirect('index.php?controller=order-opc');
}
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'errors' => $this->errors,
'discount_name' => Tools::safeOutput($discountName)
));
@@ -124,7 +124,7 @@ class ParentOrderControllerCore extends FrontController
$this->_setNoCarrier();
}
- self::$smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
+ $this->smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
}
public function setMedia()
@@ -132,18 +132,18 @@ class ParentOrderControllerCore extends FrontController
parent::setMedia();
// Adding CSS style sheet
- Tools::addCSS(_THEME_CSS_DIR_.'addresses.css');
- Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');
+ $this->addCSS(_THEME_CSS_DIR_.'addresses.css');
+ $this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');
// Adding JS files
- Tools::addJS(_THEME_JS_DIR_.'tools.js');
+ $this->addJS(_THEME_JS_DIR_.'tools.js');
if ((Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 AND Tools::getValue('step') == 1) OR Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
- Tools::addJS(_THEME_JS_DIR_.'order-address.js');
- Tools::addJS(_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js');
+ $this->addJS(_THEME_JS_DIR_.'order-address.js');
+ $this->addJS(_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js');
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')) OR Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
{
- Tools::addJS(_THEME_JS_DIR_.'cart-summary.js');
- Tools::addJS(_PS_JS_DIR_.'jquery/jquery-typewatch.pack.js');
+ $this->addJS(_THEME_JS_DIR_.'cart-summary.js');
+ $this->addJS(_PS_JS_DIR_.'jquery/jquery-typewatch.pack.js');
}
}
@@ -231,7 +231,7 @@ class ParentOrderControllerCore extends FrontController
global $currency;
if (file_exists(_PS_SHIP_IMG_DIR_.(int)(self::$cart->id_carrier).'.jpg'))
- self::$smarty->assign('carrierPicture', 1);
+ $this->smarty->assign('carrierPicture', 1);
$summary = self::$cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas((int)(self::$cart->id));
@@ -257,14 +257,14 @@ class ParentOrderControllerCore extends FrontController
$total_free_ship = 0;
break;
}
- self::$smarty->assign('free_ship', $total_free_ship);
+ $this->smarty->assign('free_ship', $total_free_ship);
}
// for compatibility with 1.2 themes
foreach($summary['products'] AS $key => $product)
$summary['products'][$key]['quantity'] = $product['cart_quantity'];
- self::$smarty->assign($summary);
- self::$smarty->assign(array(
+ $this->smarty->assign($summary);
+ $this->smarty->assign(array(
'token_cart' => Tools::getToken(false),
'isVirtualCart' => self::$cart->isVirtualCart(),
'productNumber' => self::$cart->nbProducts(),
@@ -280,7 +280,7 @@ class ParentOrderControllerCore extends FrontController
'currencyRate' => $currency->conversion_rate,
'currencyFormat' => $currency->format,
'currencyBlank' => $currency->blank));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary),
'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary)
));
@@ -315,7 +315,7 @@ class ParentOrderControllerCore extends FrontController
unset($tmpAddress);
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'addresses' => $customerAddresses,
'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
@@ -339,7 +339,7 @@ class ParentOrderControllerCore extends FrontController
{
$deliveryAddress = new Address((int)(self::$cart->id_address_delivery));
if (Validate::isLoadedObject($deliveryAddress) AND ($deliveryAddress->id_customer == $customer->id))
- self::$smarty->assign('delivery', $deliveryAddress);
+ $this->smarty->assign('delivery', $deliveryAddress);
}
/* If invoice address is valid in cart, assign it to Smarty */
@@ -347,11 +347,11 @@ class ParentOrderControllerCore extends FrontController
{
$invoiceAddress = new Address((int)(self::$cart->id_address_invoice));
if (Validate::isLoadedObject($invoiceAddress) AND ($invoiceAddress->id_customer == $customer->id))
- self::$smarty->assign('invoice', $invoiceAddress);
+ $this->smarty->assign('invoice', $invoiceAddress);
}
}
if ($oldMessage = Message::getMessageByCartId((int)(self::$cart->id)))
- self::$smarty->assign('oldMessage', $oldMessage['message']);
+ $this->smarty->assign('oldMessage', $oldMessage['message']);
}
protected function _assignCarrier()
@@ -361,7 +361,7 @@ class ParentOrderControllerCore extends FrontController
$id_zone = Address::getZoneById((int)($address->id));
$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups());
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'checked' => $this->_setDefaultCarrierSelection($carriers),
'carriers' => $carriers,
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')),
@@ -385,7 +385,7 @@ class ParentOrderControllerCore extends FrontController
else
$this->link_conditions .= '&content_only=1';
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'checkedTOS' => (int)(self::$cookie->checkedTOS),
'recyclablePackAllowed' => (int)(Configuration::get('PS_RECYCLABLE_PACK')),
'giftAllowed' => (int)(Configuration::get('PS_GIFT_WRAPPING')),
@@ -400,7 +400,7 @@ class ParentOrderControllerCore extends FrontController
protected function _assignPayment()
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
'HOOK_PAYMENT' => Module::hookExecPayment()
));
diff --git a/controllers/PasswordController.php b/controllers/PasswordController.php
index f587f5b91..213a66891 100644
--- a/controllers/PasswordController.php
+++ b/controllers/PasswordController.php
@@ -63,7 +63,7 @@ class PasswordControllerCore extends FrontController
'{url}' => self::$link->getPageLink('password', true, NULL, 'token='.$customer->secure_key.'&id_customer='.(int)$customer->id)),
$customer->email,
$customer->firstname.' '.$customer->lastname))
- self::$smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
+ $this->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
else
$this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
}
@@ -92,7 +92,7 @@ class PasswordControllerCore extends FrontController
'{passwd}' => $password),
$customer->email,
$customer->firstname.' '.$customer->lastname))
- self::$smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
+ $this->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
else
$this->errors[] = Tools::displayError('Error occurred when sending the e-mail.');
}
@@ -110,7 +110,7 @@ class PasswordControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'password.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'password.tpl');
}
}
diff --git a/controllers/PricesDropController.php b/controllers/PricesDropController.php
index eac4685f0..7324c1b4b 100644
--- a/controllers/PricesDropController.php
+++ b/controllers/PricesDropController.php
@@ -37,7 +37,7 @@ class PricesDropControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
public function process()
@@ -48,7 +48,7 @@ class PricesDropControllerCore extends FrontController
$nbProducts = Product::getPricesDrop((int)self::$cookie->id_lang, NULL, NULL, true);
$this->pagination($nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => Product::getPricesDrop((int)self::$cookie->id_lang, (int)$this->p - 1, (int)$this->n, false, $this->orderBy, $this->orderWay, false, false, (int)$this->id_current_shop),
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'nbProducts' => $nbProducts,
@@ -59,7 +59,7 @@ class PricesDropControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'prices-drop.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'prices-drop.tpl');
}
}
diff --git a/controllers/ProductController.php b/controllers/ProductController.php
index dc92fbad6..f532ed91b 100644
--- a/controllers/ProductController.php
+++ b/controllers/ProductController.php
@@ -33,9 +33,9 @@ class ProductControllerCore extends FrontController
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'product.css');
- Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');
- Tools::addJS(array(
+ $this->addCSS(_THEME_CSS_DIR_.'product.css');
+ $this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');
+ $this->addJS(array(
_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js',
_PS_JS_DIR_.'jquery/jquery.idTabs.modified.js',
_PS_JS_DIR_.'jquery/jquery.scrollTo-1.4.2-min.js',
@@ -45,13 +45,14 @@ class ProductControllerCore extends FrontController
if (Configuration::get('PS_DISPLAY_JQZOOM') == 1)
{
- Tools::addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen');
- Tools::addJS(_PS_JS_DIR_.'jquery/jquery.jqzoom.js');
+ $this->addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen');
+ $this->addJS(_PS_JS_DIR_.'jquery/jquery.jqzoom.js');
}
}
public function preProcess()
{
+ $context = Context::getContext();
if ($id_product = (int)Tools::getValue('id_product'))
$this->product = new Product($id_product, true, self::$cookie->id_lang, (int)$this->id_current_shop);
@@ -66,7 +67,7 @@ class ProductControllerCore extends FrontController
// $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain
if (Validate::isLoadedObject($this->product))
{
- $canonicalURL = self::$link->getProductLink($this->product);
+ $canonicalURL = $context->link->getProductLink($this->product);
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/i', Tools::getProtocol().$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))
{
header('HTTP/1.0 301 Moved');
@@ -86,16 +87,16 @@ class ProductControllerCore extends FrontController
$default_rewrite = array();
foreach ($rewrite_infos AS $infos)
- $default_rewrite[$infos['id_lang']] = self::$link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']);
+ $default_rewrite[$infos['id_lang']] = $context->link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']);
- self::$smarty->assign('lang_rewrite_urls', $default_rewrite);
+ $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
}
}
public function process()
{
- global $cart, $currency;;
parent::process();
+ $context = Context::getContext();
if (!$id_product = (int)(Tools::getValue('id_product')) OR !Validate::isUnsignedId($id_product))
$this->errors[] = Tools::displayError('Product not found');
@@ -108,36 +109,36 @@ class ProductControllerCore extends FrontController
header('HTTP/1.1 404 page not found');
$this->errors[] = Tools::displayError('Pproduct is no longer available.');
}
- elseif (!$this->product->checkAccess((int)(self::$cookie->id_customer)))
+ elseif (!$this->product->checkAccess(isset($context->customer) ? $context->customer->id : 0))
$this->errors[] = Tools::displayError('You do not have access to this product.');
else
{
- self::$smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id)));
+ $this->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id)));
if (!$this->product->active)
- self::$smarty->assign('adminActionDisplay', true);
+ $this->smarty->assign('adminActionDisplay', true);
/* rewrited url set */
- $rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite);
+ $rewrited_url = $context->link->getProductLink($this->product->id, $this->product->link_rewrite);
/* Product pictures management */
require_once('images.inc.php');
- self::$smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
+ $this->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
if (Tools::isSubmit('submitCustomizedDatas'))
{
- $this->pictureUpload($this->product, $cart);
- $this->textRecord($this->product, $cart);
+ $this->pictureUpload($this->product, $context->cart);
+ $this->textRecord($this->product, $context->cart);
$this->formTargetFormat();
}
- elseif (isset($_GET['deletePicture']) AND !$cart->deletePictureToProduct((int)($this->product->id), (int)(Tools::getValue('deletePicture'))))
+ elseif (isset($_GET['deletePicture']) AND !$context->cart->deletePictureToProduct((int)($this->product->id), (int)(Tools::getValue('deletePicture'))))
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
$files = self::$cookie->getFamily('pictures_'.(int)($this->product->id));
$textFields = self::$cookie->getFamily('textFields_'.(int)($this->product->id));
foreach ($textFields as $key => $textField)
$textFields[$key] = str_replace('
', "\n", $textField);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'pictures' => $files,
'textFields' => $textFields));
@@ -172,7 +173,7 @@ class ProductControllerCore extends FrontController
if (isset($category) AND Validate::isLoadedObject($category))
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'path' => Tools::getPath((int)$category->id, $this->product->name, true),
'category' => $category,
'subCategories' => $category->getSubCategories((int)(self::$cookie->id_lang), true),
@@ -181,29 +182,29 @@ class ProductControllerCore extends FrontController
'return_category_name' => Tools::safeOutput($category->name)));
}
else
- self::$smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name));
+ $this->smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name));
- self::$smarty->assign('return_link', (isset($category->id) AND $category->id) ? Tools::safeOutput(self::$link->getCategoryLink($category)) : 'javascript: history.back();');
+ $this->smarty->assign('return_link', (isset($category->id) AND $category->id) ? Tools::safeOutput($context->link->getCategoryLink($category)) : 'javascript: history.back();');
$lang = Configuration::get('PS_LANG_DEFAULT');
if (Pack::isPack((int)($this->product->id), (int)($lang)) AND !Pack::isInStock((int)($this->product->id), (int)($lang)))
$this->product->quantity = 0;
- $group_reduction = (100 - Group::getReduction((int)(self::$cookie->id_customer))) / 100;
- $id_customer = (isset(self::$cookie->id_customer) AND self::$cookie->id_customer) ? (int)(self::$cookie->id_customer) : 0;
- $id_group = $id_customer ? (int)(Customer::getDefaultGroupId($id_customer)) : _PS_DEFAULT_CUSTOMER_GROUP_;
+ $id_customer = (isset($context->customer) ? (int)($context->customer->id) : 0);
+ $group_reduction = (100 - Group::getReduction($id_customer)) / 100;
+ $id_group = (isset($context->customer) ? $context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
$id_country = (int)($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
// Tax
- $tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
- self::$smarty->assign('tax_rate', $tax);
+ $tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
+ $this->smarty->assign('tax_rate', $tax);
- $ecotax_rate = (float) Tax::getProductEcotaxRate($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
+ $ecotax_rate = (float) Tax::getProductEcotaxRate($context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX'))
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)($this->product->id), (int)(Shop::getCurrentShop()), (int)(self::$cookie->id_currency), $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)($tax)),
'product' => $this->product,
'ecotax_tax_inc' => $ecotaxTaxAmount,
@@ -220,7 +221,7 @@ class ProductControllerCore extends FrontController
'group_reduction' => $group_reduction,
'col_img_dir' => _PS_COL_IMG_DIR_,
));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'),
'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'),
'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product),
@@ -236,7 +237,7 @@ class ProductControllerCore extends FrontController
{
if ($image['cover'])
{
- self::$smarty->assign('mainImage', $images[0]);
+ $this->smarty->assign('mainImage', $images[0]);
$cover = $image;
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$image['id_image']) : $image['id_image']);
$cover['id_image_only'] = (int)($image['id_image']);
@@ -244,16 +245,16 @@ class ProductControllerCore extends FrontController
$productImages[(int)($image['id_image'])] = $image;
}
if (!isset($cover))
- $cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang).'-default', 'legend' => 'No picture', 'title' => 'No picture');
+ $cover = array('id_image' => $context->language->iso_code.'-default', 'legend' => 'No picture', 'title' => 'No picture');
$size = Image::getSize('large');
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'cover' => $cover,
'imgWidth' => (int)($size['width']),
'mediumSize' => Image::getSize('medium'),
'largeSize' => Image::getSize('large'),
'accessories' => $this->product->getAccessories((int)(self::$cookie->id_lang))));
if (sizeof($productImages))
- self::$smarty->assign('images', $productImages);
+ $this->smarty->assign('images', $productImages);
/* Attributes / Groups & colors */
$colors = array();
@@ -327,7 +328,7 @@ class ProductControllerCore extends FrontController
$combinations[$id_product_attribute]['list'] = $attributeList;
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'groups' => $groups,
'combinaisons' => $combinations, /* Kept for compatibility purpose only */
'combinations' => $combinations,
@@ -335,18 +336,18 @@ class ProductControllerCore extends FrontController
'combinationImages' => $combinationImages));
}
- self::$smarty->assign(array(
- 'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}),
+ $this->smarty->assign(array(
+ 'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}),
'customizationFields' => $this->product->getCustomizationFields((int)(self::$cookie->id_lang))
));
// Pack management
- self::$smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int)(self::$cookie->id_lang), true) : array());
- self::$smarty->assign('packs', Pack::getPacksTable($this->product->id, (int)(self::$cookie->id_lang), true, 1));
+ $this->smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, (int)(self::$cookie->id_lang), true) : array());
+ $this->smarty->assign('packs', Pack::getPacksTable($this->product->id, (int)(self::$cookie->id_lang), true, 1));
}
}
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'ENT_NOQUOTES' => ENT_NOQUOTES,
'outOfStockAllowed' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK')),
'errors' => $this->errors,
@@ -356,10 +357,10 @@ class ProductControllerCore extends FrontController
'display_qties' => (int)(Configuration::get('PS_DISPLAY_QTIES')),
'display_ht' => !Tax::excludeTaxeOption(),
'ecotax' => (!sizeof($this->errors) AND $this->product->ecotax > 0 ? Tools::convertPrice((float)($this->product->ecotax)) : 0),
- 'currencySign' => $currency->sign,
- 'currencyRate' => $currency->conversion_rate,
- 'currencyFormat' => $currency->format,
- 'currencyBlank' => $currency->blank,
+ 'currencySign' => $context->currency->sign,
+ 'currencyRate' => $context->currency->conversion_rate,
+ 'currencyFormat' => $context->currency->format,
+ 'currencyBlank' => $context->currency->blank,
'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM')
));
}
@@ -367,7 +368,7 @@ class ProductControllerCore extends FrontController
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'product.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'product.tpl');
}
public function pictureUpload(Product $product, Cart $cart)
@@ -431,8 +432,8 @@ class ProductControllerCore extends FrontController
if (strncmp($field, 'group_', 6) == 0)
$customizationFormTarget = preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customizationFormTarget);
if (isset($_POST['quantityBackup']))
- self::$smarty->assign('quantityBackup', (int)($_POST['quantityBackup']));
- self::$smarty->assign('customizationFormTarget', $customizationFormTarget);
+ $this->smarty->assign('quantityBackup', (int)($_POST['quantityBackup']));
+ $this->smarty->assign('customizationFormTarget', $customizationFormTarget);
}
public function formatQuantityDiscounts($specificPrices, $price, $taxRate)
diff --git a/controllers/SearchController.php b/controllers/SearchController.php
index de59284c2..26ed0b23f 100644
--- a/controllers/SearchController.php
+++ b/controllers/SearchController.php
@@ -43,11 +43,10 @@ class SearchControllerCore extends FrontController
public function preProcess()
{
parent::preProcess();
-
+
$query = urldecode(Tools::getValue('q'));
if ($this->ajaxSearch)
{
- self::$link = new Link();
$searchResults = Search::find((int)(Tools::getValue('id_lang')), $query, 1, 10, 'position', 'desc', true, true, (int)$this->id_current_shop);
foreach ($searchResults AS &$product)
$product['product_link'] = self::$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
@@ -63,7 +62,7 @@ class SearchControllerCore extends FrontController
Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
$nbProducts = $search['total'];
$this->pagination($nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
'search_products' => $search['result'],
'nbProducts' => $search['total'],
@@ -80,7 +79,7 @@ class SearchControllerCore extends FrontController
Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
$nbProducts = $search['total'];
$this->pagination($nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => $search['result'], // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
'search_products' => $search['result'],
'nbProducts' => $search['total'],
@@ -93,7 +92,7 @@ class SearchControllerCore extends FrontController
$this->pagination($nbProducts);
$result = Search::searchTag((int)(self::$cookie->id_lang), $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay, false, true, (int)$this->id_current_shop);
Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result)));
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'search_tag' => $tag,
'products' => $result, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
'search_products' => $result,
@@ -102,13 +101,13 @@ class SearchControllerCore extends FrontController
}
else
{
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'products' => array(),
'search_products' => array(),
'pages_nb' => 1,
'nbProducts' => 0));
}
- self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'));
+ $this->smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'));
}
public function displayHeader()
@@ -116,13 +115,13 @@ class SearchControllerCore extends FrontController
if (!$this->instantSearch AND !$this->ajaxSearch)
parent::displayHeader();
else
- self::$smarty->assign('static_token', Tools::getToken(false));
+ $this->smarty->assign('static_token', Tools::getToken(false));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'search.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'search.tpl');
}
public function displayFooter()
@@ -136,7 +135,7 @@ class SearchControllerCore extends FrontController
parent::setMedia();
if (!$this->instantSearch AND !$this->ajaxSearch)
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
}
diff --git a/controllers/SitemapController.php b/controllers/SitemapController.php
index 7a7dc1068..4819cd483 100644
--- a/controllers/SitemapController.php
+++ b/controllers/SitemapController.php
@@ -37,27 +37,27 @@ class SitemapControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'sitemap.css');
- Tools::addJS(_THEME_JS_DIR_.'tools/treeManagement.js');
+ $this->addCSS(_THEME_CSS_DIR_.'sitemap.css');
+ $this->addJS(_THEME_JS_DIR_.'tools/treeManagement.js');
}
public function process()
{
parent::process();
- self::$smarty->assign('categoriesTree', Category::getRootCategory(NULL, (int)$this->id_current_shop)->recurseLiteCategTree(0));
- self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1, (int)$this->id_current_shop));
- self::$smarty->assign('voucherAllowed', (int)(Configuration::get('PS_VOUCHERS')));
+ $this->smarty->assign('categoriesTree', Category::getRootCategory(NULL, (int)$this->id_current_shop)->recurseLiteCategTree(0));
+ $this->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1, (int)$this->id_current_shop));
+ $this->smarty->assign('voucherAllowed', (int)(Configuration::get('PS_VOUCHERS')));
$blockmanufacturer = Module::getInstanceByName('blockmanufacturer');
$blocksupplier = Module::getInstanceByName('blocksupplier');
- self::$smarty->assign('display_manufacturer_link', (((int)$blockmanufacturer->id) ? true : false));
- self::$smarty->assign('display_supplier_link', (((int)$blocksupplier->id) ? true : false));
- self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
- self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
+ $this->smarty->assign('display_manufacturer_link', (((int)$blockmanufacturer->id) ? true : false));
+ $this->smarty->assign('display_supplier_link', (((int)$blocksupplier->id) ? true : false));
+ $this->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS'));
+ $this->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP'));
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'sitemap.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'sitemap.tpl');
}
}
diff --git a/controllers/StoresController.php b/controllers/StoresController.php
index ba93c9faa..b5041eb37 100644
--- a/controllers/StoresController.php
+++ b/controllers/StoresController.php
@@ -123,7 +123,7 @@ class StoresControllerCore extends FrontController
$smarty->assign('days_datas', $days_datas);
$smarty->assign('id_country', $store['id_country']);
- $other .= self::$smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
+ $other .= $this->smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
}
$newnode->setAttribute('addressNoHtml', strip_tags(str_replace('
', ' ', $address)));
@@ -192,7 +192,7 @@ class StoresControllerCore extends FrontController
global $link;
parent::process();
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'defaultLat' => (float)Configuration::get('PS_STORES_CENTER_LAT'),
'defaultLong' => (float)Configuration::get('PS_STORES_CENTER_LONG'),
'searchUrl' => $link->getPageLink('stores')
@@ -202,15 +202,15 @@ class StoresControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'stores.css');
+ $this->addCSS(_THEME_CSS_DIR_.'stores.css');
if (!Configuration::get('PS_STORES_SIMPLIFIED'))
- Tools::addJS(_THEME_JS_DIR_.'stores.js');
- Tools::addJS('http://maps.google.com/maps/api/js?sensor=true');
+ $this->addJS(_THEME_JS_DIR_.'stores.js');
+ $this->addJS('http://maps.google.com/maps/api/js?sensor=true');
}
public function displayContent()
{
parent::displayContent();
- self::$smarty->display(_PS_THEME_DIR_.'stores.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'stores.tpl');
}
}
diff --git a/controllers/SupplierController.php b/controllers/SupplierController.php
index 2dd40e626..4d297880a 100644
--- a/controllers/SupplierController.php
+++ b/controllers/SupplierController.php
@@ -32,7 +32,7 @@ class SupplierControllerCore extends FrontController
public function setMedia()
{
parent::setMedia();
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
public function process()
@@ -44,7 +44,7 @@ class SupplierControllerCore extends FrontController
{
$nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
$this->pagination((int)$nbProducts);
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'nb_products' => $nbProducts,
'products' => $this->supplier->getProducts($id_supplier, (int)self::$cookie->id_lang, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
'path' => ($this->supplier->active ? Tools::safeOutput($this->supplier->name) : ''),
@@ -70,7 +70,7 @@ class SupplierControllerCore extends FrontController
foreach ($data AS &$item)
$item['image'] = (!file_exists($imgDir.'/'.$item['id_supplier'].'-medium.jpg')) ?
Language::getIsoById((int)(self::$cookie->id_lang)).'-default' : $item['id_supplier'];
- self::$smarty->assign(array(
+ $this->smarty->assign(array(
'pages_nb' => ceil($nbProducts / (int)($this->n)),
'nbSuppliers' => $nbProducts,
'mediumSize' => Image::getSize('medium'),
@@ -79,7 +79,7 @@ class SupplierControllerCore extends FrontController
));
}
else
- self::$smarty->assign('nbSuppliers', 0);
+ $this->smarty->assign('nbSuppliers', 0);
}
}
@@ -93,9 +93,9 @@ class SupplierControllerCore extends FrontController
{
parent::displayContent();
if ($this->supplier)
- self::$smarty->display(_PS_THEME_DIR_.'supplier.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'supplier.tpl');
else
- self::$smarty->display(_PS_THEME_DIR_.'supplier-list.tpl');
+ $this->smarty->display(_PS_THEME_DIR_.'supplier-list.tpl');
}
}
diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php
index 6a1dd5d35..3c8969280 100644
--- a/modules/blockadvertising/blockadvertising.php
+++ b/modules/blockadvertising/blockadvertising.php
@@ -210,12 +210,11 @@ class BlockAdvertising extends Module
*/
function hookRightColumn($params)
{
- global $smarty, $protocol_content;
-
- Tools::addCSS($this->_path.'blockadvertising.css', 'all');
- $smarty->assign('image', $protocol_content.$this->adv_img);
- $smarty->assign('adv_link', $this->adv_link);
- $smarty->assign('adv_title', $this->adv_title);
+ $context = Context::getContext();
+ $context->controller->addCSS($this->_path.'blockadvertising.css', 'all');
+ $context->controller->smarty->assign('image', $context->link->protocol_content.$this->adv_img);
+ $context->controller->smarty->assign('adv_link', $this->adv_link);
+ $context->controller->smarty->assign('adv_title', $this->adv_title);
return $this->display(__FILE__, 'blockadvertising.tpl');
}
diff --git a/modules/blockbestsellers/blockbestsellers.php b/modules/blockbestsellers/blockbestsellers.php
index 3eac716f4..3e3ad6c0c 100644
--- a/modules/blockbestsellers/blockbestsellers.php
+++ b/modules/blockbestsellers/blockbestsellers.php
@@ -120,13 +120,13 @@ class BlockBestSellers extends Module
{
return $this->hookRightColumn($params);
}
-
public function hookHeader($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
- Tools::addCSS(($this->_path).'blockbestsellers.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockbestsellers.css', 'all');
}
}
diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php
index e6b80d036..f9a9bef38 100644
--- a/modules/blockcart/blockcart.php
+++ b/modules/blockcart/blockcart.php
@@ -185,10 +185,10 @@ class BlockCart extends Module
{
if (Configuration::get('PS_CATALOG_MODE'))
return;
-
- Tools::addCSS(($this->_path).'blockcart.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockcart.css', 'all');
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')))
- Tools::addJS(($this->_path).'ajax-cart.js');
+ $context->controller->addJS(($this->_path).'ajax-cart.js');
}
}
diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php
index 3d97b19a8..b16e54336 100644
--- a/modules/blockcategories/blockcategories.php
+++ b/modules/blockcategories/blockcategories.php
@@ -323,8 +323,9 @@ class BlockCategories extends Module
public function hookHeader()
{
- Tools::addJS(_THEME_JS_DIR_.'tools/treeManagement.js');
- Tools::addCSS(($this->_path).'blockcategories.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addJS(_THEME_JS_DIR_.'tools/treeManagement.js');
+ $context->controller->addCSS(($this->_path).'blockcategories.css', 'all');
}
private function _clearBlockcategoriesCache()
diff --git a/modules/blockcms/blockcms.php b/modules/blockcms/blockcms.php
index cd12c5776..a87355378 100755
--- a/modules/blockcms/blockcms.php
+++ b/modules/blockcms/blockcms.php
@@ -131,16 +131,17 @@ class BlockCms extends Module
return array_merge($this->getBlocksCMS(self::LEFT_COLUMN), $this->getBlocksCMS(self::RIGHT_COLUMN));
}
- static public function getCMStitlesFooter()
+ static public function getCMStitlesFooter($context = null)
{
- global $cookie;
-
+ if (!$context)
+ $context = Context::getContext();
+
$footerCms = Configuration::get('FOOTER_CMS');
if (empty($footerCms))
return array();
$cmsCategories = explode('|', $footerCms);
$content = array();
- $link = new Link();
+
foreach ($cmsCategories AS $cmsCategory)
{
$ids = explode('_', $cmsCategory);
@@ -151,9 +152,9 @@ class BlockCms extends Module
FROM `'._DB_PREFIX_.'cms_category_lang` cl
INNER JOIN `'._DB_PREFIX_.'cms_category` c ON (cl.`id_cms_category` = c.`id_cms_category`)
WHERE cl.`id_cms_category` = '.(int)$ids[1].' AND (c.`active` = 1 OR c.`id_cms_category` = 1)
- AND cl.`id_lang` = '.(int)$cookie->id_lang);
+ AND cl.`id_lang` = '.(int)$context->language->id);
- $content[$cmsCategory]['link'] = $link->getCMSCategoryLink((int)$ids[1], $query['link_rewrite']);
+ $content[$cmsCategory]['link'] = $context->link->getCMSCategoryLink((int)$ids[1], $query['link_rewrite']);
$content[$cmsCategory]['meta_title'] = $query['name'];
}
elseif (!$ids[0])
@@ -163,9 +164,9 @@ class BlockCms extends Module
FROM `'._DB_PREFIX_.'cms_lang` cl
INNER JOIN `'._DB_PREFIX_.'cms` c ON (cl.`id_cms` = c.`id_cms`)
WHERE cl.`id_cms` = '.(int)$ids[1].' AND c.`active` = 1
- AND cl.`id_lang` = '.(int)$cookie->id_lang);
+ AND cl.`id_lang` = '.(int)$context->language->id);
- $content[$cmsCategory]['link'] = $link->getCMSLink((int)$ids[1], $query['link_rewrite']);
+ $content[$cmsCategory]['link'] = $context->link->getCMSLink((int)$ids[1], $query['link_rewrite']);
$content[$cmsCategory]['meta_title'] = $query['meta_title'];
}
}
@@ -173,9 +174,10 @@ class BlockCms extends Module
return $content;
}
- static public function getCMStitles($location)
+ static public function getCMStitles($location, $context = null)
{
- global $cookie;
+ if (!$context)
+ $context = Context::getContext();
$id_current_shop = Shop::getCurrentShop();
$cmsCategories = Db::getInstance()->ExecuteS('
@@ -183,11 +185,11 @@ class BlockCms extends Module
FROM `'._DB_PREFIX_.'cms_block` bc
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
- WHERE bc.`location` = '.(int)($location).' AND ccl.`id_lang` = '.(int)($cookie->id_lang).' AND bcl.`id_lang` = '.(int)($cookie->id_lang).' AND bc.id_shop='.(int)$id_current_shop.'
+ WHERE bc.`location` = '.(int)($location).' AND ccl.`id_lang` = '.(int)$context->language->id.' AND bcl.`id_lang` = '.(int)$context->language->id.' AND bc.id_shop='.(int)$id_current_shop.'
ORDER BY `position`');
$content = array();
- $link = new Link();
+
if (is_array($cmsCategories) AND sizeof($cmsCategories))
foreach ($cmsCategories AS $cmsCategory)
{
@@ -199,14 +201,14 @@ class BlockCms extends Module
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_lang` cl ON (bcp.`id_cms` = cl.`id_cms`)
INNER JOIN `'._DB_PREFIX_.'cms` c ON (bcp.`id_cms` = c.`id_cms`)
- WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].' AND cl.`id_lang` = '.(int)$cookie->id_lang.' AND bcp.`is_category` = 0 AND c.`active` = 1
+ WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].' AND cl.`id_lang` = '.(int)$context->language->id.' AND bcp.`is_category` = 0 AND c.`active` = 1
ORDER BY `position`');
$links = array();
if (sizeof($content[$key]['cms']))
foreach ($content[$key]['cms'] AS $row)
{
- $row['link'] = $link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
+ $row['link'] = $context->link->getCMSLink((int)($row['id_cms']), $row['link_rewrite']);
$links[] = $row;
}
@@ -217,20 +219,20 @@ class BlockCms extends Module
FROM `'._DB_PREFIX_.'cms_block_page` bcp
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON (bcp.`id_cms` = cl.`id_cms_category`)
WHERE bcp.`id_cms_block` = '.(int)$cmsCategory['id_cms_block'].'
- AND cl.`id_lang` = '.(int)$cookie->id_lang.'
+ AND cl.`id_lang` = '.(int)$context->language->id.'
AND bcp.`is_category` = 1');
$links = array();
if (sizeof($content[$key]['categories']))
foreach ($content[$key]['categories'] as $row)
{
- $row['link'] = $link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']);
+ $row['link'] = $context->link->getCMSCategoryLink((int)$row['id_cms'], $row['link_rewrite']);
$links[] = $row;
}
$content[$key]['categories'] = $links;
$content[$key]['name'] = $cmsCategory['block_name'];
- $content[$key]['category_link'] = $link->getCMSCategoryLink((int)$cmsCategory['id_cms_category'], $cmsCategory['link_rewrite']);
+ $content[$key]['category_link'] = $context->link->getCMSCategoryLink((int)$cmsCategory['id_cms_category'], $cmsCategory['link_rewrite']);
$content[$key]['category_name'] = $cmsCategory['category_name'];
}
@@ -748,7 +750,8 @@ class BlockCms extends Module
public function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockcms.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockcms.css', 'all');
}
public function getL($key)
diff --git a/modules/blockcurrencies/blockcurrencies.php b/modules/blockcurrencies/blockcurrencies.php
index 666d797b0..9fbbd3584 100644
--- a/modules/blockcurrencies/blockcurrencies.php
+++ b/modules/blockcurrencies/blockcurrencies.php
@@ -74,7 +74,8 @@ class BlockCurrencies extends Module
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
- Tools::addCSS(($this->_path).'blockcurrencies.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockcurrencies.css', 'all');
}
}
diff --git a/modules/blocklanguages/blocklanguages.php b/modules/blocklanguages/blocklanguages.php
index 56304af0c..2f8aeaa52 100644
--- a/modules/blocklanguages/blocklanguages.php
+++ b/modules/blocklanguages/blocklanguages.php
@@ -68,7 +68,8 @@ class BlockLanguages extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blocklanguages.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blocklanguages.css', 'all');
}
}
diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php
index 0c716d293..9a2d77f03 100644
--- a/modules/blocklayered/blocklayered.php
+++ b/modules/blocklayered/blocklayered.php
@@ -81,10 +81,11 @@ class BlockLayered extends Module
$id_parent = (int)Tools::getValue('id_category', Tools::getValue('id_category_layered', 1));
if ($id_parent == 1)
return;
- Tools::addJS(($this->_path).'blocklayered.js');
- Tools::addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
- Tools::addCSS(($this->_path).'blocklayered.css', 'all');
- Tools::addCSS(_PS_CSS_DIR_.'jquery-ui-1.8.10.custom.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addJS(($this->_path).'blocklayered.js');
+ $context->controller->addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
+ $context->controller->addCSS(($this->_path).'blocklayered.css', 'all');
+ $context->controller->addCSS(_PS_CSS_DIR_.'jquery-ui-1.8.10.custom.css', 'all');
}
diff --git a/modules/blockmanufacturer/blockmanufacturer.php b/modules/blockmanufacturer/blockmanufacturer.php
index b85d682c5..b6522ec93 100644
--- a/modules/blockmanufacturer/blockmanufacturer.php
+++ b/modules/blockmanufacturer/blockmanufacturer.php
@@ -128,6 +128,7 @@ class BlockManufacturer extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockmanufacturer.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockmanufacturer.css', 'all');
}
}
diff --git a/modules/blockmyaccount/blockmyaccount.php b/modules/blockmyaccount/blockmyaccount.php
index 05484f3ae..b4e2c6216 100644
--- a/modules/blockmyaccount/blockmyaccount.php
+++ b/modules/blockmyaccount/blockmyaccount.php
@@ -86,7 +86,8 @@ class BlockMyAccount extends Module
}
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockmyaccount.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockmyaccount.css', 'all');
}
}
diff --git a/modules/blocknewproducts/blocknewproducts.php b/modules/blocknewproducts/blocknewproducts.php
index 082d5a865..4d049c085 100644
--- a/modules/blocknewproducts/blocknewproducts.php
+++ b/modules/blocknewproducts/blocknewproducts.php
@@ -113,7 +113,8 @@ class BlockNewProducts extends Module
public function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blocknewproducts.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blocknewproducts.css', 'all');
}
}
diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php
index 597e2c0cb..5b7db6475 100644
--- a/modules/blocknewsletter/blocknewsletter.php
+++ b/modules/blocknewsletter/blocknewsletter.php
@@ -278,7 +278,8 @@ class Blocknewsletter extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blocknewsletter.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blocknewsletter.css', 'all');
}
}
diff --git a/modules/blockpaymentlogo/blockpaymentlogo.php b/modules/blockpaymentlogo/blockpaymentlogo.php
index c2940b128..2cff98070 100644
--- a/modules/blockpaymentlogo/blockpaymentlogo.php
+++ b/modules/blockpaymentlogo/blockpaymentlogo.php
@@ -137,7 +137,8 @@ class BlockPaymentLogo extends Module
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
- Tools::addCSS(($this->_path).'blockpaymentlogo.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all');
}
}
diff --git a/modules/blockpermanentlinks/blockpermanentlinks.php b/modules/blockpermanentlinks/blockpermanentlinks.php
index cdcf64fbb..953e6f94f 100644
--- a/modules/blockpermanentlinks/blockpermanentlinks.php
+++ b/modules/blockpermanentlinks/blockpermanentlinks.php
@@ -78,7 +78,8 @@ class BlockPermanentLinks extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockpermanentlinks.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all');
}
}
diff --git a/modules/blockrss/blockrss.php b/modules/blockrss/blockrss.php
index 3614b38fa..92ce989c7 100644
--- a/modules/blockrss/blockrss.php
+++ b/modules/blockrss/blockrss.php
@@ -160,7 +160,8 @@ class Blockrss extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockrss.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockrss.css', 'all');
}
}
diff --git a/modules/blocksearch/blocksearch.php b/modules/blocksearch/blocksearch.php
index 1f5e24795..c3d95121a 100644
--- a/modules/blocksearch/blocksearch.php
+++ b/modules/blocksearch/blocksearch.php
@@ -80,22 +80,23 @@ class BlockSearch extends Module
*/
private function _hookCommon($params)
{
- global $smarty;
- $smarty->assign('ENT_QUOTES', ENT_QUOTES);
- $smarty->assign('search_ssl', (int)(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'));
+ $context = Context::getContext();
+
+ $context->controller->smarty->assign('ENT_QUOTES', ENT_QUOTES);
+ $context->controller->smarty->assign('search_ssl', (int)(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'));
$ajaxSearch=(int)(Configuration::get('PS_SEARCH_AJAX'));
- $smarty->assign('ajaxsearch', $ajaxSearch);
+ $context->controller->smarty->assign('ajaxsearch', $ajaxSearch);
$instantSearch = (int)(Configuration::get('PS_INSTANT_SEARCH'));
- $smarty->assign('instantsearch', $instantSearch);
+ $context->controller->smarty->assign('instantsearch', $instantSearch);
if ($ajaxSearch)
{
- Tools::addCSS(_PS_CSS_DIR_.'jquery.autocomplete.css');
- Tools::addJS(_PS_JS_DIR_.'jquery/jquery.autocomplete.js');
+ $context->controller->addCSS(_PS_CSS_DIR_.'jquery.autocomplete.css');
+ $context->controller->addJS(_PS_JS_DIR_.'jquery/jquery.autocomplete.js');
}
- Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
- Tools::addCSS(($this->_path).'blocksearch.css', 'all');
+ $context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');
+ $context->controller->addCSS(($this->_path).'blocksearch.css', 'all');
return true;
}
}
diff --git a/modules/blockspecials/blockspecials.php b/modules/blockspecials/blockspecials.php
index a13b9aa46..f799bdba9 100644
--- a/modules/blockspecials/blockspecials.php
+++ b/modules/blockspecials/blockspecials.php
@@ -107,7 +107,8 @@ class BlockSpecials extends Module
{
if (Configuration::get('PS_CATALOG_MODE'))
return ;
- Tools::addCSS(($this->_path).'blockspecials.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockspecials.css', 'all');
}
}
diff --git a/modules/blockstore/blockstore.php b/modules/blockstore/blockstore.php
index 4ce7b6a61..ec39a4c6e 100644
--- a/modules/blockstore/blockstore.php
+++ b/modules/blockstore/blockstore.php
@@ -71,7 +71,8 @@ class BlockStore extends Module
function hookHeader($params)
{
- Tools::addCSS($this->_path.'/blockstore.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS($this->_path.'/blockstore.css', 'all');
}
public function postProcess()
diff --git a/modules/blocksupplier/blocksupplier.php b/modules/blocksupplier/blocksupplier.php
index d10a03ec4..2f8320fa9 100644
--- a/modules/blocksupplier/blocksupplier.php
+++ b/modules/blocksupplier/blocksupplier.php
@@ -133,7 +133,8 @@ class BlockSupplier extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blocksupplier.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blocksupplier.css', 'all');
}
}
diff --git a/modules/blocktags/blocktags.php b/modules/blocktags/blocktags.php
index 650601a84..504105dfc 100644
--- a/modules/blocktags/blocktags.php
+++ b/modules/blocktags/blocktags.php
@@ -119,7 +119,8 @@ class BlockTags extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blocktags.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blocktags.css', 'all');
}
}
diff --git a/modules/blockuserinfo/blockuserinfo.php b/modules/blockuserinfo/blockuserinfo.php
index 068906c71..3e6fe560e 100644
--- a/modules/blockuserinfo/blockuserinfo.php
+++ b/modules/blockuserinfo/blockuserinfo.php
@@ -74,7 +74,8 @@ class BlockUserInfo extends Module
public function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockuserinfo.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockuserinfo.css', 'all');
}
}
diff --git a/modules/blockviewed/blockviewed.php b/modules/blockviewed/blockviewed.php
index 8de9247bc..73d56df1c 100644
--- a/modules/blockviewed/blockviewed.php
+++ b/modules/blockviewed/blockviewed.php
@@ -186,6 +186,7 @@ class BlockViewed extends Module
function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockviewed.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockviewed.css', 'all');
}
}
diff --git a/modules/blockwishlist/blockwishlist.php b/modules/blockwishlist/blockwishlist.php
index 352d9f740..dd4412fc3 100644
--- a/modules/blockwishlist/blockwishlist.php
+++ b/modules/blockwishlist/blockwishlist.php
@@ -171,7 +171,8 @@ class BlockWishList extends Module
public function hookHeader($params)
{
- Tools::addCSS(($this->_path).'blockwishlist.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'blockwishlist.css', 'all');
return $this->display(__FILE__, 'blockwishlist-header.tpl');
}
diff --git a/modules/carriercompare/carriercompare.php b/modules/carriercompare/carriercompare.php
index a4974cf4c..b56d41d1a 100755
--- a/modules/carriercompare/carriercompare.php
+++ b/modules/carriercompare/carriercompare.php
@@ -56,8 +56,9 @@ class CarrierCompare extends Module
$fileName = explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF']);
if ($fileName[(sizeof($fileName)-1)] != 'order.php')
return;
- Tools::addCSS(($this->_path).'style.css', 'all');
- Tools::addJS(($this->_path).'carriercompare.js');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'style.css', 'all');
+ $context->controller->addJS(($this->_path).'carriercompare.js');
}
/*
diff --git a/modules/criteo/criteo.php b/modules/criteo/criteo.php
index 5c929ca07..c81b69d81 100755
--- a/modules/criteo/criteo.php
+++ b/modules/criteo/criteo.php
@@ -115,10 +115,13 @@ class Criteo extends Module
}
}
- public static function buildCSV()
+ public static function buildCSV($context = null)
{
- global $cookie, $country_infos;
- $cookie = new Cookie('ps');
+ if (!$context)
+ $context = Context::getContext();
+
+ global $country_infos;
+
$country_infos = array('id_group' => 0, 'id_tax' => 1);
$html = '';
/* First line, columns */
@@ -140,11 +143,7 @@ class Criteo extends Module
'PS_SHOP_NAME',
'PS_CURRENCY_DEFAULT',
'PS_CARRIER_DEFAULT'));
- /* Language */
- $language = new Language(intval($conf['PS_LANG_DEFAULT']));
- /* Link instance for products links */
- $link = new Link();
$result = Db::getInstance()->ExecuteS('
SELECT DISTINCT p.`id_product`, i.`id_image`
FROM `'._DB_PREFIX_.'product` p
@@ -166,7 +165,7 @@ class Criteo extends Module
$line[] = $product->manufacturer_name.' - '.$product->name[intval($conf['PS_LANG_DEFAULT'])];
$line[] = Tools::getProtocol().$_SERVER['HTTP_HOST']._THEME_PROD_DIR_.$imageObj->getExistingImgPath().'-small.jpg';
$line[] = Tools::getProtocol().$_SERVER['HTTP_HOST']._THEME_PROD_DIR_.$imageObj->getExistingImgPath().'-thickbox.jpg';
- $line[] = $link->getProductLink(intval($product->id), $product->link_rewrite[intval($conf['PS_LANG_DEFAULT'])], $product->ean13).'&utm_source=criteo&aff=criteo';
+ $line[] = $context->link->getProductLink(intval($product->id), $product->link_rewrite[intval($conf['PS_LANG_DEFAULT'])], $product->ean13).'&utm_source=criteo&aff=criteo';
$line[] = str_replace(array("\n", "\r", "\t", '|'), '', strip_tags(html_entity_decode($product->description_short[intval($conf['PS_LANG_DEFAULT'])], ENT_COMPAT, 'UTF-8')));
$price = $product->getPrice(true, intval(Product::getDefaultAttribute($product->id)));
@@ -185,11 +184,12 @@ class Criteo extends Module
echo $html;
}
- public static function buildXML()
+ public static function buildXML($context = null)
{
- global $cookie, $country_infos;
-
- $cookie = new Cookie('ps');
+ global $country_infos;
+ if (!$context)
+ $context = Context::getContext();
+
$country_infos = array('id_group' => 0, 'id_tax' => 1);
$html = ''."\n";
/* First line, columns */
@@ -207,11 +207,6 @@ class Criteo extends Module
'PS_SHOP_NAME',
'PS_CURRENCY_DEFAULT',
'PS_CARRIER_DEFAULT'));
- /* Language */
- $language = new Language(intval($conf['PS_LANG_DEFAULT']));
-
- /* Link instance for products links */
- $link = new Link();
/* Searching for products */
$result = Db::getInstance()->ExecuteS('
@@ -237,7 +232,7 @@ class Criteo extends Module
$line[] = Tools::getProtocol().$_SERVER['HTTP_HOST']._THEME_PROD_DIR_.$imageObj->getExistingImgPath().'-small.jpg';
$line[] = Tools::getProtocol().$_SERVER['HTTP_HOST']._THEME_PROD_DIR_.$imageObj->getExistingImgPath().'-thickbox.jpg';
- $line[] = $link->getProductLink(intval($product->id), $product->link_rewrite[intval($conf['PS_LANG_DEFAULT'])], $product->ean13).'&utm_source=criteo&aff=criteo';
+ $line[] = $context->link->getProductLink(intval($product->id), $product->link_rewrite[intval($conf['PS_LANG_DEFAULT'])], $product->ean13).'&utm_source=criteo&aff=criteo';
$line[] = str_replace(array("\n", "\r", "\t", '|'), '', strip_tags(html_entity_decode($product->description_short[intval($conf['PS_LANG_DEFAULT'])], ENT_COMPAT, 'UTF-8')));
$price = $product->getPrice(true, intval(Product::getDefaultAttribute($product->id)));
@@ -322,8 +317,8 @@ class Criteo extends Module
public function hookOrderConfirmation($params)
{
- global $cookie, $country_infos;
- $cookie = new Cookie('ps');
+ global $country_infos;
+
$country_infos = array('id_group' => 0,
'id_tax' => 1);
$cart = new Cart(intval($params['objOrder']->id_cart));
diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php
index 07edf5912..fbaaa25bf 100755
--- a/modules/crossselling/crossselling.php
+++ b/modules/crossselling/crossselling.php
@@ -96,7 +96,8 @@ class CrossSelling extends Module
public function hookHeader()
{
- Tools::addCSS(($this->_path).'crossselling.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'crossselling.css', 'all');
}
/**
diff --git a/modules/editorial/editorial.php b/modules/editorial/editorial.php
index 8cf3dd346..d30d476b1 100644
--- a/modules/editorial/editorial.php
+++ b/modules/editorial/editorial.php
@@ -313,6 +313,7 @@ class Editorial extends Module
public function hookHeader()
{
- Tools::addCSS(($this->_path).'editorial.css', 'all');
+ $context = Context::getContext();
+ $context->controller->addCSS(($this->_path).'editorial.css', 'all');
}
}
diff --git a/modules/gsitemap/gsitemap.php b/modules/gsitemap/gsitemap.php
index dfbd93a3e..034633c30 100644
--- a/modules/gsitemap/gsitemap.php
+++ b/modules/gsitemap/gsitemap.php
@@ -140,9 +140,10 @@ XML;
* @param string $filename
* @return bool
*/
- private function generateSitemap($shopID, $filename = '', $replaceUrl = array())
+ private function generateSitemap($shopID, $filename = '', $replaceUrl = array(), $context = null)
{
- $link = new Link();
+ if (!$context)
+ $context = Context::getContext();
$langs = Language::getLanguages();
$shop = new Shop($shopID);
if (!$shop->id)
@@ -185,7 +186,7 @@ XML;
$cmss = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($cmss AS $cms)
{
- $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $link->getCMSLink((int)$cms['id_cms']);
+ $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $context->link->getCMSLink((int)$cms['id_cms'], $cms['link_rewrite'], false, (int)$cms['id_lang']) : $context->link->getCMSLink((int)$cms['id_cms']);
$this->_addSitemapNode($xml, $tmpLink, '0.8', 'daily');
}
@@ -220,7 +221,7 @@ XML;
if (($priority = 0.9 - ($category['level_depth'] / 10)) < 0.1)
$priority = 0.1;
- $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']) : $link->getCategoryLink((int)$category['id_category']);
+ $tmpLink = Configuration::get('PS_REWRITING_SETTINGS') ? $context->link->getCategoryLink((int)$category['id_category'], $category['link_rewrite'], (int)$category['id_lang']) : $context->link->getCategoryLink((int)$category['id_category']);
$this->_addSitemapNode($xml, $tmpLink, $priority, 'weekly', substr($category['date_upd'], 0, 10));
}
@@ -249,7 +250,7 @@ XML;
if (($priority = 0.7 - ($product['level_depth'] / 10)) < 0.1)
$priority = 0.1;
- $tmpLink = $link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']));
+ $tmpLink = $context->link->getProductLink((int)($product['id_product']), $product['link_rewrite'], $product['category'], $product['ean13'], (int)($product['id_lang']));
$sitemap = $this->_addSitemapNode($xml, $tmpLink, $priority, 'weekly', substr($product['date_upd'], 0, 10));
$sitemap = $this->_addSitemapNodeImage($sitemap, $product);
}
@@ -278,10 +279,10 @@ XML;
if(Configuration::get('PS_REWRITING_SETTINGS'))
foreach ($pages AS $page => $ssl)
foreach($langs as $lang)
- $this->_addSitemapNode($xml, $link->getPageLink($page, $ssl, $lang['id_lang']), '0.5', 'monthly');
+ $this->_addSitemapNode($xml, $context->link->getPageLink($page, $ssl, $lang['id_lang']), '0.5', 'monthly');
else
foreach($pages AS $page => $ssl)
- $this->_addSitemapNode($xml, $link->getPageLink($page, $ssl), '0.5', 'monthly');
+ $this->_addSitemapNode($xml, $context->link->getPageLink($page, $ssl), '0.5', 'monthly');
$xmlString = $xml->asXML();
@@ -315,11 +316,12 @@ XML;
return $sitemap;
}
- private function _addSitemapNodeImage($xml, $product)
+ private function _addSitemapNodeImage($xml, $product, $context = null)
{
- $link = new Link();
+ if (!$context)
+ $context = Context::getContext();
$image = $xml->addChild('image', null, 'http://www.google.com/schemas/sitemap-image/1.1');
- $image->addChild('loc', htmlspecialchars($link->getImageLink($product['link_rewrite'], (int)$product['id_product'].'-'.(int)$product['id_image'])), 'http://www.google.com/schemas/sitemap-image/1.1');
+ $image->addChild('loc', htmlspecialchars($context->link->getImageLink($product['link_rewrite'], (int)$product['id_product'].'-'.(int)$product['id_image'])), 'http://www.google.com/schemas/sitemap-image/1.1');
$legend_image = preg_replace('/(&+)/i', '&', $product['legend_image']);
$image->addChild('caption', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1');
diff --git a/modules/loyalty/loyalty-program.php b/modules/loyalty/loyalty-program.php
index 553daaddc..afb164ea7 100644
--- a/modules/loyalty/loyalty-program.php
+++ b/modules/loyalty/loyalty-program.php
@@ -37,8 +37,9 @@ include_once(dirname(__FILE__).'/LoyaltyStateModule.php');
if (!$cookie->isLogged())
Tools::redirect('index.php?controller=authentication&back=modules/loyalty/loyalty-program.php');
-Tools::addCSS(_PS_CSS_DIR_.'jquery.cluetip.css', 'all');
-Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.dimensions.js',_PS_JS_DIR_.'jquery/jquery.cluetip.js'));
+$context = Context::getContext();
+$context->controller->addCSS(_PS_CSS_DIR_.'jquery.cluetip.css', 'all');
+$context->controller->addJS(array(_PS_JS_DIR_.'jquery/jquery.dimensions.js',_PS_JS_DIR_.'jquery/jquery.cluetip.js'));
$customerPoints = (int)(LoyaltyModule::getPointsByCustomer((int)($cookie->id_customer)));
diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php
index 691cf998c..f57cffc6c 100644
--- a/modules/mailalerts/mailalerts.php
+++ b/modules/mailalerts/mailalerts.php
@@ -318,21 +318,20 @@ class MailAlerts extends Module
$this->sendCustomerAlert((int)$result['id_product'], (int)$params['id_product_attribute']);
}
- public function sendCustomerAlert($id_product, $id_product_attribute)
+ public function sendCustomerAlert($id_product, $id_product_attribute, $context = null)
{
- global $cookie, $link;
-
- $link = new Link();
+ if (!$context)
+ $context = Context::getContext();
$customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT id_customer, customer_email
FROM `'._DB_PREFIX_.'mailalert_customer_oos`
WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute);
- $product = new Product((int)$id_product, false, (int)$cookie->id_lang);
+ $product = new Product((int)$id_product, false, (int)$context->language->id);
$templateVars = array(
'{product}' => (is_array($product->name) ? $product->name[(int)Configuration::get('PS_LANG_DEFAULT')] : $product->name),
- '{product_link}' => $link->getProductLink($product)
+ '{product_link}' => $context->link->getProductLink($product)
);
foreach ($customers AS $cust)
{
@@ -347,9 +346,8 @@ class MailAlerts extends Module
$customer_email = $cust['customer_email'];
$customer_id = 0;
}
- $id_lang = (is_object($cookie) AND isset($cookie->id_lang)) ? (int)$cookie->id_lang : (int)Configuration::get('PS_LANG_DEFAULT');
- $iso = Language::getIsoById((int)$id_lang);
-
+ $iso = $context->language->iso_code;
+
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.txt') AND file_exists(dirname(__FILE__).'/mails/'.$iso.'/customer_qty.html'))
Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), 'customer_qty', Mail::l('Product available'), $templateVars, strval($customer_email), NULL, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
if ($customer_id)
diff --git a/modules/ogone/confirmation.php b/modules/ogone/confirmation.php
index 147a1714d..4026a6f4d 100644
--- a/modules/ogone/confirmation.php
+++ b/modules/ogone/confirmation.php
@@ -33,13 +33,13 @@ $ogone = new Ogone();
$id_module = $ogone->id;
$id_cart = Tools::getValue('orderID');
$key = Db::getInstance()->getValue('SELECT secure_key FROM '._DB_PREFIX_.'customer WHERE id_customer = '.(int)$cookie->id_customer);
-$link = new Link();
+$context = Context::getContext;
$smarty->assign(array(
'id_module' => $id_module,
'id_cart' => $id_cart,
'key' => $key,
- 'ogone_link' => (method_exists($link, 'getPageLink') ? $link->getPageLink('my-account') : _PS_BASE_URL_.'my-account')
+ 'ogone_link' => (method_exists($context->link, 'getPageLink') ? $context->link->getPageLink('my-account') : _PS_BASE_URL_.'my-account')
));
echo $ogone->display(dirname(__FILE__), 'waiting.tpl');
diff --git a/modules/ogone/ogone.php b/modules/ogone/ogone.php
index 332568837..6a44403a2 100644
--- a/modules/ogone/ogone.php
+++ b/modules/ogone/ogone.php
@@ -183,17 +183,18 @@ class Ogone extends PaymentModule
public function hookOrderConfirmation($params)
{
- global $smarty, $cookie;
+ if (!$context)
+ $context = Context::getContext();
if ($params['objOrder']->module != $this->name)
return;
if ($params['objOrder']->valid)
- $smarty->assign(array('status' => 'ok', 'id_order' => $params['objOrder']->id));
+ $context->controller->smarty->assign(array('status' => 'ok', 'id_order' => $params['objOrder']->id));
else
- $smarty->assign('status', 'failed');
- $link = new Link();
- $smarty->assign('ogone_link', (method_exists($link, 'getPageLink') ? $link->getPageLink('contact', true) : Tools::getHttpHost(true).'contact'));
+ $context->controller->smarty->assign('status', 'failed');
+
+ $context->controller->smarty->assign('ogone_link', (method_exists($link, 'getPageLink') ? $context->link->getPageLink('contact', true) : Tools::getHttpHost(true).'contact'));
return $this->display(dirname(__FILE__), 'hookorderconfirmation.tpl');
}
diff --git a/modules/productscategory/productscategory.php b/modules/productscategory/productscategory.php
index 57ee2224b..fc3080dfc 100644
--- a/modules/productscategory/productscategory.php
+++ b/modules/productscategory/productscategory.php
@@ -176,7 +176,8 @@ class productsCategory extends Module
public function hookHeader($params)
{
- Tools::addCSS($this->_path.'productscategory.css', 'all');
- Tools::addJS(array($this->_path.'productscategory.js', _PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js'));
+ $context = Context::getContext();
+ $context->controller->addCSS($this->_path.'productscategory.css', 'all');
+ $context->controller->addJS(array($this->_path.'productscategory.js', _PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js'));
}
}
\ No newline at end of file
diff --git a/modules/referralprogram/referralprogram-program.php b/modules/referralprogram/referralprogram-program.php
index 55a9dfed3..d04643b26 100644
--- a/modules/referralprogram/referralprogram-program.php
+++ b/modules/referralprogram/referralprogram-program.php
@@ -35,8 +35,9 @@ include_once(dirname(__FILE__).'/ReferralProgramModule.php');
if (!$cookie->isLogged())
Tools::redirect('index.php?controller=authentication&back=modules/referralprogram/referralprogram-program.php');
-Tools::addCSS(_PS_CSS_DIR_.'thickbox.css', 'all');
-Tools::addJS(array(_PS_JS_DIR_.'jquery/thickbox-modified.js',_PS_JS_DIR_.'jquery/jquery.idTabs.modified.js'));
+$context = Context::getContext();
+$context->controller->addCSS(_PS_CSS_DIR_.'thickbox.css', 'all');
+$context->controller->addJS(array(_PS_JS_DIR_.'jquery/thickbox-modified.js',_PS_JS_DIR_.'jquery/jquery.idTabs.modified.js'));
include(dirname(__FILE__).'/../../header.php');