* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7541 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); include_once(PS_ADMIN_DIR.'/tabs/AdminAttributes.php'); class AdminAttributesGroups extends AdminTab { /** @var object AdminAttributes() instance */ private $adminAttributes; public function __construct() { $this->adminAttributes = new AdminAttributes(); $this->table = 'attribute_group'; $this->className = 'AttributeGroup'; $this->lang = true; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'name' => array('title' => $this->l('Name'), 'width' => 140), 'attribute' => array('title' => $this->l('Attributes'), 'width' => 240, 'orderby' => false, 'search' => false)); parent::__construct(); } public function display() { global $currentIndex; if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors)) OR isset($_GET['updateattribute']) OR isset($_GET['addattribute'])) { $this->adminAttributes->displayForm($this->token); echo '

'.$this->l('Back to list').'
'; } else parent::display(); } public function postProcess() { global $cookie, $currentIndex; $this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id); $this->adminAttributes->postProcess($this->token); if (Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') { if (isset($_POST[$this->table.'Box'])) { $object = new $this->className(); if ($object->deleteSelection($_POST[$this->table.'Box'])) Tools::redirectAdmin($currentIndex.'&conf=2'.'&token='.$this->token); $this->_errors[] = Tools::displayError('An error occurred while deleting selection.'); } else $this->_errors[] = Tools::displayError('You must select at least one element to delete.'); } else $this->_errors[] = Tools::displayError('You do not have permission to delete here.'); } else parent::postProcess(); } public function displayErrors() { $this->adminAttributes->displayErrors(); parent::displayErrors(); } /* Report to AdminTab::displayList() for more details */ public function displayList() { global $currentIndex, $cookie; echo '
'.$this->l('Add attributes group').'
'.$this->l('Add attribute').'

'.$this->l('Click on the group name to view its attributes. Click again to hide them.').'

'; if ($this->_list === false) Tools::displayError('No elements found'); $this->displayListHeader(); echo ''; if (!sizeof($this->_list)) echo ''.$this->l('No elements found').''; $irow = 0; foreach ($this->_list AS $tr) { $id = (int)($tr['id_'.$this->table]); echo ' '.$tr['name'].' '; echo ' '.$this->l('Edit').'  '.$this->l('Delete').' '; } $this->displayListFooter(); } public function displayForm($isMainTab = true) { global $currentIndex; parent::displayForm(); if (!($obj = $this->loadObject(true))) return; echo '
'.($obj->id ? '' : '').'
'.$this->l('Attributes group').'
'; foreach ($this->_languages as $language) echo '
* '.$this->l('Invalid characters:').' <>;=#{} 
'; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤public_name', 'name'); echo '
'; foreach ($this->_languages as $language) echo '
* '.$this->l('Invalid characters:').' <>;=#{} 

'.$this->l('Term or phrase displayed to the customer').'

'; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤public_name', 'public_name'); echo '
getFieldValue($obj, 'is_color_group') ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'is_color_group') ? 'checked="checked" ' : '').'/>

'.$this->l('This is a color group').'

* '.$this->l('Required field').'
'; } }