From ea67b720ecf36d5671f46b5adfab99a1746d79f9 Mon Sep 17 00:00:00 2001 From: rMalie Date: Thu, 15 Mar 2012 09:33:23 +0000 Subject: [PATCH] // Refacto generateShopList() --- admin-dev/functions.php | 44 -------------------------- admin-dev/header.inc.php | 2 +- classes/controller/AdminController.php | 2 +- classes/helper/Helper.php | 41 ++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 46 deletions(-) diff --git a/admin-dev/functions.php b/admin-dev/functions.php index 9a06203cd..56c7322ac 100644 --- a/admin-dev/functions.php +++ b/admin-dev/functions.php @@ -390,50 +390,6 @@ function simpleXMLToArray ($xml, $flattenValues = true, $flattenAttributes = tru return $return; } -/** - * Generate a sweet HTML list for shop selection - * - * @todo move in adminTab - * @return string - */ -function generateShopList() -{ - $tree = Shop::getTree(); - $context = Context::getContext(); - - // Get default value - if (Shop::getContext() == Shop::CONTEXT_ALL) - $value = ''; - else if (Shop::getContext() == Shop::CONTEXT_GROUP) - $value = 'g-'.Shop::getContextGroupShopID(); - else - $value = 's-'.Shop::getContextShopID(); - - // Generate HTML - $url = $_SERVER['REQUEST_URI'].(($_SERVER['QUERY_STRING']) ? '&' : '?').'setShopContext='; - $html = ''; - - return $html; -} - /** * for retrocompatibility with old AdminTab, old index.php * diff --git a/admin-dev/header.inc.php b/admin-dev/header.inc.php index 421348273..ade435b40 100644 --- a/admin-dev/header.inc.php +++ b/admin-dev/header.inc.php @@ -280,7 +280,7 @@ echo ' '; if (Shop::isFeatureActive()) - echo '
'.translate('Select your shop:').' '.generateShopList().'
'; + echo '
'.translate('Select your shop:').' '.Helper::renderShopList().'
'; echo ''; echo Hook::exec('displayBackOfficeTop'); diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 818938db9..1f28a2c7b 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1278,7 +1278,7 @@ class AdminControllerCore extends Controller 'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))), 'quick_access' => $quick_access, 'multi_shop' => Shop::isFeatureActive(), - 'shop_list' => (Shop::isFeatureActive() ? generateShopList() : null), //@TODO refacto + 'shop_list' => Helper::renderShopList(), 'shop' => $this->context->shop, 'group_shop' => $this->context->shop->getGroup(), 'tab' => $tab, diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index 4cd3c011a..588fecbc3 100755 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -350,5 +350,46 @@ class HelperCore return $tpl->fetch(); } + + public static function renderShopList() + { + if (!Shop::isFeatureActive()) + return null; + + $tree = Shop::getTree(); + $context = Context::getContext(); + + // Get default value + if (Shop::getContext() == Shop::CONTEXT_ALL) + $value = ''; + else if (Shop::getContext() == Shop::CONTEXT_GROUP) + $value = 'g-'.Shop::getContextGroupShopID(); + else + $value = 's-'.Shop::getContextShopID(); + + // Generate HTML + $url = $_SERVER['REQUEST_URI'].(($_SERVER['QUERY_STRING']) ? '&' : '?').'setShopContext='; + $html = ''; + + return $html; + } }