Current File : /home/pacjaorg/public_html/kmm/administrator/components/com_djclassifieds/lib/djcategory.php |
<?php
/**
* @package DJ-Classifieds
* @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://dj-extensions.com
* @author email contact@dj-extensions.com
*/
defined('_JEXEC') or die('Restricted access');
require_once(JPATH_ROOT . '/administrator/components/com_djclassifieds/lib/djregion.php');
require_once(JPATH_ROOT . '/administrator/components/com_djclassifieds/lib/djseo.php');
class DJOptionList
{
var $text;
var $value;
var $disable;
var $id;
var $level;
var $parent_id;
var $name;
function __construct()
{
$text = null;
$value = null;
$disable = null;
}
}
class CatItem
{
var $id;
var $name;
var $alias;
var $price;
var $points;
var $description;
var $parent_id;
var $parent_name;
var $ordering;
var $published;
var $autopublish;
var $theme;
var $level;
var $items_count;
var $access;
var $ads_disabled;
var $restriction_18;
var $have_children;
function __construct()
{
$id = null;
$name = null;
$alias = null;
$price = null;
$points = null;
$description = null;
$parent_id = null;
$parent_name = null;
$ordering = null;
$published = null;
$autopublish = null;
$theme = null;
$access = null;
$ads_disabled = null;
$restriction_18 = null;
$items_count = 0;
$level = 0;
$have_children = null;
}
}
class DJClassifiedsCategory
{
var $parent_id;
var $id;
var $name;
var $children = array();
var $level;
var $alias;
var $theme;
var $restriction_18;
var $published;
function __construct()
{
$parent_id = null;
$id = null;
$name = null;
$children[] = null;
$elem[] = null;
$level = 0;
}
public static function getCatSelect($pub = '0', $ord = 'ord')
{
$cats = DJClassifiedsCategory::getCategoriesSortParent($pub, $ord);
if (isset($cats[0])) {
$sort_cats = DJClassifiedsCategory::getListSelect($cats[0], $cats);
} else {
$sort_cats = array();
}
return $sort_cats;
}
public static function getSubCatSelect($parent_id)
{
$db = JFactory::getDBO();
$options = array();
$query = "SELECT * FROM #__djcf_categories WHERE parent_id=" . $parent_id . " ORDER BY ordering";
$db->setQuery($query);
$cats = $db->loadObjectList();
foreach ($cats as $cat) {
$op = new DJOptionList;
$op->text = $cat->name;;
$op->value = $cat->id;
$options[] = $op;
}
return $options;
}
public static function getCatAll($pub = '0', $ord = 'ord', $ord_dir = 'ASC')
{
$cats = DJClassifiedsCategory::getCategoriesSortParent($pub, $ord, $ord_dir);
if (isset($cats[0])) {
$sort_cats = DJClassifiedsCategory::getListAll($cats[0], $cats);
} else {
$sort_cats = array();
}
return $sort_cats;
}
public static function getCatAllItemsCount($pub = '0', $ord = 'ord', $hide_empty = '0')
{
$cats = DJClassifiedsCategory::getCategoriesSortParent($pub, $ord);
if (isset($cats[0])) {
$sort_cats = DJClassifiedsCategory::getListAll($cats[0], $cats);
} else {
$sort_cats = array();
}
$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;
}
}
}
if ($hide_empty) {
$cat_items = array();
for ($i = 0; $i < count($sort_cats); $i++) {
if ($sort_cats[$i]->items_count) {
$cat_items[] = $sort_cats[$i];
}
}
return $cat_items;
} else {
return $sort_cats;
}
}
public static function getSubCat($id, $pub = '0', $ord = 'ord', $type = 0, $add_main = 1)
{
$cats = DJClassifiedsCategory::getCategoriesSortParent($pub, $ord);
if (isset($cats[0])) {
$sort_cats = DJClassifiedsCategory::getListSubcat($cats[0], $cats, $id);
if ($type == 1) {
$cat_ids = '';
foreach ($sort_cats as $cat) {
if ($cat->id == $id) {
if (!$add_main) {
continue;
}
}
if ($cat_ids) {
$cat_ids .= ',';
}
$cat_ids .= $cat->id;
}
$sort_cats = $cat_ids;
}
} else {
$sort_cats = array();
}
return $sort_cats;
}
public static function getSubCatIemsCount($id, $pub = '0', $ord = 'ord', $hide_empty = '0') // backward compatibility
{
return self::getSubCatItemsCount($id, $pub, $ord, $hide_empty);
}
public static function getSubCatItemsCount($id, $pub = '0', $ord = 'ord', $hide_empty = '0')
{
$cats = DJClassifiedsCategory::getCategoriesSortParent($pub, $ord);
if (isset($cats[0])) {
$sort_cats = DJClassifiedsCategory::getListSubcat($cats[0], $cats, $id);
} else {
$sort_cats = array();
}
$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;
}
}
}
if ($hide_empty) {
$cat_items = array();
for ($i = 0; $i < count($sort_cats); $i++) {
if ($sort_cats[$i]->items_count) {
$cat_items[] = $sort_cats[$i];
}
}
return $cat_items;
} else {
return $sort_cats;
}
}
public static function getParentPath($pub = '0', $cid = '0', $ord = 'ord', $return_type = '')
{
$cats = DJClassifiedsCategory::getCategories($pub, $ord);
$cat_path = array();
$cat_path_flat = '';
if (count($cats)) {
while ($cid != 0) {
if (isset($cats[$cid])) {
if ($return_type) {
$cat_path_flat .= ',' . $cats[$cid]->id;
} else {
$subcat = new DJClassifiedsCategory();
$subcat->id = $cats[$cid]->id;
$subcat->name = $cats[$cid]->name;
$subcat->alias = $cats[$cid]->alias;
$subcat->parent_id = $cats[$cid]->parent_id;
$subcat->theme = $cats[$cid]->theme;
$subcat->restriction_18 = $cats[$cid]->restriction_18;
$subcat->published = $cats[$cid]->published;
$cat_path[] = $subcat;
}
$cid = $cats[$cid]->parent_id;
} else {
break;
}
}
}
if ($return_type) {
if ($cat_path_flat) {
$cat_path_flat .= ',';
}
return $cat_path_flat;
} else {
return $cat_path;
}
}
public static function getSEOParentPath($cid = '0')
{
$cats = DJClassifiedsCategory::getCategories('1', 'ord');
$cat_path = array();
while ($cid != 0) {
if (isset($cats[$cid])) {
$cat_path[] = $cats[$cid]->id . ':' . $cats[$cid]->alias;
$cid = $cats[$cid]->parent_id;
} else {
break;
}
}
return $cat_path;
}
public static function getMenuCategories($cid = '0', $show_count = '1', $ord = 'ord', $hide_empty = '0', $parent_id = '0', $only_current_lvl = '0', $only_current_sublvl = '0')
{
$cats = DJClassifiedsCategory::getCategoriesSortParent(1, $ord);
$cat_active = '';
$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) {
$cat_found = 0;
foreach ($sort_cats as $c) {
if ($c->id == $cid) {
$cat_active = $c;
}
if ($c->id == $cat_id) {
$cat_id = $c->parent_id;
$cat_path .= $cat_id . ',';
$cat_found = 1;
break;
}
}
if (!$cat_found) {
$cat_path = '';
break;
}
}
}
$menu_cats = array();
for ($i = 0; $i < count($sort_cats); $i++) {
$sort_cats[$i]->have_children = 0;
if (isset($cats_all[$sort_cats[$i]->id])) {
$sort_cats[$i]->have_children = 1;
} else {
$sort_cats[$i]->have_children = 0;
}
if (strstr($cat_path, ',' . $sort_cats[$i]->id . ',') || strstr($cat_path, ',' . $sort_cats[$i]->parent_id . ',')) {
if ($hide_empty) {
if ($sort_cats[$i]->items_count > 0) {
$menu_cats[] = $sort_cats[$i];
}
} else {
$menu_cats[] = $sort_cats[$i];
}
}
}
if ($only_current_lvl) {
$cats_lvl = array();
foreach ($menu_cats as $cat) {
if ($cat->parent_id == $parent_id) {
$cat->level = 0;
$cats_lvl[] = $cat;
}
}
$menu_cats = $cats_lvl;
$cat_path = ',' . $cid . ',';
} else if ($only_current_sublvl) {
$cats_lvl = array();
$cats_sublvl = array();
foreach ($menu_cats as $cat) {
if ($cat->parent_id == $parent_id) {
$cat->level = 0;
$cats_lvl[] = $cat;
}
if ($cat_active) {
if ($cat->parent_id == $cat_active->id) {
$cat->level = 0;
$cats_sublvl[] = $cat;
}
}
}
if (count($cats_sublvl) > 0) {
$menu_cats = $cats_sublvl;
} else {
$menu_cats = $cats_lvl;
}
$cat_path = ',' . $cid . ',';
}
$ret = array();
$ret[] = $menu_cats;
$ret[] = $cat_path;
$ret[] = $sort_cats;
return $ret;
}
private static $_categories = null;
private static $_categories_sparent = null;
private static $_items_count = null;
public static function getCategory($cid, $p = '0')
{
$user = JFactory::getUser();
if ($p) {
$pub = ' AND c.published!=0 ';
$groups_acl = implode(',', $user->getAuthorisedViewLevels());
$access_view = " AND c.access_view IN (" . $groups_acl . ") ";
} else {
$pub = '';
$access_view = '';
}
$db = JFactory::getDBO();
$date_now = JFactory::getDate()->toSQL();
$item_where = '';
$reglist = DJClassifiedsRegion::getDefaultRegionsIds();
if ($reglist) {
$item_where .= ' AND i.region_id IN (' . $reglist . ') ';
}
$query = "SELECT c.*, cc.name as parent_name,IFNULL(i.items_count,0) + IFNULL(ic.items_count,0) AS items_count FROM #__djcf_categories c "
. "LEFT JOIN #__djcf_categories cc ON c.parent_id=cc.id "
. "LEFT JOIN (SELECT i.cat_id, count(i.id) as items_count "
. "FROM #__djcf_items i WHERE i.published=1 AND i.blocked=0 AND i.date_exp > '" . $date_now . "' " . $item_where . " GROUP BY i.cat_id) i ON i.cat_id=c.id "
. "LEFT JOIN (SELECT ic.cat_id, count(ic.item_id) as items_count "
. "FROM #__djcf_items_categories ic, #__djcf_items i WHERE ic.item_id=i.id AND i.published=1 AND i.blocked=0 AND i.date_exp > '" . $date_now . "' GROUP BY ic.cat_id) ic ON ic.cat_id=c.id "
. "WHERE c.id= " . $cid . " " . $pub . $access_view . " LIMIT 1";
$db->setQuery($query);
$category = $db->loadObject();
return $category;
}
static function setItemsCount()
{
$db = JFactory::getDBO();
$par = JComponentHelper::getParams('com_djclassifieds');
$date_now = JFactory::getDate()->format('Y-m-d H:00:00');
$item_where = "";
$reglist = DJClassifiedsRegion::getDefaultRegionsIds();
if ($reglist) {
$item_where .= "AND i.region_id IN (" . $reglist . ") ";
}
if (!isset(self::$_items_count)) {
$query = "SELECT cat_id, count(*) as items_count FROM "
. "(SELECT i.cat_id FROM #__djcf_items i WHERE i.published=1 AND i.blocked=0 AND i.date_exp > '" . $date_now . "' " . $item_where
. (JPluginHelper::isEnabled('djclassifieds', 'multicategories') ? "UNION ALL SELECT ic.cat_id FROM #__djcf_items_categories ic INNER JOIN #__djcf_items i ON ic.item_id=i.id WHERE i.published=1 AND i.blocked=0 AND i.date_exp > '" . $date_now . "' " . $item_where : "")
. ") v GROUP BY cat_id";
if ($par->get('cache_lib_cats', '0') == '1') {
$cache = JFactory::getCache();
$cache->setCaching(1);
self::$_items_count = $cache->get(array('DJClassifiedsCategory', 'getItemsCount'), array($query));
} else {
$db->setQuery($query);
self::$_items_count = $db->loadObjectList('cat_id');
}
}
}
public static function getItemsCount($query)
{
$db = JFactory::getDBO();
$db->setQuery($query);
return $db->loadObjectList('cat_id');
}
static function getAllCategories($p = '0', $ord = 'ordering', $ord_dir = 'ASC')
{
$db = JFactory::getDBO();
$user = JFactory::getUser();
$where = "";
if ($p) {
$groups_acl = implode(',', $user->getAuthorisedViewLevels());
$where = "WHERE published=1 AND access_view IN (" . $groups_acl . ") ";
}
$order = $ord == 'ord' ? 'ordering' : $ord;
$query = "SELECT * FROM #__djcf_categories "
. $where
. "ORDER BY parent_id, " . $order . " " . $ord_dir;
$db->setQuery($query);
$allcategories = $db->loadObjectList('id');
return $allcategories;
}
public static function getCategories($p = '0', $ord = 'ord', $ord_dir = 'ASC')
{
if (!self::$_categories) {
self::$_categories = array();
}
if (isset(self::$_categories[$p . '_' . $ord])) {
return self::$_categories[$p . '_' . $ord];
}
$allcategories = self::getAllCategories($p, $ord, $ord_dir);
self::setItemsCount();
foreach ($allcategories as $cat) {
$cat->parent_name = isset($allcategories[$cat->parent_id]) ? $allcategories[$cat->parent_id]->name : '';
$cat->items_count = !empty(self::$_items_count[$cat->id]) ? self::$_items_count[$cat->id]->items_count : 0;
if (!$cat->alias) {
$cat->alias = DJClassifiedsSEO::getAliasName($cat->name);
}
}
self::$_categories[$p . '_' . $ord] = $allcategories;
return self::$_categories[$p . '_' . $ord];
}
public static function getCategoriesSortParent($p = '0', $ord = 'ordering', $ord_dir = 'ASC')
{
if (!self::$_categories_sparent) {
self::$_categories_sparent = array();
}
if (isset(self::$_categories_sparent[$p . '_' . $ord])) {
return self::$_categories_sparent[$p . '_' . $ord];
}
$allcategories = self::getAllCategories($p, $ord, $ord_dir);
self::setItemsCount();
$categories = array();
foreach ($allcategories as $cat) {
$cat->parent_name = isset($allcategories[$cat->parent_id]) ? $allcategories[$cat->parent_id]->name : '';
$cat->items_count = !empty(self::$_items_count[$cat->id]) ? self::$_items_count[$cat->id]->items_count : 0;
if (!$cat->alias) {
$cat->alias = DJClassifiedsSEO::getAliasName($cat->name);
}
if (!isset($categories[$cat->parent_id])) {
$categories[$cat->parent_id] = array();
}
$categories[$cat->parent_id][] = $cat;
}
self::$_categories_sparent[$p . '_' . $ord] = $categories;
return self::$_categories_sparent[$p . '_' . $ord];
}
public static function getListSelect(&$lists, &$lists_const, &$option = array())
{
foreach ($lists as $list) {
$op = new DJOptionList;
$op->text = $list->name;;
$op->value = $list->id;
$op->level = !empty($list->level) ? $list->level : 0;
$option[] = $op;
$children = array();
if (isset($lists_const[$list->id])) {
for ($i = 0; $i < count($lists_const[$list->id]); $i++) {
$child = new DJOptionList();
$child->id = $lists_const[$list->id][$i]->id;
$child->parent_id = $lists_const[$list->id][$i]->parent_id;
if (isset($list->level)) {
$child->level = $list->level + 1;
} else {
$child->level = 1;
}
$new_name = $lists_const[$list->id][$i]->name;
for ($lev = 0; $lev < $child->level; $lev++) {
$new_name = "- " . $new_name;
}
$child->name = $new_name;
$children[] = $child;
}
DJClassifiedsCategory::getListSelect($children, $lists_const, $option);
unset($lists_const[$list->id]);
}
}
return ($option);
}
public static function getListAll(&$lists, &$lists_const, &$option = array())
{
foreach ($lists as $list) {
$cat_item = new CatItem;
$cat_item->id = $list->id;
$cat_item->name = $list->name;
$cat_item->alias = $list->alias;
$cat_item->price = $list->price;
$cat_item->points = $list->points;
$cat_item->description = $list->description;
$cat_item->parent_id = $list->parent_id;
$cat_item->parent_name = $list->parent_name;
$cat_item->ordering = $list->ordering;
$cat_item->published = $list->published;
$cat_item->autopublish = $list->autopublish;
$cat_item->theme = $list->theme;
$cat_item->access = $list->access;
$cat_item->ads_disabled = $list->ads_disabled;
$cat_item->items_count = $list->items_count;
$cat_item->restriction_18 = $list->restriction_18;
if (isset($list->level)) {
$cat_item->level = $list->level;
} else {
$cat_item->level = 0;
}
$option[] = $cat_item;
$children = array();
if (isset($lists_const[$list->id])) {
for ($i = 0; $i < count($lists_const[$list->id]); $i++) {
$child = new CatItem();
$child->id = $lists_const[$list->id][$i]->id;
$child->name = $lists_const[$list->id][$i]->name;
$child->alias = $lists_const[$list->id][$i]->alias;
$child->parent_id = $lists_const[$list->id][$i]->parent_id;
$child->price = $lists_const[$list->id][$i]->price;
$child->points = $lists_const[$list->id][$i]->points;
$child->description = $lists_const[$list->id][$i]->description;
$child->parent_id = $lists_const[$list->id][$i]->parent_id;
$child->parent_name = $lists_const[$list->id][$i]->parent_name;
$child->ordering = $lists_const[$list->id][$i]->ordering;
$child->published = $lists_const[$list->id][$i]->published;
$child->autopublish = $lists_const[$list->id][$i]->autopublish;
$child->theme = $lists_const[$list->id][$i]->theme;
$child->access = $lists_const[$list->id][$i]->access;
$child->ads_disabled = $lists_const[$list->id][$i]->ads_disabled;
$child->items_count = $lists_const[$list->id][$i]->items_count;
$child->restriction_18 = $lists_const[$list->id][$i]->restriction_18;
if (isset($list->level)) {
$child->level = $list->level + 1;
} else {
$child->level = 1;
}
$children[] = $child;
}
DJClassifiedsCategory::getListAll($children, $lists_const, $option);
unset($lists_const[$list->id]);
}
}
return ($option);
}
public static function getListSubcat(&$lists, &$lists_const, $main_id = 0, $main_level = 0, $main_f = 0, &$option = array())
{
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 || $main_id == $list->id)) {
$cat_item = new CatItem;
$cat_item->id = $list->id;
$cat_item->name = $list->name;
$cat_item->alias = $list->alias;
$cat_item->price = $list->price;
$cat_item->points = $list->points;
$cat_item->description = $list->description;
$cat_item->parent_id = $list->parent_id;
$cat_item->parent_name = $list->parent_name;
$cat_item->ordering = $list->ordering;
$cat_item->published = $list->published;
$cat_item->autopublish = $list->autopublish;
$cat_item->theme = $list->theme;
$cat_item->access = $list->access;
$cat_item->ads_disabled = $list->ads_disabled;
$cat_item->items_count = $list->items_count;
$cat_item->restriction_18 = $list->restriction_18;
$cat_item->level = $current_level;
$option[] = $cat_item;
}
$children = array();
if (isset($lists_const[$list->id])) {
for ($i = 0; $i < count($lists_const[$list->id]); $i++) {
$child = new CatItem();
$child->id = $lists_const[$list->id][$i]->id;
$child->name = $lists_const[$list->id][$i]->name;
$child->alias = $lists_const[$list->id][$i]->alias;
$child->parent_id = $lists_const[$list->id][$i]->parent_id;
$child->price = $lists_const[$list->id][$i]->price;
$child->points = $lists_const[$list->id][$i]->points;
$child->description = $lists_const[$list->id][$i]->description;
$child->parent_id = $lists_const[$list->id][$i]->parent_id;
$child->parent_name = $lists_const[$list->id][$i]->parent_name;
$child->ordering = $lists_const[$list->id][$i]->ordering;
$child->published = $lists_const[$list->id][$i]->published;
$child->autopublish = $lists_const[$list->id][$i]->autopublish;
$child->theme = $lists_const[$list->id][$i]->theme;
$child->access = $lists_const[$list->id][$i]->access;
$child->ads_disabled = $lists_const[$list->id][$i]->ads_disabled;
$child->items_count = $lists_const[$list->id][$i]->items_count;
$child->restriction_18 = $lists_const[$list->id][$i]->restriction_18;
if (isset($list->level)) {
$child->level = $list->level + 1;
} else {
$child->level = 1;
}
$children[] = $child;
}
DJClassifiedsCategory::getListSubcat($children, $lists_const, $main_id, $main_level, $main_f, $option);
//echo count($lists_const).' ';
unset($lists_const[$list->id]);
}
}
return ($option);
}
public static function getCatFullPath($cid, $link = false, $delimiter = ' - ')
{
$cats = self::getParentPath('1', $cid);
$cat_items = array();
foreach ($cats as $key => $cat) {
$cat_item = '<span class="cat_path path' . $key . ' cat' . $cat->id . '">';
if ($link) {
$cat_item .= '<a href="' . DJClassifiedsSEO::getCategoryRoute($cat->id . ':' . $cat->alias) . '">' . JText::_($cat->name) . '</a>';
} else {
$cat_item .= JText::_($cat->name);
}
$cat_item .= '</span>';
$cat_items[] = $cat_item;
}
$cat_items = array_reverse($cat_items);
return implode('<span class="delimiter">' . $delimiter . '</span>', $cat_items);
}
public static function unpublishChildren($cid_arr)
{
$db = JFactory::getDBO();
foreach ($cid_arr as $cid) {
$cat_ids = array_map(function ($v) {
return $v->id;
}, DJClassifiedsCategory::getSubCat($cid));
if ($cat_ids) {
$query = "UPDATE #__djcf_categories SET published=0 WHERE id IN (" . implode(',', $cat_ids) . ")";
$db->setQuery($query);
$db->execute();
}
}
}
public static function publishParents($cid_arr)
{
$db = JFactory::getDBO();
foreach ($cid_arr as $cid) {
$cat_ids = array_map(function ($v) {
return $v->id;
}, DJClassifiedsCategory::getParentPath('0', $cid));
if ($cat_ids) {
$query = "UPDATE #__djcf_categories SET published=1 WHERE id IN (" . implode(',', $cat_ids) . ")";
$db->setQuery($query);
$db->execute();
}
}
}
static function getRootCat($cat_id)
{
$cat_path = self::getParentPath('0', $cat_id);
$root_cat = end($cat_path);
return $root_cat;
}
}