Example #1
0
    /**
     * show megamenu item configuration.
     */
    protected function showFormSetting()
    {
        $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/admin/jquery.nestable.js');
        $this->context->controller->addJS(__PS_BASE_URI__ . 'modules/leobootstrapmenu/assets/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/leobootstrapmenu/assets/admin/form.css');
        //		$action_widget = $this->base_config_url.'&widgets=1';
        $this->widget->loadEngines();
        //		$widget = $this->widget;
        $id_lang = $this->context->language->id;
        $id_btmegamenu = (int) Tools::getValue('id_btmegamenu');
        $obj = new Btmegamenu($id_btmegamenu);
        $tree = $obj->getTree();
        $categories = LeoBtmegamenuHelper::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')));
        $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_btmegamenu', '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', 'required' => true, 'lang' => true, 'class' => 'url-type-group-lang', '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', 'desc' => $this->l('This menu is only for display content,PLease do not select it for menu level 1'), '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', 'label' => $this->l('Or Menu Icon Image'), 'name' => 'image', 'display_image' => true, 'default' => '', 'desc' => $this->l('Use image icon if no use con Class'), 'thumb' => '', 'title' => $this->l('Icon Preview')), array('type' => 'switch', 'label' => $this->l('Group Submenu'), 'name' => 'is_group', 'values' => $soption, 'default' => '0', 'desc' => $this->l('Group all sub menu to display in same level')), array('type' => 'text', 'label' => $this->l('Column'), 'name' => 'colums', 'values' => $soption, 'default' => '1', 'desc' => $this->l('Set each sub menu item as column'))), '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);
        $live_editor_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="' . $live_editor_url . '" class="btn btn-danger"> ' . $this->l('Live Edit Tools') . '</a> ' . $this->l('To Make Rich Content For Megamenu') . '</div></div></div>';
        $output = $html . '
                 <ul class="nav nav-tabs clearfix">
                  <li class="active"><a href="#megamenu" data-toggle="tab">' . $this->l('Megamenu') . '</a></li>
                </ul>

 
            <div class="tab-content clearfix">
              <div class="tab-pane active" id="megamenu">
        ';
        $show_cavas = Configuration::get('LEO_MEGAMENU_CAVAS');
        $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">' . $this->l('To sort orders or update parent-child, you drap and drop expected menu, then click to Update button to Save') . '<hr><p><input type="button" value="' . $this->l('New Menu Item') . '" id="addcategory" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-danger" name="addcategory">
					<a   href="' . Context::getContext()->link->getAdminLink('AdminLeotempcpWidgets') . '" class="leo-modal-action btn btn-modeal btn-success btn-info">' . $this->l('List Widget') . '</a></p>
					<hr><p><input type="button" value="' . $this->l('Update') . '" id="show_cavas" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-info" ></p>
						<label>' . $this->l('Show Cavas') . '</label>
						<select name="show_cavas" class="show_cavas">
							<option value="1" ' . (isset($show_cavas) && $show_cavas == 1 ? 'checked' : null) . '>' . $this->l('Yes') . '</option>
							<option value="0" ' . (isset($show_cavas) && $show_cavas == 0 ? 'checked' : null) . '>' . $this->l('No') . '</option>
						</select>
					<hr><p><input type="button" value="' . $this->l('Update Positions') . '" id="serialize" data-loading-text="' . $this->l('Processing ...') . '" class="btn btn-danger" name="serialize"></p><hr>' . $tree . '</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><script>$(\'#myTab a[href="#profile"]\').tab(\'show\')</script>';
        return $output;
    }
Example #2
0
 private function _displayForm()
 {
     $params = $this->params;
     $id_lang = $this->context->language->id;
     $id_btmegamenu = (int) Tools::getValue('id_btmegamenu');
     $obj = new Btmegamenu($id_btmegamenu);
     $tree = $obj->getTree();
     $categories = LeoBtmegamenuHelper::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);
     require_once dirname(__FILE__) . '/form.php';
 }