Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public function renderForm($args, $data)
 {
     global $currentIndex;
     $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')));
     $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);
 }
Exemplo n.º 3
0
    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>';
    }
Exemplo n.º 4
0
 /**
  * Listing ajax des catégories
  */
 public function displayAjaxCategoriesList()
 {
     //Insertion des styles admin nécessaire à l'affichage des actions ajax
     foreach ($this->css_files as $css_key => $css_type) {
         echo '<link rel="stylesheet" type="text/css" href="' . $css_key . '" type="' . $css_type . '"/>';
     }
     //Géneration du tree des catégories
     if (_PS_VERSION_ < '1.6') {
         $categoryTree = new Helper();
         echo $categoryTree->renderCategoryTree(2, array(), 'id-category-for-insert');
     } else {
         $categoryTree = new HelperTreeCategories('categories-tree', $this->l('Check the category to display the link'));
         echo $categoryTree->setAttribute()->setInputName('id-category-for-insert')->render();
     }
 }
Exemplo n.º 5
0
    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);
    }
Exemplo n.º 6
0
 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' => '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 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);
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 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 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!&amp;lt;&amp;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');
     }
     if (Tools::getIsset('addgroup')) {
         $this->fields_value['price_display_method'] = Configuration::get('PRICE_DISPLAY_METHOD');
     }
     $this->fields_value['reduction'] = isset($group->reduction) ? $group->reduction : 0;
     $tree = new HelperTreeCategories('categories-tree');
     $this->tpl_form_vars['categoryTreeView'] = $tree->setRootCategory((int) Category::getRootCategory()->id)->render();
     return parent::renderForm();
 }
Exemplo n.º 12
0
 public function displayAjaxGetCategoriesFromRootCategory()
 {
     if (Tools::isSubmit('id_category')) {
         $selected_cat = array((int) Tools::getValue('id_category'));
         $children = Category::getChildren((int) Tools::getValue('id_category'), $this->context->language->id);
         foreach ($children as $child) {
             $selected_cat[] = $child['id_category'];
         }
         $helper = new HelperTreeCategories('categories-tree', null, (int) Tools::getValue('id_category'), null, false);
         $this->content = $helper->setSelectedCategories($selected_cat)->setUseSearch(true)->setUseCheckBox(true)->render();
     }
     parent::displayAjax();
 }
Exemplo n.º 13
0
 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();
 }
