diff --git a/classes/AdminTab.php b/classes/AdminTab.php index a63496ae1..406f5b436 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -480,10 +480,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/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/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..169c2ba0b 100755 --- a/classes/FrontController.php +++ b/classes/FrontController.php @@ -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 $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')) { @@ -321,6 +325,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 */ @@ -431,16 +458,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'); } } @@ -456,8 +483,6 @@ class FrontControllerCore public function displayHeader() { - global $css_files, $js_files; - if (!self::$initialized) $this->init(); @@ -485,15 +510,15 @@ 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->assign('css_files', $this->css_files); + self::$smarty->assign('js_files', array_unique($this->js_files)); self::$smarty->display(_PS_THEME_DIR_.'header.tpl'); } @@ -613,5 +638,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 static 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..098498786 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -31,6 +31,10 @@ class LinkCore protected $allow; protected $url; public static $cache = array('page' => array()); + + public $protocol_link; + public $protocol_content; + public $useSSL; /** * Constructor (initialization only) diff --git a/classes/Product.php b/classes/Product.php index 17cc7cd88..441491a39 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -290,17 +290,17 @@ class ProductCore extends ObjectModel public function __construct($id_product = NULL, $full = false, $id_lang = NULL, $id_shop = NULL) { - global $cart; - parent::__construct($id_product, $id_lang, $id_shop); + $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 +412,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 +1447,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 +1734,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 +1748,16 @@ 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 = $context->customer->id_default_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 */ - if (!$id_cart AND !Validate::isCookie($cookie)) + if (!$id_cart) 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 +1771,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 +1793,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 +1944,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 +2192,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 +2203,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 +2336,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 +2739,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) @@ -2890,19 +2879,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 +2912,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..5ee7b396c 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -268,20 +268,20 @@ class ToolsCore /** * Change language in cookie while clicking on a flag */ - public static function setCookieLanguage() + public static function setCookieLanguage($context = null) { - global $cookie; - + if (!$context) + $context = Context::getContent(); /* If language does not exist or is disabled, erase it */ - if ($cookie->id_lang) + if ($context->cookie->id_lang) { - $lang = new Language((int)$cookie->id_lang); + $lang = new Language((int)$context->cookie->id_lang); if (!Validate::isLoadedObject($lang) OR !$lang->active OR !$lang->isAssociatedToShop()) - $cookie->id_lang = NULL; + $context->cookie->id_lang = NULL; } /* Automatically detect language if not already defined */ - if (!$cookie->id_lang AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) + if (!$context->cookie->id_lang AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = explode(',', self::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])); if (self::strlen($array[0]) > 2) @@ -295,24 +295,22 @@ class ToolsCore { $lang = new Language((int)(Language::getIdByIso($string))); if (Validate::isLoadedObject($lang) AND $lang->active) - $cookie->id_lang = (int)($lang->id); + $context->cookie->id_lang = (int)($lang->id); } } /* If language file not present, you must use default language file */ - if (!$cookie->id_lang OR !Validate::isUnsignedId($cookie->id_lang)) - $cookie->id_lang = (int)(Configuration::get('PS_LANG_DEFAULT')); + if (!$context->cookie->id_lang OR !Validate::isUnsignedId($$context->cookie->id_lang)) + $context->cookie->id_lang = (int)(Configuration::get('PS_LANG_DEFAULT')); - $iso = Language::getIsoById((int)$cookie->id_lang); + $iso = Language::getIsoById((int)$context->cookie->id_lang); @include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php'); return $iso; } - public static function switchLanguage() + public static function switchLanguage($cookie) { - global $cookie; - if ($id_lang = (int)(self::getValue('id_lang')) AND Validate::isUnsignedId($id_lang)) $cookie->id_lang = $id_lang; } @@ -1387,108 +1385,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 +1494,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 +1567,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/OrderController.php b/controllers/OrderController.php index 1ee6004e2..d87e6f254 100644 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -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 diff --git a/controllers/ProductController.php b/controllers/ProductController.php index dc92fbad6..45ec456fb 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,7 +87,7 @@ 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); } @@ -94,8 +95,8 @@ class ProductControllerCore extends FrontController 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,7 +109,7 @@ 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 { @@ -118,7 +119,7 @@ class ProductControllerCore extends FrontController self::$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'); @@ -126,11 +127,11 @@ class ProductControllerCore extends FrontController 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)); @@ -183,22 +184,22 @@ class ProductControllerCore extends FrontController else self::$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();'); + self::$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')})); + $tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); self::$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); @@ -244,7 +245,7 @@ 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( 'cover' => $cover, @@ -336,7 +337,7 @@ class ProductControllerCore extends FrontController } self::$smarty->assign(array( - 'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), + '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)) )); @@ -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') )); } 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..57aae5f4f 100755 --- a/modules/blockcms/blockcms.php +++ b/modules/blockcms/blockcms.php @@ -748,7 +748,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/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/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/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');