/** * show megamenu item configuration. */ protected function showFormSetting() { $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/psmegamenu/views/js/admin/jquery.nestable.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/psmegamenu/views/js/admin/form.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/plugins/jquery.cookie-plugin.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/ui/jquery.ui.tabs.min.js'); $this->context->controller->addCss(__PS_BASE_URI__ . 'js/jquery/ui/themes/base/jquery.ui.tabs.css'); $this->context->controller->addCss(__PS_BASE_URI__ . 'modules/psmegamenu/views/css/admin/form.css'); $this->widget->loadEngines(); $id_lang = $this->context->language->id; $id_psmegamenu = (int) Tools::getValue('id_psmegamenu'); $obj = new Psbtmegamenu($id_psmegamenu); $tree = $obj->getTree(); $categories = PsMegamenuHelper::getCategories(); $manufacturers = Manufacturer::getManufacturers(false, $id_lang, true); $suppliers = Supplier::getSuppliers(false, $id_lang, true); $cmss = CMS::listCms($this->context->language->id, false, true); $menus = $obj->getDropdown(null, $obj->id_parent); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))); $image_url = ''; if ($obj->image && is_file(_PSMEGAMENU_IMAGE_DIR_ . $obj->image)) { $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; $image_url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST']) . _PSMEGAMENU_IMAGE_URL_ . $obj->image; } $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('Create New MegaMenu Item.')), 'input' => array(array('type' => 'hidden', 'label' => $this->l('Megamenu ID'), 'name' => 'id_psmegamenu', 'default' => 0), array('type' => 'text', 'label' => $this->l('Title:'), 'name' => 'title', 'value' => true, 'lang' => true, 'default' => ''), array('type' => 'text', 'label' => $this->l('Sub Title:'), 'lang' => true, 'name' => 'text', 'cols' => 40, 'rows' => 10, 'default' => ''), array('type' => 'select', 'label' => $this->l('Parent ID'), 'name' => 'id_parent', 'options' => array('query' => $menus, 'id' => 'id', 'name' => 'title'), 'default' => 'url'), array('type' => 'switch', 'label' => $this->l('Is Active'), 'name' => 'active', 'values' => $soption, 'default' => '1'), array('type' => 'switch', 'label' => $this->l('Show Title'), 'name' => 'show_title', 'values' => $soption, 'default' => '1'), array('type' => 'select', 'label' => $this->l('Menu Type'), 'name' => 'type', 'id' => 'menu_type', 'desc' => $this->l('Select a menu link type and fill data for following input'), 'options' => array('query' => array(array('id' => 'url', 'name' => $this->l('Url')), array('id' => 'category', 'name' => $this->l('Category')), array('id' => 'product', 'name' => $this->l('Product')), array('id' => 'manufacture', 'name' => $this->l('Manufacture')), array('id' => 'supplier', 'name' => $this->l('Supplier')), array('id' => 'cms', 'name' => $this->l('Cms')), array('id' => 'html', 'name' => $this->l('Html'))), 'id' => 'id', 'name' => 'name'), 'default' => 'url'), array('type' => 'text', 'label' => $this->l('Product ID'), 'name' => 'product_type', 'id' => 'product_type', 'class' => 'menu-type-group', 'default' => ''), array('type' => 'select', 'label' => $this->l('CMS Type'), 'name' => 'cms_type', 'id' => 'cms_type', 'options' => array('query' => $cmss, 'id' => 'id_cms', 'name' => 'meta_title'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'text', 'label' => $this->l('URL'), 'name' => 'url', 'id' => 'url_type', 'class' => 'menu-type-group', 'default' => ''), array('type' => 'select', 'label' => $this->l('Category Type'), 'name' => 'category_type', 'id' => 'category_type', 'options' => array('query' => $categories, 'id' => 'id_category', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'select', 'label' => $this->l('Manufacture Type'), 'name' => 'manufacture_type', 'id' => 'manufacture_type', 'options' => array('query' => $manufacturers, 'id' => 'id_manufacturer', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'select', 'label' => $this->l('Supplier Type'), 'name' => 'supplier_type', 'id' => 'supplier_type', 'options' => array('query' => $suppliers, 'id' => 'id_supplier', 'name' => 'name'), 'default' => '', 'class' => 'menu-type-group'), array('type' => 'textarea', 'label' => $this->l('HTML Type'), 'name' => 'content_text', 'lang' => true, 'default' => '', 'autoload_rte' => true, 'class' => 'menu-type-group-lang'), array('type' => 'select', 'label' => $this->l('Target Open'), 'name' => 'target', 'options' => array('query' => array(array('id' => '_self', 'name' => $this->l('Self')), array('id' => '_blank', 'name' => $this->l('Blank')), array('id' => '_parent', 'name' => $this->l('Parent')), array('id' => '_top', 'name' => $this->l('Top'))), 'id' => 'id', 'name' => 'name'), 'default' => '_self'), array('type' => 'text', 'label' => $this->l('Menu Class'), 'name' => 'menu_class', 'display_image' => true, 'default' => ''), array('type' => 'text', 'label' => $this->l('Menu Icon Class'), 'name' => 'icon_class', 'display_image' => true, 'default' => '', 'desc' => $this->l('The module integrated with FontAwesome') . '.' . $this->l('Check list of icons and class name in here') . ' <a href="http://fontawesome.io/" target="_blank">http://fontawesome.io/</a> or your icon class'), array('type' => 'file_pts', 'label' => $this->l('Or Menu Icon Image'), 'name' => 'image', 'display_image' => true, 'default' => '', 'image' => $image_url, 'delete_url' => $this->base_config_url . '&delete_icon=1', 'title' => $this->l('Icon Preview')), array('type' => 'select', 'label' => $this->l('Sub Menu Type'), 'name' => 'type_submenu', 'options' => array('query' => array(array('id' => 'menu', 'name' => $this->l('Menu')), array('id' => 'html', 'name' => $this->l('HTML'))), 'id' => 'id', 'name' => 'name'), 'default' => 'menu', 'desc' => $this->l('Submenu will be showed if select option Menu')), array('type' => 'textarea', 'label' => $this->l('Sub Menu Content:'), 'name' => 'submenu_content_text', 'value' => true, 'lang' => true, 'default' => '', 'autoload_rte' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button btn btn-danger')); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); foreach (Language::getLanguages(false) as $lang) { $helper->languages[] = array('id_lang' => $lang['id_lang'], 'iso_code' => $lang['iso_code'], 'name' => $lang['name'], 'is_default' => $default_lang == $lang['id_lang'] ? 1 : 0); } $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->toolbar_scroll = true; $helper->title = $this->displayName; $helper->submit_action = 'save' . $this->name; $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($obj), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); $liveeditor_url = AdminController::$currentIndex . '&configure=' . $this->name . '&liveeditor=1&token=' . Tools::getAdminTokenLite('AdminModules'); $action = AdminController::$currentIndex . '&configure=' . $this->name . '&save' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'); $helper->toolbar_btn = array('back' => array('href' => AdminController::$currentIndex . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list'))); $html = $this->_html . '<div class="col-lg-12"> <div class="alert alert-info clearfix"> <div class="pull-right">Using <a href="' . $liveeditor_url . '" class="btn btn-danger"> ' . $this->l('Live Megamenu Editor') . '</a> ' . $this->l('To Make Rich Content For Megamenu') . '</div></div></div>'; $output = $html . ' <ul class="nav nav-tabs clearfix" id="myTab"> <li class="active"><a href="#megamenu" data-toggle="tab">' . $this->l('Megamenu') . '</a></li> <li><a href="#widgets" data-toggle="tab">' . $this->l('Widgets') . '</a></li> </ul> <div class="tab-content clearfix"> <div class="tab-pane active" id="megamenu"> '; $addnew = AdminController::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&configure=' . $this->name . '&tab_module=front_office_features&module_name=' . $this->name; $output .= '<div class="col-md-4"><div class="panel panel-default"><h3 class="panel-title">' . $this->l('Tree Megamenu Management') . '</h3> <div class="panel-content"><div class="alert alert-warning">' . $this->l('To sort orders or update parent-child, you drap and drop expected menu, then click to Update button to Save') . '</div> <hr> <p> <div class="pull-right"> <input type="button" value="' . $this->l('New Category') . '" id="addcategory" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-default " name="addcategory"> <a href="' . $liveeditor_url . '" class="btn btn-danger"> ' . $this->l('Editor') . '</a> </div> <input type="button" value="' . $this->l('Update Positions') . '" id="serialize" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-primary" name="serialize"></p><hr>' . $tree . '<p><input type="button" value="' . $this->l('Update Positions') . '" id="serialize-tree" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-primary" name="serialize"></p></div></div></div> <div class="col-md-8">' . $helper->generateForm($this->fields_form) . '</div> <script type="text/javascript">var addnew ="' . $addnew . '"; var action="' . $action . '"; $("#content").PavMegaMenuList({action:action,addnew:addnew});</script>'; $output .= '</div>'; $output .= '<div class="tab-pane" id="widgets"> <div> <p><a href="' . AdminController::$currentIndex . '& configure=' . $this->name . '&widgets=1&token=' . Tools::getAdminTokenLite('AdminModules') . '" class="btn btn-info pts-modal-action btn btn-modeal btn-success btn-action">' . $this->l('Create Widget') . '</a></p> </div>' . $this->widgetsList() . '</div>'; $output .= '</div><script>$(\'#myTab a[href="#profile"]\').tab(\'show\')</script>'; return $output; }