* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7465 $ * @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'); class AdminAttributes extends AdminTab { public function __construct() { $this->table = 'attribute'; $this->className = 'Attribute'; $this->lang = true; $this->edit = true; $this->delete = true; $this->fieldImageSettings = array('name' => 'texture', 'dir' => 'co'); parent::__construct(); } /** * Display form */ public function displayForm($token = NULL) { if (!Combination::isFeatureActive()) { $this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' '.$this->l('Performances').''); return; } parent::displayForm(); if (!($obj = $this->loadObject(true))) return; $color = ($obj->color ? $obj->color : 0); $attributes_groups = AttributeGroup::getAttributesGroups($this->_defaultFormLanguage); $strAttributesGroups = ''; echo '
'.($obj->id ? '' : '').'
'.$this->l('Attribute').'
'; foreach ($this->_languages as $language) echo '
* '.$this->l('Invalid characters:').' <>;=#{} 
'; echo ' '; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true); echo '
*
'; if (Shop::isMultiShopActivated()) { echo '
'; $this->displayAssoShop('group_shop'); echo '
'; } echo '
*

'.$this->l('HTML colors only (e.g.,').' "lightblue", "#CC6600")

'.$this->l('Upload color texture from your computer').'
'.$this->l('This will override the HTML color!').'

'.(file_exists(_PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.$obj->id.'.jpg') ? ' '.$this->l('delete').'' : $this->l('None') ).'

'.Module::hookExec('attributeForm', array('id_attribute' => $obj->id)).'
* '.$this->l('Required field').'
'; } /** * Manage page processing */ public function postProcess($token = NULL) { if (!Combination::isFeatureActive()) return; Module::hookExec('postProcessAttribute', array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessFeatureValue to stop saving process if (Tools::getValue('submitDel'.$this->table)) { if ($this->tabAccess['delete'] === '1') { if (isset($_POST[$this->table.$_POST['groupid'].'Box'])) { $object = new $this->className(); if ($object->deleteSelection($_POST[$this->table.$_POST['groupid'].'Box'])) Tools::redirectAdmin(self::$currentIndex.'&conf=2'.'&token='.($token ? $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.'); } elseif (Tools::isSubmit('submitAdd'.$this->table)) { $id_attribute = (int)Tools::getValue('id_attribute'); // Adding last position to the attribute if not exist if ($id_attribute <= 0) { $sql = 'SELECT `position`+1 FROM `'._DB_PREFIX_.'attribute` WHERE id_attribute_group = '.(int)Tools::getValue('id_attribute_group').' ORDER BY position DESC'; // set the position of the new attribute in $_POST for postProcess() method $_POST['position'] = DB::getInstance()->getValue($sql); } // clean \n\r characters foreach ($_POST as $key => $value) if (stripos($key, 'name_') !== false) $_POST[$key] = str_replace ('\n', '', str_replace('\r', '', $value)); parent::postProcess(); } else parent::postProcess(); } }