From 9169995adc64620a0449667fd7ac25e0ab0bdced Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 22 Jul 2013 17:35:59 +0200 Subject: [PATCH] // Small fixes and code cleaning --- classes/Product.php | 5 +++-- classes/controller/AdminController.php | 25 ++++++------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index eefa229e1..d0e6d40d8 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -868,12 +868,13 @@ class ProductCore extends ObjectModel AND cp.id_product = '.$this->id ); - foreach ($result as $categ_to_delete) - $this->deleteCategory($categ_to_delete['id_category']); // if none are found, it's an error if (!is_array($result)) return false; + foreach ($result as $categ_to_delete) + $this->deleteCategory($categ_to_delete['id_category']); + if (!$this->addToCategories($categories)) return false; diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 967e5a8bf..e85dc9cb8 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -1197,8 +1197,7 @@ class AdminControllerCore extends Controller $tpl_action = $this->tpl_folder.$this->display.'.tpl'; - // Check if action template has been override - + // Check if action template has been overriden foreach ($this->context->smarty->getTemplateDir() as $template_dir) if (file_exists($template_dir.DIRECTORY_SEPARATOR.$tpl_action) && $this->display != 'view' && $this->display != 'options') { @@ -1217,27 +1216,15 @@ class AdminControllerCore extends Controller $page = $this->content; if ($conf = Tools::getValue('conf')) - if ($this->json) - $this->context->smarty->assign('conf', Tools::jsonEncode($this->_conf[(int)$conf])); - else - $this->context->smarty->assign('conf', $this->_conf[(int)$conf]); - - $notifications_type = array('errors', 'warnings', 'informations', 'confirmations'); - foreach($notifications_type as $type) - if ($this->json) - $this->context->smarty->assign($type, Tools::jsonEncode(array_unique($this->$type))); - else - $this->context->smarty->assign($type, array_unique($this->$type)); + $this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]); - if ($this->json) - $this->context->smarty->assign('page', Tools::jsonEncode($page)); - else - $this->context->smarty->assign('page', $page); - + foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type) + $this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type)); + + $this->context->smarty->assign('page', $this->json ? Tools::jsonEncode($page) : $page); $this->smartyOutputContent($this->layout); } - /** * add a warning message to display at the top of the page *