public static
getCategoryTreeArray
(mixed $ordering = 1, mixed $display = '', mixed $hide = '', mixed $type = array(0, 1), mixed $lang = '', mixed $limitCount = -1)
public static function getCategoryTreeArray($ordering = 1, $display = '', $hide = '', $type = array(0, 1), $lang = '', $limitCount = -1)
{
$cis = str_replace(',', '', 'o' . $ordering . 'd' . $display . 'h' . $hide . 'l' . $lang . 'c' . $limitCount);
if (empty(self::$categoryA[$cis])) {
/*phocacart import('phocacart.ordering.ordering');*/
$itemOrdering = PhocacartOrdering::getOrderingText($ordering, 1);
if ($itemOrdering != '') {
$itemOrdering = 'c.parent_id, ' . $itemOrdering;
}
$db = Factory::getDBO();
$wheres = array();
$user = PhocacartUser::getUser();
$userLevels = implode(',', $user->getAuthorisedViewLevels());
$userGroups = implode(',', PhocacartGroup::getGroupsById($user->id, 1, 1));
$wheres[] = " c.access IN (" . $userLevels . ")";
$wheres[] = " (gc.group_id IN (" . $userGroups . ") OR gc.group_id IS NULL)";
$wheres[] = " c.published = 1";
if ($lang != '' && $lang != '*') {
$wheres[] = PhocacartUtilsSettings::getLangQuery('c.language', $lang);
}
if (!empty($type) && is_array($type)) {
$wheres[] = " c.type IN (" . implode(',', $type) . ")";
}
if ($display != '') {
$wheres[] = " c.id IN (" . $display . ")";
}
if ($hide != '') {
$wheres[] = " c.id NOT IN (" . $hide . ")";
}
if ((int) $limitCount > -1) {
$wheres[] = " c.count_products > " . (int) $limitCount;
}
$query = 'SELECT c.id, c.title, c.alias, c.parent_id, c.icon_class, c.image, c.description, c.count_products' . ' FROM #__phocacart_categories AS c' . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2' . ' WHERE ' . implode(' AND ', $wheres) . ' ORDER BY ' . $itemOrdering;
$db->setQuery($query);
$items = $db->loadAssocList();
self::$categoryA[$cis] = self::categoryTree($items);
}
return self::$categoryA[$cis];
}