当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::recurseLiteCategTree方法代码示例

本文整理汇总了PHP中Category::recurseLiteCategTree方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::recurseLiteCategTree方法的具体用法?PHP Category::recurseLiteCategTree怎么用?PHP Category::recurseLiteCategTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::recurseLiteCategTree方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recurseLiteCategTree

 /**
  * Recursive scan of subcategories
  *
  * @param integer $max_depth Maximum depth of the tree (i.e. 2 => 3 levels depth)
  * @param integer $current_depth specify the current depth in the tree (don't use it, only for rucursivity!)
  * @param integer $id_lang Specify the id of the language used
  * @param array $excluded_ids_array specify a list of ids to exclude of results
  *
  * @return array Subcategories lite tree
  */
 public function recurseLiteCategTree($max_depth = 3, $current_depth = 0, $id_lang = null, $excluded_ids_array = null)
 {
     $id_lang = is_null($id_lang) ? Context::getContext()->language->id : (int) $id_lang;
     if (!(int) $id_lang) {
         $id_lang = _USER_ID_LANG_;
     }
     $children = array();
     $subcats = $this->getSubCategories($id_lang, true);
     if (($max_depth == 0 || $current_depth < $max_depth) && $subcats && count($subcats)) {
         foreach ($subcats as &$subcat) {
             if (!$subcat['id_category']) {
                 break;
             } else {
                 if (!is_array($excluded_ids_array) || !in_array($subcat['id_category'], $excluded_ids_array)) {
                     $categ = new Category($subcat['id_category'], $id_lang);
                     $children[] = $categ->recurseLiteCategTree($max_depth, $current_depth + 1, $id_lang, $excluded_ids_array);
                 }
             }
         }
     }
     if (is_array($this->description)) {
         foreach ($this->description as $lang => $description) {
             $this->description[$lang] = Category::getDescriptionClean($description);
         }
     } else {
         $this->description = Category::getDescriptionClean($this->description);
     }
     return array('id' => (int) $this->id, 'link' => Context::getContext()->link->getCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:39,代码来源:Category.php

示例2: getCategoryByIdAndSupplier

 /**
  * @return boolean if the supplier get the categorie or child in n+3
  **/
 public static function getCategoryByIdAndSupplier($id_supplier, $id_category, $category_root = 2, $id_lang = false)
 {
     $my_category = new Category($id_category, $id_lang);
     $sub_categories = $my_category->recurseLiteCategTree(3, 0, $id_lang, null)['children'];
     //$sub_categories = /*Category::getChildren($id_category, $id_lang, true, false);*/ $my_category->getSubCategories($id_lang,true);
     $sql = '
         SELECT c.id_category, cl.name, c.id_parent
         FROM `' . _DB_PREFIX_ . 'category` c
         ' . Shop::addSqlAssociation('category', 'c') . '
                     INNER JOIN ' . _DB_PREFIX_ . 'product p ON p.id_category_default = c.id_category
         LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON c.`id_category` = cl.`id_category`' . Shop::addSqlRestrictionOnLang('cl') . '
         WHERE p.id_supplier=' . $id_supplier . ($id_lang ? 'AND `id_lang` = ' . (int) $id_lang : '') . ' ' . (!$id_lang ? 'GROUP BY c.id_category' : '') . '
         ORDER BY c.`level_depth` ASC, category_shop.`position` ASC';
     $resultWithShipper = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
     $supplierTmp = array();
     $boolPresent = false;
     foreach ($resultWithShipper as $key) {
         $boolPresent = false;
         foreach ($sub_categories as $key2) {
             if ($key['id_parent'] == $key2['id'] || $key['id_parent'] == $id_category) {
                 return true;
             }
             foreach ($key2['children'] as $key3) {
                 if ($key['id_parent'] == $key3['id']) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:yewed,项目名称:share,代码行数:34,代码来源:Category.php

示例3: recurseLiteCategTree

 /**
  * Recursive scan of subcategories
  *
  * @param integer $maxDepth Maximum depth of the tree (i.e. 2 => 3 levels depth)
  * @param integer $currentDepth specify the current depth in the tree (don't use it, only for rucursivity!)
  * @param array $excludedIdsArray specify a list of ids to exclude of results
  * @param integer $idLang Specify the id of the language used
  *
  * @return array Subcategories lite tree
  */
 function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $idLang = NULL, $excludedIdsArray = NULL)
 {
     global $link;
     //get idLang
     $idLang = is_null($idLang) ? _USER_ID_LANG_ : intval($idLang);
     //recursivity for subcategories
     $children = array();
     $subcats = $this->getSubCategories($idLang, true);
     if (sizeof($subcats) and ($maxDepth == 0 or $currentDepth < $maxDepth)) {
         foreach ($subcats as &$subcat) {
             if (!$subcat['id_category']) {
                 break;
             } elseif (!is_array($excludedIdsArray) || !in_array($subcat['id_category'], $excludedIdsArray)) {
                 $categ = new Category($subcat['id_category'], $idLang);
                 $categ->name = Category::hideCategoryPosition($categ->name);
                 $children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, $idLang, $excludedIdsArray);
             }
         }
     }
     return array('id' => $this->id_category, 'link' => $link->getCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
 }
开发者ID:raulgimenez,项目名称:dreamongraphics_shop,代码行数:31,代码来源:Category.php

示例4: recurseLiteCategTree

 /**
  * Recursive scan of subcategories
  *
  * @param integer $maxDepth Maximum depth of the tree (i.e. 2 => 3 levels depth)
  * @param integer $currentDepth specify the current depth in the tree (don't use it, only for rucursivity!)
  * @param array $excludedIdsArray specify a list of ids to exclude of results
  * @param integer $idLang Specify the id of the language used
  *
  * @return array Subcategories lite tree
  */
 function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $id_lang = NULL, $excludedIdsArray = NULL)
 {
     global $link;
     if (!(int) $id_lang) {
         $id_lang = _USER_ID_LANG_;
     }
     $children = array();
     if (($maxDepth == 0 or $currentDepth < $maxDepth) and $subcats = $this->getSubCategories((int) $id_lang, true) and sizeof($subcats)) {
         foreach ($subcats as &$subcat) {
             if (!$subcat['id_category']) {
                 break;
             } elseif (!is_array($excludedIdsArray) || !in_array($subcat['id_category'], $excludedIdsArray)) {
                 $categ = new Category((int) $subcat['id_category'], (int) $id_lang);
                 $children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, (int) $id_lang, $excludedIdsArray);
             }
         }
     }
     return array('id' => (int) $this->id_category, 'link' => $link->getCategoryLink((int) $this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
 }
开发者ID:greench,项目名称:prestashop,代码行数:29,代码来源:Category.php

示例5: getChildrenWithNbSelectedSubCat

    public static function getChildrenWithNbSelectedSubCat($id_parent, $selectedCat, $id_lang)
    {
        $selectedCat = explode(',', str_replace(' ', '', $selectedCat));
        if (!is_array($selectedCat)) {
            $selectedCat = array();
        }
        if (version_compare(_PS_VERSION_, '1.4.0.0', '>=')) {
            return Db::getInstance()->ExecuteS('
					SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
					SELECT COUNT(*)
					FROM `' . _DB_PREFIX_ . 'category` c2
					WHERE c2.`id_parent` = c.`id_category`
			) > 0, 1, 0) AS has_children, ' . ($selectedCat ? '(
					SELECT count(c3.`id_category`)
					FROM `' . _DB_PREFIX_ . 'category` c3
					WHERE c3.`nleft` > c.`nleft`
					AND c3.`nright` < c.`nright`
					AND c3.`id_category`  IN (' . implode(',', array_map('intval', $selectedCat)) . ')
			)' : '0') . ' AS nbSelectedSubCat
					FROM `' . _DB_PREFIX_ . 'category` c
					LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlRestrictionOnLang('cl') : '') . ')
					WHERE `id_lang` = ' . (int) $id_lang . '
					AND c.`id_parent` = ' . (int) $id_parent . '
					ORDER BY `position` ASC');
        } else {
            $homecat = new Category((int) $id_parent, (int) $id_lang);
            $categories = $homecat->recurseLiteCategTree();
            $categories_table = array();
            if (self::_isFilledArray($categories)) {
                foreach ($categories['children'] as $categorie) {
                    $categorie_obj = new Category((int) $categorie['id'], (int) $id_lang);
                    $all_sub_categories = self::getAllSubCategories((int) $categorie['id'], (int) $id_lang);
                    $categories_table[] = array('id_category' => $categorie['id'], 'level_depth' => $categorie_obj->level_depth, 'name' => $categorie['name'], 'has_children' => (int) (is_array($categorie['children']) && sizeof($categorie['children'])), 'nbSelectedSubCat' => sizeof(array_intersect($selectedCat, array_values($all_sub_categories))));
                }
            }
            return $categories_table;
        }
    }
开发者ID:acreno,项目名称:pm-ps,代码行数:38,代码来源:AdvancedSearchCoreClass.php

示例6: displayCategoriesSelect

 private function displayCategoriesSelect($categories, $selected)
 {
     $this->_html .= '<label>' . $this->l('Category') . '</label>
   <div class="margin-form"><select name="id_category">
     <option value="">-- ' . $this->l('Choose') . ' --</option>';
     if (version_compare(_PS_VERSION_, '1.6.0.0', '>=') && method_exists('Category', 'getNestedCategories')) {
         foreach (Category::getNestedCategories(Configuration::get('PS_ROOT_CATEGORY'), $this->_cookie->id_lang) as $idCategory => $categoryInformations) {
             if (Configuration::get('PS_ROOT_CATEGORY') != $idCategory) {
                 $this->_html .= '<option value="' . $idCategory . '"' . ($selected == $idCategory ? ' selected="selected"' : '') . '>' . str_repeat('&#150 ', version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? $categoryInformations['level_depth'] - 1 : $categoryInformations['level_depth']) . $categoryInformations['name'] . '</option>';
             }
             $this->_getChildrensCategories($categoryInformations, $selected);
         }
     } else {
         if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && method_exists('Category', 'recurseLiteCategTree')) {
             $rootCategory = new Category((int) Category::getRootCategory()->id, $this->_cookie->id_lang);
             if (Configuration::get('PS_ROOT_CATEGORY') != $rootCategory->id) {
                 $this->_html .= '<option value="' . $rootCategory->id . '"' . ($selected == $rootCategory->id ? ' selected="selected"' : '') . '>' . $rootCategory->name . '</option>';
             }
             $this->_getChildrensCategories($rootCategory->recurseLiteCategTree(99999, 0, $this->_cookie->id_lang), $selected, 0);
         } else {
             $categories_bkup = $categories;
             $first_category = array_shift($categories_bkup);
             array_unshift($categories_bkup, $first_category);
             $first_category_final = array_shift($first_category);
             $this->recurseCategory($categories, $first_category_final, version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Category::getRootCategory()->id : 1, $selected);
         }
     }
     $this->_html .= ' </select></div>';
 }
开发者ID:TheTypoMaster,项目名称:neonflexible,代码行数:29,代码来源:pm_advancedtopmenu.php

示例7: generateFiltersBlock

 public function generateFiltersBlock($selected_filters)
 {
     global $smarty;
     $id_category_layered = Tools::getValue('id_category_layered', Tools::getValue('id_category'));
     $category = new Category($id_category_layered, (int) Context::getContext()->cookie->id_lang);
     if ($category->is_all) {
         return $this->display(__FILE__, 'blocklayered_nofilters.tpl');
     }
     $parent_cat = new Category($category->id_parent, (int) Context::getContext()->cookie->id_lang);
     $children_cats = $parent_cat->recurseLiteCategTree(1);
     if ($filter_block = $this->getFilterBlock($selected_filters)) {
         if ($filter_block['nbr_filterBlocks'] == 0) {
             $smarty->assign(array('id_category_layered' => $id_category_layered, 'page_layered' => isset($_GET['p']) ? $_GET['p'] : 1, 'blocklayered_children_cat' => $children_cats, 'controller_layered' => $_GET['controller']));
             return $this->display(__FILE__, 'blocklayered_nofilters.tpl');
         }
         $translate = array();
         $translate['price'] = $this->l('price');
         $translate['weight'] = $this->l('weight');
         $smarty->assign($filter_block);
         $smarty->assign(array('hide_0_values' => Configuration::get('PS_LAYERED_HIDE_0_VALUES'), 'page_layered' => isset($_GET['p']) ? $_GET['p'] : 1, 'blocklayeredSliderName' => $translate, 'blocklayeredSliderName_js' => json_encode($translate), 'filters_js' => json_encode($filter_block['filters'])));
         return $this->display(__FILE__, 'blocklayered.tpl');
     } else {
         $parent_cat = new Category(Configuration::get('PS_HOME_CATEGORY'), (int) Context::getContext()->cookie->id_lang);
         $children_cats = $parent_cat->recurseLiteCategTree(1);
         $smarty->assign(array('id_category_layered' => $id_category_layered, 'blocklayered_children_cat' => $children_cats, 'controller_layered' => $_GET['controller'], 'search_query' => isset($_GET['search_query']) ? $_GET['search_query'] : null, 'page_layered' => isset($_GET['p']) ? $_GET['p'] : 1));
         return $this->display(__FILE__, 'blocklayered_nofilters.tpl');
         //			return false;
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:29,代码来源:blocklayered.php

示例8: recurseLiteCategTree

 /**
  * Recursive scan of subcategories
  *
  * @param int    $maxDepth         Maximum depth of the tree (i.e. 2 => 3 levels depth)
  * @param int    $currentDepth     specify the current depth in the tree (don't use it, only for recursive calls!)
  * @param int    $idLang           Specify the id of the language used
  * @param array  $excludedIdsArray Specify a list of IDs to exclude of results
  *
  * @param string $format
  *
  * @return array Subcategories lite tree
  */
 public function recurseLiteCategTree($maxDepth = 3, $currentDepth = 0, $idLang = null, $excludedIdsArray = null, $format = 'default')
 {
     $idLang = is_null($idLang) ? Context::getContext()->language->id : (int) $idLang;
     $children = array();
     $subcats = $this->getSubCategories($idLang, true);
     if (($maxDepth == 0 || $currentDepth < $maxDepth) && $subcats && count($subcats)) {
         foreach ($subcats as &$subcat) {
             if (!$subcat['id_category']) {
                 break;
             } elseif (!is_array($excludedIdsArray) || !in_array($subcat['id_category'], $excludedIdsArray)) {
                 $categ = new Category($subcat['id_category'], $idLang);
                 $children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, $idLang, $excludedIdsArray, $format);
             }
         }
     }
     if (is_array($this->description)) {
         foreach ($this->description as $lang => $description) {
             $this->description[$lang] = Category::getDescriptionClean($description);
         }
     } else {
         $this->description = Category::getDescriptionClean($this->description);
     }
     if ($format === 'sitemap') {
         return array('id' => 'category-page-' . (int) $this->id, 'label' => $this->name, 'url' => Context::getContext()->link->getCategoryLink($this->id, $this->link_rewrite), 'children' => $children);
     }
     return array('id' => (int) $this->id, 'link' => Context::getContext()->link->getCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:39,代码来源:Category.php


注:本文中的Category::recurseLiteCategTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。