diff --git a/admin-dev/themes/template/categories/list_header.tpl b/admin-dev/themes/template/categories/list_header.tpl index db3bc3595..323aa785b 100644 --- a/admin-dev/themes/template/categories/list_header.tpl +++ b/admin-dev/themes/template/categories/list_header.tpl @@ -1,13 +1,44 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + {extends file="helper/list/list_header.tpl"} + {block name=leadin}
{if count($categories_tree) == 0}   {l s='Home'} {else} -   {l s='Home'} >  +   {l s='Home'} >  {foreach $categories_tree key=key item=category} + {if $key == 0} {$category.name} + {else} + {$category.name} >  + {/if} {/foreach} {/if}
diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php index 85668d5e4..d3762774e 100644 --- a/controllers/admin/AdminCategoriesController.php +++ b/controllers/admin/AdminCategoriesController.php @@ -39,8 +39,6 @@ class AdminCategoriesControllerCore extends AdminController $this->lang = true; $this->deleted = false; - $this->requiredDatabase = true; - $this->context = Context::getContext(); $this->fieldImageSettings = array( @@ -114,13 +112,16 @@ class AdminCategoriesControllerCore extends AdminController public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) { parent::getList($id_lang, 'position', $order_way, $start, $limit, Context::getContext()->shop->getID(true)); - } + // Check each row to see if there are combinations and get the correct action in consequence - public function initContent() - { - if ($this->display == 'view') - $this->initView(); - parent::initContent(); + $nb_items = count($this->_list); + for ($i = 0; $i < $nb_items; $i++) + { + $item = &$this->_list[$i]; + $category_tree = Category::getChildren((int)$item['id_category'], $this->context->language->id); + if (!count($category_tree)) + $this->addRowActionSkipList('view', array($item['id_category'])); + } } public function initView() @@ -131,23 +132,31 @@ class AdminCategoriesControllerCore extends AdminController public function initToolbar() { - // $this->toolbar_title = stripslashes($this->_category->getName()); if (empty($this->display)) $this->toolbar_btn['new'] = array( 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, 'desc' => $this->l('Add new') ); - if (Tools::getValue('id_category')) + if (Tools::getValue('id_category') && !Tools::isSubmit('updatecategory')) + { $this->toolbar_btn['edit'] = array( 'href' => self::$currentIndex.'&update'.$this->table.'&id_category='.Tools::getValue('id_category').'&token='.$this->token, 'desc' => $this->l('Edit') ); + $back = Tools::safeOutput(Tools::getValue('back', '')); + if (empty($back)) + $back = self::$currentIndex.'&token='.$this->token; + $this->toolbar_btn['cancel'] = array( + 'href' => $back, + 'desc' => $this->l('Cancel') + ); + } if ($this->display == 'view') $this->toolbar_btn['new'] = array( 'href' => self::$currentIndex.'&add'.$this->table.'&id_parent='.Tools::getValue('id_category').'&token='.$this->token, 'desc' => $this->l('Add new') ); - parent::initToolbar(); + parent::initToolbar(); } public function initForm() @@ -155,7 +164,7 @@ class AdminCategoriesControllerCore extends AdminController $this->initToolbar(); $obj = $this->loadObject(true); $selected_cat = array(isset($obj->id_parent) ? $obj->id_parent : Tools::getValue('id_parent', 1)); - if (sizeof($selected_cat) > 0) + if (count($selected_cat) > 0) { if (isset($selected_cat[0])) $selected_cat = implode(',', $selected_cat); @@ -299,7 +308,6 @@ class AdminCategoriesControllerCore extends AdminController foreach ($groups as $group) $this->fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], (in_array($group['id_group'], $carrier_groups_ids))); - return parent::initForm(); } @@ -326,8 +334,10 @@ class AdminCategoriesControllerCore extends AdminController if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) { // check if request at least one object with noZeroObject - if (isset($object->noZeroObject) && count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) - $this->_errors[] = Tools::displayError('You need at least one object.').' '.$this->table.'
'.Tools::displayError('You cannot delete all of the items.'); + if (isset($object->noZeroObject) && + count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) + $this->_errors[] = Tools::displayError('You need at least one object.').' '. + $this->table.'
'.Tools::displayError('You cannot delete all of the items.'); else { if ($this->deleted) @@ -343,7 +353,8 @@ class AdminCategoriesControllerCore extends AdminController } } else - $this->_errors[] = Tools::displayError('An error occurred while deleting object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); + $this->_errors[] = Tools::displayError('An error occurred while deleting object.').' '. + $this->table.' '.Tools::displayError('(cannot load object)'); } else $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); @@ -353,11 +364,12 @@ class AdminCategoriesControllerCore extends AdminController if ($this->tabAccess['edit'] !== '1') $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); else if (!Validate::isLoadedObject($object = new Category((int)Tools::getValue($this->identifier, Tools::getValue('id_category_to_move', 1))))) - $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '.$this->table.' '.Tools::displayError('(cannot load object)'); - if (!$object->updatePosition((int)(Tools::getValue('way')), (int)Tools::getValue('position'))) + $this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' '. + $this->table.' '.Tools::displayError('(cannot load object)'); + if (!$object->updatePosition((int)Tools::getValue('way'), (int)Tools::getValue('position'))) $this->_errors[] = Tools::displayError('Failed to update the position.'); else - Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier, Tools::getValue('id_category_parent', 1)))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCategories')); + Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)Tools::getValue($this->identifier, Tools::getValue('id_category_parent', 1))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCategories')); } /* Delete multiple objects */ else if (Tools::getValue('submitDel'.$this->table)) @@ -390,11 +402,17 @@ class AdminCategoriesControllerCore extends AdminController protected function postImage($id) { $ret = parent::postImage($id); - if (($id_category = (int)Tools::getValue('id_category')) && isset($_FILES) && count($_FILES) && $_FILES['image']['name'] != null && file_exists(_PS_CAT_IMG_DIR_.$id_category.'.jpg')) + if (($id_category = (int)Tools::getValue('id_category')) && + isset($_FILES) && count($_FILES) && $_FILES['image']['name'] != null && + file_exists(_PS_CAT_IMG_DIR_.$id_category.'.jpg')) { $images_types = ImageType::getImagesTypes('categories'); foreach ($images_types as $k => $image_type) - imageResize(_PS_CAT_IMG_DIR_.$id_category.'.jpg', _PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($image_type['name']).'.jpg', (int)$image_type['width'], (int)$image_type['height']); + imageResize( + _PS_CAT_IMG_DIR_.$id_category.'.jpg', + _PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($image_type['name']).'.jpg', + (int)$image_type['width'], (int)$image_type['height'] + ); } return $ret; }