bootstrap = true; parent::__construct(); } public function initPageHeaderToolbar() { parent::initPageHeaderToolbar(); $this->page_header_toolbar_btn['back_to_list'] = array( 'href' => $this->context->link->getAdminLink('AdminAdvConstructor'), 'desc' => $this->l('Retour à la liste de bloc', null, null, false), 'icon' => 'process-icon-back' ); if ($this->display != 'edit' && $this->display != 'add') { $this->page_header_toolbar_btn['back_to_choice'] = array( 'href' => $this->context->link->getAdminLink('AdminAdvConstructorPosition'), 'desc' => $this->l('Retour au choix du hook', null, null, false), 'icon' => 'process-icon-back' ); } } public function renderForm() { $context = Context::getContext(); $hooks_id = explode( ",", Configuration::get('ADVCONSTRUCTOR_HOOKS') ); $hooks = array(); foreach ($hooks_id as $hook_id) { $hook = new Hook($hook_id, $context->language->id); $hooks[] = array( 'id' => $hook->id, 'name' => $hook->name ); } $this->fields_form = array( 'multilang' => true, 'tinymce' => true, 'legend' => array( 'title' => $this->l('Choissisez le hook'), ), 'submit' => array( 'name' => 'submitHook', 'title' => $this->l('Changer les positions') ), 'input' => array( 'icon' => array( 'type' => 'select', 'label' => $this->l('Hook'), 'name' => 'hook', 'required' => FALSE, 'options' => array( 'query' => $hooks, 'id' => 'id', 'name' => 'name' ) ) ) ); return parent::renderForm(); } public function renderList() { $context = Context::getContext(); $this->table = 'advconstructor_hook'; $this->className = 'AdvConstructorHook'; $this->identifier = 'id_advconstructor_hook'; $this->lang = false; $this->deleted = false; $this->bootstrap = true; $this->explicitSelect = true; $this->context = Context::getContext(); $this->_defaultOrderBy = 'position'; $this->position_identifier = 'ID'; $this->_select = "a.`id_advconstructor`, c.`title` AS `NAME`"; $this->_where = ' AND a.`id_hook` = '.$this->_hook; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'advconstructor_lang` c ON (c.`id_advconstructor` = a.`id_advconstructor` AND c.`id_lang` = '.$context->language->id.') '; $this->fields_list = array( 'id_advconstructor_hook' => array( 'title' => $this->l('ID de la position'), 'align' => 'center', 'width' => 25 ), 'id_advconstructor' => array( 'title' => $this->l('ID du bloc'), 'align' => 'center', 'width' => 25 ), 'NAME' => array( 'title' => $this->l('Nom du bloc'), 'align' => 'center' ), 'position' => array( 'title' => $this->l('Position'), 'align' => 'center', 'position' => 'position', 'filter_key' => 'a!position' ) ); return parent::renderList(); } public function postProcess() { if ( Tools::isSubmit("submitHook") ) { $this->_step = 1; $this->_hook = Tools::getValue('hook'); $this->display = 'list'; } else { $this->display = 'add'; } return parent::postProcess(); } public function ajaxProcessUpdatePositions() { $way = (int)(Tools::getValue('way')); $id = (int)(Tools::getValue('id')); $positions = Tools::getValue('advconstructor_hook'); $page = (int)Tools::getValue('page'); $selected_pagination = (int)Tools::getValue('selected_pagination'); $obj = 'position hook'; if ( is_array($positions) ) { foreach ($positions as $position => $value) { $pos = explode('_', $value); if (isset($pos[2]) && (int)$pos[2] === $id) { $hook_position = new AdvConstructorHook((int)$pos[2]); if (isset($position) && $hook_position->updatePosition( $way, $position ) ) { die(true); } else { die('{"hasError" : true, errors : "Cannot update blocks position"}'); } } } } else { die('{"hasError" : true, errors : "Cannot update blocks position"}'); } } }