本文整理汇总了PHP中Category::getRootCategory方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getRootCategory方法的具体用法?PHP Category::getRootCategory怎么用?PHP Category::getRootCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::getRootCategory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
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;
}
示例2: renderForm
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>';
}
示例3: renderForm
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);
}
示例4: getTemplateVarSitemap
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;
}
示例5: renderForm
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);
}
示例6: renderForm
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);
}
示例7: hookTop
/**
* 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');
}
示例8: process
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'));
}
示例9: initContent
/**
* 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');
}
示例10: getData
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;
}
示例11: executeIndex
/**
* 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();
}
}
示例12: renderForm
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);
}
示例13: renderForm
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);
}
示例14: renderForm
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);
}
示例15: getCategLang
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']);
}