/** * we get the locations in an array miltidimensional by deep. * @return array */ public static function get_multidimensional($limit = NULL) { $cache_name = is_int($limit) ? 'locs_m' . '_' . $limit : 'locs_m'; if (($locs_m = Core::cache($cache_name)) === NULL) { $locs = new self(); $locs->order_by('order', 'asc'); if (is_int($limit)) { $locs->limit($limit); } $locs = $locs->find_all()->cached()->as_array('id_location'); //for each location we get his siblings $locs_s = array(); foreach ($locs as $loc) { $locs_s[$loc->id_location_parent][] = $loc->id_location; } //last build multidimensional array if (count($locs_s) > 1) { $locs_m = self::multi_locs($locs_s); } else { $locs_m = array(); } Core::cache($cache_name, $locs_m); } return $locs_m; }
/** * we get the categories in an array miltidimensional by deep. * @return array */ public static function get_multidimensional($limit = NULL) { $cache_name = is_int($limit) ? 'cats_m' . '_' . $limit : 'cats_m'; //multidimensional array if (($cats_m = Core::cache($cache_name)) === NULL) { $cats = new self(); $cats->order_by('order', 'asc'); if (is_int($limit)) { $cats->limit($limit); } $cats = $cats->find_all()->cached()->as_array('id_category'); //for each category we get his siblings $cats_s = array(); foreach ($cats as $cat) { $cats_s[$cat->id_category_parent][] = $cat->id_category; } //last build multidimensional array if (count($cats_s) > 1) { $cats_m = self::multi_cats($cats_s); } else { $cats_m = array(); } Core::cache($cache_name, $cats_m); } return $cats_m; }