* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminTabs extends AdminTab { public function __construct() { global $cookie; $this->table = 'tab'; $this->className = 'Tab'; $this->lang = true; $this->edit = true; $this->delete = true; $this->_select = '(SELECT stl.`name` FROM `'._DB_PREFIX_.'tab_lang` stl WHERE stl.`id_tab` = a.`id_parent` AND stl.`id_lang` = '.(int)($cookie->id_lang).' LIMIT 1) AS parent'; $this->fieldImageSettings = array('name' => 'icon', 'dir' => 't'); $this->imageType = 'gif'; $tabs = array(0 => $this->l('Home')); foreach (Tab::getTabs((int)$cookie->id_lang, 0) AS $tab) $tabs[$tab['id_tab']] = $tab['name']; $this->fieldsDisplay = array( 'id_tab' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 200), 'logo' => array('title' => $this->l('Icon'), 'align' => 'center', 'image' => 't', 'image_id' => 'class_name', 'orderby' => false, 'search' => false), 'parent' => array('title' => $this->l('Parent'), 'width' => 200, 'type' => 'select', 'select' => $tabs, 'filter_key' => 'a!id_parent'), 'module' => array('title' => $this->l('Module'))); parent::__construct(); } public function postProcess() { if (($id_tab = (int)(Tools::getValue('id_tab'))) AND ($direction = Tools::getValue('move')) AND Validate::isLoadedObject($tab = new Tab($id_tab))) { global $currentIndex; if ($tab->move($direction)) Tools::redirectAdmin($currentIndex.'&token='.$this->token); } else { if (!Tools::getValue('position')) $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent')); parent::postProcess(); } } private function _posTabs($name, $arrayTabs) { global $currentIndex; if (sizeof($arrayTabs) > 1) { echo ' '; for ($i = 0; $i < sizeof($arrayTabs); $i++) { $tab = $arrayTabs[$i]; echo ''; } echo '
'.stripslashes($tab['name']).'
'; if ($i) echo ' '; if ($i < sizeof($arrayTabs) - 1) echo '
'; } } public function displayList() { global $cookie, $currentIndex; parent::displayList(); $tabs = Tab::getTabs((int)$cookie->id_lang, 0); echo '

'.$this->l('Positions').'

'.$this->l('Level').' 1

'; $this->_posTabs($this->l('Main'), $tabs); echo '

'.$this->l('Level').' 2

'; foreach ($tabs AS $t) $this->_posTabs(stripslashes($t['name']), Tab::getTabs((int)$cookie->id_lang, $t['id_tab'])); } public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); if (!($obj = $this->loadObject(true))) return; echo '
'.($obj->id ? '' : '').' '.($obj->position ? '' : '').'
'.$this->l('Tabs').'
'; foreach ($this->_languages as $language) echo '
* '.$this->l('Invalid characters:').' <>;=#{} 
'; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name'); echo '
 
*
 
 
'.($obj->id ? ' /img/t/'.$obj->class_name.'.gif' : '').'

'.$this->l('Upload logo from your computer').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)

 
 
* '.$this->l('Required field').'
'; } public function afterImageUpload() { if (!($obj = $this->loadObject(true))) return; @rename(_PS_IMG_DIR_.'t/'.$obj->id.'.gif', _PS_IMG_DIR_.'t/'.$obj->class_name.'.gif'); } }