public function subcatsList($sType = '', $mDevice = '', $nParentID = 0){
$showAll = false;
if (Request::isAJAX()) {
$sType = $this->input->getpost('act', TYPE_STR);
$mDevice = $this->input->post('device', TYPE_STR);
$nParentID = $this->input->post('parent', TYPE_UINT);
$showAll = $this->input->post('showAll', TYPE_BOOL);
}
$sListingUrl = static::url('items.search');
$oIcon = self::categoryIcon(0);
$ICON_BIG = BBSCategoryIcon::BIG;
$ICON_SMALL = BBSCategoryIcon::SMALL;
switch ($sType) {
//case 'index': {}
//break;
case 'search': {
if ($mDevice == bff::DEVICE_DESKTOP){
$nSelectedID = 0;
if ($nParentID > self::CATS_ROOTID) {
$aParentData = array(
'id',
'pid',
'numlevel',
'numleft',
'numright',
'title',
'keyword',
'icon_' . $ICON_BIG . ' as icon',
'items',
'subs'
);
$aParent = $this->model->catData($nParentID, $aParentData);
if (!empty($aParent)) {
if (!$aParent['subs']) {
# в данной категории нет подкатегорий
# формируем список подкатегорий ее parent-категории
$aParent = $this->model->catData($aParent['pid'], $aParentData);
if (!empty($aParent)) {
$nSelectedID = $nParentID;
$nParentID = $aParent['id'];
}
}
}
}
$aData = $this->model->catsList($sType, $mDevice, $nParentID, $ICON_BIG);
if (!empty($aData)) {
foreach ($aData as &$v) {
$v['l'] = $sListingUrl . $v['k'] . '/';
$v['i'] = $oIcon->url($v['id'], $v['i'], $ICON_BIG);
$v['active'] = ($v['id'] == $nSelectedID);
}
unset($v);
}
if ($nParentID > self::CATS_ROOTID) {
if (!empty($aParent)) {
$aParent['link'] = $sListingUrl . $aParent['keyword'] . '/';
$aParent['main'] = ($aParent['pid'] == self::CATS_ROOTID);
if ($aParent['main']) {
$aParent['icon'] = $oIcon->url($aParent['id'], $aParent['icon'], $ICON_BIG);
} else {
# глубже второго уровня, получаем настройки основной категории
$aParentsID = $this->model->catParentsID($aParent, false);
if (!empty($aParentsID[1])) {
$aParentMain = $this->model->catData($aParentsID[1], array(
'id',
'icon_' . $ICON_BIG . ' as icon'
)
);
$aParent['icon'] = $oIcon->url($aParentsID[1], $aParentMain['icon'], $ICON_BIG);
}
}
$aData = array('cats' => $aData, 'parent' => $aParent, 'step' => 2);
$aData = $this->viewPHP($aData, 'search.cats.desktop.subcats');
if (Request::isAJAX()) {
$this->ajaxResponseForm(array('html' => $aData));
} else {
return $aData;
}
} else {
$this->errors->impossible();
$this->ajaxResponseForm(array('html' => ''));
}
} //else {
// $nTotal = config::get('bbs_items_total_publicated', 0);
// $aData = array('cats' => $aData, 'total' => $nTotal, 'step' => 1);
// return $this->viewPHP($aData, 'search.cats.desktop.cats');
// }
}
}
break;
}
}