diff --git a/admin-dev/tabs/AdminReturn.php b/admin-dev/tabs/AdminReturn.php index 6d6c3bbd7..7d9069650 100644 --- a/admin-dev/tabs/AdminReturn.php +++ b/admin-dev/tabs/AdminReturn.php @@ -29,13 +29,12 @@ class AdminReturn extends AdminTab { public function __construct() { - global $cookie; - + $context = Context::getContext(); $this->table = 'order_return'; $this->className = 'OrderReturn'; $this->colorOnBackground = true; $this->_select = 'orsl.`name`'; - $this->_join = 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)($cookie->id_lang).')'; + $this->_join = 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.(int)$context->language->id.')'; $this->fieldsDisplay = array( 'id_order_return' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), @@ -54,8 +53,7 @@ class AdminReturn extends AdminTab public function postProcess() { - global $currentIndex, $cookie; - + $context = Context::getContext(); if (Tools::isSubmit('deleteorder_return_detail')) { if ($this->tabAccess['delete'] === '1') @@ -103,7 +101,7 @@ class AdminReturn extends AdminTab '{firstname}' => $customer->firstname, '{id_order_return}' => $id_order_return, '{state_order_return}' => $orderReturnState->name[(int)(Configuration::get('PS_LANG_DEFAULT'))]); - Mail::Send((int)($cookie->id_lang), 'order_return_state', Mail::l('Your order return state has changed'), $vars, $customer->email, $customer->firstname.' '.$customer->lastname); + Mail::Send(clan, 'order_return_state', Mail::l('Your order return state has changed'), $vars, $customer->email, $customer->firstname.' '.$customer->lastname); Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token); } } @@ -118,8 +116,7 @@ class AdminReturn extends AdminTab public function display() { - global $currentIndex, $cookie; - + $context = Context::getContext(); // Include current tab if (isset($_GET['update'.$this->table])) { @@ -133,7 +130,7 @@ class AdminReturn extends AdminTab } else { - $this->getList((int)($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL); + $this->getList($context->language->id, !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL); $this->displayList(); $this->displayOptionsList(); $this->includeSubTab('display'); @@ -143,7 +140,6 @@ class AdminReturn extends AdminTab public function displayListContent($token = NULL) { - global $currentIndex, $cookie; $irow = 0; if ($this->_list) foreach ($this->_list AS $tr) @@ -159,7 +155,7 @@ class AdminReturn extends AdminTab public function displayForm($isMainTab = true) { - global $currentIndex, $cookie; + $context = Context::getContext(); parent::displayForm(); if (!($obj = $this->loadObject(true))) @@ -175,12 +171,12 @@ class AdminReturn extends AdminTab $customer = new Customer((int)($obj->id_customer)); echo '
.')
-

.')
-
+
-
+
| '.$product->name.' | +'.$product->name.' | '.(!empty($product->reference) ? ''.$this->l('Ref:').' '.$product->reference.' | ' : '').' '.(!empty($product->ean13) ? ''.$this->l('EAN13:').' '.$product->ean13.' | ' : '').' '.(!empty($product->upc) ? ''.$this->l('UPC:').' '.$product->upc.' | ' : '').' @@ -82,7 +82,7 @@ class AdminSuppliers extends AdminTab else { echo ' -
|---|
| '.$this->l('Attribute name').' | @@ -92,7 +92,7 @@ class AdminSuppliers extends AdminTab '.(Configuration::get('PS_STOCK_MANAGEMENT') ? ''.$this->l('Quantity').' | ' : '').'
|---|
- '.$this->l('Cancel').' + '.$this->l('Cancel').'
'; $this->_html .= ' @@ -568,13 +566,11 @@ class BlockCms extends Module SET `position` = '.((int)Tools::getValue('position')).' WHERE `id_cms_block` = '.(int)Tools::getValue('id_cms_block')); } - Tools::redirectAdmin($currentIndex.'index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); + Tools::redirectAdmin(AdminTab::$currentIndex.'index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); } private function _postProcess() { - global $currentIndex; - if (Tools::isSubmit('submitBlockCMS')) { $position = Db::getInstance()->getValue(' @@ -641,9 +637,9 @@ class BlockCms extends Module VALUES('.(int)$id_cms_block.', '.(int)$cms_properties[1].', '.(int)$cms_properties[0].')'); } if (Tools::isSubmit('addBlockCMS')) - Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlockCMSConfirmation'); + Tools::redirectAdmin(AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlockCMSConfirmation'); elseif (Tools::isSubmit('editBlockCMS')) - Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMSConfirmation'); + Tools::redirectAdmin(AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlockCMSConfirmation'); } elseif (Tools::isSubmit('deleteBlockCMS') AND Tools::getValue('id_cms_block')) { @@ -664,7 +660,7 @@ class BlockCms extends Module DELETE FROM `'._DB_PREFIX_.'cms_block_page` WHERE `id_cms_block` = '.(int)(Tools::getValue('id_cms_block'))); - Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteBlockCMSConfirmation'); + Tools::redirectAdmin(AdminTab::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteBlockCMSConfirmation'); } else $this->_html .= $this->displayError($this->l('Error: you are trying to delete a non-existent block cms')); @@ -705,10 +701,9 @@ class BlockCms extends Module public function hookLeftColumn() { - global $smarty; - + $context = Context::getContext(); $cms_titles = self::getCMStitles(self::LEFT_COLUMN); - $smarty->assign(array( + $context->controller->smarty->assign(array( 'block' => 1, 'cms_titles' => $cms_titles, 'theme_dir' => _PS_THEME_DIR_ @@ -718,10 +713,10 @@ class BlockCms extends Module public function hookRightColumn() { - global $smarty; + $context = Context::getContext(); $cms_titles = self::getCMStitles(self::RIGHT_COLUMN); - $smarty->assign(array( + $context->controller->smarty->assign(array( 'block' => 1, 'cms_titles' => $cms_titles, 'theme_dir' => _PS_THEME_DIR_ @@ -731,12 +726,12 @@ class BlockCms extends Module public function hookFooter() { - global $smarty; + $context = Context::getContext(); if (Configuration::get('FOOTER_BLOCK_ACTIVATION')) { $cms_titles = self::getCMStitlesFooter(); - $smarty->assign(array( + $context->controller->smarty->assign(array( 'block' => 0, 'cmslinks' => $cms_titles, 'theme_dir' => _PS_THEME_DIR_, diff --git a/modules/blockcurrencies/blockcurrencies.php b/modules/blockcurrencies/blockcurrencies.php index 9fbbd3584..8bf2aca30 100644 --- a/modules/blockcurrencies/blockcurrencies.php +++ b/modules/blockcurrencies/blockcurrencies.php @@ -60,13 +60,13 @@ class BlockCurrencies extends Module if (Configuration::get('PS_CATALOG_MODE')) return ; - global $smarty; + $context = Context::getContext(); $id_current_shop = $this->shopID; $currencies = Currency::getCurrencies(false, 1, $id_current_shop); if (!sizeof($currencies)) return ''; - $smarty->assign('currencies', $currencies); + $context->controller->smarty->assign('currencies', $currencies); return $this->display(__FILE__, 'blockcurrencies.tpl'); } diff --git a/modules/blocklanguages/blocklanguages.php b/modules/blocklanguages/blocklanguages.php index 2f8aeaa52..5603deefe 100644 --- a/modules/blocklanguages/blocklanguages.php +++ b/modules/blocklanguages/blocklanguages.php @@ -57,12 +57,12 @@ class BlockLanguages extends Module */ function hookTop($params) { - global $smarty; + $context = Context::getContext(); $languages = Language::getLanguages(true, $this->shopID); if (!sizeof($languages)) return ''; - $smarty->assign('languages', $languages); + $context->controller->smarty->assign('languages', $languages); return $this->display(__FILE__, 'blocklanguages.tpl'); } diff --git a/modules/blocklayered/blocklayered-ajax.php b/modules/blocklayered/blocklayered-ajax.php index 63e60df63..cc15c3f0f 100644 --- a/modules/blocklayered/blocklayered-ajax.php +++ b/modules/blocklayered/blocklayered-ajax.php @@ -25,8 +25,6 @@ * International Registred Trademark & Property of PrestaShop SA */ -global $cookie; - include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../init.php'); include(dirname(__FILE__).'/blocklayered.php'); diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index e8b06f4ed..060d24fe6 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -405,8 +405,7 @@ class BlockLayered extends Module public function generateFiltersBlock($selectedFilters = array()) { - global $smarty, $link, $cookie; - $id_lang = (int)$cookie->id_lang; + $context = Context::getContext(); /* If the current category isn't defined of if it's homepage, we have nothing to display */ $id_parent = (int)Tools::getValue('id_category', Tools::getValue('id_category_layered', 1)); @@ -420,7 +419,7 @@ class BlockLayered extends Module SELECT c.id_category, c.id_parent, cl.name FROM '._DB_PREFIX_.'category c LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category) - WHERE c.nleft > '.(int)$category->nleft.' and c.nright <= '.(int)$category->nright.' AND c.active = 1 AND c.id_parent = '.(int)$category->id.' AND cl.id_lang = '.(int)$cookie->id_lang.' + WHERE c.nleft > '.(int)$category->nleft.' and c.nright <= '.(int)$category->nright.' AND c.active = 1 AND c.id_parent = '.(int)$category->id.' AND cl.id_lang = '.(int)$context->language->id.' ORDER BY c.position ASC'); $whereC = ' cp.`id_category` = '.(int)$id_parent.' OR '; @@ -483,7 +482,7 @@ class BlockLayered extends Module SELECT fvl.id_feature_value, fvl.value FROM '._DB_PREFIX_.'feature_value fv LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fv.id_feature_value) - WHERE (fv.custom IS NULL OR fv.custom = 0) AND fv.id_feature = '.(int)$filterBlocks[(int)$filter['position']]['id_key'].' AND fvl.id_lang = '.(int)$id_lang); + WHERE (fv.custom IS NULL OR fv.custom = 0) AND fv.id_feature = '.(int)$filterBlocks[(int)$filter['position']]['id_key'].' AND fvl.id_lang = '.(int)$context->language->id); break; @@ -494,7 +493,7 @@ class BlockLayered extends Module SELECT al.id_attribute, al.name, a.color FROM '._DB_PREFIX_.'attribute a LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = a.id_attribute) - WHERE a.id_attribute_group = '.(int)$filterBlocks[(int)$filter['position']]['id_key'].' AND al.id_lang = '.(int)$id_lang); + WHERE a.id_attribute_group = '.(int)$filterBlocks[(int)$filter['position']]['id_key'].' AND al.id_lang = '.(int)$context->language->id); break; } } @@ -505,7 +504,7 @@ class BlockLayered extends Module $fNames = Db::getInstance()->ExecuteS(' SELECT id_feature, name FROM '._DB_PREFIX_.'feature_lang - WHERE id_lang = '.(int)$cookie->id_lang.' AND id_feature IN ('.implode(',', $f).')'); + WHERE id_lang = '.(int)$context->language->id.' AND id_feature IN ('.implode(',', $f).')'); $fNameByID = array(); foreach ($fNames AS $fName) $fNameByID[(int)$fName['id_feature']] = $fName['name']; @@ -518,7 +517,7 @@ class BlockLayered extends Module SELECT ag.id_attribute_group, agl.public_name, ag.is_color_group FROM '._DB_PREFIX_.'attribute_group ag LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = ag.id_attribute_group) - WHERE agl.id_lang = '.(int)$cookie->id_lang.' AND ag.id_attribute_group IN ('.implode(',', $a).')'); + WHERE agl.id_lang = '.(int)$context->language->id.' AND ag.id_attribute_group IN ('.implode(',', $a).')'); $aNameByID = $colorGroups = array(); foreach ($aNames AS $aName) @@ -714,9 +713,9 @@ class BlockLayered extends Module foreach ($_GET as $key => $val) $params .= $key.'='.$val.'&'; - $share_url = $link->getCategoryLink((int)$category->id, $category->link_rewrite[(int)$cookie->id_lang], (int)$cookie->id_lang).rtrim($params, '&'); + $share_url = $context->link->getCategoryLink((int)$category->id, $category->link_rewrite[(int)$context->language->id], $context->language->id).rtrim($params, '&'); - $smarty->assign(array( + $context->controller->smarty->assign(array( 'display_share' => (int)Configuration::get('PS_LAYERED_SHARE'), 'share_url' => $this->getShortLink($share_url), 'layered_use_checkboxes' => (int)Configuration::get('PS_LAYERED_NAVIGATION_CHECKBOXES'), @@ -731,11 +730,11 @@ class BlockLayered extends Module public function ajaxCall() { - global $smarty, $cookie; + $context = Context::getContext(); $selectedFilters = $this->getSelectedFilters(); $products = $this->getProductByFilters($selectedFilters); - $products = Product::getProductsProperties((int)$cookie->id_lang, $products); + $products = Product::getProductsProperties($context->language->id, $products); $nbProducts = $this->nbr_products; $range = 2; /* how many pages around page selected */ @@ -757,7 +756,7 @@ class BlockLayered extends Module if ($stop > $pages_nb) $stop = (int)($pages_nb); - $smarty->assign('nb_products', $nbProducts); + $context->controller->smarty->assign('nb_products', $nbProducts); $pagination_infos = array( 'pages_nb' => (int)($pages_nb), 'p' => (int)($p), @@ -767,15 +766,15 @@ class BlockLayered extends Module 'stop' => (int)($stop), 'nArray' => $nArray = (int)(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 10 ? array((int)(Configuration::get('PS_PRODUCTS_PER_PAGE')), 10, 20, 50) : array(10, 20, 50) ); - $smarty->assign($pagination_infos); + $context->controller->smarty->assign($pagination_infos); - $smarty->assign('products', $products); + $context->controller->smarty->assign('products', $products); /* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */ return Tools::jsonEncode(array( 'filtersBlock' => $this->generateFiltersBlock($selectedFilters), - 'productList' => $smarty->fetch(_PS_THEME_DIR_.'product-list.tpl'), - 'pagination' => $smarty->fetch(_PS_THEME_DIR_.'pagination.tpl') + 'productList' => $context->controller->smarty->fetch(_PS_THEME_DIR_.'product-list.tpl'), + 'pagination' => $context->controller->smarty->fetch(_PS_THEME_DIR_.'pagination.tpl') )); // return '