public static
getCategoryTreeFormat
(mixed $ordering = 1, mixed $display = '', mixed $hide = '', mixed $type = array(0, 1), mixed $lang = '', mixed $format = 'js')
public static function getCategoryTreeFormat($ordering = 1, $display = '', $hide = '', $type = array(0, 1), $lang = '', $format = 'js')
{
$cis = str_replace(',', '', 'o' . $ordering . 'd' . $display . 'h' . $hide . 'l' . $lang);
if (empty(self::$categoryF[$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 . ")";
}
$columns = 'c.id, c.title, c.alias, c.parent_id';
$groupsFull = $columns;
$groupsFast = 'c.id';
$groups = PhocacartUtilsSettings::isFullGroupBy() ? $groupsFull : $groupsFast;
$query = 'SELECT c.id, c.ordering, c.title, c.alias, c.parent_id' . ' 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) . ' GROUP BY ' . $groups . ' ORDER BY ' . $itemOrdering;
$db->setQuery($query);
$items = $db->loadAssocList();
$tree = self::categoryTree($items);
$currentCatid = self::getActiveCategoryId();
if ($format == 'simple') {
self::$categoryF[$cis] = self::nestedToUlSimple($tree, $currentCatid);
} else {
self::$categoryF[$cis] = self::nestedToUl($tree, $currentCatid);
}
}
return self::$categoryF[$cis];
}