Exemple #1
0
 public static function getListSubreg(&$lists, &$lists_const, $main_id = 0, $main_level = 0, $main_f = 0, &$option = array())
 {
     $liczba = count($lists_const);
     foreach ($lists as $list) {
         if (isset($list->level)) {
             $current_level = $list->level;
         } else {
             $current_level = 0;
         }
         if ($main_f == 1 && ($main_level > $current_level || $current_level == $main_level)) {
             break;
         }
         if ($main_id == $list->id) {
             $main_f = 1;
             $main_level = $current_level;
         }
         if ($main_f == 1 && $main_level < $current_level) {
             $cat_item = new CatItem();
             $cat_item->id = $list->id;
             $cat_item->name = $list->name;
             $cat_item->parent_id = $list->parent_id;
             $cat_item->parent_name = $list->parent_name;
             $cat_item->country = $list->country;
             $cat_item->city = $list->city;
             $cat_item->published = $list->published;
             $cat_item->level = $current_level;
             $option[] = $cat_item;
         }
         $childs = array();
         if (isset($lists_const[$list->id])) {
             for ($i = 0; $i < count($lists_const[$list->id]); $i++) {
                 $child = new RegionItem();
                 $child->id = $lists_const[$list->id][$i]->id;
                 $child->name = $lists_const[$list->id][$i]->name;
                 $child->parent_id = $lists_const[$list->id][$i]->parent_id;
                 $child->parent_name = $lists_const[$list->id][$i]->parent_name;
                 $child->country = $lists_const[$list->id][$i]->country;
                 $child->city = $lists_const[$list->id][$i]->city;
                 $child->published = $lists_const[$list->id][$i]->published;
                 if (isset($list->level)) {
                     $child->level = $list->level + 1;
                 } else {
                     $child->level = 1;
                 }
                 $childs[] = $child;
             }
             DJClassifiedsRegion::getListSubreg($childs, $lists_const, $main_id, $main_level, $main_f, $option);
             //echo count($lists_const).' ';
             unset($lists_const[$list->id]);
         }
     }
     return $option;
 }