public function renderForm($args, $data) { $options = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))); $orderby = array(array('order' => 'date_add', 'name' => $this->l('Date Add')), array('order' => 'date_upd', 'name' => $this->l('Date Update')), array('order' => 'name', 'name' => $this->l('Name')), array('order' => 'id_product', 'name' => $this->l('Product Id')), array('order' => 'price', 'name' => $this->l('Price'))); $orderway = array(array('orderway' => 'ASC', 'name' => $this->l('Ascending')), array('orderway' => 'DESC', 'name' => $this->l('Descending'))); $root = Category::getRootCategory(); $categories = array(); $helper = $this->getFormHelper(); $items = ''; $tab_edit = ''; if ($data['params'] && isset($data['params']['leotab']) && $data['params']['leotab']) { $tabs = $data['params']['leotab']; $items = $this->getTabs($tabs); if (Tools::getValue('id_tab')) { $id_tab = Tools::getValue('id_tab'); $tab_edit = $items[$id_tab] ? $items[$id_tab] : ''; $categories = $items[$id_tab]['categories'] ? $items[$id_tab]['categories'] : array(); } } $tree = new HelperTreeCategories('categories-tree', 'Categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Number of Items In Page'), 'name' => 'itemspage', 'default' => 3, 'desc' => $this->l('The maximum number of products in each page tab (default: 3).')), array('type' => 'text', 'label' => $this->l('Number of Columns In Page'), 'name' => 'columns', 'default' => 3, 'desc' => $this->l('The maximum number of products in each page tab (default: 3).')), array('type' => 'text', 'label' => $this->l('Number of products displayed In Tab'), 'name' => 'itemstab', 'default' => 6, 'desc' => $this->l('The maximum number of products in each tab (default: 6).')), array('type' => 'select', 'label' => $this->l('Order By:'), 'desc' => $this->l('The maximum number of products in each page (default: 3).'), 'name' => 'orderby', 'default' => 'date_add', 'options' => array('query' => $orderby, 'id' => 'order', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Order Way:'), 'desc' => $this->l('The maximum number of products in each page (default: 3).'), 'name' => 'orderway', 'default' => 'date_add', 'options' => array('query' => $orderway, 'id' => 'orderway', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000, 'desc' => $this->l('Enter Time(miniseconds) to play carousel. Value 0 to stop.')), array('type' => 'setting_tab', 'name' => 'setting_tab', 'lang' => true, 'tree' => $tree->render(), 'default' => '')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => (int) Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'text_title' => 'title_' . Context::getContext()->language->iso_code, 'path' => __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/img/icontab/', 'images' => LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . _THEME_NAME_ . '/img/icontab/'), 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'items' => $items, 'tab_edit' => $tab_edit); return $helper->generateForm($this->fields_form); }
public function renderForm($data) { $helper = $this->getFormHelper(); $types = array(); $types[] = array('value' => 'newest', 'text' => $this->l('Products Newest')); $types[] = array('value' => 'bestseller', 'text' => $this->l('Products Bestseller')); $types[] = array('value' => 'special', 'text' => $this->l('Products Special')); $types[] = array('value' => 'featured', 'text' => $this->l('Products Featured')); $types[] = array('value' => 'toprating', 'text' => $this->l('Products Top Rating')); $lists = array(array('value' => 'grid', 'text' => $this->l('Grid')), array('value' => 'list1', 'text' => $this->l('List 1')), array('value' => 'list2', 'text' => $this->l('List 2'))); $modes = array(array('value' => 'normal', 'text' => $this->l('Normal')), array('value' => 'carousel', 'text' => $this->l('Carousel'))); $this->fields_form[1]['form'] = array('input' => array(array('type' => 'categories_select', 'label' => $this->l('Categories:'), 'name' => 'categoryBox', 'default' => ''))); $values = $this->getConfigFieldsValues($data); $selected_cat = $values['categoryBox']; $categories = explode(',', $selected_cat); $root = Category::getRootCategory(); $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $category_tpl = $tree->render(); $key = time(); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Banner'), 'name' => 'banner_imagefile', 'class' => 'imageupload', 'default' => '', 'id' => 'banner_imagefile' . $key, 'desc' => 'Put image folder in the image folder ROOT_SHOP_DIR/img/'), array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'cols' => 40, 'rows' => 20, 'value' => true, 'lang' => true, 'default' => '', 'autoload_rte' => false, 'desc' => 'Enter HTML CODE in here'), array('type' => 'categories_select', 'label' => $this->l('Categories:'), 'name' => 'categoryBox', 'category_tree' => $category_tpl, 'default' => '1,2,3', 'desc' => $this->l('Categories only apply for Products List Type: Products Newest, Products Bestseller, Products Special, Products Top Rating, Products Most View')), array('type' => 'text', 'label' => $this->l('Limit'), 'name' => 'limit', 'default' => 6), array('type' => 'select', 'label' => $this->l('Products List Type'), 'name' => 'list_type', 'options' => array('query' => $types, 'id' => 'value', 'name' => 'text'), 'default' => 'newest', 'desc' => $this->l('Select a Product List Type')), array('type' => 'select', 'label' => $this->l('Display Mode'), 'name' => 'display_mode', 'options' => array('query' => $modes, 'id' => 'value', 'name' => 'text'), 'default' => 'carousel'), array('type' => 'text', 'label' => $this->l('Number Columns On Large Desktops.'), 'name' => 'columns', 'desc' => $this->l('The maximum column items in tab.'), 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Small Desktops'), 'name' => 'nbr_desktops', 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Tablets'), 'name' => 'nbr_tablets', 'default' => '2'), array('type' => 'text', 'label' => $this->l('Number Columns On Mobile'), 'name' => 'nbr_mobile', 'default' => '1'), array('type' => 'select', 'label' => $this->l('List Mode'), 'name' => 'list_mode', 'options' => array('query' => $lists, 'id' => 'value', 'name' => 'text'), 'default' => 'grid')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); $string = ' <script type="text/javascript"> $(".imageupload").WPO_Gallery({gallery:false}); </script> '; return '<div id="imageslist' . $key . '">' . $helper->generateForm($this->fields_form) . $string . '</div>'; }
public function renderForm($args, $data) { # validate module unset($args); // $options = array( // array( // 'id' => 'active_on', // 'value' => 1, // 'label' => $this->l('Enabled') // ), // array( // 'id' => 'active_off', // 'value' => 0, // 'label' => $this->l('Disabled') // ) // ); $orderby = array(array('order' => 'date_add', 'name' => $this->l('Date Add')), array('order' => 'date_upd', 'name' => $this->l('Date Update')), array('order' => 'name', 'name' => $this->l('Name')), array('order' => 'id_product', 'name' => $this->l('Product Id')), array('order' => 'price', 'name' => $this->l('Price'))); $orderway = array(array('orderway' => 'ASC', 'name' => $this->l('Ascending')), array('orderway' => 'DESC', 'name' => $this->l('Descending'))); $root = Category::getRootCategory(); $categories = array(); $helper = $this->getFormHelper(); $items = ''; $tab_edit = ''; if ($data['params'] && isset($data['params']['leotab']) && $data['params']['leotab']) { $tabs = $data['params']['leotab']; $items = $this->getTabs($tabs); if (Tools::getValue('id_tab')) { $id_tab = Tools::getValue('id_tab'); $tab_edit = $items[$id_tab] ? $items[$id_tab] : ''; $categories = $items[$id_tab]['categories'] ? $items[$id_tab]['categories'] : array(); } } $tree = new HelperTreeCategories('categories-tree', 'Categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); // Add library owl carousel $owl_carousel = new LeomanagewidgetsOwlCarousel(); $arrays = $owl_carousel->getOwlCarouselAdminFormOptions(); foreach ($arrays as $key => $array) { # validate module unset($key); $this->fields_form[1]['form']['input'][] = $array; } $this->fields_form[1]['form']['input'][] = array('type' => 'setting_tab', 'name' => 'setting_tab', 'lang' => true, 'tree' => $tree->render(), 'default' => ''); $theme_dir = Context::getContext()->shop->theme_directory; $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => (int) Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'text_title' => 'title_' . Context::getContext()->language->iso_code, 'path' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/icontab/', 'images' => LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/icontab/'), 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'items' => $items, 'tab_edit' => $tab_edit); return $helper->generateForm($this->fields_form); }
public function renderForm($data) { $helper = $this->getFormHelper(); $soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled', 'producttabs')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled', 'producttabs'))); $lists = array(array('value' => 'grid', 'text' => $this->l('Grid')), array('value' => 'list1', 'text' => $this->l('List 1')), array('value' => 'list2', 'text' => $this->l('List 2'))); $modes = array(array('value' => 'normal', 'text' => $this->l('Normal')), array('value' => 'carousel', 'text' => $this->l('Carousel'))); $this->fields_form[1]['form'] = array('input' => array(array('type' => 'categories_select', 'label' => $this->l('Categories:'), 'name' => 'categoryBox', 'default' => ''))); $values = $this->getConfigFieldsValues($data); $selected_cat = $values['categoryBox']; $categories = explode(',', $selected_cat); $root = Category::getRootCategory(); $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $category_tpl = $tree->render(); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.', 'producttabs')), 'input' => array(array('type' => 'text', 'label' => $this->l('Sub Title.'), 'name' => 'sub_title', 'desc' => $this->l('Display Sub Title.'), 'default' => '', 'lang' => true), array('type' => 'categories_select', 'label' => $this->l('Categories:', 'producttabs'), 'name' => 'categoryBox', 'category_tree' => $category_tpl, 'default' => '1,2,3', 'desc' => $this->l('Categories only apply for Products List Type: Products Newest, Products Bestseller, Products Special, Products Top Rating, Products Most View', 'producttabs')), array('type' => 'text', 'label' => $this->l('Limit', 'producttabs'), 'name' => 'limit', 'default' => 6), array('type' => 'select', 'label' => $this->l('Display Mode'), 'name' => 'display_mode', 'options' => array('query' => $modes, 'id' => 'value', 'name' => 'text'), 'default' => 'carousel'), array('type' => 'text', 'label' => $this->l('Number Columns On Large Desktops.'), 'name' => 'columns', 'desc' => $this->l('The maximum column items in tab.'), 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Small Desktops'), 'name' => 'nbr_desktops', 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Tablets'), 'name' => 'nbr_tablets', 'default' => '2'), array('type' => 'text', 'label' => $this->l('Number Columns On Mobile'), 'name' => 'nbr_mobile', 'default' => '1'), array('type' => 'select', 'label' => $this->l('List Mode'), 'name' => 'list_mode', 'options' => array('query' => $lists, 'id' => 'value', 'name' => 'text'), 'default' => 'grid'), array('type' => 'switch', 'label' => $this->l('Enable Newest', 'producttabs'), 'name' => 'enable_newest', 'values' => $soption, 'default' => '1', 'desc' => $this->l('Whethere to display Newest Products', 'producttabs')), array('type' => 'switch', 'label' => $this->l('Enable Featured', 'producttabs'), 'name' => 'enable_featured', 'values' => $soption, 'default' => '0', 'desc' => $this->l('Whethere to display featured Products', 'producttabs')), array('type' => 'switch', 'label' => $this->l('Enable Bestseller', 'producttabs'), 'name' => 'enable_bestseller', 'values' => $soption, 'default' => '1', 'desc' => $this->l('Whethere to display Bestseller Products', 'producttabs')), array('type' => 'switch', 'label' => $this->l('Enable Special', 'producttabs'), 'name' => 'enable_special', 'values' => $soption, 'default' => '1', 'desc' => $this->l('Whethere to display Special Products', 'producttabs')), array('type' => 'switch', 'label' => $this->l('Enable Top Rating', 'producttabs'), 'name' => 'enable_toprating', 'values' => $soption, 'default' => '1', 'desc' => $this->l('Whethere to display Top Rating Products', 'producttabs'))), 'submit' => array('title' => $this->l('Save', 'producttabs'), 'class' => 'button')); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
public function renderForm($args, $data) { # validate module unset($args); $helper = $this->getFormHelper(); $root = Category::getRootCategory(); $selected_cat = array(); $selected_cates = ''; $selected_images = ''; $themeName = Context::getContext()->shop->getTheme(); $image_path = 'themes/' . $themeName . '/img/icontab/'; $imageList = $this->getImages($image_path); if ($data) { if ($data['params'] && isset($data['params']['categoryBox']) && $data['params']['categoryBox']) { $selected_cat = $data['params']['categoryBox']; } if ($data['params'] && isset($data['params']['category_img']) && $data['params']['category_img']) { //$selected_images = Tools::jsonDecode($data['params']['category_val'],true); $selected_images = $data['params']['category_img']; } if ($data['params'] && isset($data['params']['selected_cates']) && $data['params']['selected_cates']) { $selected_cates = $data['params']['selected_cates']; } } // $cate = new Category(13); // $result = $cate-> getParentsCategories(); // echo "<pre>";print_r($result);die; $tree = new HelperTreeCategories('image_cate_tree', 'All Categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($selected_cat); // $list_image = array('default.gif', 'leo.gif'); $orderby = array(array('order' => 'position', 'name' => $this->l('Position')), array('order' => 'depth', 'name' => $this->l('Depth')), array('order' => 'name', 'name' => $this->l('Name'))); $showicons = array(array('show' => '1', 'name' => $this->l('Yes')), array('show' => '2', 'name' => $this->l('Level 1 categories')), array('show' => '0', 'name' => $this->l('No'))); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'img_cat', 'name' => 'img_cat', 'imageList' => $imageList, 'selected_images' => $selected_images, 'selected_cates' => $selected_cates, 'lang' => true, 'tree' => $tree->render(), 'default' => ''), array('type' => 'text', 'label' => $this->l('Depth'), 'name' => 'cate_depth', 'default' => '1'), array('type' => 'select', 'label' => $this->l('Order By:'), 'name' => 'orderby', 'default' => 'position', 'options' => array('query' => $orderby, 'id' => 'order', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Show icons:'), 'name' => 'showicons', 'default' => '1', 'options' => array('query' => $showicons, 'id' => 'show', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Limit'), 'name' => 'limit', 'default' => '5'), array('type' => 'hidden', 'name' => 'id_root', 'default' => '2'), array('type' => 'hidden', 'name' => 'id_lang', 'default' => '1')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right sub_categories', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right sub_categories', 'type' => 'submit', 'name' => 'saveleotempcp'))); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $data_form = $this->getConfigFieldsValues($data); $data_form['id_root'] = $root->id; $data_form['id_lang'] = Context::getContext()->employee->id_lang; //echo "<pre>";print_r($data);die; $helper->tpl_vars = array('fields_value' => $data_form, 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
public function renderForm($data) { $helper = $this->getFormHelper(); $lists = array(array('value' => 'grid', 'text' => $this->l('Grid')), array('value' => 'list1', 'text' => $this->l('List 1')), array('value' => 'list2', 'text' => $this->l('List 2'))); $modes = array(array('value' => 'normal', 'text' => $this->l('Normal')), array('value' => 'carousel', 'text' => $this->l('Carousel'))); $this->fields_form[1]['form'] = array('input' => array(array('type' => 'category_tab', 'label' => 'Categories', 'name' => 'categorytab', 'default' => ''), array('type' => 'categoryBox', 'label' => 'Categories', 'name' => 'categoryBox', 'default' => ''))); $values = $this->getConfigFieldsValues($data); $selected_cat = $values['categoryBox']; $categories = explode(',', $selected_cat); $root = Category::getRootCategory(); $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $category_tpl = $tree->render(); $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[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'category_tab', 'label' => $this->l('Categories'), 'name' => 'categorytab', 'category_tpl' => $category_tpl, 'default' => ''), array('type' => 'categoryBox', 'label' => '', 'name' => 'categoryBox', 'default' => ''), array('type' => 'switch', 'label' => $this->l('Show Image'), 'name' => 'show_image', 'values' => $soption, 'default' => '1'), array('type' => 'switch', 'label' => $this->l('Show Category Title'), 'name' => 'show_cat_title', 'values' => $soption, 'default' => '1'), array('type' => 'switch', 'label' => $this->l('Show Category Description'), 'name' => 'show_description', 'values' => $soption, 'default' => '0'), array('type' => 'text', 'label' => $this->l('Category Description Limit'), 'name' => 'limit_description', 'default' => 25), array('type' => 'switch', 'label' => $this->l('Show Sub Categories'), 'name' => 'show_sub_category', 'values' => $soption, 'default' => '0'), array('type' => 'text', 'label' => $this->l('Sub Category Limit'), 'name' => 'limit_subcategory', 'default' => 5), array('type' => 'switch', 'label' => $this->l('Show Product Number'), 'name' => 'show_nb_product', 'values' => $soption, 'default' => '0'), array('type' => 'switch', 'label' => $this->l('Show Products List'), 'name' => 'show_products', 'values' => $soption, 'default' => '0'), array('type' => 'text', 'label' => $this->l('Limit'), 'name' => 'limit', 'default' => 6), array('type' => 'text', 'label' => $this->l('Number Columns On Large Desktops.'), 'name' => 'columns', 'desc' => $this->l('The maximum column items in tab.'), 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Small Desktops'), 'name' => 'nbr_desktops', 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Tablets'), 'name' => 'nbr_tablets', 'default' => '2'), array('type' => 'text', 'label' => $this->l('Number Columns On Mobile'), 'name' => 'nbr_mobile', 'default' => '1'), array('type' => 'select', 'label' => $this->l('List Mode'), 'name' => 'list_mode', 'options' => array('query' => $lists, 'id' => 'value', 'name' => 'text'), 'default' => 'grid')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $fields_value = $this->getConfigFieldsValues($data); $selected_cat = $values['categoryBox']; $fields_value['categoryBox'] = $values['categoryBox'] ? explode(',', $values['categoryBox']) : array(); $fields_value['categorytab'] = $values['categorytab'] ? Tools::jsonDecode($values['categorytab'], true) : ''; $helper->tpl_vars = array('fields_value' => $fields_value, 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
public function renderForm($data) { $helper = $this->getFormHelper(); $this->fields_form[1]['form'] = array('input' => array(array('type' => 'category_tab', 'label' => 'Categories', 'name' => 'categorytab', 'default' => ''), array('type' => 'categoryBox', 'label' => 'Categories', 'name' => 'categoryBox', 'default' => ''))); $values = $this->getConfigFieldsValues($data); $selected_cat = $values['categoryBox']; $categories = explode(',', $selected_cat); $root = Category::getRootCategory(); $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $category_tpl = $tree->render(); $orders = array(array('value' => 'date_add', 'name' => $this->l('Date Add')), array('value' => 'date_add DESC', 'name' => $this->l('Date Add DESC')), array('value' => 'name', 'name' => $this->l('Name')), array('value' => 'name DESC', 'name' => $this->l('Name DESC')), array('value' => 'quantity', 'name' => $this->l('Quantity')), array('value' => 'quantity DESC', 'name' => $this->l('Quantity DESC')), array('value' => 'price', 'name' => $this->l('Price')), array('value' => 'price DESC', 'name' => $this->l('Price DESC'))); $lists = array(array('value' => 'grid', 'text' => $this->l('Grid')), array('value' => 'list1', 'text' => $this->l('List 1')), array('value' => 'list2', 'text' => $this->l('List 2'))); $modes = array(array('value' => 'normal', 'text' => $this->l('Normal')), array('value' => 'carousel', 'text' => $this->l('Carousel'))); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'category_tab', 'label' => $this->l('Categories'), 'name' => 'categorytab', 'category_tpl' => $category_tpl, 'default' => ''), array('type' => 'categoryBox', 'label' => '', 'name' => 'categoryBox', 'default' => ''), array('type' => 'text', 'label' => $this->l('Limit'), 'name' => 'limit', 'default' => 6), array('type' => 'select', 'label' => $this->l('Order By'), 'name' => 'order_by', 'options' => array('query' => $orders, 'id' => 'value', 'name' => 'name'), 'default' => 'date_add DESC'), array('type' => 'select', 'label' => $this->l('Display Mode'), 'name' => 'display_mode', 'options' => array('query' => $modes, 'id' => 'value', 'name' => 'text'), 'default' => 'carousel'), array('type' => 'text', 'label' => $this->l('Number Columns On Large Desktops.'), 'name' => 'columns', 'desc' => $this->l('The maximum column items in tab.'), 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Small Desktops'), 'name' => 'nbr_desktops', 'default' => '4'), array('type' => 'text', 'label' => $this->l('Number Columns On Tablets'), 'name' => 'nbr_tablets', 'default' => '2'), array('type' => 'text', 'label' => $this->l('Number Columns On Mobile'), 'name' => 'nbr_mobile', 'default' => '1'), array('type' => 'select', 'label' => $this->l('List Mode'), 'name' => 'list_mode', 'options' => array('query' => $lists, 'id' => 'value', 'name' => 'text'), 'default' => 'grid')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $fields_value = $this->getConfigFieldsValues($data); $selected_cat = $values['categoryBox']; $fields_value['categoryBox'] = $values['categoryBox'] ? explode(',', $values['categoryBox']) : array(); $fields_value['categorytab'] = $values['categorytab'] ? Tools::jsonDecode($values['categorytab'], true) : ''; $helper->tpl_vars = array('fields_value' => $fields_value, 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
private function _displayForm() { /* Gets Slides */ $id_lang = $this->context->cookie->id_lang; $root_cate_id = Configuration::get('ROOT_CATEGORY'); $id_category = Tools::getValue('id_category', $root_cate_id); $current_cate = new Category($id_category, $id_lang); $parent_cate = new Category($current_cate->id_parent, $id_lang); $categories = Category::getChildren($id_category, $id_lang); $displayList = false; $slides = array(); if (Tools::getValue('id_category') && $id_category > $root_cate_id) { $displayList = true; $slides = $this->getSlides(null, $id_category); } //category tree // Generate category selection tree $tree = new HelperTreeCategories('categories-tree', $this->l('Filter by category')); $tree->setAttribute('is_category_filter', (bool) $id_category)->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', AdminController::$currentIndex) . '&token=' . Tools::getAdminTokenLite('AdminModules'))->setInputName('id-category')->setSelectedCategories(array((int) $id_category)); $categoryTree = $tree->render(); $this->context->smarty->assign(array('slide_width' => Configuration::get('CATESLIDER_WIDTH'), 'slide_height' => Configuration::get('CATESLIDER_HEIGHT'), 'slide_speed' => Configuration::get('CATESLIDER_SPEED'), 'slide_pause' => Configuration::get('CATESLIDER_PAUSE'), 'slide_loop' => Configuration::get('CATESLIDER_LOOP'), 'categoryTree' => $categoryTree, 'displayList' => $displayList, 'current_cate' => $current_cate, 'slides' => $slides)); return $this->display(__FILE__, 'views/templates/admin/main.tpl'); }
public function initFormAssociations($obj) { $product = $obj; $data = $this->createTemplate($this->tpl_form); // Prepare Categories tree for display in Associations tab $root = Category::getRootCategory(); $default_category = $this->context->cookie->id_category_products_filter ? $this->context->cookie->id_category_products_filter : Context::getContext()->shop->id_category; if (!$product->id || !$product->isAssociatedToShop()) { $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); } else { if (Tools::isSubmit('categoryBox')) { $selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language); } else { $selected_cat = Product::getProductCategoriesFull($product->id, $this->default_form_language); } } // Multishop block $data->assign('feature_shop_active', Shop::isFeatureActive()); $helper = new HelperForm(); if ($this->object && $this->object->id) { $helper->id = $this->object->id; } else { $helper->id = null; } $helper->table = $this->table; $helper->identifier = $this->identifier; // Accessories block $accessories = Product::getAccessoriesLight($this->context->language->id, $product->id); if ($post_accessories = Tools::getValue('inputAccessories')) { $post_accessories_tab = explode('-', Tools::getValue('inputAccessories')); foreach ($post_accessories_tab as $accessory_id) { if (!$this->haveThisAccessory($accessory_id, $accessories) && ($accessory = Product::getAccessoryById($accessory_id))) { $accessories[] = $accessory; } } } $data->assign('accessories', $accessories); $product->manufacturer_name = Manufacturer::getNameById($product->id_manufacturer); $categories = array(); foreach ($selected_cat as $key => $category) { $categories[] = $key; } $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setTemplate('tree_associated_categories.tpl')->setHeaderTemplate('tree_associated_header.tpl')->setRootCategory($root->id)->setUseCheckBox(true)->setUseSearch(true)->setSelectedCategories($categories); $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), 'selected_cat' => $selected_cat, 'id_category_default' => $product->getDefaultCategory(), 'category_tree' => $tree->render(), 'product' => $product, 'link' => $this->context->link, 'is_shop_context' => Shop::getContext() == Shop::CONTEXT_SHOP)); $this->tpl_form_vars['custom_form'] = $data->fetch(); }
public function generate() { $this->tpl = $this->createTemplate($this->base_tpl); if (is_null($this->submit_action)) { $this->submit_action = 'submitAdd' . $this->table; } $categories = true; $color = true; $date = true; $tinymce = true; $textarea_autosize = true; $file = true; foreach ($this->fields_form as $fieldset_key => &$fieldset) { if (isset($fieldset['form']['tabs'])) { $tabs[] = $fieldset['form']['tabs']; } if (isset($fieldset['form']['input'])) { foreach ($fieldset['form']['input'] as $key => &$params) { // If the condition is not met, the field will not be displayed if (isset($params['condition']) && !$params['condition']) { unset($this->fields_form[$fieldset_key]['form']['input'][$key]); } switch ($params['type']) { case 'select': $field_name = (string) $params['name']; // If multiple select check that 'name' field is suffixed with '[]' if (isset($params['multiple']) && $params['multiple'] && stripos($field_name, '[]') === false) { $params['name'] .= '[]'; } break; case 'categories': if ($categories) { if (!isset($params['tree']['id'])) { throw new PrestaShopException('Id must be filled for categories tree'); } $tree = new HelperTreeCategories($params['tree']['id'], isset($params['tree']['title']) ? $params['tree']['title'] : null); if (isset($params['name'])) { $tree->setInputName($params['name']); } if (isset($params['tree']['selected_categories'])) { $tree->setSelectedCategories($params['tree']['selected_categories']); } if (isset($params['tree']['disabled_categories'])) { $tree->setDisabledCategories($params['tree']['disabled_categories']); } if (isset($params['tree']['root_category'])) { $tree->setRootCategory($params['tree']['root_category']); } if (isset($params['tree']['use_search'])) { $tree->setUseSearch($params['tree']['use_search']); } if (isset($params['tree']['use_checkbox'])) { $tree->setUseCheckBox($params['tree']['use_checkbox']); } if (isset($params['tree']['set_data'])) { $tree->setData($params['tree']['set_data']); } $this->context->smarty->assign('categories_tree', $tree->render()); $categories = false; } break; case 'file': $uploader = new HelperUploader(); $uploader->setId(isset($params['id']) ? $params['id'] : null); $uploader->setName($params['name']); $uploader->setUrl(isset($params['url']) ? $params['url'] : null); $uploader->setMultiple(isset($params['multiple']) ? $params['multiple'] : false); $uploader->setUseAjax(isset($params['ajax']) ? $params['ajax'] : false); $uploader->setMaxFiles(isset($params['max_files']) ? $params['max_files'] : null); if (isset($params['files']) && $params['files']) { $uploader->setFiles($params['files']); } elseif (isset($params['image']) && $params['image']) { // Use for retrocompatibility $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($params['image']) ? $params['image'] : null, 'size' => isset($params['size']) ? $params['size'] : null, 'delete_url' => isset($params['delete_url']) ? $params['delete_url'] : null))); } if (isset($params['file']) && $params['file']) { // Use for retrocompatibility $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_FILE, 'size' => isset($params['size']) ? $params['size'] : null, 'delete_url' => isset($params['delete_url']) ? $params['delete_url'] : null, 'download_url' => isset($params['file']) ? $params['file'] : null))); } if (isset($params['thumb']) && $params['thumb']) { // Use for retrocompatibility $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($params['thumb']) ? '<img src="' . $params['thumb'] . '" alt="' . (isset($params['title']) ? $params['title'] : '') . '" title="' . (isset($params['title']) ? $params['title'] : '') . '" />' : null))); } $uploader->setTitle(isset($params['title']) ? $params['title'] : null); $params['file'] = $uploader->render(); break; case 'color': if ($color) { // Added JS file $this->context->controller->addJqueryPlugin('colorpicker'); $color = false; } break; case 'date': if ($date) { $this->context->controller->addJqueryUI('ui.datepicker'); $date = false; } break; case 'textarea': if ($tinymce) { $iso = $this->context->language->iso_code; $this->tpl_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $this->tpl_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_); $this->tpl_vars['tinymce'] = true; $this->context->controller->addJS(_PS_JS_DIR_ . 'tiny_mce/tiny_mce.js'); $this->context->controller->addJS(_PS_JS_DIR_ . 'admin/tinymce.inc.js'); $tinymce = false; } if ($textarea_autosize) { $this->context->controller->addJqueryPlugin('autosize'); $textarea_autosize = false; } break; case 'shop': $disable_shops = isset($params['disable_shared']) ? $params['disable_shared'] : false; $params['html'] = $this->renderAssoShop($disable_shops); if (Shop::getTotalShops(false) == 1) { if (isset($this->fields_form[$fieldset_key]['form']['force']) && !$this->fields_form[$fieldset_key]['form']['force'] || !isset($this->fields_form[$fieldset_key]['form']['force'])) { unset($this->fields_form[$fieldset_key]['form']['input'][$key]); } } break; } } } } $this->tpl->assign(array('title' => $this->title, 'toolbar_btn' => $this->toolbar_btn, 'show_toolbar' => $this->show_toolbar, 'toolbar_scroll' => $this->toolbar_scroll, 'submit_action' => $this->submit_action, 'firstCall' => $this->first_call, 'current' => $this->currentIndex, 'token' => $this->token, 'table' => $this->table, 'identifier' => $this->identifier, 'name_controller' => $this->name_controller, 'languages' => $this->languages, 'current_id_lang' => $this->context->language->id, 'defaultFormLanguage' => $this->default_form_language, 'allowEmployeeFormLang' => $this->allow_employee_form_lang, 'form_id' => $this->id, 'tabs' => isset($tabs) ? $tabs : null, 'fields' => $this->fields_form, 'fields_value' => $this->fields_value, 'required_fields' => $this->getFieldsRequired(), 'vat_number' => Module::isInstalled('vatnumber') && file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'module_dir' => _MODULE_DIR_, 'base_url' => $this->context->shop->getBaseURL(), 'contains_states' => isset($this->fields_value['id_country']) && isset($this->fields_value['id_state']) ? Country::containsStates($this->fields_value['id_country']) : null, 'show_cancel_button' => $this->show_cancel_button, 'back_url' => $this->back_url)); return parent::generate(); }
public function renderForm() { if (!($group = $this->loadObject(true))) { return; } $this->fields_form = array('legend' => array('title' => $this->l('Customer group'), 'icon' => 'icon-group'), 'submit' => array('title' => $this->l('Save')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => true, 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:') . ' 0-9!&lt;&gt;,;?=+()@#"�{}_$%:'), array('type' => 'text', 'label' => $this->l('Discount'), 'name' => 'reduction', 'suffix' => '%', 'col' => 1, 'hint' => $this->l('Automatically apply this value as a discount on all products for members of this customer group.')), array('type' => 'select', 'label' => $this->l('Price display method'), 'name' => 'price_display_method', 'col' => 2, 'hint' => $this->l('How prices are displayed in the order summary for this customer group.'), 'options' => array('query' => array(array('id_method' => PS_TAX_EXC, 'name' => $this->l('Tax excluded')), array('id_method' => PS_TAX_INC, 'name' => $this->l('Tax included'))), 'id' => 'id_method', 'name' => 'name')), array('type' => 'switch', 'label' => $this->l('Show prices'), 'name' => 'show_prices', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'show_prices_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'show_prices_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Customers in this group can view prices.')), array('type' => 'group_discount_category', 'label' => $this->l('Category discount'), 'name' => 'reduction', 'values' => $group->id ? $this->formatCategoryDiscountList((int) $group->id) : array()), array('type' => 'modules', 'label' => $this->l('Modules Authorization'), 'name' => 'auth_modules', 'values' => $this->formatModuleListAuth($group->id)))); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso'); } $this->fields_value['reduction'] = isset($group->reduction) ? $group->reduction : 0; $tree = new HelperTreeCategories('categories-tree'); $this->tpl_form_vars['categoryTreeView'] = $tree->render(); return parent::renderForm(); }