From 2d77925e7dd67222621cd07d65c3dfe536d4224f Mon Sep 17 00:00:00 2001 From: rMalie Date: Tue, 12 Jul 2011 16:28:20 +0000 Subject: [PATCH] // Refactoring of shop class with new context --- admin-dev/index.php | 16 ++---- admin-dev/tabs/AdminCatalog.php | 2 +- admin-dev/tabs/AdminCategories.php | 7 +-- admin-dev/tabs/AdminImport.php | 23 ++++---- admin-dev/tabs/AdminModules.php | 17 +++--- admin-dev/tabs/AdminProducts.php | 6 +-- admin-dev/tabs/AdminStockMvt.php | 30 +++++------ classes/AdminTab.php | 2 +- classes/Cart.php | 2 +- classes/Category.php | 2 +- classes/Connection.php | 24 ++++----- classes/Context.php | 57 ++++++++++++++++++-- classes/Currency.php | 6 +-- classes/Customer.php | 4 +- classes/FrontController.php | 4 +- classes/ObjectModel.php | 10 ++-- classes/Page.php | 2 +- classes/PaymentModule.php | 2 +- classes/Product.php | 20 +++---- classes/ProductSale.php | 10 ++-- classes/Search.php | 7 ++- classes/Shop.php | 23 ++++---- classes/ShopUrl.php | 4 +- controllers/ManufacturerController.php | 2 +- controllers/SearchController.php | 4 +- modules/blockcategories/blockcategories.php | 58 ++++++++++----------- modules/blocklayered/blocklayered.php | 13 +++-- modules/paypal/express/submit.php | 44 ++++++++-------- 28 files changed, 216 insertions(+), 185 deletions(-) diff --git a/admin-dev/index.php b/admin-dev/index.php index 323fe58da..017cf08c4 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -78,18 +78,12 @@ if (empty($tab) and !sizeof($_POST)) { echo ' '.translate('You are currently view/configure your store for').' '; - if (Shop::getContextType() == Shop::CONTEXT_ALL) + if (Context::getContext()->shop->getContextType() == Shop::CONTEXT_ALL) echo 'all shops'; - elseif (Shop::getContextType() == Shop::CONTEXT_GROUP) - { - $group_shop = new GroupShop((int)Shop::getCurrentGroupShop()); - echo 'all shops of group shop '.$group_shop->name.''; - } - elseif (Shop::getContextType() == Shop::CONTEXT_SHOP) - { - $shop = new Shop((int)Shop::getCurrentShop()); - echo 'shop '.$shop->name.''; - } + elseif (Context::getContext()->shop->getContextType() == Shop::CONTEXT_GROUP) + echo 'all shops of group shop '.Context::getContext()->shop->getGroup()->name.''; + elseif (Context::getContext()->shop->getContextType() == Shop::CONTEXT_SHOP) + echo 'shop '.Context::getContext()->shop->name.''; echo '  '; } diff --git a/admin-dev/tabs/AdminCatalog.php b/admin-dev/tabs/AdminCatalog.php index b52508e10..6fb690cfb 100644 --- a/admin-dev/tabs/AdminCatalog.php +++ b/admin-dev/tabs/AdminCatalog.php @@ -176,7 +176,7 @@ class AdminCatalog extends AdminTab if (!$id_category) { $home = true; - $id_category = Context::getContext()->shop->id_category1; + $id_category = Context::getContext()->shop->id_category; } $catalog_tabs = array('category', 'product'); // Cleaning links diff --git a/admin-dev/tabs/AdminCategories.php b/admin-dev/tabs/AdminCategories.php index 9da265d9e..17fb64e7e 100644 --- a/admin-dev/tabs/AdminCategories.php +++ b/admin-dev/tabs/AdminCategories.php @@ -220,11 +220,8 @@ class AdminCategories extends AdminTab return; $active = $this->getFieldValue($obj, 'active'); $customer_groups = $obj->getGroups(); - if (Shop::getContextType() == Shop::CONTEXT_SHOP) - { - $shop = new Shop(Shop::getCurrentShop()); - $id_category = $shop->id_category; - } + if ($context->shop->getContextType() == Shop::CONTEXT_SHOP) + $id_category = $context->shop->id_category; else $id_category = (int)Tools::getValue('id_parent'); diff --git a/admin-dev/tabs/AdminImport.php b/admin-dev/tabs/AdminImport.php index ad1300473..c1d967647 100644 --- a/admin-dev/tabs/AdminImport.php +++ b/admin-dev/tabs/AdminImport.php @@ -589,7 +589,6 @@ class AdminImport extends AdminTab public function productImport() { - global $cookie; $this->receiveTab(); $handle = $this->openCsvFile(); $defaultLanguageId = (int)(Configuration::get('PS_LANG_DEFAULT')); @@ -788,7 +787,8 @@ class AdminImport extends AdminTab { $specificPrice = new SpecificPrice(); $specificPrice->id_product = (int)($product->id); - $specificPrice->id_shop = (int)(Shop::getCurrentShop()); + // @todo multishop specific price import + $specificPrice->id_shop = $context->shop->getID(); $specificPrice->id_currency = 0; $specificPrice->id_country = 0; $specificPrice->id_group = 0; @@ -849,7 +849,7 @@ class AdminImport extends AdminTab if (isset($product->image) AND is_array($product->image) and sizeof($product->image)) { - $productHasImages = (bool)Image::getImages((int)($cookie->id_lang), (int)($product->id)); + $productHasImages = (bool)Image::getImages($context->language->id, (int)($product->id)); foreach ($product->image AS $key => $url) if (!empty($url)) { @@ -1239,9 +1239,9 @@ class AdminImport extends AdminTab public function displayForm($isMainTab = true) { - global $currentIndex, $cookie; parent::displayForm(); + $context = Context::getContext(); if ((Tools::getValue('import')) AND (isset($this->_warnings) AND !sizeof($this->_warnings))) echo '
'.$this->l('The .CSV file has been imported into your shop.').'
'; @@ -1270,7 +1270,7 @@ class AdminImport extends AdminTab echo '
'.$this->l('Upload').' -
+

'.$this->l('You can also upload your file by FTP and put it in').' '.realpath(dirname(__FILE__).'/../import/').'. @@ -1295,7 +1295,7 @@ class AdminImport extends AdminTab { echo '
- +
'.$this->l('Import').' @@ -1321,7 +1321,7 @@ class AdminImport extends AdminTab
@@ -1360,7 +1360,7 @@ class AdminImport extends AdminTab