示例#1
0
 /**
  * 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 recursive!)
  * @param integer $lang_id 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 recurseLiteCategoryTree($max_depth = 3, $current_depth = 0, $lang_id = null, $excluded_ids_array = null)
 {
     $lang_id = is_null($lang_id) ? JeproshopContext::getContext()->language->lang_id : (int) $lang_id;
     $children = array();
     $subCategories = $this->getSubCategories($lang_id, true);
     if (($max_depth == 0 || $current_depth < $max_depth) && $subCategories && count($subCategories)) {
         foreach ($subCategories as &$subCategory) {
             if (!$subCategory->category_id) {
                 break;
             } else {
                 if (!is_array($excluded_ids_array) || !in_array($subCategory->category_id, $excluded_ids_array)) {
                     $category = new JeproshopCategoryModelCategory($subCategory->category_id, $lang_id);
                     $children[] = $category->recurseLiteCategoryTree($max_depth, $current_depth + 1, $lang_id, $excluded_ids_array);
                 }
             }
         }
     }
     if (is_array($this->description)) {
         foreach ($this->description as $language_id => $description) {
             $this->description[$language_id] = JeproshopTools::getDescriptionClean($description);
         }
     } else {
         $this->description = JeproshopTools::getDescriptionClean($this->description);
     }
     return array('category_id' => (int) $this->category_id, 'link' => JRoute::_('index.php?option=com_jeproshop&view=category&category_id=' . $this->category_id . '&link_rewrite=' . $this->link_rewrite . '&' . JeproshopTools::getCategoryToken() . '=1'), 'name' => $this->name, 'desc' => $this->description, 'children' => $children);
 }