public function getData() { if (!isset($this->_data)) { $shop = $this->getShop(); $lang = $this->getLang(); if (empty($this->_root_category)) { $root_category = Category::getRootCategory($lang, new Shop((int) Configuration::get('PS_SHOP_DEFAULT')))->id; } $categories = $new_selected_categories = array(); $selected_categories = Category::getAllCategoriesName($root_category, $lang, false, null, false); $categories[$root_category] = Category::getChildren($root_category, $lang, false, (int) Configuration::get('PS_SHOP_DEFAULT')); foreach ($selected_categories as $selected_category) { $category = new Category($selected_category['id_category'], $lang, (int) Configuration::get('PS_SHOP_DEFAULT')); $new_selected_categories[] = $selected_category['id_category']; $parents = $category->getParentsCategories($lang); foreach ($parents as $value) { $new_selected_categories[] = $value['id_category']; } } $new_selected_categories = array_unique($new_selected_categories); foreach ($new_selected_categories as $selected_category) { $current_category = Category::getChildren($selected_category, $lang, false, (int) Configuration::get('PS_SHOP_DEFAULT')); if (!empty($current_category)) { $categories[$selected_category] = $current_category; } } $tree = $this->fillTree($categories, $root_category); if (!empty($children)) { $tree[$root_category]['children'] = $children; } $this->setData($tree); } return $this->_data; }
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() { $root_category = Category::getRootCategory(); $root_category = array('id_category' => $root_category->id, 'name' => $root_category->name); $cats = array(); if ($c = Configuration::get('yamarket_с_categories')) { $uc = unserialize($c); if (is_array($uc)) { $cats = $uc; } } $this->fields_form[0]['form'] = array('legend' => array('title' => $this->l('Settings'), 'image' => _PS_ADMIN_IMG_ . 'information.png'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop Name'), 'desc' => $this->l('Shop name in yandex market'), 'name' => 'yamarket_с_shop'), array('type' => 'text', 'label' => $this->l('Сompany name'), 'desc' => $this->l('Your company name'), 'name' => 'yamarket_с_company'), array('type' => 'text', 'label' => $this->l('Shipping cost'), 'desc' => $this->l('Shipping cost in shop region'), 'name' => 'yamarket_с_shippingcost'), array('type' => 'text', 'label' => $this->l('Information'), 'desc' => $this->l('Information about minimal order cost, minimal product quantity or prepayment'), 'name' => 'yamarket_с_info'), array('type' => 'switch', 'label' => $this->l('Gzip compression'), 'desc' => $this->l('Compress export file'), 'name' => 'yamarket_с_gzip', 'values' => array(array('id' => 'yamarket_с_gzip_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'yamarket_с_gzip_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Combinations'), 'desc' => $this->l('Export combinations'), 'name' => 'yamarket_с_combinations', 'values' => array(array('id' => 'yamarket_с_combinations_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'yamarket_с_combinations_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'checkbox', 'label' => $this->l('Shipping'), 'desc' => $this->l('Delivery, pickup and store'), 'name' => 'yamarket_с_shipping', 'is_bool' => false, 'values' => array('id' => 'id', 'name' => 'label', 'query' => array(array('id' => '[1]', 'val' => 1, 'label' => $this->l('Delivery availability')), array('id' => '[2]', 'val' => 1, 'label' => $this->l('Pickup in store availability')), array('id' => '[3]', 'val' => 1, 'label' => $this->l('Can buy in Store'))))), array('type' => 'switch', 'label' => $this->l('Currencies'), 'desc' => $this->l('If not checked will be used default currency'), 'name' => 'yamarket_с_currencies', 'values' => array(array('id' => 'yamarket_с_currencies_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'yamarket_с_currencies_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Availability'), 'desc' => $this->l('Product availability'), 'name' => 'yamarket_с_availability', 'is_bool' => false, 'values' => array(array('id' => 'yamarket_с_availability_0', 'value' => 0, 'label' => $this->l('All avaible')), array('id' => 'yamarket_с_availability_1', 'value' => 1, 'label' => $this->l('If quantity >0, then avaible, else on request')), array('id' => 'yamarket_с_availability_2', 'value' => 2, 'label' => $this->l('If quantity = 0, product not exported')), array('id' => 'yamarket_с_availability_3', 'value' => 3, 'label' => $this->l('All on request')))), array('type' => 'categories', 'label' => $this->l('Categories'), 'desc' => $this->l('Categories to export. If necessary, subcategories must be checked too.'), 'name' => 'yamarket_с_categories', 'tree' => array('use_search' => false, 'id' => 'categoryBox', 'use_checkbox' => true, 'selected_categories' => $cats))), 'submit' => array('name' => 'submityamarket_с', 'title' => $this->l('Save'))); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Yandex Market configuration information'), 'image' => _PS_ADMIN_IMG_ . 'information.png'), 'input' => array(array('type' => 'text', 'label' => $this->l('Static url'), 'desc' => $this->l('URL to download file generated by cron or Export button.'), 'name' => 'url1'), array('type' => 'text', 'label' => $this->l('Dinamic url'), 'desc' => $this->l('URL to download dinamicaly generated export file.'), 'name' => 'url2'), array('type' => 'text', 'label' => $this->l('Cron url'), 'desc' => $this->l('URL to regenerate export file by cron.'), 'name' => 'url3'))); $helper = new HelperForm(); $helper->module = $this; $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->submit_action = 'submityamarket_с'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); return $helper->generateForm($this->fields_form); }
public function getTemplateVarSitemap() { $pages = []; $catalog_mode = Configuration::isCatalogMode(); $cms = CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1); foreach ($cms['cms'] as $p) { $pages[] = ['id' => 'cms-page-' . $p['id_cms'], 'label' => $p['meta_title'], 'url' => $this->context->link->getCMSLink(new CMS($p['id_cms']))]; } $pages[] = ['id' => 'stores-page', 'label' => $this->trans('Our stores', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('stores')]; $pages[] = ['id' => 'contact-page', 'label' => $this->trans('Contact us', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('contact')]; $pages[] = ['id' => 'sitemap-page', 'label' => $this->trans('Sitemap', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('sitemap')]; $pages[] = ['id' => 'login-page', 'label' => $this->trans('Log in', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')]; $pages[] = ['id' => 'register-page', 'label' => $this->trans('Create new account', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')]; $catalog = ['new-product' => ['id' => 'new-product-page', 'label' => $this->trans('New products', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('new-products')]]; if ($catalog_mode && Configuration::get('PS_DISPLAY_BEST_SELLERS')) { $catalog['best-sales'] = ['id' => 'best-sales-page', 'label' => $this->trans('Best sellers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('best-sales')]; $catalog['prices-drop'] = ['id' => 'prices-drop-page', 'label' => $this->trans('Price drop', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('prices-drop')]; } if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $manufacturers = Manufacturer::getLiteManufacturersList($this->context->language->id, 'sitemap'); $catalog['manufacturer'] = ['id' => 'manufacturer-page', 'label' => $this->trans('Manufacturers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $manufacturers]; $suppliers = Supplier::getLiteSuppliersList($this->context->language->id, 'sitemap'); $catalog['supplier'] = ['id' => 'supplier-page', 'label' => $this->trans('Suppliers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $suppliers]; } $categories = Category::getRootCategory()->recurseLiteCategTree(0, 0, null, null, 'sitemap'); $catalog['category'] = ['id' => 'category-page', 'label' => $this->trans('Categories', array(), 'Shop.Theme.Catalog'), 'url' => '#', 'children' => $categories['children']]; $sitemap = [['id' => 'page-page', 'label' => $this->trans('Pages', array(), 'Shop.Theme'), 'url' => '#', 'children' => $pages], ['id' => 'catalog-page', 'label' => $this->trans('Catalog', array(), 'Shop.Theme'), 'url' => '#', 'children' => $catalog]]; return $sitemap; }
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); }
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); }
/** * Returns module content for header * * @param array $params Parameters * @return string Content */ function hookTop($params) { global $smarty; //construct categories $depth = 0; $rootCateg = Category::getRootCategory()->recurseLiteCategTree($depth); if (isset($_GET['id_category'])) { $smarty->assign('currentCategoryId', intval($_GET['id_category'])); } $smarty->assign('bar_tpl_path', _PS_MODULE_DIR_ . 'categoriesbar/category-bar-level.tpl'); $smarty->assign('categoriesLevel', $rootCateg); return $this->display(__FILE__, 'categoriesbar.tpl'); }
public function process() { parent::process(); self::$smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); self::$smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(_USER_ID_LANG_, 1, 1, 1)); self::$smarty->assign('voucherAllowed', (int) Configuration::get('PS_VOUCHERS')); $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); self::$smarty->assign('display_manufacturer_link', (int) $blockmanufacturer->id ? true : false); self::$smarty->assign('display_supplier_link', (int) $blocksupplier->id ? true : false); self::$smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); self::$smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) Configuration::get('PS_VOUCHERS')); $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active); $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->setTemplate(_PS_THEME_DIR_ . 'sitemap.tpl'); }
public function getData() { if (!isset($this->_data)) { $shop = $this->getShop(); $lang = $this->getLang(); $root_category = (int) $this->getRootCategory(); if ($this->_full_tree) { $this->setData(Category::getNestedCategories($root_category, $lang, false, null, $this->useShopRestriction())); $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } elseif ($this->_children_only) { if (empty($root_category)) { $root_category = Category::getRootCategory()->id; } $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id); $children = $this->fillTree($categories, $root_category); $this->setData($children); } else { if (empty($root_category)) { $root_category = Category::getRootCategory()->id; } $new_selected_categories = array(); $selected_categories = $this->getSelectedCategories(); $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id); foreach ($selected_categories as $selected_category) { $category = new Category($selected_category, $lang, $shop->id); $new_selected_categories[] = $selected_category; $parents = $category->getParentsCategories($lang); foreach ($parents as $value) { $new_selected_categories[] = $value['id_category']; } } $new_selected_categories = array_unique($new_selected_categories); foreach ($new_selected_categories as $selected_category) { $current_category = Category::getChildren($selected_category, $lang, false, $shop->id); if (!empty($current_category)) { $categories[$selected_category] = $current_category; } } $tree = Category::getCategoryInformations(array($root_category), $lang); $children = $this->fillTree($categories, $root_category); if (!empty($children)) { $tree[$root_category]['children'] = $children; } $this->setData($tree); $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } } return $this->_data; }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { //get current slug $slug = $request->getParameter('crumb'); $this->product = null; $product = null; $category = null; $this->catid = null; //We need to identify what path is being accessed through the URL via the slugs if ($slug != "") { $slugs = explode("/", $slug); $count = count($slugs); if ($count == 0) { //if no slugs, set root level category (all) $category = Category::getRootCategory(); } elseif ($count == 1) { //if 1 slug only, set category $category = Category::getCategoryFromSlug($slugs[0]); } else { //if multiple slugs if ($slugs[$count - 2] == "product") { //if third to last slug is "product", we are viewing a product... $product = Product::getProductFromSlug($slugs[$count - 1]); //...so get that product... if ($count > 2) { $category = Category::getCategoryFromSlug($slugs[$count - 3]); //...and its associated category... } else { $category = null; //...or not, if product is being viewed directly } } else { //When viewing a product, the route will always prepend /product in order to identify. //If that is not found, we are just viewing a category. $category = Category::getCategoryFromSlug($slugs[$count - 1]); } } } if ($product != null) { $this->product = $product; } if ($category != null) { $this->catid = $category->getId(); } }
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($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); }
public static function getCategLang($id_gcategory, $id_shop, $id_lang) { $ret = Db::getInstance()->executeS(' SELECT g.*, gl.gcategory, gl.id_lang, cl.name as gcat_name FROM ' . _DB_PREFIX_ . 'gshoppingflux g LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = g.id_gcategory AND cl.id_shop=' . (int) $id_shop . ') LEFT JOIN ' . _DB_PREFIX_ . 'gshoppingflux_lang gl ON (gl.id_gcategory = g.id_gcategory AND gl.id_shop=' . (int) $id_shop . ') WHERE 1 ' . (!is_null($id_gcategory) ? ' AND g.id_gcategory = "' . (int) $id_gcategory . '"' : '') . ' AND g.id_shop IN (0, ' . (int) $id_shop . ');'); $gcateg = array(); foreach ($ret as $l => $line) { $gcateg[$line['id_lang']] = Tools::safeOutput($line['gcategory']); } $shop = new Shop($id_shop); $root = Category::getRootCategory($id_lang, $shop); $ret[0]['breadcrumb'] = self::getPath((int) $id_gcategory, '', $id_lang, $id_shop, $root->id_category); if (empty($ret[0]['breadcrumb']) || $ret[0]['breadcrumb'] == ' > ') { $ret[0]['breadcrumb'] = $ret[0]['gcat_name']; } return array('breadcrumb' => $ret[0]['breadcrumb'], 'gcategory' => $gcateg, 'export' => $ret[0]['export'], 'condition' => $ret[0]['condition'], 'availability' => $ret[0]['availability'], 'gender' => $ret[0]['gender'], 'age_group' => $ret[0]['age_group'], 'color' => $ret[0]['color'], 'material' => $ret[0]['material'], 'pattern' => $ret[0]['pattern'], 'size' => $ret[0]['size']); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive()); if (Module::isInstalled('blockmanufacturer') && Module::isEnabled('blockmanufacturer')) { $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $this->context->smarty->assign('display_manufacturer_link', isset($blockmanufacturer->active) ? (bool) $blockmanufacturer->active : false); } else { $this->context->smarty->assign('display_manufacturer_link', 0); } if (Module::isInstalled('blocksupplier') && Module::isEnabled('blocksupplier')) { $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('display_supplier_link', isset($blocksupplier->active) ? (bool) $blocksupplier->active : false); } else { $this->context->smarty->assign('display_supplier_link', 0); } $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('PS_DISPLAY_BEST_SELLERS', Configuration::get('PS_DISPLAY_BEST_SELLERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->setTemplate(_PS_THEME_DIR_ . 'sitemap.tpl'); }
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); }
/** * Return path to a product category * * @param string $urlBase Start URL * @param integer $id_category Start category * @param string $path Current path * @param string $highlight String to highlight (in XHTML/CSS) * @param string $type Category type (products/cms) */ function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryType = 'catalog', $home = false) { $context = Context::getContext(); if ($categoryType == 'catalog') { $category = Db::getInstance()->getRow(' SELECT id_category, level_depth, nleft, nright FROM ' . _DB_PREFIX_ . 'category WHERE id_category = ' . (int) $id_category); if (isset($category['id_category'])) { $sql = 'SELECT c.id_category, cl.name, cl.link_rewrite FROM ' . _DB_PREFIX_ . 'category c LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (cl.id_category = c.id_category' . Shop::addSqlRestrictionOnLang('cl') . ') WHERE c.nleft <= ' . (int) $category['nleft'] . ' AND c.nright >= ' . (int) $category['nright'] . ' AND cl.id_lang = ' . (int) $context->language->id . ($home ? ' AND c.id_category=' . $id_category : '') . ' AND c.id_category != ' . (int) Category::getTopCategory()->id . ' GROUP BY c.id_category ORDER BY c.level_depth ASC LIMIT ' . (!$home ? (int) ($category['level_depth'] + 1) : 1); $categories = Db::getInstance()->executeS($sql); $fullPath = ''; $n = 1; $nCategories = (int) sizeof($categories); foreach ($categories as $category) { $link = Context::getContext()->link->getAdminLink('AdminCategories'); $edit = '<a href="' . $link . '&id_category=' . (int) $category['id_category'] . '&' . ($category['id_category'] == 1 || $home ? 'viewcategory' : 'updatecategory') . '" title="' . ($category['id_category'] == Category::getRootCategory()->id_category ? 'Home' : 'Modify') . '"><i class="icon-' . ($category['id_category'] == Category::getRootCategory()->id_category || $home ? 'home' : 'pencil') . '"></i></a> '; $fullPath .= $edit . ($n < $nCategories ? '<a href="' . $urlBase . '&id_category=' . (int) $category['id_category'] . '&viewcategory&token=' . Tools::getAdminToken('AdminCategories' . (int) Tab::getIdFromClassName('AdminCategories') . (int) $context->employee->id) . '" title="' . htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8') . '">' : '') . (!empty($highlight) ? str_ireplace($highlight, '<span class="highlight">' . htmlentities($highlight, ENT_NOQUOTES, 'UTF-8') . '</span>', $category['name']) : $category['name']) . ($n < $nCategories ? '</a>' : '') . ($n++ != $nCategories || !empty($path) ? ' > ' : ''); } return $fullPath . $path; } } elseif ($categoryType == 'cms') { $category = new CMSCategory($id_category, $context->language->id); if (!$category->id) { return $path; } $name = $highlight != null ? str_ireplace($highlight, '<span class="highlight">' . $highlight . '</span>', CMSCategory::hideCMSCategoryPosition($category->name)) : CMSCategory::hideCMSCategoryPosition($category->name); $edit = '<a href="' . $urlBase . '&id_cms_category=' . $category->id . '&addcategory&token=' . Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) $context->employee->id) . '"> <i class="icon-pencil"></i></a> '; if ($category->id == 1) { $edit = '<li><a href="' . $urlBase . '&id_cms_category=' . $category->id . '&viewcategory&token=' . Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) $context->employee->id) . '"> <i class="icon-home"></i></a></li> '; } $path = $edit . '<li><a href="' . $urlBase . '&id_cms_category=' . $category->id . '&viewcategory&token=' . Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) $context->employee->id) . '"> ' . $name . '</a></li> > ' . $path; if ($category->id == 1) { return substr($path, 0, strlen($path) - 3); } return getPath($urlBase, $category->id_parent, $path, '', 'cms'); } }
public function getContent() { global $cookie; $html = ''; if (Tools::isSubmit('SubmitFilter')) { if (!Tools::getValue('layered_tpl_name')) { $html .= ' <div class="error"> <span style="float:right"> <a href="" id="hideError"><img src="../img/admin/close.png" alt="X"></a> </span> <img src="../img/admin/error2.png">' . $this->l('Filter template name required (cannot be empty)') . ' </div>'; } else { if (isset($_POST['id_layered_filter']) && $_POST['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) $_POST['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); } 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); } } } Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'layered_filter_shop WHERE `id_layered_filter` = ' . (int) $id_layered_filter); 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'] . ')'); } } $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'); $this->buildLayeredCategories(); $html .= '<div class="conf">' . $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.')) . '</div>'; } } } 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')); $html .= ' <div class="conf">' . $this->l('Settings saved successfully') . '</div>'; } else { if (isset($_GET['deleteFilterTemplate'])) { $layered_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT filters FROM ' . _DB_PREFIX_ . 'layered_filter WHERE id_layered_filter = ' . (int) $_GET['id_layered_filter']); if ($layered_values) { Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'layered_filter WHERE id_layered_filter = ' . (int) $_GET['id_layered_filter'] . ' LIMIT 1'); $this->buildLayeredCategories(); $html .= ' <div class="conf">' . $this->l('Filter template deleted, categories updated (reverted to default Filter template).') . ' </div>'; } else { $html .= ' <div class="error"> <img src="../img/admin/error.png" alt="" title="" /> ' . $this->l('Filter template not found') . ' </div>'; } } } } $html .= ' <div id="ajax-message-ok" class="conf ajax-message" style="display: none"> <span class="message"></span> </div> <div id="ajax-message-ko" class="error ajax-message" style="display: none"> <span class="message"></span> </div> <h2>' . $this->l('Layered navigation') . '</h2> <fieldset class="width4"> <legend><img src="../img/admin/cog.gif" alt="" />' . $this->l('Indexes and caches') . '</legend> <span id="indexing-warning" style="display: none; color:red; font-weight: bold">' . $this->l('Indexing is in progress. Please do not leave this page') . '<br/><br/></span>'; if (!Configuration::getGlobalValue('PS_LAYERED_INDEXED')) { $html .= ' <script type="text/javascript"> $(document).ready(function() { $(\'#url-indexer\').click(); $(\'#full-index\').click(); }); </script>'; } $category_ist = array(); foreach (Db::getInstance()->executeS('SELECT id_category FROM `' . _DB_PREFIX_ . 'category`') as $category) { if ($category['id_category'] != 1) { $category_ist[] = $category['id_category']; } } $domain = Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST']; $html .= ' <a class="bold ajaxcall-recurcive" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" href="' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '">' . $this->l('Index all missing prices') . '</a> <br /> <a class="bold ajaxcall-recurcive" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index" href="' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&full=1">' . $this->l('Rebuild entire price index') . '</a> <br /> <a class="bold ajaxcall" id="attribute-indexer" rel="attribute" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index" href="' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-attribute-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '">' . $this->l('Build attribute index') . '</a> <br /> <a class="bold ajaxcall" id="url-indexer" rel="price" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index" href="' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-url-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&truncate=1">' . $this->l('Build URL index') . '</a> <br /> <br /> ' . $this->l('You can set a cron job that will rebuild price index using the following URL:') . '<br /><b>' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-price-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&full=1</b> <br /> ' . $this->l('You can set a cron job that will rebuild URL index using the following URL:') . '<br /><b>' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-url-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&truncate=1</b> <br /> ' . $this->l('You can set a cron job that will rebuild attribute index using the following URL:') . '<br /><b>' . $domain . __PS_BASE_URI__ . 'modules/blocklayered/blocklayered-attribute-indexer.php' . '?token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '</b> <br /><br /> ' . $this->l('A nightly rebuild is recommended.') . ' <script type="text/javascript"> $(\'.ajaxcall\').click(function() { if (this.legend == undefined) this.legend = $(this).html(); if (this.running == undefined) this.running = false; if (this.running == true) return false; $(\'.ajax-message\').hide(); this.running = true; if (typeof(this.restartAllowed) == \'undefined\' || this.restartAllowed) { $(this).html(this.legend+\' ' . addslashes($this->l('(in progress)')) . '\'); $(\'#indexing-warning\').show(); } this.restartAllowed = false; var type = $(this).attr(\'rel\'); $.ajax({ url: this.href+\'&ajax=1\', context: this, dataType: \'json\', cache: \'false\', success: function(res) { this.running = false; this.restartAllowed = true; $(\'#indexing-warning\').hide(); $(this).html(this.legend); if (type == \'price\') $(\'#ajax-message-ok span\').html(\'' . addslashes($this->l('URL indexation finished')) . '\'); else $(\'#ajax-message-ok span\').html(\'' . addslashes($this->l('Attribute indexation finished')) . '\'); $(\'#ajax-message-ok\').show(); return; }, error: function(res) { this.restartAllowed = true; $(\'#indexing-warning\').hide(); if (type == \'price\') $(\'#ajax-message-ko span\').html(\'' . addslashes($this->l('URL indexation failed')) . '\'); else $(\'#ajax-message-ko span\').html(\'' . addslashes($this->l('Attribute indexation failed')) . '\'); $(\'#ajax-message-ko\').show(); $(this).html(this.legend); this.running = false; } }); return false; }); $(\'.ajaxcall-recurcive\').each(function(it, elm) { $(elm).click(function() { if (this.cursor == undefined) this.cursor = 0; if (this.legend == undefined) this.legend = $(this).html(); if (this.running == undefined) this.running = false; if (this.running == true) return false; $(\'.ajax-message\').hide(); this.running = true; if (typeof(this.restartAllowed) == \'undefined\' || this.restartAllowed) { $(this).html(this.legend+\' ' . addslashes($this->l('(in progress)')) . '\'); $(\'#indexing-warning\').show(); } this.restartAllowed = false; $.ajax({ url: this.href+\'&ajax=1&cursor=\'+this.cursor, context: this, dataType: \'json\', cache: \'false\', success: function(res) { this.running = false; if (res.result) { this.cursor = 0; $(\'#indexing-warning\').hide(); $(this).html(this.legend); $(\'#ajax-message-ok span\').html(\'' . addslashes($this->l('Price indexation finished')) . '\'); $(\'#ajax-message-ok\').show(); return; } this.cursor = parseInt(res.cursor); $(this).html(this.legend+\' ' . addslashes($this->l('(in progress, %s products price to index)')) . '\'.replace(\'%s\', res.count)); $(this).click(); }, error: function(res) { this.restartAllowed = true; $(\'#indexing-warning\').hide(); $(\'#ajax-message-ko span\').html(\'' . addslashes($this->l('Price indexation failed')) . '\'); $(\'#ajax-message-ko\').show(); $(this).html(this.legend); this.cursor = 0; this.running = false; } }); return false; }); }); </script> </fieldset> <br /> <fieldset class="width4"> <legend><img src="../img/admin/cog.gif" alt="" />' . $this->l('Existing filter templates') . '</legend>'; $filters_templates = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'layered_filter ORDER BY date_add DESC'); if (count($filters_templates)) { $html .= '<p>' . count($filters_templates) . ' ' . $this->l('filter templates are configured:') . '</p> <table id="table-filter-templates" class="table" style="width: 700px;"> <tr> <th>' . $this->l('ID') . '</th> <th>' . $this->l('Name') . '</th> <th>' . $this->l('Categories') . '</th> <th>' . $this->l('Created on') . '</th> <th>' . $this->l('Actions') . '</th> </tr>'; foreach ($filters_templates as $filters_template) { /* Clean request URI first */ $_SERVER['REQUEST_URI'] = preg_replace('/&deleteFilterTemplate=[0-9]*&id_layered_filter=[0-9]*/', '', $_SERVER['REQUEST_URI']); $html .= ' <tr> <td>' . (int) $filters_template['id_layered_filter'] . '</td> <td style="text-align: left; padding-left: 10px; width: 270px;">' . $filters_template['name'] . '</td> <td style="text-align: center;">' . (int) $filters_template['n_categories'] . '</td> <td>' . Tools::displayDate($filters_template['date_add'], null, true) . '</td> <td> <a href="#" onclick="return updElements(' . ($filters_template['n_categories'] ? 0 : 1) . ', ' . (int) $filters_template['id_layered_filter'] . ');"> <img src="../img/admin/edit.gif" alt="" title="' . $this->l('Edit') . '" /></a> <a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&deleteFilterTemplate=1&id_layered_filter=' . (int) $filters_template['id_layered_filter'] . '" onclick="return confirm(\'' . addslashes(sprintf($this->l('Delete filter template #%d?'), (int) $filters_template['id_layered_filter'])) . '\');"> <img src="../img/admin/delete.gif" alt="" title="' . $this->l('Delete') . '" /></a> </td> </tr>'; } $html .= ' </table>'; } else { $html .= $this->l('No filter template found.'); } $html .= ' </fieldset><br /> <fieldset class="width4"> <legend><img src="../img/admin/cog.gif" alt="" />' . $this->l('Build your own filter template') . '</legend> <link rel="stylesheet" href="' . _PS_CSS_DIR_ . 'jquery-ui-1.8.10.custom.css" /> <style type="text/css"> #error-filter-name { display: none; } #layered_container_left ul, #layered_container_right ul { list-style-type: none; padding-left: 0px; } .ui-effects-transfer { border: 1px solid #CCC; } .ui-state-highlight { height: 1.5em; line-height: 1.2em; } ul#selected_filters, #layered_container_right ul { list-style-type: none; margin: 0; padding: 0; } ul#selected_filters li, #layered_container_right ul li { width: 326px; font-size: 11px; padding: 8px 9px 7px 20px; height: 14px; margin-bottom: 5px; } ul#selected_filters li span.ui-icon { position: absolute; margin-top: -2px; margin-left: -18px; } #layered_container_right ul li span { display: none; } #layered_container_right ul li { padding-left: 8px; position: relative; } #layered_container_left ul li { cursor: move; position: relative; } #layered-cat-counter { display: none; } #layered-step-2, #layered-step-3 { display: none; } #layered-step-2 h3 { margin-top: 0; } #table-filter-templates tr th, #table-filter-templates tr td { text-align: center; } .filter_type { width: 70px; position: absolute; right: 53px; top: 5px;} .filter_show_limit { position: absolute; width: 40px; right: 5px; top: 5px; } #layered-step-3 .alert { width: auto; } #fancybox-content { height: 400px !important; overflow: auto !important; } </style> <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" onsubmit="return checkForm();">'; $html .= ' <h2>' . $this->l('Step 1/3 - Select categories') . '</h2> <p style="margin-top: 20px;"> <span style="color: #585A69;display: block;float: left;font-weight: bold;text-align: right;width: 200px;" >' . $this->l('Use this template for:') . '</span> <input type="radio" id="scope_1" name="scope" value="1" style="margin-left: 15px;" onclick="$(\'#error-treeview\').hide(); $(\'#layered-step-2\').show(); updElements(1, 0);" /> <label for="scope_1" style="float: none;">' . $this->l('All categories') . '</label> <input type="radio" id="scope_2" name="scope" value="2" style="margin-left: 15px;" class="layered-category-selection" onclick="$(\'label a#inline\').click(); $(\'#layered-step-2\').show();" /> <style> .link { color: black; cursor: pointer; text-decoration: underline; } .link:hover { color: gray; } </style> <label for="scope_2" style="float: none;"><a id="inline" href="#layered-categories-selection" style="text-decoration: underline;"></a>' . preg_replace('/\\*([^*]+)\\*/Usi', '<span class="link">$1</span>', $this->l('*Specific* categories')) . ' (<span id="layered-cat-counter"></span> ' . $this->l('selected') . ')</label> </p>'; $shops = Shop::getShops(true, null, true); if (count($shops) > 1) { $helper = new HelperForm(); $helper->id = null; $helper->table = 'layered_filter'; $helper->identifier = 'id_layered_filter'; if (Shop::isFeatureActive()) { $html .= '<span style="color: #585A69;display: block;float: left;font-weight: bold;text-align: right;width: 200px;" >' . $this->l('Choose shop association:') . '</span>'; $html .= '<div id="shop_association" style="width: 300px;margin-left: 215px;">' . $helper->renderAssoShop() . '</div>'; } } $html .= ' <div id="error-treeview" class="error" style="display: none;"> <img src="../img/admin/error2.png" alt="" /> ' . $this->l('Please select at least one specific category or select "All categories".') . ' </div> <div style="display: none;"> <div id="layered-categories-selection" style="padding: 10px; text-align: left;"> <h2>' . $this->l('Categories using this template') . '</h2> <ol style="padding-left: 20px;"> <li>' . $this->l('Select one ore more category using this filter template') . '</li> <li>' . $this->l('Press "Save this selection" or close the window to save') . '</li> </ol>'; $selected_cat = array(); // Translations are not automatic for the moment ;) 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')); } $helper = new Helper(); $html .= $helper->renderCategoryTree(null, $selected_cat, 'categoryBox'); $html .= ' <br /> <center><input type="button" class="button" value="' . $this->l('Save this selection') . '" onclick="$.fancybox.close();" /></center> </div> </div> <div id="layered-step-2"> <hr size="1" noshade /> <h2>' . $this->l('Step 2/3 - Select filters') . '</h2> <div id="layered_container"> <div id="layered_container_left" style="width: 360px; float: left; height: 200px; overflow-y: auto;"> <h3>' . $this->l('Selected filters') . ' <span id="num_sel_filters">(0)</span></h3> <p id="no-filters">' . $this->l('No filters selected yet.') . '</p> <ul id="selected_filters"></ul> </div> <div id="layered-ajax-refresh"> ' . $this->ajaxCallBackOffice() . ' </div> </div> <div class="clear"></div> <hr size="1" noshade />'; $this->context->controller->addJQueryPlugin('fancybox'); $this->context->controller->addJQueryUI('ui.sortable'); $this->context->controller->addJQueryUI('ui.draggable'); $this->context->controller->addJQueryUI('effects.transfer'); $id_lang = Context::getContext()->cookie->id_lang; $html .= ' <script type="text/javascript"> function updLayCounters(showAlert) { $(\'#num_sel_filters\').html(\'(\'+$(\'ul#selected_filters\').find(\'li\').length+\')\'); $(\'#num_avail_filters\').html(\'(\'+$(\'#layered_container_right ul\').find(\'li\').length+\')\'); if ($(\'ul#selected_filters\').find(\'li\').length >= 1) { $(\'#layered-step-3\').show(); $(\'#layered-step-3 .alert\').hide(); } else { if (showAlert) $(\'#layered-step-3\').show(); else $(\'#layered-step-3\').hide(); $(\'#layered-step-3 .alert\').show(); } } function updPositions() { $(\'#layered_container_left li\').each(function(idx) { $(this).find(\'span.position\').html(parseInt(1+idx)+\'. \'); }); } function updCatCounter() { $(\'#layered-cat-counter\').html($(\'#categories-treeview\').find(\'input:checked\').length); $(\'#layered-cat-counter\').show(); } function updHeight() { $(\'#layered_container_left\').css(\'height\', 30+(1+$(\'#layered_container_left\').find(\'li\').length)*34); $(\'#layered_container_right\').css(\'height\', 30+(1+$(\'#layered_container_right\').find(\'li\').length)*34); } function updElements(all, id_layered_filter) { if ($(\'#error-treeview\').is(\':hidden\')) $(\'#layered-step-2\').show(); else $(\'#layered-step-2\').hide(); $(\'#layered-ajax-refresh\').css(\'background-color\', \'black\'); $(\'#layered-ajax-refresh\').css(\'opacity\', \'0.2\'); $(\'#layered-ajax-refresh\').html(\'<div style="margin: 0 auto; padding: 10px; text-align: center;">\' +\'<img src="../img/admin/ajax-loader-big.gif" alt="" /><br /><p style="color: white;">' . addslashes($this->l('Loading...')) . '</p></div>\'); $.ajax( { type: \'POST\', url: \'' . __PS_BASE_URI__ . '\' + \'modules/blocklayered/blocklayered-ajax-back.php\', data: \'layered_token=' . substr(Tools::encrypt('blocklayered/index'), 0, 10) . '&id_lang=' . $id_lang . '&\' +(all ? \'\' : $(\'input[name="categoryBox[]"]\').serialize()+\'&\') +(id_layered_filter ? \'id_layered_filter=\'+parseInt(id_layered_filter) : \'\') +\'&base_folder=' . urlencode(_PS_ADMIN_DIR_) . '\', success: function(result) { $(\'#layered-ajax-refresh\').css(\'background-color\', \'transparent\'); $(\'#layered-ajax-refresh\').css(\'opacity\', \'1\'); $(\'#layered-ajax-refresh\').html(result); $(\'#layered_container_right li input\').each(function() { if ($(\'#layered_container_left\').find(\'input[id="\'+$(this).attr(\'id\')+\'"]\').length > 0) $(this).parent().remove(); }); updHeight(); updLayCounters(true); } }); return false; } function checkForm() { if ($(\'#layered_tpl_name\').val() == \'\') { $(\'#error-filter-name\').show(); return false; } else if ($(\'#scope_1\').attr(\'checked\') && $(\'#n_existing\').val() > 0) if (!confirm(\'' . addslashes($this->l('You selected -All categories-, all existing filter templates will be deleted, OK?')) . '\')) return false; return true; } function launch() { $(\'#layered_container input\').live(\'click\', function () { if ($(this).parent().hasClass(\'layered_right\')) { $(\'p#no-filters\').hide(); $(this).parent().css(\'background\', \'url("../img/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png") repeat-x scroll 50% 50% #FDF5CE\'); $(this).parent().removeClass(\'layered_right\'); $(this).parent().addClass(\'layered_left\'); $(this).effect(\'transfer\', { to: $(\'#layered_container_left ul#selected_filters\') }, 300, function() { $(this).parent().appendTo(\'ul#selected_filters\'); updLayCounters(false); updHeight(); updPositions(); }); } else { $(this).parent().css(\'background\', \'url("../img/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png") repeat-x scroll 50% 50% #F6F6F6\'); $(this).effect(\'transfer\', { to: $(\'#layered_container_right ul#all_filters\') }, 300, function() { $(this).parent().removeClass(\'layered_left\'); $(this).parent().addClass(\'layered_right\'); $(this).parent().appendTo(\'ul#all_filters\'); updLayCounters(true); updHeight(); updPositions(); if ($(\'#layered_container_left ul\').length == 0) $(\'p#no-filters\').show(); }); } enableSortable(); }); $(\'label a#inline\').fancybox({ \'hideOnContentClick\': false, \'onClosed\': function() { lock_treeview_hidding = false; $(\'#categories-treeview\').parent().parent().hide(); updCatCounter(); if ($(\'#categories-treeview\').find(\'input:checked\').length == 0) $(\'#error-treeview\').show(); else $(\'#error-treeview\').hide(); updElements(0, 0); }, \'onComplete\': function() { lock_treeview_hidding = true; $(\'#categories-treeview\').parent().parent().show(); if($($(\'#categories-treeview li\')[0]).attr(\'cleaned\')) return; if($($(\'#categories-treeview li\')[0]).attr(\'cleaned\', true)) $($(\'#categories-treeview li\')[0]).removeClass(\'static\'); $($(\'#categories-treeview li span\')[0]).trigger(\'click\'); $($(\'#categories-treeview li\')[0]).children(\'div\').remove(); $($(\'#categories-treeview li\')[0]). removeClass(\'collapsable lastCollapsable\'). addClass(\'last static\'); $(\'.hitarea\').live(\'click\', function(it) { $(this).parent().find(\'> .category_label\').click(); }); } }); updHeight(); updLayCounters(false); updPositions(); updCatCounter(); enableSortable(); } function enableSortable() { $(function() { $(\'ul#selected_filters\').sortable({ axis: \'y\', update: function() { updPositions(); }, placeholder: \'ui-state-highlight\' }); $(\'ul#selected_filters\').disableSelection(); }); } $(document).ready(function() { launch(); }); </script> </div> <div id="layered-step-3"> <div id="error-filter-name" class="error"> <img src="../img/admin/error.png" alt="" title="" />' . $this->l('Errors:') . ' <ul> <li>' . $this->l('Filter template name required (cannot be empty)') . '</li> </ul> </div> <h2>' . $this->l('Step 3/3 - Name your template') . '</h2> <p>' . $this->l('Template name:') . ' <input type="text" id="layered_tpl_name" onkeyup="if ($(this).val() != \'\') { $(\'#error-filter-name\').hide(); } else { $(\'#error-filter-name\').show(); }" name="layered_tpl_name" maxlength="64" value="' . sprintf($this->l('My template %s'), date('Y-m-d')) . '" style="width: 200px; font-size: 11px;" /> <span style="font-size: 10px; font-style: italic;">(' . $this->l('only as a reminder') . ')</span></p> <hr size="1" noshade /> <p class="alert">' . $this->l('No filters selected, the blocklayered will be disable for the categories seleted.') . '</p> <br /> <center><input type="submit" class="button" name="SubmitFilter" value="' . $this->l('Save this filter template') . '" /></center> </div> <input type="hidden" name="id_layered_filter" id="id_layered_filter" value="0" /> <input type="hidden" name="n_existing" id="n_existing" value="' . (int) count($filters_templates) . '" /> </form> </fieldset><br /> <fieldset class="width4"> <legend><img src="../img/admin/cog.gif" alt="" /> ' . $this->l('Configuration') . '</legend> <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post"> <table border="0" style="font-size: 11px; width: 100%; margin: 0 auto;" class="table"> <tr> <th style="text-align: center;">' . $this->l('Option') . '</th> <th style="text-align: center; width: 200px;">' . $this->l('Value') . '</th> </tr> <tr> <td style="text-align: right;">' . $this->l('Hide filter values with no product is matching') . '</td> <td style="text-align: center;"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_hide_0_values" value="1" ' . (Configuration::get('PS_LAYERED_HIDE_0_VALUES') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_hide_0_values" value="0" ' . (!Configuration::get('PS_LAYERED_HIDE_0_VALUES') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr> <td style="text-align: right;">' . $this->l('Show the number of matching products') . '</td> <td style="text-align: center;"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_show_qties" value="1" ' . (Configuration::get('PS_LAYERED_SHOW_QTIES') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_show_qties" value="0" ' . (!Configuration::get('PS_LAYERED_SHOW_QTIES') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr> <td style="text-align: right;">' . $this->l('Show products from subcategories') . '</td> <td style="text-align: center;"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_full_tree" value="1" ' . (Configuration::get('PS_LAYERED_FULL_TREE') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_full_tree" value="0" ' . (!Configuration::get('PS_LAYERED_FULL_TREE') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr style="text-align: center;"> <td style="text-align: right;">' . $this->l('Category filter depth (0 for no limits, 1 by default)') . '</td> <td> <input type="text" name="ps_layered_filter_category_depth" value="' . (Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH') !== false ? Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH') : 1) . '" /> </td> </tr> <tr style="text-align: center;"> <td style="text-align: right;">' . $this->l('Use tax to filter price') . '</td> <td> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_filter_price_usetax" value="1" ' . (Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_filter_price_usetax" value="0" ' . (!Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr style="text-align: center;"> <td style="text-align: right;">' . $this->l('Allow indexing robots (google, yahoo, bing, ...) to use condition filter') . '</td> <td> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_filter_index_condition" value="1" ' . (Configuration::get('PS_LAYERED_FILTER_INDEX_CDT') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_filter_index_condition" value="0" ' . (!Configuration::get('PS_LAYERED_FILTER_INDEX_CDT') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr style="text-align: center;"> <td style="text-align: right;">' . $this->l('Allow indexing robots (google, yahoo, bing, ...) to use availability filter') . '</td> <td> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_filter_index_availability" value="1" ' . (Configuration::get('PS_LAYERED_FILTER_INDEX_QTY') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_filter_index_availability" value="0" ' . (!Configuration::get('PS_LAYERED_FILTER_INDEX_QTY') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr style="text-align: center;"> <td style="text-align: right;">' . $this->l('Allow indexing robots (google, yahoo, bing, ...) to use manufacturer filter') . '</td> <td> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_filter_index_manufacturer" value="1" ' . (Configuration::get('PS_LAYERED_FILTER_INDEX_MNF') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_filter_index_manufacturer" value="0" ' . (!Configuration::get('PS_LAYERED_FILTER_INDEX_MNF') ? 'checked="checked"' : '') . ' /> </td> </tr> <tr style="text-align: center;"> <td style="text-align: right;">' . $this->l('Allow indexing robots (google, yahoo, bing, ...) to use category filter') . '</td> <td> <img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" /> ' . $this->l('Yes') . ' <input type="radio" name="ps_layered_filter_index_category" value="1" ' . (Configuration::get('PS_LAYERED_FILTER_INDEX_CAT') ? 'checked="checked"' : '') . ' /> <img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" style="margin-left: 10px;" /> ' . $this->l('No') . ' <input type="radio" name="ps_layered_filter_index_category" value="0" ' . (!Configuration::get('PS_LAYERED_FILTER_INDEX_CAT') ? 'checked="checked"' : '') . ' /> </td> </tr> </table> <p style="text-align: center;"><input type="submit" class="button" name="submitLayeredSettings" value="' . $this->l('Save configuration') . '" /></p> </form> </fieldset>'; return $html; }
/** * Get Each parent category of this category until the root category * * @param int $id_lang Language ID * @return array Corresponding categories */ public function getParentsCategories($id_lang = null) { $context = Context::getContext()->cloneContext(); $context->shop = clone $context->shop; if (is_null($id_lang)) { $id_lang = $context->language->id; } $categories = null; $id_current = $this->id; if (count(Category::getCategoriesWithoutParent()) > 1 && Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && count(Shop::getShops(true, null, true)) != 1) { $context->shop->id_category = (int) Configuration::get('PS_ROOT_CATEGORY'); } elseif (!$context->shop->id) { $context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT')); } $id_shop = $context->shop->id; while (true) { $sql = ' SELECT c.*, cl.* FROM `' . _DB_PREFIX_ . 'category` c LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('cl') . ')'; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')'; } $sql .= ' WHERE c.`id_category` = ' . (int) $id_current; if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) { $sql .= ' AND cs.`id_shop` = ' . (int) $context->shop->id; } $root_category = Category::getRootCategory(); if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && (!Tools::isSubmit('id_category') || (int) Tools::getValue('id_category') == (int) $root_category->id || (int) $root_category->id == (int) $context->shop->id_category)) { $sql .= ' AND c.`id_parent` != 0'; } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if ($result) { $categories[] = $result; } elseif (!$categories) { $categories = array(); } if (!$result || $result['id_category'] == $context->shop->id_category) { return $categories; } $id_current = $result['id_parent']; } }
public static function GetFirstAvailableCategory() { $wsawnnlcy = "first_available_category"; global $cookie; ${$wsawnnlcy} = Category::getRootCategory(); if ($first_available_category->id > 2) { return $first_available_category->id; } ${"GLOBALS"}["nljswqny"] = "sql"; ${${"GLOBALS"}["gnsbnykowac"]} = "SELECT c.id_category \n\t\t\t\tFROM " . _DB_PREFIX_ . "category c \n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "category_lang cl ON (c.id_category=cl.id_category AND cl.id_lang=" . $cookie->id_lang . ") \n\t\t\t\tWHERE id_parent=" . $first_available_category->id . "\n\t\t\t\tORDER BY cl.name"; return (int) Db::getInstance()->getValue(${${"GLOBALS"}["nljswqny"]}); }
/** * This checks if the template set is available for mobile themes, * otherwise the front template is choosen. */ public function setMobileTemplate($template) { // Needed for site map $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive()); $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active); $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->context->smarty->assign('conditions', Configuration::get('PS_CONDITIONS')); $this->context->smarty->assign('id_cgv', Configuration::get('PS_CONDITIONS_CMS_ID')); $this->context->smarty->assign('PS_SHOP_NAME', Configuration::get('PS_SHOP_NAME')); $mobile_template = ''; $tpl_file = basename($template); $dirname = dirname($template) . (substr(dirname($template), -1, 1) == '/' ? '' : '/'); if ($dirname == _PS_THEME_DIR_) { if (file_exists(_PS_THEME_MOBILE_DIR_ . $tpl_file)) { $template = _PS_THEME_MOBILE_DIR_ . $tpl_file; } } elseif ($dirname == _PS_THEME_MOBILE_DIR_) { if (!file_exists(_PS_THEME_MOBILE_DIR_ . $tpl_file) && file_exists(_PS_THEME_DIR_ . $tpl_file)) { $template = _PS_THEME_DIR_ . $tpl_file; } } $assign = array(); $assign['tpl_file'] = basename($tpl_file, '.tpl'); if (isset($this->php_self)) { $assign['controller_name'] = $this->php_self; } $this->context->smarty->assign($assign); $this->template = $template; }
public function renderForm() { $this->context->controller->addCSS($this->_path . 'css/yamarket.css', 'all'); $this->context->controller->addJS($this->_path . 'js/yamarket.js', 'all'); $offer_type = Tools::getValue('YAMARKET_EXPORT_TYPE', Configuration::get('YAMARKET_EXPORT_TYPE')); $root_category = Category::getRootCategory(); if (!$root_category->id) { $root_category->id = 0; $root_category->name = $this->l('Root'); } $root_category = array('id_category' => (int) $root_category->id, 'name' => $root_category->name); $selected_cat = array(); foreach (Tools::getValue('categoryBox', $this->selected_cats) as $row) { $selected_cat[] = $row; } $fields_form = array('form' => array('legend' => array('title' => $this->l('Settings'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'text', 'label' => $this->l('Company Name'), 'name' => 'YAMARKET_COMPANY_NAME', 'required' => true), array('type' => 'text', 'label' => $this->l('Local delivery cost'), 'name' => 'YAMARKET_DELIVERY_PRICE', 'required' => true), array('type' => 'radio', 'label' => $this->l('Description'), 'name' => 'YAMARKET_DESC_TYPE', 'class' => 't', 'values' => array(array('id' => 'YAMARKET_DESC_TYPE_normal', 'value' => 0, 'label' => $this->l('Normal')), array('id' => 'YAMARKET_DESC_TYPE_short', 'value' => 1, 'label' => $this->l('Short')))), array('type' => 'radio', 'label' => $this->l('Offer type'), 'name' => 'YAMARKET_EXPORT_TYPE', 'class' => 't', 'desc' => '<p style="clear:both">' . $this->l('Offer type, see descriptions on') . '<br> <a class="action_module" href="http://help.yandex.ru/partnermarket/offers.xml#base">http://help.yandex.ru/partnermarket/offers.xml#base</a><br> <a class="action_module" href="http://help.yandex.ru/partnermarket/offers.xml#vendor">http://help.yandex.ru/partnermarket/offers.xml#vendor</a> </p>', 'values' => array(array('id' => 'YAMARKET_EXPORT_TYPE_simple', 'value' => 0, 'label' => $this->l('Simplified')), array('id' => 'YAMARKET_EXPORT_TYPE_vendor', 'value' => 1, 'label' => $this->l('Vendor.model')))), array('type' => 'text', 'label' => $this->l('Country of origin attribute name'), 'name' => 'YAMARKET_COUNTRY_OF_ORIGIN'), array('type' => 'text', 'label' => $this->l('Model attribute name'), 'name' => 'YAMARKET_MODEL_NAME', 'desc' => $this->l('Leave empty to use product name as model name')), array('type' => 'categories', 'label' => $this->l('Categories to export:'), 'name' => 'categoryBox', 'values' => array('trads' => array('Root' => $root_category, 'selected' => $this->l('Selected'), 'Check all' => $this->l('Check all'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All')), 'selected_cat' => $selected_cat, 'input_name' => 'categoryBox[]', 'use_radio' => false, 'use_search' => false, 'disabled_categories' => array(), 'top_category' => Category::getTopCategory(), 'use_context' => true), 'tree' => array('id' => 'categories-tree', 'use_checkbox' => true, 'use_search' => false, 'selected_categories' => $selected_cat, 'input_name' => 'categoryBox[]'), 'selected_cat' => $selected_cat), array('type' => 'text', 'label' => '<sales_notes>', 'name' => 'YAMARKET_SALES_NOTES', 'size' => 50, 'desc' => $this->l('50 characters max')), array('type' => 'checkbox', 'label' => $this->l('Delivery settings'), 'name' => 'YAMARKET_DELIVERY', 'desc' => $this->l('Details: ') . '<a class="action_module" href="https://help.yandex.ru/partnermarket/delivery.xml">help.yandex.ru/partnermarket/delivery.xml</a>', 'values' => array('query' => array(array('id' => 'DELIVERY', 'name' => '<delivery>', 'val' => '1'), array('id' => 'PICKUP', 'name' => '<pickup>', 'val' => '1'), array('id' => 'STORE', 'name' => '<store>', 'val' => '1')), 'id' => 'id', 'name' => 'name'))), 'submit' => array('title' => $this->l('Save')))); $helper = new HelperForm(); $helper->show_toolbar = false; $this->fields_form = array(); $helper->table = $this->table; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->identifier = $this->identifier; $helper->submit_action = 'submit' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id); $output = $helper->generateForm(array($fields_form)); return $output; }
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'); } 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(); }
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'); } } } }
public function renderForm() { $this->initToolbar(); $obj = $this->loadObject(true); $id_shop = Context::getContext()->shop->id; $selected_cat = array(isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop) ? (int) $obj->id_parent : (int) Tools::getValue('id_parent', Category::getRootCategory()->id)); $unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP')); $guest = new Group(Configuration::get('PS_GUEST_GROUP')); $default = new Group(Configuration::get('PS_CUSTOMER_GROUP')); $unidentified_group_information = sprintf($this->l('%s - All people without a validated customer account.'), '<b>' . $unidentified->name[$this->context->language->id] . '</b>'); $guest_group_information = sprintf($this->l('%s - Customer who placed an order with the Guest Checkout.'), '<b>' . $guest->name[$this->context->language->id] . '</b>'); $default_group_information = sprintf($this->l('%s - All people who have created an account on this site.'), '<b>' . $default->name[$this->context->language->id] . '</b>'); $root_category = Category::getRootCategory(); $root_category = array('id_category' => $root_category->id, 'name' => $root_category->name); $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Category'), 'image' => '../img/admin/tab-categories.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'lang' => true, 'size' => 48, 'required' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'radio', 'label' => $this->l('Displayed:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'categories', 'label' => $this->l('Parent category:'), 'name' => 'id_parent', 'values' => array('trads' => array('Root' => $root_category, 'selected' => $this->l('selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All')), 'selected_cat' => $selected_cat, 'input_name' => 'id_parent', 'use_radio' => true, 'use_search' => false, 'disabled_categories' => array(4), 'top_category' => Category::getTopCategory(), 'use_context' => true)), array('type' => 'radio', 'label' => $this->l('Root Category:'), 'name' => 'is_root_category', 'required' => false, 'is_bool' => true, 'class' => 't', 'values' => array(array('id' => 'is_root_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'is_root_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'textarea', 'label' => $this->l('Description:'), 'name' => 'description', 'lang' => true, 'rows' => 10, 'cols' => 100, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'file', 'label' => $this->l('Image:'), 'name' => 'image', 'display_image' => true, 'desc' => $this->l('Upload category logo from your computer')), array('type' => 'text', 'label' => $this->l('Meta title:'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description:'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords:'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}', 'desc' => $this->l('To add "tags" click in the field, write something, then press "Enter"')), array('type' => 'text', 'label' => $this->l('Friendly URL:'), 'name' => 'link_rewrite', 'lang' => true, 'required' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed')), array('type' => 'group', 'label' => $this->l('Group access:'), 'name' => 'groupBox', 'values' => Group::getGroups(Context::getContext()->language->id), 'info_introduction' => $this->l('You now have three default customer groups.'), 'unidentified' => $unidentified_group_information, 'guest' => $guest_group_information, 'customer' => $default_group_information, 'desc' => $this->l('Mark all customer groups you want to give access to this category'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); $this->tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) && $obj->hasMultishopEntries(); $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso'); } // remove category tree and radio button "is_root_category" if this category has the root category as parent category to avoid any conflict if ($this->_category->id_parent == Category::getTopCategory()->id && Tools::isSubmit('updatecategory')) { foreach ($this->fields_form['input'] as $k => $input) { if (in_array($input['name'], array('id_parent', 'is_root_category'))) { unset($this->fields_form['input'][$k]); } } } if (Tools::isSubmit('add' . $this->table . 'root')) { unset($this->fields_form['input'][2], $this->fields_form['input'][3]); } if (!($obj = $this->loadObject(true))) { return; } $image = ImageManager::thumbnail(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true); $this->fields_value = array('image' => $image ? $image : false, 'size' => $image ? filesize(_PS_CAT_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false); // Added values of object Group $category_groups_ids = $obj->getGroups(); $groups = Group::getGroups($this->context->language->id); // if empty $carrier_groups_ids : object creation : we set the default groups if (empty($category_groups_ids)) { $preselected = array(Configuration::get('PS_UNIDENTIFIED_GROUP'), Configuration::get('PS_GUEST_GROUP'), Configuration::get('PS_CUSTOMER_GROUP')); $category_groups_ids = array_merge($category_groups_ids, $preselected); } foreach ($groups as $group) { $this->fields_value['groupBox_' . $group['id_group']] = Tools::getValue('groupBox_' . $group['id_group'], in_array($group['id_group'], $category_groups_ids)); } return parent::renderForm(); }
/** * * @param array $root array with the name and ID of the tree root category, if null the Shop's root category will be used * @param type $selected_cat array of selected categories * Format * Array * ( * [0] => 1 * [1] => 2 * ) * OR * Array * ( * [1] => Array * ( * [id_category] => 1 * [name] => Home page * ) * ) * @param string $input_name name of input * @param bool $use_radio use radio tree or checkbox tree * @param bool $use_search display a find category search box * @param array $disabled_categories * @param bool $use_in_popup * @param bool $use_shop_context * @return string */ public function renderCategoryTree($root = null, $selected_cat = array(), $input_name = 'categoryBox', $use_radio = false, $use_search = false, $disabled_categories = array(), $use_in_popup = false, $use_shop_context = false) { $translations = array('selected' => $this->l('Selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All'), 'search' => $this->l('Find a category')); $top_category = Category::getTopCategory(); if (Tools::isSubmit('id_shop')) { $id_shop = Tools::getValue('id_shop'); } else { if (Context::getContext()->shop->id) { $id_shop = Context::getContext()->shop->id; } else { if (!Shop::isFeatureActive()) { $id_shop = Configuration::get('PS_SHOP_DEFAULT'); } else { $id_shop = 0; } } } $shop = new Shop($id_shop); $root_category = Category::getRootCategory(null, $shop); $disabled_categories[] = $top_category->id; if (!$root) { $root = array('name' => $root_category->name, 'id_category' => $root_category->id); } if (!$use_radio) { $input_name = $input_name . '[]'; } if ($use_search) { $this->context->controller->addJs(_PS_JS_DIR_ . 'jquery/plugins/autocomplete/jquery.autocomplete.js'); } $html = ' <script type="text/javascript"> var inputName = \'' . addcslashes($input_name, '\'') . '\';' . "\n"; if (count($selected_cat) > 0) { if (isset($selected_cat[0])) { $html .= ' var selectedCat = "' . implode(',', array_map('intval', $selected_cat)) . '";' . "\n"; } else { $html .= ' var selectedCat = "' . implode(',', array_map('intval', array_keys($selected_cat))) . '";' . "\n"; } } else { $html .= ' var selectedCat = \'\';' . "\n"; } $html .= ' var selectedLabel = \'' . $translations['selected'] . '\'; var home = \'' . addcslashes($root['name'], '\'') . '\'; var use_radio = ' . (int) $use_radio . ';'; $html .= '</script>'; $html .= ' <div class="category-filter"> <a class="btn btn-link" href="#" id="collapse_all"><i class="icon-collapse"></i> ' . $translations['Collapse All'] . '</a> <a class="btn btn-link" href="#" id="expand_all"><i class="icon-expand"></i> ' . $translations['Expand All'] . '</a> ' . (!$use_radio ? ' <a class="btn btn-link" href="#" id="check_all"><i class="icon-check"></i> ' . $translations['Check All'] . '</a> <a class="btn btn-link" href="#" id="uncheck_all"><i class="icon-check-empty"></i> ' . $translations['Uncheck All'] . '</a>' : '') . ($use_search ? ' <div class="row"> <label class="control-label col-lg-6" for="search_cat">' . $translations['search'] . ' :</label> <div class="col-lg-6"> <input type="text" name="search_cat" id="search_cat"/> </div> </div>' : '') . '</div>'; $home_is_selected = false; foreach ($selected_cat as $cat) { if (is_array($cat)) { $disabled = in_array($cat['id_category'], $disabled_categories); if ($cat['id_category'] != $root['id_category']) { $html .= '<input ' . ($disabled ? 'disabled="disabled"' : '') . ' type="hidden" name="' . $input_name . '" value="' . $cat['id_category'] . '" >'; } else { $home_is_selected = true; } } else { $disabled = in_array($cat, $disabled_categories); if ($cat != $root['id_category']) { $html .= '<input ' . ($disabled ? 'disabled="disabled"' : '') . ' type="hidden" name="' . $input_name . '" value="' . $cat . '" >'; } else { $home_is_selected = true; } } } $root_input = ''; if ($root['id_category'] != $top_category->id || Tools::isSubmit('ajax') && Tools::getValue('action') == 'getCategoriesFromRootCategory') { $root_input = ' <p class="checkbox"><i class="icon-folder-open"></i><label> <input type="' . (!$use_radio ? 'checkbox' : 'radio') . '" name="' . $input_name . '" value="' . $root['id_category'] . '" ' . ($home_is_selected ? 'checked' : '') . ' onclick="clickOnCategoryBox($(this));" />' . $root['name'] . '</label></p>'; } $html .= ' <div class="container"> <div class="well"> <ul id="categories-treeview"> <li id="' . $root['id_category'] . '" class="hasChildren"> <span class="folder">' . $root_input . ' </span> <ul> <li><span class="placeholder"> </span></li> </ul> </li> </ul> </div> </div>'; if ($use_search) { $html .= '<script type="text/javascript">searchCategory();</script>'; } return $html; }
/** * This checks if the template set is available for mobile themes, * otherwise the front template is choosen. */ public function setMobileTemplate($template) { // Needed for site map $blockmanufacturer = Module::getInstanceByName('blockmanufacturer'); $blocksupplier = Module::getInstanceByName('blocksupplier'); $this->context->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0)); $this->context->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1)); $this->context->smarty->assign('voucherAllowed', (int) CartRule::isFeatureActive()); $this->context->smarty->assign('display_manufacturer_link', (bool) $blockmanufacturer->active); $this->context->smarty->assign('display_supplier_link', (bool) $blocksupplier->active); $this->context->smarty->assign('PS_DISPLAY_SUPPLIERS', Configuration::get('PS_DISPLAY_SUPPLIERS')); $this->context->smarty->assign('PS_DISPLAY_BEST_SELLERS', Configuration::get('PS_DISPLAY_BEST_SELLERS')); $this->context->smarty->assign('display_store', Configuration::get('PS_STORES_DISPLAY_SITEMAP')); $this->context->smarty->assign('conditions', Configuration::get('PS_CONDITIONS')); $this->context->smarty->assign('id_cgv', Configuration::get('PS_CONDITIONS_CMS_ID')); $this->context->smarty->assign('PS_SHOP_NAME', Configuration::get('PS_SHOP_NAME')); $template = $this->getTemplatePath($template); $assign = array(); $assign['tpl_file'] = basename($template, '.tpl'); if (isset($this->php_self)) { $assign['controller_name'] = $this->php_self; } $this->context->smarty->assign($assign); $this->template = $template; }
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(); }