From c8acd7a824874d537acdceec0b71c8b96d396486 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Wed, 13 Jul 2011 16:35:06 +0000 Subject: [PATCH] // Context part 6 --- admin-dev/init.php | 1 + admin-dev/tabs/AdminAccess.php | 8 +- admin-dev/tabs/AdminAddresses.php | 20 +-- admin-dev/tabs/AdminAliases.php | 5 +- admin-dev/tabs/AdminAttachments.php | 3 - admin-dev/tabs/AdminAttributeGenerator.php | 20 +-- classes/AdminTab.php | 175 ++++++++------------- 7 files changed, 88 insertions(+), 144 deletions(-) diff --git a/admin-dev/init.php b/admin-dev/init.php index 139216cb6..4319eba40 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -93,5 +93,6 @@ $context->employee = $employee; $context->cookie = $cookie; $context->link = $link; $context->language = $language; +$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $context->country = new Country(Configuration::get('PS_COUNTRY_DEFAULT')); $context->shop = new Shop(Shop::getContext('shop', true)); \ No newline at end of file diff --git a/admin-dev/tabs/AdminAccess.php b/admin-dev/tabs/AdminAccess.php index 652a4f0cf..7bbc19bb9 100644 --- a/admin-dev/tabs/AdminAccess.php +++ b/admin-dev/tabs/AdminAccess.php @@ -63,13 +63,13 @@ class AdminAccess extends AdminTab public function displayForm($isMainTab = true) { - global $cookie, $currentIndex; + $context = Context::getContext(); parent::displayForm(); $currentProfile = (int)($this->getCurrentProfileId()); - $tabs = Tab::getTabs($cookie->id_lang); - $profiles = Profile::getProfiles((int)($cookie->id_lang)); - $accesses = Profile::getProfileAccesses((int)($currentProfile)); + $tabs = Tab::getTabs($context->language->id); + $profiles = Profile::getProfiles($context->language->id); + $accesses = Profile::getProfileAccesses($context->language->id); echo '
'.$this->l('Attributes generator').''. - $this->l('Add or modify attributes for product:').' '.$this->product->name[$cookie->id_lang].' + $this->l('Add or modify attributes for product:').' '.$this->product->name[$context->language->id].'

'; echo ' diff --git a/classes/AdminTab.php b/classes/AdminTab.php index c75010dc0..2964baff8 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -171,15 +171,9 @@ abstract class AdminTabCore public function __construct() { - global $cookie, $currentIndex; $context = Context::getContext(); $context->tab = $this; - /*$currentIndex = $_SERVER['SCRIPT_NAME'].($tab ? '?tab='.$tab : ''); - if ($back = Tools::getValue('back')) - $currentIndex .= '&back='.urlencode($back); - $this->currentIndex = $currentIndex;*/ - $this->id = Tab::getCurrentTabId(); $this->_conf = array( 1 => $this->l('Deletion successful'), 2 => $this->l('Selection successfully deleted'), @@ -200,7 +194,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)$cookie->id_employee); + $this->token = Tools::getAdminToken($className.(int)$this->id.(int)$context->employee->id); if (!Tools::isMultiShopActivated()) $this->shopLinkType = ''; @@ -238,13 +232,10 @@ abstract class AdminTabCore /** * Manage page display (form, list...) - * - * @global string $currentIndex Current URL in order to keep current Tab */ public function display() { - global $currentIndex, $cookie; - + $context = Context::getContext(); // Include other tab in current tab if ($this->includeSubTab('display', array('submitAdd2', 'add', 'update', 'view'))){} @@ -255,18 +246,18 @@ abstract class AdminTabCore { $this->displayForm(); if ($this->tabAccess['view']) - echo '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; + echo '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; } else echo $this->l('You do not have permission to add here'); } elseif (isset($_GET['update'.$this->table])) { - if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $cookie->id_employee == Tools::getValue('id_employee'))) + if ($this->tabAccess['edit'] === '1' OR ($this->table == 'employee' AND $context->employee->id == Tools::getValue('id_employee'))) { $this->displayForm(); if ($this->tabAccess['view']) - echo '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; + echo '

'.((Tools::getValue('back')) ? $this->l('Back') : $this->l('Back to list')).'
'; } else echo $this->l('You do not have permission to edit here'); @@ -276,7 +267,7 @@ abstract class AdminTabCore else { - $this->getList((int)$cookie->id_lang); + $this->getList($context->language->id); $this->displayList(); $this->displayOptionsList(); $this->displayRequiredFields(); @@ -291,7 +282,6 @@ abstract class AdminTabCore public function displayRequiredFields() { - global $currentIndex; if (!$this->tabAccess['add'] OR !$this->tabAccess['delete'] === '1' OR !$this->requiredDatabase) return; $rules = call_user_func_array(array($this->className, 'getValidationRules'), array($this->className)); @@ -303,7 +293,7 @@ abstract class AdminTabCore

'.$this->l('Set required fields for this section').'