$document = JFactory::getDocument(); DJClassifiedsTheme::includeCSSfiles(); $language = JFactory::getLanguage(); $c_lang = $language->getTag(); if ($c_lang == 'pl-PL' || $c_lang == 'en-GB') { $language->load('com_djclassifieds', JPATH_SITE . '/components/com_djclassifieds', null, true); } else { if (!$language->load('com_djclassifieds', JPATH_SITE, null, true)) { $language->load('com_djclassifieds', JPATH_SITE . '/components/com_djclassifieds', null, true); } } } $djcfcatlib = new DJClassifiedsCategory(); $list = modDjClassifiedsSearch::getCats(); if ($params->get('cat_hide_empty', '0')) { $list = $djcfcatlib->getCatAllItemsCount(1, $params->get('cat_ordering', 'ord'), $params->get('cat_hide_empty', '0')); $categories = array(); $categories[0] = array(); foreach ($list as $cat) { if (!isset($categories[$cat->parent_id])) { $categories[$cat->parent_id] = array(); } $categories[$cat->parent_id][] = $cat; } //echo '<pre>';print_r($categories);die(); } else { $categories = $djcfcatlib->getCategoriesSortParent(1, $params->get('cat_ordering', 'ord')); } $regions = modDjClassifiedsSearch::getRegions(); $types = modDjClassifiedsSearch::getTypes(); require JModuleHelper::getLayoutPath('mod_djclassifieds_search');
public static function getMenuCategories($cid = '0', $show_count = '1', $ord = 'ord', $hide_empty = '0') { $cats = DJClassifiedsCategory::getCategoriesSortParent(1, $ord); $cats_all = $cats; if (isset($cats[0])) { $sort_cats = DJClassifiedsCategory::getListAll($cats[0], $cats); } else { $sort_cats = array(); } if ($show_count) { $max_level = '0'; foreach ($sort_cats as $c) { if ($c->level > $max_level) { $max_level = $c->level; } } for ($level = $max_level; $level > -1; $level--) { $parent_value = 0; for ($c = count($sort_cats); $c > 0; $c--) { if ($parent_value > 0 && $level > $sort_cats[$c - 1]->level) { $sort_cats[$c - 1]->items_count = $sort_cats[$c - 1]->items_count + $parent_value; $parent_value = 0; } if ($level == $sort_cats[$c - 1]->level) { $parent_value = $parent_value + $sort_cats[$c - 1]->items_count; } } } } $cat_path = ',' . $cid . ','; if ($cid > 0) { $cat_id = $cid; while ($cat_id != 0) { foreach ($sort_cats as $c) { if ($c->id == $cat_id) { $cat_id = $c->parent_id; $cat_path .= $cat_id . ','; break; } } } } $menu_cats = array(); $empty_cat_level = 0; for ($i = 0; $i < count($sort_cats); $i++) { if (strstr($cat_path, ',' . $sort_cats[$i]->id . ',') || strstr($cat_path, ',' . $sort_cats[$i]->parent_id . ',')) { if (isset($cats_all[$sort_cats[$i]->id])) { $sort_cats[$i]->have_childs = 1; } else { $sort_cats[$i]->have_childs = 0; } if ($hide_empty) { if ($sort_cats[$i]->items_count > 0) { $menu_cats[] = $sort_cats[$i]; } } else { $menu_cats[] = $sort_cats[$i]; } } } //echo '<pre>';print_R($menu_cats);die(); $ret = array(); $ret[] = $menu_cats; $ret[] = $cat_path; return $ret; }