本文整理汇总了PHP中CMSCategory::recurseLiteCategTree方法的典型用法代码示例。如果您正苦于以下问题:PHP CMSCategory::recurseLiteCategTree方法的具体用法?PHP CMSCategory::recurseLiteCategTree怎么用?PHP CMSCategory::recurseLiteCategTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMSCategory
的用法示例。
在下文中一共展示了CMSCategory::recurseLiteCategTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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_ : (int) $idLang;
//recursivity for subcategories
$children = array();
if (($maxDepth == 0 or $currentDepth < $maxDepth) and $subcats = $this->getSubCategories($idLang, true) and sizeof($subcats)) {
foreach ($subcats as &$subcat) {
if (!$subcat['id_cms_category']) {
break;
} elseif (!is_array($excludedIdsArray) || !in_array($subcat['id_cms_category'], $excludedIdsArray)) {
$categ = new CMSCategory($subcat['id_cms_category'], $idLang);
$categ->name = CMSCategory::hideCMSCategoryPosition($categ->name);
$children[] = $categ->recurseLiteCategTree($maxDepth, $currentDepth + 1, $idLang, $excludedIdsArray);
}
}
}
return array('id' => $this->id_cms_category, 'link' => $link->getCMSCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
}
示例2: recurseLiteCategTree
/**
* Recursive scan of subcategories
*
* @param integer $max_depth 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 $excluded_ids_array specify a list of ids to exclude of results
* @param integer $idLang Specify the id of the language used
*
* @return array Subcategories lite tree
*/
public function recurseLiteCategTree($max_depth = 3, $currentDepth = 0, $id_lang = null, $excluded_ids_array = null, Link $link = null)
{
if (!$link) {
$link = Context::getContext()->link;
}
if (is_null($id_lang)) {
$id_lang = Context::getContext()->language->id;
}
// recursivity for subcategories
$children = array();
$subcats = $this->getSubCategories($id_lang, true);
if (($max_depth == 0 || $currentDepth < $max_depth) && $subcats && count($subcats)) {
foreach ($subcats as &$subcat) {
if (!$subcat['id_cms_category']) {
break;
} elseif (!is_array($excluded_ids_array) || !in_array($subcat['id_cms_category'], $excluded_ids_array)) {
$categ = new CMSCategory($subcat['id_cms_category'], $id_lang);
$categ->name = CMSCategory::hideCMSCategoryPosition($categ->name);
$children[] = $categ->recurseLiteCategTree($max_depth, $currentDepth + 1, $id_lang, $excluded_ids_array);
}
}
}
return array('id' => $this->id_cms_category, 'link' => $link->getCMSCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
}
示例3: 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 array $excluded_ids_array specify a list of ids to exclude of results
* @param integer $id_lang Specify the id of the language used
*
* @return array Subcategories lite tree
*/
public function recurseLiteCategTree($max_depth = 3, $current_depth = 0, $id_lang = null, $excluded_ids_array = null)
{
global $link;
$id_lang = !(int) $id_lang ? _USER_ID_LANG_ : (int) $id_lang;
$children = array();
if (($max_depth == 0 || $current_depth < $max_depth) && ($subcats = $this->getSubCategories((int) $id_lang, true))) {
if (count($subcats)) {
/* Keep this line out of the first if statement to avoid side effect due to the assignation */
foreach ($subcats as &$subcat) {
if (!$subcat['id_cms_category']) {
break;
} elseif (!is_array($excluded_ids_array) || !in_array($subcat['id_cms_category'], $excluded_ids_array)) {
$categ = new CMSCategory((int) $subcat['id_cms_category'], (int) $id_lang);
$categ->name = CMSCategory::hideCMSCategoryPosition($categ->name);
$children[] = $categ->recurseLiteCategTree($max_depth, $current_depth + 1, (int) $id_lang, $excluded_ids_array);
}
}
}
}
return array('id' => (int) $this->id_cms_category, 'link' => $link->getCMSCategoryLink($this->id, $this->link_rewrite), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
}