* @copyright PrestaShop * @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0 * @version 1.3 * */ include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); 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 list').'
'; } else parent::display(); } /* Report to AdminTab::displayList() for more details */ public function displayList() { global $currentIndex; echo '
'.$this->l('Add feature').'
'.$this->l('Add feature value').'

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

'; $this->displayListHeader(); echo ''; if (!sizeof($this->_list)) echo ''.$this->l('No features found.').''; $irow = 0; foreach ($this->_list AS $tr) { $id = intval($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(); $obj = $this->loadObject(true); echo '
'.($obj->id ? '' : '').'
'.$this->l('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(); } } ?>