Exemplo n.º 14
0
    public function getContent()
    {
        global $cookie;
        $message = '';
        if (Tools::isSubmit('SubmitFilter')) {
            if (!Tools::getValue('layered_tpl_name')) {
                $message = $this->displayError($this->l('Filter template name required (cannot be empty)'));
            } elseif (!Tools::getValue('categoryBox')) {
                $message = $this->displayError($this->l('You must select at least one category.'));
            } else {
                if (Tools::getValue('id_layered_filter')) {
                    Db::getInstance()->execute('
						DELETE FROM ' . _DB_PREFIX_ . 'layered_filter
						WHERE id_layered_filter = ' . (int) Tools::getValue('id_layered_filter'));
                    $this->buildLayeredCategories();
                }
                if (Tools::getValue('scope') == 1) {
                    Db::getInstance()->execute('TRUNCATE TABLE ' . _DB_PREFIX_ . 'layered_filter');
                    $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
						SELECT id_category
						FROM ' . _DB_PREFIX_ . 'category');
                    foreach ($categories as $category) {
                        $_POST['categoryBox'][] = (int) $category['id_category'];
                    }
                }
                $id_layered_filter = (int) Tools::getValue('id_layered_filter');
                if (!$id_layered_filter) {
                    $id_layered_filter = (int) Db::getInstance()->Insert_ID();
                }
                $shop_list = array();
                if (isset($_POST['checkBoxShopAsso_layered_filter'])) {
                    foreach ($_POST['checkBoxShopAsso_layered_filter'] as $id_shop => $row) {
                        $assos[] = array('id_object' => (int) $id_layered_filter, 'id_shop' => (int) $id_shop);
                        $shop_list[] = (int) $id_shop;
                    }
                } else {
                    $shop_list = array(Context::getContext()->shop->id);
                }
                Db::getInstance()->execute('
					DELETE FROM ' . _DB_PREFIX_ . 'layered_filter_shop
					WHERE `id_layered_filter` = ' . (int) $id_layered_filter);
                if (count($_POST['categoryBox'])) {
                    /* Clean categoryBox before use */
                    if (isset($_POST['categoryBox']) && is_array($_POST['categoryBox'])) {
                        foreach ($_POST['categoryBox'] as &$category_box_tmp) {
                            $category_box_tmp = (int) $category_box_tmp;
                        }
                    }
                    $filter_values = array();
                    foreach ($_POST['categoryBox'] as $idc) {
                        $filter_values['categories'][] = (int) $idc;
                    }
                    $filter_values['shop_list'] = $shop_list;
                    $values = false;
                    foreach ($_POST['categoryBox'] as $id_category_layered) {
                        foreach ($_POST as $key => $value) {
                            if (substr($key, 0, 17) == 'layered_selection' && $value == 'on') {
                                $values = true;
                                $type = 0;
                                $limit = 0;
                                if (Tools::getValue($key . '_filter_type')) {
                                    $type = Tools::getValue($key . '_filter_type');
                                }
                                if (Tools::getValue($key . '_filter_show_limit')) {
                                    $limit = Tools::getValue($key . '_filter_show_limit');
                                }
                                $filter_values[$key] = array('filter_type' => (int) $type, 'filter_show_limit' => (int) $limit);
                            }
                        }
                    }
                    $values_to_insert = array('name' => pSQL(Tools::getValue('layered_tpl_name')), 'filters' => pSQL(serialize($filter_values)), 'n_categories' => (int) count($filter_values['categories']), 'date_add' => date('Y-m-d H:i:s'));
                    if (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) {
                        $values_to_insert['id_layered_filter'] = (int) Tools::getValue('id_layered_filter');
                    }
                    Db::getInstance()->autoExecute(_DB_PREFIX_ . 'layered_filter', $values_to_insert, 'INSERT');
                    $id_layered_filter = (int) Db::getInstance()->Insert_ID();
                    if (isset($assos)) {
                        foreach ($assos as $asso) {
                            Db::getInstance()->execute('
							INSERT INTO ' . _DB_PREFIX_ . 'layered_filter_shop (`id_layered_filter`, `id_shop`)
							VALUES(' . $id_layered_filter . ', ' . (int) $asso['id_shop'] . ')');
                        }
                    }
                    $this->buildLayeredCategories();
                    $message = $this->displayConfirmation($this->l('Your filter') . ' "' . Tools::safeOutput(Tools::getValue('layered_tpl_name')) . '" ' . (isset($_POST['id_layered_filter']) && $_POST['id_layered_filter'] ? $this->l('was updated successfully.') : $this->l('was added successfully.')));
                }
            }
        } else {
            if (Tools::isSubmit('submitLayeredSettings')) {
                Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', (int) Tools::getValue('ps_layered_hide_0_values'));
                Configuration::updateValue('PS_LAYERED_SHOW_QTIES', (int) Tools::getValue('ps_layered_show_qties'));
                Configuration::updateValue('PS_LAYERED_FULL_TREE', (int) Tools::getValue('ps_layered_full_tree'));
                Configuration::updateValue('PS_LAYERED_FILTER_PRICE_USETAX', (int) Tools::getValue('ps_layered_filter_price_usetax'));
                Configuration::updateValue('PS_LAYERED_FILTER_CATEGORY_DEPTH', (int) Tools::getValue('ps_layered_filter_category_depth'));
                Configuration::updateValue('PS_LAYERED_FILTER_INDEX_QTY', (int) Tools::getValue('ps_layered_filter_index_availability'));
                Configuration::updateValue('PS_LAYERED_FILTER_INDEX_CDT', (int) Tools::getValue('ps_layered_filter_index_condition'));
                Configuration::updateValue('PS_LAYERED_FILTER_INDEX_MNF', (int) Tools::getValue('ps_layered_filter_index_manufacturer'));
                Configuration::updateValue('PS_LAYERED_FILTER_INDEX_CAT', (int) Tools::getValue('ps_layered_filter_index_category'));
                if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                    $message = '<div class="alert alert-success">' . $this->l('Settings saved successfully') . '</div>';
                } else {
                    $message = '<div class="conf">' . $this->l('Settings saved successfully') . '</div>';
                }
            } else {
                if (Tools::getValue('deleteFilterTemplate')) {
                    $layered_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
				SELECT filters
				FROM ' . _DB_PREFIX_ . 'layered_filter
				WHERE id_layered_filter = ' . (int) Tools::getValue('id_layered_filter'));
                    if ($layered_values) {
                        Db::getInstance()->execute('
					DELETE FROM ' . _DB_PREFIX_ . 'layered_filter
					WHERE id_layered_filter = ' . (int) Tools::getValue('id_layered_filter') . ' LIMIT 1');
                        $this->buildLayeredCategories();
                        $message = $this->displayConfirmation($this->l('Filter template deleted, categories updated (reverted to default Filter template).'));
                    } else {
                        $message = $this->displayError($this->l('Filter template not found'));
                    }
                }
            }
        }
        $category_box = array();
        $attribute_groups = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT ag.id_attribute_group, ag.is_color_group, agl.name, COUNT(DISTINCT(a.id_attribute)) n
			FROM ' . _DB_PREFIX_ . 'attribute_group ag
			LEFT JOIN ' . _DB_PREFIX_ . 'attribute_group_lang agl ON (agl.id_attribute_group = ag.id_attribute_group)
			LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = ag.id_attribute_group)
			WHERE agl.id_lang = ' . (int) $cookie->id_lang . '
			GROUP BY ag.id_attribute_group');
        $features = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT fl.id_feature, fl.name, COUNT(DISTINCT(fv.id_feature_value)) n
			FROM ' . _DB_PREFIX_ . 'feature_lang fl
			LEFT JOIN ' . _DB_PREFIX_ . 'feature_value fv ON (fv.id_feature = fl.id_feature)
			WHERE (fv.custom IS NULL OR fv.custom = 0) AND fl.id_lang = ' . (int) $cookie->id_lang . '
			GROUP BY fl.id_feature');
        if (Shop::isFeatureActive() && count(Shop::getShops(true, null, true)) > 1) {
            $helper = new HelperForm();
            $helper->id = Tools::getValue('id_layered_filter', null);
            $helper->table = 'layered_filter';
            $helper->identifier = 'id_layered_filter';
            $this->context->smarty->assign('asso_shops', $helper->renderAssoShop());
        }
        if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
            $tree_categories_helper = new HelperTreeCategories('categories-treeview');
            $tree_categories_helper->setRootCategory(Shop::getContext() == Shop::CONTEXT_SHOP ? Category::getRootCategory()->id_category : 0)->setUseCheckBox(true);
        } else {
            if (Shop::getContext() == Shop::CONTEXT_SHOP) {
                $root_category = Category::getRootCategory();
                $root_category = array('id_category' => $root_category->id_category, 'name' => $root_category->name);
            } else {
                $root_category = array('id_category' => '0', 'name' => $this->l('Root'));
            }
            $tree_categories_helper = new Helper();
        }
        $module_url = Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . $this->getPathUri();
        if (method_exists($this->context->controller, 'addJquery')) {
            $this->context->controller->addJS($this->_path . 'js/blocklayered_admin.js');
            if (version_compare(_PS_VERSION_, '1.6.0.3', '>=') === true) {
                $this->context->controller->addjqueryPlugin('sortable');
            } elseif (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/jquery.sortable.js');
            } else {
                $this->context->controller->addJS($this->_path . 'js/jquery.sortable.js');
            }
        }
        if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
            $this->context->controller->addCSS($this->_path . 'css/blocklayered_admin_1.6.css');
        } else {
            $this->context->controller->addCSS($this->_path . 'css/blocklayered_admin.css');
        }
        if (Tools::getValue('add_new_filters_template')) {
            $this->context->smarty->assign(array('current_url' => $this->context->link->getAdminLink('AdminModules') . '&configure=blocklayered&tab_module=front_office_features&module_name=blocklayered', 'uri' => $this->getPathUri(), 'id_layered_filter' => 0, 'template_name' => sprintf($this->l('My template - %s'), date('Y-m-d')), 'attribute_groups' => $attribute_groups, 'features' => $features, 'total_filters' => 6 + count($attribute_groups) + count($features)));
            if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                $this->context->smarty->assign('categories_tree', $tree_categories_helper->render());
            } else {
                $this->context->smarty->assign('categories_tree', $tree_categories_helper->renderCategoryTree($root_category, array(), 'categoryBox'));
            }
            if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                return $this->display(__FILE__, 'views/templates/admin/add_1.6.tpl');
            } else {
                return $this->display(__FILE__, 'views/templates/admin/add.tpl');
            }
        } else {
            if (Tools::getValue('edit_filters_template')) {
                $template = Db::getInstance()->getRow('
				SELECT *
				FROM `' . _DB_PREFIX_ . 'layered_filter`
				WHERE id_layered_filter = ' . (int) Tools::getValue('id_layered_filter'));
                $filters = unserialize($template['filters']);
                if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                    $tree_categories_helper->setSelectedCategories($filters['categories']);
                    $this->context->smarty->assign('categories_tree', $tree_categories_helper->render());
                } else {
                    $this->context->smarty->assign('categories_tree', $tree_categories_helper->renderCategoryTree($root_category, $filters['categories'], 'categoryBox'));
                }
                $select_shops = $filters['shop_list'];
                unset($filters['categories']);
                unset($filters['shop_list']);
                $this->context->smarty->assign(array('current_url' => $this->context->link->getAdminLink('AdminModules') . '&configure=blocklayered&tab_module=front_office_features&module_name=blocklayered', 'uri' => $this->getPathUri(), 'id_layered_filter' => (int) Tools::getValue('id_layered_filter'), 'template_name' => $template['name'], 'attribute_groups' => $attribute_groups, 'features' => $features, 'filters' => Tools::jsonEncode($filters), 'total_filters' => 6 + count($attribute_groups) + count($features)));
                if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                    return $this->display(__FILE__, 'views/templates/admin/add_1.6.tpl');
                } else {
                    return $this->display(__FILE__, 'views/templates/admin/add.tpl');
                }
            } else {
                $this->context->smarty->assign(array('message' => $message, 'uri' => $this->getPathUri(), 'PS_LAYERED_INDEXED' => Configuration::getGlobalValue('PS_LAYERED_INDEXED'), 'current_url' => Tools::safeOutput(preg_replace('/&deleteFilterTemplate=[0-9]*&id_layered_filter=[0-9]*/', '', $_SERVER['REQUEST_URI'])), 'id_lang' => Context::getContext()->cookie->id_lang, 'token' => substr(Tools::encrypt('blocklayered/index'), 0, 10), 'base_folder' => urlencode(_PS_ADMIN_DIR_), 'price_indexer_url' => $module_url . 'blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10), 'full_price_indexer_url' => $module_url . 'blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&full=1', 'attribute_indexer_url' => $module_url . 'blocklayered-attribute-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10), 'url_indexer_url' => $module_url . 'blocklayered-url-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&truncate=1', 'filters_templates' => Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'layered_filter ORDER BY date_add DESC'), 'hide_values' => Configuration::get('PS_LAYERED_HIDE_0_VALUES'), 'show_quantities' => Configuration::get('PS_LAYERED_SHOW_QTIES'), 'full_tree' => Configuration::get('PS_LAYERED_FULL_TREE'), 'category_depth' => Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH'), 'price_use_tax' => Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX'), 'index_cdt' => Configuration::get('PS_LAYERED_FILTER_INDEX_CDT'), 'index_qty' => Configuration::get('PS_LAYERED_FILTER_INDEX_QTY'), 'index_mnf' => Configuration::get('PS_LAYERED_FILTER_INDEX_MNF'), 'index_cat' => Configuration::get('PS_LAYERED_FILTER_INDEX_CAT'), 'limit_warning' => $this->displayLimitPostWarning(21 + count($attribute_groups) * 3 + count($features) * 3)));
                if (version_compare(_PS_VERSION_, '1.6.0', '>=') === true) {
                    return $this->display(__FILE__, 'views/templates/admin/view_1.6.tpl');
                } else {
                    return $this->display(__FILE__, 'views/templates/admin/view.tpl');
                }
            }
        }
    }
Exemplo n.º 15
0
 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();
 }