function rss_board($item_id, $cfg){ if(!cmsCore::getInstance()->isComponentEnable('board')) { return false; } $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('board'); $model = new cms_model_board(); global $_LANG; $channel = array(); $items = array(); if ($item_id && preg_match('/^([0-9]+)$/ui', $item_id)) { $cat = $model->getCategory($item_id); if(!$cat) { return false; } $model->whereCatIs($cat['id']); $channel['title'] = $cat['title']; $channel['description'] = preg_replace ("'&([a-z]{2,5});'iu", '', $cat['description']); $channel['link'] = HOST.'/board/'.$cat['id']; } else { $channel['title'] = $_LANG['BOARD']; $channel['description'] = $_LANG['BOARD']; $channel['link'] = HOST; } $inDB->orderBy('pubdate', 'DESC'); $inDB->limit($cfg['maxitems']); $advs = $model->getAdverts(false, false, false, true); if($advs){ foreach($advs as $item){ $item['link'] = HOST.'/board/read'.$item['id'].'.html'; $item['comments'] = $item['link'].'#c'; $item['category'] = $item['cat_title']; $item['description'] = mb_substr(strip_tags($item['content']), 0, 250). '...'; $image_file = PATH.'/images/board/small/'.$item['file']; $image_url = HOST.'/images/board/small/'.$item['file']; $item['image'] = file_exists($image_file) ? $image_url : ''; $item['size'] = round(filesize($image_file)); $items[] = $item; } } return array('channel' => $channel, 'items' => $items); }
function mod_latestboard($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('board'); $model = new cms_model_board(); if (!isset($cfg['shownum'])) { $cfg['shownum'] = 5; } if (!isset($cfg['onlyvip'])) { $cfg['onlyvip'] = 0; } if (!isset($cfg['butvip'])) { $cfg['butvip'] = 0; } if (@$cfg['cat_id']) { if (!@$cfg['subs']) { $model->whereCatIs($cfg['cat_id']); } else { $cat = $inDB->get_fields('cms_board_cats', "id='{$cfg['cat_id']}'", 'NSLeft, NSRight'); if (!$cat) { return false; } $model->whereThisAndNestedCats($cat['NSLeft'], $cat['NSRight']); } } // только ВИП if ($cfg['onlyvip'] && !$cfg['butvip']) { $model->whereVip(1); } // кроме ВИП if ($cfg['butvip'] && !$cfg['onlyvip']) { $model->whereVip(0); } $inDB->orderBy('i.is_vip', 'DESC, i.pubdate DESC'); $inDB->limitPage(1, $cfg['shownum']); $items = $model->getAdverts(false, true, false, true); cmsPage::initTemplate('modules', 'mod_latestboard')->assign('items', $items)->assign('cfg', $cfg)->display('mod_latestboard.tpl'); return true; }