diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 406f5b436..a63496ae1 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -480,11 +480,10 @@ abstract class AdminTabCore * Overload this method for custom checking * * @param integer $id Object id used for deleting images - * @deprecated As of 1.5 use ObjectModel->deleteImage instead. + * TODO This function will soon be deprecated. 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 61ea90cc6..095522247 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -72,10 +72,6 @@ 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 642d842d9..6ca696eb1 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 = _PS_DEFAULT_CUSTOMER_GROUP_; + public $id_default_group; /** @var string Lastname */ public $lastname; @@ -93,11 +93,7 @@ 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 169c2ba0b..68ab2fedf 100755 --- a/classes/FrontController.php +++ b/classes/FrontController.php @@ -52,10 +52,6 @@ class FrontControllerCore public static $initialized = false; protected static $currentCustomerGroups; - - public $css_files; - public $js_files; - public $nb_items_per_page; public function __construct() { @@ -76,7 +72,7 @@ class FrontControllerCore public function init() { - global $smarty, $iso, $defaultCountry; + global $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files; if (self::$initialized) return; @@ -85,8 +81,8 @@ class FrontControllerCore $this->id_current_shop = (int)Shop::getCurrentShop(); $this->id_current_group_shop = (int)Shop::getCurrentGroupShop(); - $this->css_files = array(); - $this->js_files = array(); + $css_files = array(); + $js_files = array(); if ($this->ssl AND (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED')) { @@ -325,29 +321,6 @@ 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 */ @@ -458,16 +431,16 @@ class FrontControllerCore { global $cookie; - $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')); + 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')); if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_))) { - $this->addJS(array( + Tools::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') ); - $this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css'); + Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css'); } } @@ -483,6 +456,8 @@ class FrontControllerCore public function displayHeader() { + global $css_files, $js_files; + if (!self::$initialized) $this->init(); @@ -510,15 +485,15 @@ class FrontControllerCore { // CSS compressor management if (Configuration::get('PS_CSS_THEME_CACHE')) - $this->css_files = Tools::cccCSS($this->css_files); + Tools::cccCss(); //JS compressor management if (Configuration::get('PS_JS_THEME_CACHE')) - $this->js_files = Tools::cccJs($this->js_files); + Tools::cccJs(); } - self::$smarty->assign('css_files', $this->css_files); - self::$smarty->assign('js_files', array_unique($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'); } @@ -638,98 +613,5 @@ 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 098498786..846afebf5 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -31,10 +31,6 @@ 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 441491a39..17cc7cd88 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($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')}); + 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')}); else $this->tax_rate = Tax::getProductTaxRate($this->id, NULL); $this->new = $this->isNew(); @@ -412,22 +412,30 @@ class ProductCore extends ObjectModel return $fields; } - public static function initPricesComputation($customer = NULL) + public static function initPricesComputation($id_customer = NULL) { - if ($customer) + global $cookie; + + if ($id_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($customer = NULL) + public static function getTaxCalculationMethod($id_customer = NULL) { - if ($customer) - self::initPricesComputation((int)($customer)); + if ($id_customer) + self::initPricesComputation((int)($id_customer)); return (int)(self::$_taxCalculationMethod); } @@ -1447,15 +1455,15 @@ class ProductCore extends ObjectModel return Product::getProductsProperties((int)$id_lang, $result); } - static protected function _getProductIdByDate($beginning, $ending, $context = null) + static protected function _getProductIdByDate($beginning, $ending) { - if (!$context) - $context = Context::getContext(); + global $cookie, $cart; - $id_address = $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; + $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')}; $ids = Address::getCountryAndState($id_address); $id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); - return SpecificPrice::getProductIdByDate(Shop::getCurrentShop(), $context->currency->id, $id_country, $context->customer->id_default_group, $beginning, $ending); + return SpecificPrice::getProductIdByDate((int)(Shop::getCurrentShop()), (int)($cookie->id_currency), $id_country, $id_group, $beginning, $ending); } /** @@ -1734,13 +1742,10 @@ 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, $context = null) + $usereduc = true, $quantity = 1, $forceAssociatedTax = false, $id_customer = NULL, $id_cart = NULL, $id_address = NULL, &$specificPriceOutput = NULL, $with_ecotax = TRUE) { - if (!$context) - $context = Context::getContext(); - - $cur_cart = $context->cart; + global $cookie, $cart; + $cur_cart = $cart; if (isset($divisor)) Tools::displayParameterAsDeprecated('divisor'); @@ -1748,16 +1753,18 @@ class ProductCore extends ObjectModel if (!Validate::isBool($usetax) OR !Validate::isUnsignedId($id_product)) die(Tools::displayError()); // Initializations - $id_group = $context->customer->id_default_group; + 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_; 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) + if (!$id_cart AND !Validate::isCookie($cookie)) die(Tools::displayError()); - $cur_cart = new Cart($id_cart); + $cur_cart = $id_cart ? new Cart((int)($id_cart)) : new Cart((int)($cookie->id_cart)); } if ((int)($id_cart)) @@ -1771,7 +1778,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($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT')); + $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'))); // retrieve address informations $id_country = (int)Country::getDefaultCountryId(); @@ -1793,11 +1800,12 @@ class ProductCore extends ObjectModel $id_county = (int)County::getIdCountyByZipCode($id_state, $postcode); } } - elseif (isset($context->customer->geoloc_id_country)) + elseif (isset($cookie->id_country)) { - $id_country = (int)$context->customer->geoloc_id_country; - $id_state = (int)$context->customer->id_state; - $postcode = (int)$context->customer->postcode; + // fetch address from cookie + $id_country = (int)$cookie->id_country; + $id_state = (int)$cookie->id_state; + $postcode = (int)$cookie->postcode; $id_county = (int)County::getIdCountyByZipCode($id_state, $postcode); } @@ -1944,17 +1952,20 @@ class ProductCore extends ObjectModel return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency); } - public static function isDiscounted($id_product, $quantity = 1, $context = null) + public static function isDiscounted($id_product, $quantity = 1) { - $id_group = $context->customer->id_default_group; - $cart_quantity = !$context->cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' + 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(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` - WHERE `id_product` = '.(int)($id_product).' AND `id_cart` = '.(int)($context->cart->id) + WHERE `id_product` = '.(int)($id_product).' AND `id_cart` = '.(int)($cart->id) ); $quantity = $cart_quantity ? $cart_quantity : $quantity; - $id_currency = (int)$context->currency->id; - $ids = Address::getCountryAndState((int)($context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); + $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_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); @@ -2192,10 +2203,9 @@ 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, $context = null) + public static function reinjectQuantities(&$orderDetail, $quantity) { - if (!$context) - $context = Context::getContext(); + global $cookie; if (!Validate::isLoadedObject($orderDetail)) die(Tools::displayError()); @@ -2203,12 +2213,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)$context->employee->id)) + 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)) 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)$context->employee->id)) + if (!$product->addStockMvt((int)$quantity, _STOCK_MOVEMENT_ORDER_REASON_, (int)$orderDetail->product_attribute_id, (int)$orderDetail->id_order, (int)$cookie->id_employee)) return false; $orderDetail->product_quantity_reinjected += (int)($quantity); @@ -2336,7 +2346,9 @@ 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 @@ -2739,11 +2751,10 @@ class ProductCore extends ObjectModel /** * Get the link of the product page of this product */ - public function getLink($context = null) + public function getLink() { - if (!$context) - $context = Context::getContext(); - return $context->link->getProductLink($this); + global $link; + return $link->getProductLink($this); } public function getTags($id_lang) @@ -2879,16 +2890,19 @@ class ProductCore extends ObjectModel ** Customization management */ - public static function getAllCustomizedDatas($id_cart, $id_lang = null, $context = null) + public static function getAllCustomizedDatas($id_cart, $id_lang = null) { - if (!$context) - $context = Context::getContext(); - + global $cookie; // No need to query if there isn't any real cart! if (!$id_cart) return false; - if (!$id_lang) - $id_lang = $context->language->id; + 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 (!$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` @@ -2912,6 +2926,34 @@ 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 5ee7b396c..d9919a79e 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($context = null) + public static function setCookieLanguage() { - if (!$context) - $context = Context::getContent(); + global $cookie; + /* If language does not exist or is disabled, erase it */ - if ($context->cookie->id_lang) + if ($cookie->id_lang) { - $lang = new Language((int)$context->cookie->id_lang); + $lang = new Language((int)$cookie->id_lang); if (!Validate::isLoadedObject($lang) OR !$lang->active OR !$lang->isAssociatedToShop()) - $context->cookie->id_lang = NULL; + $cookie->id_lang = NULL; } /* Automatically detect language if not already defined */ - if (!$context->cookie->id_lang AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) + if (!$cookie->id_lang AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $array = explode(',', self::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])); if (self::strlen($array[0]) > 2) @@ -295,22 +295,24 @@ class ToolsCore { $lang = new Language((int)(Language::getIdByIso($string))); if (Validate::isLoadedObject($lang) AND $lang->active) - $context->cookie->id_lang = (int)($lang->id); + $cookie->id_lang = (int)($lang->id); } } /* If language file not present, you must use default language file */ - if (!$context->cookie->id_lang OR !Validate::isUnsignedId($$context->cookie->id_lang)) - $context->cookie->id_lang = (int)(Configuration::get('PS_LANG_DEFAULT')); + if (!$cookie->id_lang OR !Validate::isUnsignedId($cookie->id_lang)) + $cookie->id_lang = (int)(Configuration::get('PS_LANG_DEFAULT')); - $iso = Language::getIsoById((int)$context->cookie->id_lang); + $iso = Language::getIsoById((int)$cookie->id_lang); @include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php'); return $iso; } - public static function switchLanguage($cookie) + public static function switchLanguage() { + global $cookie; + if ($id_lang = (int)(self::getValue('id_lang')) AND Validate::isUnsignedId($id_lang)) $cookie->id_lang = $id_lang; } @@ -1385,42 +1387,108 @@ 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) { - Tools::displayAsDeprecated(); - $context = Context::getContext(); - $context->controller->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; } - + /** * 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') { - Tools::displayAsDeprecated(); - $context = Context::getContext(); - $context->controller->addCSS($css_uri, $css_media_type); + 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; } + /** * Combine Compress and Cache CSS (ccc) calls * - * @param array css_files - * @return array processed css_files */ - public static function cccCss($css_files) { + public static function cccCss() { + global $css_files; //inits $css_files_by_media = array(); $compressed_css_files = array(); @@ -1494,17 +1562,14 @@ 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($js_files) { + public static function cccJS() { + global $js_files; //inits $compressed_js_files_not_found = array(); $js_files_infos = array(); @@ -1567,7 +1632,7 @@ class ToolsCore // rebuild the original js_files array $url = str_replace(_PS_ROOT_DIR_.'/', __PS_BASE_URI__, $compressed_js_path); - return array_merge(array($protocolLink.Tools::getMediaServer($url).$url), $js_external_files); + $js_files = array_merge(array($protocolLink.Tools::getMediaServer($url).$url), $js_external_files); } diff --git a/controllers/OrderController.php b/controllers/OrderController.php index d87e6f254..1ee6004e2 100644 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -260,6 +260,8 @@ 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 45ec456fb..dc92fbad6 100644 --- a/controllers/ProductController.php +++ b/controllers/ProductController.php @@ -33,9 +33,9 @@ class ProductControllerCore extends FrontController { parent::setMedia(); - $this->addCSS(_THEME_CSS_DIR_.'product.css'); - $this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen'); - $this->addJS(array( + Tools::addCSS(_THEME_CSS_DIR_.'product.css'); + Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen'); + Tools::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,14 +45,13 @@ class ProductControllerCore extends FrontController if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) { - $this->addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen'); - $this->addJS(_PS_JS_DIR_.'jquery/jquery.jqzoom.js'); + Tools::addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen'); + Tools::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); @@ -67,7 +66,7 @@ class ProductControllerCore extends FrontController // $_SERVER['HTTP_HOST'] must be replaced by the real canonical domain if (Validate::isLoadedObject($this->product)) { - $canonicalURL = $context->link->getProductLink($this->product); + $canonicalURL = self::$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'); @@ -87,7 +86,7 @@ class ProductControllerCore extends FrontController $default_rewrite = array(); foreach ($rewrite_infos AS $infos) - $default_rewrite[$infos['id_lang']] = $context->link->getProductLink((int)$id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int)$infos['id_lang']); + $default_rewrite[$infos['id_lang']] = self::$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); } @@ -95,8 +94,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'); @@ -109,7 +108,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(isset($context->customer) ? $context->customer->id : 0)) + elseif (!$this->product->checkAccess((int)(self::$cookie->id_customer))) $this->errors[] = Tools::displayError('You do not have access to this product.'); else { @@ -119,7 +118,7 @@ class ProductControllerCore extends FrontController self::$smarty->assign('adminActionDisplay', true); /* rewrited url set */ - $rewrited_url = $context->link->getProductLink($this->product->id, $this->product->link_rewrite); + $rewrited_url = self::$link->getProductLink($this->product->id, $this->product->link_rewrite); /* Product pictures management */ require_once('images.inc.php'); @@ -127,11 +126,11 @@ class ProductControllerCore extends FrontController if (Tools::isSubmit('submitCustomizedDatas')) { - $this->pictureUpload($this->product, $context->cart); - $this->textRecord($this->product, $context->cart); + $this->pictureUpload($this->product, $cart); + $this->textRecord($this->product, $cart); $this->formTargetFormat(); } - elseif (isset($_GET['deletePicture']) AND !$context->cart->deletePictureToProduct((int)($this->product->id), (int)(Tools::getValue('deletePicture')))) + elseif (isset($_GET['deletePicture']) AND !$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)); @@ -184,22 +183,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($context->link->getCategoryLink($category)) : 'javascript: history.back();'); + self::$smarty->assign('return_link', (isset($category->id) AND $category->id) ? Tools::safeOutput(self::$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; - $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_); + $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_country = (int)($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT')); // Tax - $tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); + $tax = (float)(Tax::getProductTaxRate((int)($this->product->id), $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})); self::$smarty->assign('tax_rate', $tax); - $ecotax_rate = (float) Tax::getProductEcotaxRate($context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); + $ecotax_rate = (float) Tax::getProductEcotaxRate($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); @@ -245,7 +244,7 @@ class ProductControllerCore extends FrontController $productImages[(int)($image['id_image'])] = $image; } if (!isset($cover)) - $cover = array('id_image' => $context->language->iso_code.'-default', 'legend' => 'No picture', 'title' => 'No picture'); + $cover = array('id_image' => Language::getIsoById(self::$cookie->id_lang).'-default', 'legend' => 'No picture', 'title' => 'No picture'); $size = Image::getSize('large'); self::$smarty->assign(array( 'cover' => $cover, @@ -337,7 +336,7 @@ class ProductControllerCore extends FrontController } self::$smarty->assign(array( - 'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), + 'no_tax' => Tax::excludeTaxeOption() OR !Tax::getProductTaxRate((int)$this->product->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}), 'customizationFields' => $this->product->getCustomizationFields((int)(self::$cookie->id_lang)) )); @@ -357,10 +356,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' => $context->currency->sign, - 'currencyRate' => $context->currency->conversion_rate, - 'currencyFormat' => $context->currency->format, - 'currencyBlank' => $context->currency->blank, + 'currencySign' => $currency->sign, + 'currencyRate' => $currency->conversion_rate, + 'currencyFormat' => $currency->format, + 'currencyBlank' => $currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM') )); } diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php index 3c8969280..6a1dd5d35 100644 --- a/modules/blockadvertising/blockadvertising.php +++ b/modules/blockadvertising/blockadvertising.php @@ -210,11 +210,12 @@ class BlockAdvertising extends Module */ function hookRightColumn($params) { - $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); + 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); return $this->display(__FILE__, 'blockadvertising.tpl'); } diff --git a/modules/blockbestsellers/blockbestsellers.php b/modules/blockbestsellers/blockbestsellers.php index 3e3ad6c0c..3eac716f4 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 ; - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockbestsellers.css', 'all'); + Tools::addCSS(($this->_path).'blockbestsellers.css', 'all'); } } diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index f9a9bef38..e6b80d036 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; - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockcart.css', 'all'); + + Tools::addCSS(($this->_path).'blockcart.css', 'all'); if ((int)(Configuration::get('PS_BLOCK_CART_AJAX'))) - $context->controller->addJS(($this->_path).'ajax-cart.js'); + Tools::addJS(($this->_path).'ajax-cart.js'); } } diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php index b16e54336..3d97b19a8 100644 --- a/modules/blockcategories/blockcategories.php +++ b/modules/blockcategories/blockcategories.php @@ -323,9 +323,8 @@ class BlockCategories extends Module public function hookHeader() { - $context = Context::getContext(); - $context->controller->addJS(_THEME_JS_DIR_.'tools/treeManagement.js'); - $context->controller->addCSS(($this->_path).'blockcategories.css', 'all'); + Tools::addJS(_THEME_JS_DIR_.'tools/treeManagement.js'); + Tools::addCSS(($this->_path).'blockcategories.css', 'all'); } private function _clearBlockcategoriesCache() diff --git a/modules/blockcms/blockcms.php b/modules/blockcms/blockcms.php index 57aae5f4f..cd12c5776 100755 --- a/modules/blockcms/blockcms.php +++ b/modules/blockcms/blockcms.php @@ -748,8 +748,7 @@ class BlockCms extends Module public function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockcms.css', 'all'); + Tools::addCSS(($this->_path).'blockcms.css', 'all'); } public function getL($key) diff --git a/modules/blockcurrencies/blockcurrencies.php b/modules/blockcurrencies/blockcurrencies.php index 9fbbd3584..666d797b0 100644 --- a/modules/blockcurrencies/blockcurrencies.php +++ b/modules/blockcurrencies/blockcurrencies.php @@ -74,8 +74,7 @@ class BlockCurrencies extends Module { if (Configuration::get('PS_CATALOG_MODE')) return ; - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockcurrencies.css', 'all'); + Tools::addCSS(($this->_path).'blockcurrencies.css', 'all'); } } diff --git a/modules/blocklanguages/blocklanguages.php b/modules/blocklanguages/blocklanguages.php index 2f8aeaa52..56304af0c 100644 --- a/modules/blocklanguages/blocklanguages.php +++ b/modules/blocklanguages/blocklanguages.php @@ -68,8 +68,7 @@ class BlockLanguages extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blocklanguages.css', 'all'); + Tools::addCSS(($this->_path).'blocklanguages.css', 'all'); } } diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index 9a2d77f03..0c716d293 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -81,11 +81,10 @@ class BlockLayered extends Module $id_parent = (int)Tools::getValue('id_category', Tools::getValue('id_category_layered', 1)); if ($id_parent == 1) return; - $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'); + 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'); } diff --git a/modules/blockmanufacturer/blockmanufacturer.php b/modules/blockmanufacturer/blockmanufacturer.php index b6522ec93..b85d682c5 100644 --- a/modules/blockmanufacturer/blockmanufacturer.php +++ b/modules/blockmanufacturer/blockmanufacturer.php @@ -128,7 +128,6 @@ class BlockManufacturer extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockmanufacturer.css', 'all'); + Tools::addCSS(($this->_path).'blockmanufacturer.css', 'all'); } } diff --git a/modules/blockmyaccount/blockmyaccount.php b/modules/blockmyaccount/blockmyaccount.php index b4e2c6216..05484f3ae 100644 --- a/modules/blockmyaccount/blockmyaccount.php +++ b/modules/blockmyaccount/blockmyaccount.php @@ -86,8 +86,7 @@ class BlockMyAccount extends Module } function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockmyaccount.css', 'all'); + Tools::addCSS(($this->_path).'blockmyaccount.css', 'all'); } } diff --git a/modules/blocknewproducts/blocknewproducts.php b/modules/blocknewproducts/blocknewproducts.php index 4d049c085..082d5a865 100644 --- a/modules/blocknewproducts/blocknewproducts.php +++ b/modules/blocknewproducts/blocknewproducts.php @@ -113,8 +113,7 @@ class BlockNewProducts extends Module public function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blocknewproducts.css', 'all'); + Tools::addCSS(($this->_path).'blocknewproducts.css', 'all'); } } diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php index 5b7db6475..597e2c0cb 100644 --- a/modules/blocknewsletter/blocknewsletter.php +++ b/modules/blocknewsletter/blocknewsletter.php @@ -278,8 +278,7 @@ class Blocknewsletter extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blocknewsletter.css', 'all'); + Tools::addCSS(($this->_path).'blocknewsletter.css', 'all'); } } diff --git a/modules/blockpaymentlogo/blockpaymentlogo.php b/modules/blockpaymentlogo/blockpaymentlogo.php index 2cff98070..c2940b128 100644 --- a/modules/blockpaymentlogo/blockpaymentlogo.php +++ b/modules/blockpaymentlogo/blockpaymentlogo.php @@ -137,8 +137,7 @@ class BlockPaymentLogo extends Module { if (Configuration::get('PS_CATALOG_MODE')) return ; - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all'); + Tools::addCSS(($this->_path).'blockpaymentlogo.css', 'all'); } } diff --git a/modules/blockpermanentlinks/blockpermanentlinks.php b/modules/blockpermanentlinks/blockpermanentlinks.php index 953e6f94f..cdcf64fbb 100644 --- a/modules/blockpermanentlinks/blockpermanentlinks.php +++ b/modules/blockpermanentlinks/blockpermanentlinks.php @@ -78,8 +78,7 @@ class BlockPermanentLinks extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockpermanentlinks.css', 'all'); + Tools::addCSS(($this->_path).'blockpermanentlinks.css', 'all'); } } diff --git a/modules/blockrss/blockrss.php b/modules/blockrss/blockrss.php index 92ce989c7..3614b38fa 100644 --- a/modules/blockrss/blockrss.php +++ b/modules/blockrss/blockrss.php @@ -160,8 +160,7 @@ class Blockrss extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockrss.css', 'all'); + Tools::addCSS(($this->_path).'blockrss.css', 'all'); } } diff --git a/modules/blocksearch/blocksearch.php b/modules/blocksearch/blocksearch.php index c3d95121a..1f5e24795 100644 --- a/modules/blocksearch/blocksearch.php +++ b/modules/blocksearch/blocksearch.php @@ -80,23 +80,22 @@ class BlockSearch extends Module */ private function _hookCommon($params) { - $context = Context::getContext(); - - $context->controller->smarty->assign('ENT_QUOTES', ENT_QUOTES); - $context->controller->smarty->assign('search_ssl', (int)(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')); + global $smarty; + $smarty->assign('ENT_QUOTES', ENT_QUOTES); + $smarty->assign('search_ssl', (int)(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')); $ajaxSearch=(int)(Configuration::get('PS_SEARCH_AJAX')); - $context->controller->smarty->assign('ajaxsearch', $ajaxSearch); + $smarty->assign('ajaxsearch', $ajaxSearch); $instantSearch = (int)(Configuration::get('PS_INSTANT_SEARCH')); - $context->controller->smarty->assign('instantsearch', $instantSearch); + $smarty->assign('instantsearch', $instantSearch); if ($ajaxSearch) { - $context->controller->addCSS(_PS_CSS_DIR_.'jquery.autocomplete.css'); - $context->controller->addJS(_PS_JS_DIR_.'jquery/jquery.autocomplete.js'); + Tools::addCSS(_PS_CSS_DIR_.'jquery.autocomplete.css'); + Tools::addJS(_PS_JS_DIR_.'jquery/jquery.autocomplete.js'); } - $context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css'); - $context->controller->addCSS(($this->_path).'blocksearch.css', 'all'); + Tools::addCSS(_THEME_CSS_DIR_.'product_list.css'); + Tools::addCSS(($this->_path).'blocksearch.css', 'all'); return true; } } diff --git a/modules/blockspecials/blockspecials.php b/modules/blockspecials/blockspecials.php index f799bdba9..a13b9aa46 100644 --- a/modules/blockspecials/blockspecials.php +++ b/modules/blockspecials/blockspecials.php @@ -107,8 +107,7 @@ class BlockSpecials extends Module { if (Configuration::get('PS_CATALOG_MODE')) return ; - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockspecials.css', 'all'); + Tools::addCSS(($this->_path).'blockspecials.css', 'all'); } } diff --git a/modules/blockstore/blockstore.php b/modules/blockstore/blockstore.php index ec39a4c6e..4ce7b6a61 100644 --- a/modules/blockstore/blockstore.php +++ b/modules/blockstore/blockstore.php @@ -71,8 +71,7 @@ class BlockStore extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS($this->_path.'/blockstore.css', 'all'); + Tools::addCSS($this->_path.'/blockstore.css', 'all'); } public function postProcess() diff --git a/modules/blocksupplier/blocksupplier.php b/modules/blocksupplier/blocksupplier.php index 2f8320fa9..d10a03ec4 100644 --- a/modules/blocksupplier/blocksupplier.php +++ b/modules/blocksupplier/blocksupplier.php @@ -133,8 +133,7 @@ class BlockSupplier extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blocksupplier.css', 'all'); + Tools::addCSS(($this->_path).'blocksupplier.css', 'all'); } } diff --git a/modules/blocktags/blocktags.php b/modules/blocktags/blocktags.php index 504105dfc..650601a84 100644 --- a/modules/blocktags/blocktags.php +++ b/modules/blocktags/blocktags.php @@ -119,8 +119,7 @@ class BlockTags extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blocktags.css', 'all'); + Tools::addCSS(($this->_path).'blocktags.css', 'all'); } } diff --git a/modules/blockuserinfo/blockuserinfo.php b/modules/blockuserinfo/blockuserinfo.php index 3e6fe560e..068906c71 100644 --- a/modules/blockuserinfo/blockuserinfo.php +++ b/modules/blockuserinfo/blockuserinfo.php @@ -74,8 +74,7 @@ class BlockUserInfo extends Module public function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockuserinfo.css', 'all'); + Tools::addCSS(($this->_path).'blockuserinfo.css', 'all'); } } diff --git a/modules/blockviewed/blockviewed.php b/modules/blockviewed/blockviewed.php index 73d56df1c..8de9247bc 100644 --- a/modules/blockviewed/blockviewed.php +++ b/modules/blockviewed/blockviewed.php @@ -186,7 +186,6 @@ class BlockViewed extends Module function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockviewed.css', 'all'); + Tools::addCSS(($this->_path).'blockviewed.css', 'all'); } } diff --git a/modules/blockwishlist/blockwishlist.php b/modules/blockwishlist/blockwishlist.php index dd4412fc3..352d9f740 100644 --- a/modules/blockwishlist/blockwishlist.php +++ b/modules/blockwishlist/blockwishlist.php @@ -171,8 +171,7 @@ class BlockWishList extends Module public function hookHeader($params) { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'blockwishlist.css', 'all'); + Tools::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 b56d41d1a..a4974cf4c 100755 --- a/modules/carriercompare/carriercompare.php +++ b/modules/carriercompare/carriercompare.php @@ -56,9 +56,8 @@ class CarrierCompare extends Module $fileName = explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF']); if ($fileName[(sizeof($fileName)-1)] != 'order.php') return; - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'style.css', 'all'); - $context->controller->addJS(($this->_path).'carriercompare.js'); + Tools::addCSS(($this->_path).'style.css', 'all'); + Tools::addJS(($this->_path).'carriercompare.js'); } /* diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php index fbaaa25bf..07edf5912 100755 --- a/modules/crossselling/crossselling.php +++ b/modules/crossselling/crossselling.php @@ -96,8 +96,7 @@ class CrossSelling extends Module public function hookHeader() { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'crossselling.css', 'all'); + Tools::addCSS(($this->_path).'crossselling.css', 'all'); } /** diff --git a/modules/editorial/editorial.php b/modules/editorial/editorial.php index d30d476b1..8cf3dd346 100644 --- a/modules/editorial/editorial.php +++ b/modules/editorial/editorial.php @@ -313,7 +313,6 @@ class Editorial extends Module public function hookHeader() { - $context = Context::getContext(); - $context->controller->addCSS(($this->_path).'editorial.css', 'all'); + Tools::addCSS(($this->_path).'editorial.css', 'all'); } } diff --git a/modules/loyalty/loyalty-program.php b/modules/loyalty/loyalty-program.php index afb164ea7..553daaddc 100644 --- a/modules/loyalty/loyalty-program.php +++ b/modules/loyalty/loyalty-program.php @@ -37,9 +37,8 @@ include_once(dirname(__FILE__).'/LoyaltyStateModule.php'); if (!$cookie->isLogged()) Tools::redirect('index.php?controller=authentication&back=modules/loyalty/loyalty-program.php'); -$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')); +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')); $customerPoints = (int)(LoyaltyModule::getPointsByCustomer((int)($cookie->id_customer))); diff --git a/modules/productscategory/productscategory.php b/modules/productscategory/productscategory.php index fc3080dfc..57ee2224b 100644 --- a/modules/productscategory/productscategory.php +++ b/modules/productscategory/productscategory.php @@ -176,8 +176,7 @@ class productsCategory extends Module public function hookHeader($params) { - $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')); + 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')); } } \ No newline at end of file diff --git a/modules/referralprogram/referralprogram-program.php b/modules/referralprogram/referralprogram-program.php index d04643b26..55a9dfed3 100644 --- a/modules/referralprogram/referralprogram-program.php +++ b/modules/referralprogram/referralprogram-program.php @@ -35,9 +35,8 @@ include_once(dirname(__FILE__).'/ReferralProgramModule.php'); if (!$cookie->isLogged()) Tools::redirect('index.php?controller=authentication&back=modules/referralprogram/referralprogram-program.php'); -$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')); +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')); include(dirname(__FILE__).'/../../header.php');