* @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.'/tabs/AdminFeaturesValues.php'); class AdminFeatures extends AdminTab { public function __construct() { $this->adminFeaturesValues = new AdminFeaturesValues(); $this->table = 'feature'; $this->className = 'Feature'; $this->lang = true; $this->edit = true; $this->delete = true; $this->fieldsDisplay = array( 'name' => array('title' => $this->l('Name'), 'width' => 128), 'value' => array('title' => $this->l('Values'), 'width' => 255, 'orderby' => false, 'search' => false)); parent::__construct(); } public function display() { global $currentIndex; if ((isset($_POST['submitAddfeature_value']) AND sizeof($this->adminFeaturesValues->_errors)) OR isset($_GET['updatefeature_value']) OR isset($_GET['addfeature_value'])) { $this->adminFeaturesValues->displayForm($this->token); echo '

'.$this->l('Back to the features list').'
'; } else parent::display(); } /* Report to AdminTab::displayList() for more details */ public function displayList() { global $currentIndex; echo '
'.$this->l('Add a new feature').'
'.$this->l('Add a new feature value').'

'.$this->l('Click on a feature name to view its values and then click again if you want to hide them.').'

'; $this->displayListHeader(); echo ''; if (!sizeof($this->_list)) echo ''.$this->l('No features 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 '

'.$this->l('Add a new feature').'

'.($obj->id ? '' : '').'
'.$this->l('Add a new feature').'
'; foreach ($this->_languages AS $language) echo '
* '.$this->l('Invalid characters:').' <>;=#{} 
'; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name'); echo '
* '.$this->l('Required field').'
'; } public function displayErrors() { $this->adminFeaturesValues->displayErrors(); parent::displayErrors(); } public function postProcess() { global $cookie, $currentIndex; $this->adminFeaturesValues->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id); $this->adminFeaturesValues->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(); } }