diff --git a/admin-dev/tabs/AdminAccess.php b/admin-dev/tabs/AdminAccess.php index 7bbc19bb9..bdcdf6f47 100644 --- a/admin-dev/tabs/AdminAccess.php +++ b/admin-dev/tabs/AdminAccess.php @@ -63,13 +63,12 @@ class AdminAccess extends AdminTab public function displayForm($isMainTab = true) { - $context = Context::getContext(); parent::displayForm(); $currentProfile = (int)($this->getCurrentProfileId()); - $tabs = Tab::getTabs($context->language->id); - $profiles = Profile::getProfiles($context->language->id); - $accesses = Profile::getProfileAccesses($context->language->id); + $tabs = Tab::getTabs($this->context->language->id); + $profiles = Profile::getProfiles($this->context->language->id); + $accesses = Profile::getProfileAccesses($this->context->language->id); echo '
'.$this->l('Attributes generator').''. - $this->l('Add or modify attributes for product:').' '.$this->product->name[$context->language->id].' + $this->l('Add or modify attributes for product:').' '.$this->product->name[$this->context->language->id].'

'; echo ' diff --git a/admin-dev/tabs/AdminBackup.php b/admin-dev/tabs/AdminBackup.php index c4c59a3f7..05c14c845 100644 --- a/admin-dev/tabs/AdminBackup.php +++ b/admin-dev/tabs/AdminBackup.php @@ -184,7 +184,6 @@ class AdminBackup extends AdminTab public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = NULL) { - $context = Context::getContext(); if (!Validate::isTableOrIdentifier($this->table)) die('filter is corrupted'); @@ -217,9 +216,9 @@ class AdminBackup extends AdminTab $orderWay = 'desc'; } if (empty($limit)) - $limit = ((!isset($context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $context->cookie->{$this->table.'_pagination'}); + $limit = ((!isset($this->context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $this->context->cookie->{$this->table.'_pagination'}); $limit = (int)(Tools::getValue('pagination', $limit)); - $context->cookie->{$this->table.'_pagination'} = $limit; + $this->context->cookie->{$this->table.'_pagination'} = $limit; /* Determine offset from current page */ if (!empty($_POST['submitFilter'.$this->table]) AND is_numeric($_POST['submitFilter'.$this->table])) diff --git a/admin-dev/tabs/AdminCMS.php b/admin-dev/tabs/AdminCMS.php index cbee8e4a6..408a798e8 100644 --- a/admin-dev/tabs/AdminCMS.php +++ b/admin-dev/tabs/AdminCMS.php @@ -75,7 +75,6 @@ class AdminCMS extends AdminTab public function displayForm($isMainTab = true) { - $context = Context::getContext(); parent::displayForm(); $obj = $this->loadObject(true); @@ -91,7 +90,7 @@ class AdminCMS extends AdminTab echo '
@@ -167,7 +166,7 @@ class AdminCMS extends AdminTab '.$this->_displayDraftWarning($obj->active).' '; // TinyMCE - $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$context->language->iso_code.'.js') ? $context->language->iso_code : 'en'); + $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$this->context->language->iso_code.'.js') ? $this->context->language->iso_code : 'en'); $ad = dirname($_SERVER["PHP_SELF"]); echo ' - '.$this->renderZones($tax_rules, $context->language->id); + '.$this->renderZones($tax_rules, $this->context->language->id); echo '
   @@ -383,11 +382,10 @@ class AdminTaxRulesGroup extends AdminTab protected function afterUpdate($object) { - $context = Context::getContext(); - + TaxRule::deleteByGroupId($object->id); - foreach(Country::getCountries($context->language->id, true) AS $country) + foreach(Country::getCountries($this->context->language->id, true) AS $country) { $id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_0'); @@ -455,7 +453,6 @@ class AdminTaxRulesGroup extends AdminTab public function postProcess() { - $context = Context::getContext(); if (!isset($this->table)) return false; @@ -522,7 +519,7 @@ class AdminTaxRulesGroup extends AdminTab // Default behavior (save and back) $id_product = (int)Tools::getValue('id_product'); if ($id_product) - Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id)); + Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id)); Tools::redirectAdmin(self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token); } @@ -554,7 +551,7 @@ class AdminTaxRulesGroup extends AdminTab $this->updateAssoGroupShop($object->id); $id_product = (int)Tools::getValue('id_product'); if ($id_product) - Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$context->employee->id)); + Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id)); Tools::redirectAdmin(self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token); // Default behavior (save and back) diff --git a/admin-dev/tabs/AdminTaxes.php b/admin-dev/tabs/AdminTaxes.php index e16157d90..001d6cd21 100644 --- a/admin-dev/tabs/AdminTaxes.php +++ b/admin-dev/tabs/AdminTaxes.php @@ -62,13 +62,12 @@ class AdminTaxes extends AdminTab public function displayForm($isMainTab = true) { - $context = Context::getContext(); parent::displayForm(); if (!($obj = $this->loadObject(true))) return; $zones = Zone::getZones(true); - $states = State::getStates($context->language->id); + $states = State::getStates($this->context->language->id); echo '
diff --git a/admin-dev/tabs/AdminTracking.php b/admin-dev/tabs/AdminTracking.php index 532d101b6..4e9eb4a23 100644 --- a/admin-dev/tabs/AdminTracking.php +++ b/admin-dev/tabs/AdminTracking.php @@ -50,7 +50,6 @@ class AdminTracking extends AdminTab public function getObjects($type) { - $context = Context::getContext(); switch ($type) { case 'categories_empty': @@ -96,10 +95,10 @@ class AdminTracking extends AdminTab LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` - LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$context->language->id.') - LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$context->language->id.') + LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$this->context->language->id.') + LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$context->language->id.') + LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$this->context->language->id.') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (p.`id_manufacturer` = m.`id_manufacturer`) WHERE pa.quantity <= 0 ORDER BY pa.`id_product_attribute` @@ -130,7 +129,6 @@ class AdminTracking extends AdminTab public function displayProducts() { - $context = Context::getContext(); if (isset($this->_list['obj'])) { $nbProducts = sizeof($this->_list['obj']); @@ -159,7 +157,7 @@ class AdminTracking extends AdminTab foreach ($this->_list['obj'] AS $k => $prod) { $product = new Product((int)($prod['id_product'])); - $product->name = $product->name[(int)$context->language->id]; + $product->name = $product->name[(int)$this->context->language->id]; $taxrate = Tax::getProductTaxRate($product->id); echo ' @@ -167,16 +165,16 @@ class AdminTracking extends AdminTab '.$product->id.' '.($product->manufacturer_name != NULL ? stripslashes($product->manufacturer_name) : '--').' '.$product->reference.' - '.stripslashes($product->name).' - '.Tools::displayPrice($product->getPrice(), $context->currency).' + '.stripslashes($product->name).' + '.Tools::displayPrice($product->getPrice(), $this->context->currency).' '.(float)$taxrate.'% '.$product->quantity.' '.$product->weight.' '.Configuration::get('PS_WEIGHT_UNIT').' - + - + '.$this->l('Modify this product').'  - name)).' ?\');"> + name)).' ?\');"> '.$this->l('Delete this product').' '; @@ -187,7 +185,6 @@ class AdminTracking extends AdminTab public function displayAttributes() { - $context = Context::getContext(); if (isset($this->_list['obj'])) { @@ -238,16 +235,16 @@ class AdminTracking extends AdminTab '.$prod['id_product'].' '.($prod['manufacturer_name'] != NULL ? stripslashes($prod['manufacturer_name']) : '--').' '.$prod['reference'].' - '.stripslashes($prod['name']).' ('.$prod['combination_name'].')'.' - '.Tools::displayPrice(Product::getPriceStatic((int)($prod['id_product']), true, $prod['id_product_attribute']), $context->currency).' + '.stripslashes($prod['name']).' ('.$prod['combination_name'].')'.' + '.Tools::displayPrice(Product::getPriceStatic((int)($prod['id_product']), true, $prod['id_product_attribute']), $this->context->currency).' '.(float)$taxrate.'% '.$prod['quantity'].' '.($prod['weight'] + $prod['product_weight']).' '.Configuration::get('PS_WEIGHT_UNIT').' - + - + '.$this->l('Modify this product').'  - + '.$this->l('Delete this product').' '; diff --git a/admin-dev/tabs/AdminTranslations.php b/admin-dev/tabs/AdminTranslations.php index 939bd3c0a..ee2c9a900 100644 --- a/admin-dev/tabs/AdminTranslations.php +++ b/admin-dev/tabs/AdminTranslations.php @@ -671,7 +671,6 @@ class AdminTranslations extends AdminTab } public function display() { - $context = Context::getContext(); $translations = array( 'front' => $this->l('Front Office translations'), 'back' => $this->l('Back Office translations'), @@ -780,7 +779,7 @@ class AdminTranslations extends AdminTab
'.$this->l('Copy').'

'.$this->l('Copies data from one language to another.').'
'. $this->l('Be careful, as it will replace all existing data for the destination language!').'
'. - $this->l('If necessary').', '.$this->l('first create a new language').'.

+ $this->l('If necessary').', '.$this->l('first create a new language').'.

'.$this->l('From:').'
diff --git a/admin-dev/tabs/AdminWebservice.php b/admin-dev/tabs/AdminWebservice.php index bfef21577..29fe34ded 100755 --- a/admin-dev/tabs/AdminWebservice.php +++ b/admin-dev/tabs/AdminWebservice.php @@ -234,7 +234,6 @@ echo ' public function display() { - $context = Context::getContext(); // Include other tab in current tab if ($this->includeSubTab('display', array('submitAdd2', 'add', 'update', 'view'))){} @@ -252,7 +251,7 @@ echo ' } elseif (isset($_GET['update'.$this->table])) { - if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $context->employee->id == Tools::getValue('id_employee'))) + if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee'))) { $this->displayForm(); if ($this->tabAccess['view']) @@ -268,7 +267,7 @@ echo ' { $this->checkForWarning(); - $this->getList($context->language->id); + $this->getList($this->context->language->id); $this->displayList(); $this->displayRequiredFields(); diff --git a/classes/AdminTab.php b/classes/AdminTab.php index 99b960d9b..1edfd422e 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -176,7 +176,7 @@ abstract class AdminTabCore public function __construct() { - $context = Context::getContext(); + $this->context = Context::getContext(); $this->id = Tab::getCurrentTabId(); $this->_conf = array( @@ -198,7 +198,7 @@ abstract class AdminTabCore $className = get_class($this); if ($className == 'AdminCategories' OR $className == 'AdminProducts') $className = 'AdminCatalog'; - $this->token = Tools::getAdminToken($className.(int)$this->id.(int)$context->employee->id); + $this->token = Tools::getAdminToken($className.(int)$this->id.(int)$this->context->employee->id); if (!Tools::isMultiShopActivated()) $this->shopLinkType = ''; @@ -247,7 +247,6 @@ abstract class AdminTabCore */ public function display() { - $context = Context::getContext(); // Include other tab in current tab if ($this->includeSubTab('display', array('submitAdd2', 'add', 'update', 'view'))){} @@ -265,7 +264,7 @@ abstract class AdminTabCore } elseif (isset($_GET['update'.$this->table])) { - if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $context->employee->id == Tools::getValue('id_employee'))) + if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee'))) { $this->displayForm(); if ($this->tabAccess['view']) @@ -279,7 +278,7 @@ abstract class AdminTabCore else { - $this->getList($context->language->id); + $this->getList($this->context->language->id); $this->displayList(); $this->displayOptionsList(); $this->displayRequiredFields(); @@ -543,7 +542,6 @@ abstract class AdminTabCore // set token $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; - $context = Context::getContext(); // Sub included tab postProcessing $this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset')); @@ -669,7 +667,7 @@ abstract class AdminTabCore /* Object update */ if (isset($id) AND !empty($id)) { - if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $context->employee->id == Tools::getValue('id_employee') AND Tools::isSubmit('updateemployee'))) + if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $this->context->employee->id == Tools::getValue('id_employee') AND Tools::isSubmit('updateemployee'))) { $object = new $this->className($id); if (Validate::isLoadedObject($object)) @@ -766,7 +764,7 @@ abstract class AdminTabCore /* Cancel all filters for this tab */ elseif (isset($_POST['submitReset'.$this->table])) { - $filters = $context->cookie->getFamily($this->table.'Filter_'); + $filters = $this->context->cookie->getFamily($this->table.'Filter_'); foreach ($filters AS $cookieKey => $filter) if (strncmp($cookieKey, $this->table.'Filter_', 7 + Tools::strlen($this->table)) == 0) { @@ -775,14 +773,14 @@ abstract class AdminTabCore $tmpTab = explode('!', $key); $key = (count($tmpTab) > 1 ? $tmpTab[1] : $tmpTab[0]); if (array_key_exists($key, $this->fieldsDisplay)) - unset($context->cookie->$cookieKey); + unset($this->context->cookie->$cookieKey); } - if (isset($context->cookie->{'submitFilter'.$this->table})) - unset($context->cookie->{'submitFilter'.$this->table}); - if (isset($context->cookie->{$this->table.'Orderby'})) - unset($context->cookie->{$this->table.'Orderby'}); - if (isset($context->cookie->{$this->table.'Orderway'})) - unset($context->cookie->{$this->table.'Orderway'}); + if (isset($this->context->cookie->{'submitFilter'.$this->table})) + unset($this->context->cookie->{'submitFilter'.$this->table}); + if (isset($this->context->cookie->{$this->table.'Orderby'})) + unset($this->context->cookie->{$this->table.'Orderby'}); + if (isset($this->context->cookie->{$this->table.'Orderway'})) + unset($this->context->cookie->{$this->table.'Orderway'}); unset($_POST); } @@ -793,9 +791,9 @@ abstract class AdminTabCore } /* Manage list filtering */ - elseif (Tools::isSubmit('submitFilter'.$this->table) OR $context->cookie->{'submitFilter'.$this->table} !== false) + elseif (Tools::isSubmit('submitFilter'.$this->table) OR $this->context->cookie->{'submitFilter'.$this->table} !== false) { - $_POST = array_merge($context->cookie->getFamily($this->table.'Filter_'), (isset($_POST) ? $_POST : array())); + $_POST = array_merge($this->context->cookie->getFamily($this->table.'Filter_'), (isset($_POST) ? $_POST : array())); foreach ($_POST AS $key => $value) { /* Extracting filters from $_POST on key filter_ */ @@ -1151,22 +1149,21 @@ abstract class AdminTabCore */ public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false) { - $context = Context::getContext(); /* Manage default params values */ if (empty($limit)) - $limit = ((!isset($context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[1] : $limit = $context->cookie->{$this->table.'_pagination'}); + $limit = ((!isset($this->context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[1] : $limit = $this->context->cookie->{$this->table.'_pagination'}); if (!Validate::isTableOrIdentifier($this->table)) die (Tools::displayError('Table name is invalid:').' "'.$this->table.'"'); if (empty($orderBy)) - $orderBy = $context->cookie->__get($this->table.'Orderby') ? $context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy; + $orderBy = $this->context->cookie->__get($this->table.'Orderby') ? $this->context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy; if (empty($orderWay)) - $orderWay = $context->cookie->__get($this->table.'Orderway') ? $context->cookie->__get($this->table.'Orderway') : 'ASC'; + $orderWay = $this->context->cookie->__get($this->table.'Orderway') ? $this->context->cookie->__get($this->table.'Orderway') : 'ASC'; $limit = (int)(Tools::getValue('pagination', $limit)); - $context->cookie->{$this->table.'_pagination'} = $limit; + $this->context->cookie->{$this->table.'_pagination'} = $limit; /* Check params validity */ if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay) @@ -1197,14 +1194,14 @@ abstract class AdminTabCore $selectShop = ', shop.name as shop_name '; $joinShop = ' LEFT JOIN '._DB_PREFIX_.$this->shopLinkType.' shop ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType; - $whereShop = $context->shop->sqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType); + $whereShop = $this->context->shop->sqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType); } $assos = Shop::getAssoTables(); if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'shop') { $filterKey = $assos[$this->table]['type']; - $idenfierShop = $context->shop->getListOfID(); + $idenfierShop = $this->context->shop->getListOfID(); } else if (Context::shop() == Shop::CONTEXT_GROUP) { @@ -1212,7 +1209,7 @@ abstract class AdminTabCore if (isset($assos[$this->table]) AND $assos[$this->table]['type'] == 'group_shop') { $filterKey = $assos[$this->table]['type']; - $idenfierShop = array($context->shop->getGroupID()); + $idenfierShop = array($this->context->shop->getGroupID()); } } @@ -1269,7 +1266,6 @@ abstract class AdminTabCore */ public function displayListHeader($token = NULL) { - $context = Context::getContext(); $isCms = false; if (preg_match('/cms/Ui', $this->identifier)) $isCms = true; @@ -1279,7 +1275,7 @@ abstract class AdminTabCore $token = $this->token; /* Determine total page number */ - $totalPages = ceil($this->_listTotal / Tools::getValue('pagination', (isset($context->cookie->{$this->table.'_pagination'}) ? $context->cookie->{$this->table.'_pagination'} : $this->_pagination[0]))); + $totalPages = ceil($this->_listTotal / Tools::getValue('pagination', (isset($this->context->cookie->{$this->table.'_pagination'}) ? $this->context->cookie->{$this->table.'_pagination'} : $this->_pagination[0]))); if (!$totalPages) $totalPages = 1; echo ' '; @@ -1311,7 +1307,7 @@ abstract class AdminTabCore echo ' | '.$this->l('Display').'