function f_pages(&$text) { if (mb_strpos($text, 'pagebreak') === false) { return true; } $seolink = urldecode(cmsCore::request('seolink', 'str', '')); $seolink = preg_replace('/[^a-zа-я-яёіїєґА-ЯЁІЇЄҐ0-9_\\/\\-]/ui', '', $seolink); if (!$seolink) { return true; } $regex = '/{(pagebreak)\\s*(.*?)}/iu'; $pages = preg_split($regex, $text); $n = count($pages); if ($n <= 1) { return true; } else { $page = cmsCore::request('page', 'int', 1); $text = $pages[$page - 1]; if (!$text) { cmsCore::error404(); } cmsCore::loadModel('content'); $text .= cmsPage::getPagebar($n, $page, 1, cms_model_content::getArticleURL(null, $seolink, '%page%')); return true; } }
function mod_bestcontent($mod, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('content'); $model = new cms_model_content(); if (!isset($cfg['shownum'])) { $cfg['shownum'] = 5; } if (!isset($cfg['subs'])) { $cfg['subs'] = 1; } if (!isset($cfg['cat_id'])) { $cfg['cat_id'] = 1; } $inDB->where("con.canrate = 1"); if ($cfg['cat_id']) { if (!$cfg['subs']) { //выбираем из категории $model->whereCatIs($cfg['cat_id']); } else { //выбираем из категории и подкатегорий $rootcat = $inDB->getNsCategory('cms_category', $cfg['cat_id']); if (!$rootcat) { return false; } $model->whereThisAndNestedCats($rootcat['NSLeft'], $rootcat['NSRight']); } } $inDB->orderBy('con.rating', 'DESC'); $inDB->limitPage(1, $cfg['shownum']); $content_list = $model->getArticlesList(); cmsPage::initTemplate('modules', $cfg['tpl'])->assign('articles', $content_list)->assign('cfg', $cfg)->display($cfg['tpl']); return true; }
function mod_pogoda_current($mod, $cfg) { $inCore = cmsCore::getInstance(); //Загрузка настроек компонента $component = $inCore->loadComponentConfig('pogoda'); $component["name_en"] = $component["name_en"] ? $component["name_en"] . '_' : ''; // Проверяем включен ли компонент и установлен ли city_id if (!$component['component_enabled'] || !$component['city_id']) { return false; } cmsCore::loadModel('pogoda'); $model = new cms_model_pogoda(); $model->setTable('current'); $dbWeather = $model->getWeather(); $xml = simplexml_load_string($dbWeather["xml"]); if (!$xml) { return true; } $current = array(); $current["temperature"] = round($xml->temperature["value"]) . ' °C'; $current["weather"]["value"] = $xml->weather["value"]; $current["weather"]["icon"] = $xml->weather["icon"]; cmsPage::initTemplate('modules', $cfg['tpl'])->assign('current', $current)->display($cfg['tpl']); return true; }
function search_blogs($query, $look) { $inDB = cmsDatabase::getInstance(); $searchModel = cms_model_search::initModel(); global $_LANG; $sql = "SELECT con.*, cat.title cat_title, cat.id cat_id, cat.owner owner, cat.user_id user_id, cat.seolink as bloglink\n\t\t\tFROM cms_blog_posts con\n\t\t\tINNER JOIN cms_blogs cat ON cat.id = con.blog_id AND cat.allow_who = 'all' AND cat.owner = 'user'\n\t\t\tWHERE MATCH(con.title, con.content) AGAINST ('{$query}' IN BOOLEAN MODE) AND con.published = 1 LIMIT 100"; $result = $inDB->query($sql); if ($inDB->num_rows($result)) { cmsCore::loadLanguage('components/blogs'); cmsCore::loadModel('blogs'); $model = new cms_model_blogs(); while ($item = $inDB->fetch_assoc($result)) { $result_array = array(); $result_array['link'] = $model->getPostURL($item['bloglink'], $item['seolink']); $result_array['place'] = $_LANG['BLOG'] . ' «' . $item['cat_title'] . '»'; $result_array['placelink'] = $model->getBlogURL($item['bloglink']); $result_array['description'] = $searchModel->getProposalWithSearchWord($item['content_html']); $result_array['title'] = $item['title']; $result_array['pubdate'] = $item['pubdate']; $result_array['session_id'] = session_id(); $searchModel->addResult($result_array); } } return; }
function mod_category($mod, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('content'); $model = new cms_model_content(); if (!isset($cfg['category_id'])) { $cfg['category_id'] = 0; } if (!isset($cfg['show_subcats'])) { $cfg['show_subcats'] = 1; } if (!isset($cfg['expand_all'])) { $cfg['expand_all'] = 1; } $rootcat = $inDB->getNsCategory('cms_category', $cfg['category_id']); if (!$rootcat) { return false; } $subcats_list = $model->getSubCats($rootcat['id'], $cfg['show_subcats'], $rootcat['NSLeft'], $rootcat['NSRight']); if (!$subcats_list) { return false; } $current_seolink = urldecode(cmsCore::request('seolink', 'str', '')); cmsPage::initTemplate('modules', $cfg['tpl'])->assign('cfg', $cfg)->assign('current_seolink', $current_seolink)->assign('subcats_list', $subcats_list)->display($cfg['tpl']); return true; }
function mod_forum($mod, $cfg) { $inDB = cmsDatabase::getInstance(); $default_cfg = array('shownum' => 4, 'cat_id' => 0, 'forum_id' => 0, 'subs' => 0, 'show_hidden' => 0, 'show_pinned' => 0, 'showtext' => 1, 'showforum' => 0, 'order' => 'pubdate'); $cfg = array_merge($default_cfg, $cfg); cmsCore::loadModel('forum'); $model = new cms_model_forum(); $inDB->addJoin('INNER JOIN cms_forums f ON f.id = t.forum_id'); $inDB->addSelect('f.title as forum_title'); if ($cfg['cat_id']) { $model->whereForumCatIs($cfg['cat_id']); } if ($cfg['forum_id']) { if ($cfg['subs']) { $forum = $model->getForum($cfg['forum_id']); if (!$forum) { return false; } $model->whereThisAndNestedForum($forum['NSLeft'], $forum['NSRight']); } else { $model->whereForumIs($cfg['forum_id']); } } if (!$cfg['show_hidden']) { $model->wherePublicThreads(); } if ($cfg['show_pinned']) { $model->wherePinnedThreads(); } $inDB->orderBy('t.' . $cfg['order'], 'DESC'); $inDB->limit($cfg['shownum']); $threads = $model->getThreads(); cmsPage::initTemplate('modules', $cfg['tpl'])->assign('threads', $threads)->assign('cfg', $cfg)->display($cfg['tpl']); return true; }
function mod_blogs($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); $default_cfg = array('sort' => 'pubdate', 'owner' => 'user', 'shownum' => 5, 'minrate' => 0, 'blog_id' => 0, 'showrss' => 1); $cfg = array_merge($default_cfg, $cfg); cmsCore::loadClass('blog'); $inBlog = cmsBlogs::getInstance(); $inBlog->owner = $cfg['owner']; if ($cfg['owner'] == 'club') { cmsCore::loadModel('clubs'); $model = new cms_model_clubs(); $inDB->addSelect('b.user_id as bloglink'); } else { cmsCore::loadModel('blogs'); $model = new cms_model_blogs(); } // получаем аватары владельцев $inDB->addSelect('up.imageurl'); $inDB->addJoin('LEFT JOIN cms_user_profiles up ON up.user_id = u.id'); $inBlog->whereOnlyPublic(); if ($cfg['minrate']) { $inBlog->ratingGreaterThan($cfg['minrate']); } if ($cfg['blog_id']) { $inBlog->whereBlogIs($cfg['blog_id']); } $inDB->orderBy('p.' . $cfg['sort'], 'DESC'); $inDB->limit($cfg['shownum']); $posts = $inBlog->getPosts(false, $model); if (!$posts) { return false; } cmsPage::initTemplate('modules', 'mod_blogs')->assign('posts', $posts)->assign('cfg', $cfg)->display('mod_blogs.tpl'); return true; }
function f_banners(&$text) { $phrase = 'БАННЕР'; if (mb_strpos($text, $phrase) === false) { return true; } if (!cmsCore::getInstance()->isComponentEnable('banners')) { return true; } $regex = '/{(' . $phrase . '=)\\s*(.*?)}/i'; $matches = array(); preg_match_all($regex, $text, $matches, PREG_SET_ORDER); if (!$matches) { return true; } cmsCore::loadModel('banners'); foreach ($matches as $elm) { $elm[0] = str_replace('{', '', $elm[0]); $elm[0] = str_replace('}', '', $elm[0]); mb_parse_str($elm[0], $args); $position = @$args[$phrase]; if ($position) { $output = cms_model_banners::getBannerHTML($position); } else { $output = ''; } $text = str_replace('{' . $phrase . '=' . $position . '}', $output, $text); } return true; }
function mod_clubs($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); if (!isset($cfg['count'])) { $cfg['count'] = 5; } if (!isset($cfg['type'])) { $cfg['type'] = 'id'; } if (!isset($cfg['vip_on_top'])) { $cfg['vip_on_top'] = 1; } cmsCore::loadModel('clubs'); $model = new cms_model_clubs(); if ($cfg['vip_on_top']) { $inDB->orderBy('is_vip', 'DESC, c.' . $cfg['type'] . ' DESC'); } else { $inDB->orderBy('c.' . $cfg['type'], 'DESC'); } $inDB->limit($cfg['count']); $clubs = $model->getClubs(); if (!$clubs) { return false; } cmsPage::initTemplate('modules', 'mod_clubs')->assign('clubs', $clubs)->display('mod_clubs.tpl'); return true; }
function mod_dt_newsslider($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('content'); $model = new cms_model_content(); if (!isset($cfg['cat_id'])) { $cfg['cat_id'] = 1; } if ($cfg['cat_id']) { if (!$cfg['subs']) { $model->whereCatIs($cfg['cat_id']); } else { $rootcat = $inDB->getNsCategory('cms_category', $cfg['cat_id']); if (!$rootcat) { return false; } $model->whereThisAndNestedCats($rootcat['NSLeft'], $rootcat['NSRight']); } } $inDB->orderBy('con.ordering', 'ASC'); $inDB->limit($cfg['newscount']); $slider_list = $model->getArticlesList(); if (!$slider_list) { return false; } cmsPage::initTemplate('modules', 'mod_dt_newsslider')->assign('slider', $slider_list)->assign('cfg', $cfg)->assign('module_id', $module_id)->display('mod_dt_newsslider.tpl'); return true; }
function rss_blogs($item_id, $cfg) { if (!cmsCore::getInstance()->isComponentEnable('blogs')) { return false; } $inDB = cmsDatabase::getInstance(); global $_LANG; cmsCore::loadModel('blogs'); $model = new cms_model_blogs(); cmsCore::loadClass('blog'); $inBlog = cmsBlogs::getInstance(); $inBlog->owner = 'user'; $channel = array(); $items = array(); // Формируем канал if ($item_id) { $blog = $inBlog->getBlog($item_id); if (!$blog) { return false; } //Если доступа к блогу нет, возвращаемся if (!cmsUser::checkUserContentAccess($blog['allow_who'], $blog['user_id'])) { return false; } $inBlog->whereBlogIs($blog['id']); $channel['title'] = $blog['title']; $channel['description'] = $_LANG['NEW_POSTS_IN_BLOGS']; $channel['link'] = HOST . $model->getBlogURL($blog['seolink']); } else { $channel['title'] = $_LANG['NEW_POSTS_IN_BLOGS']; $channel['description'] = $_LANG['NEW_POSTS_IN_BLOGS']; $channel['link'] = HOST .'/blogs'; } // В RSS всегда только публичные посты $inBlog->whereOnlyPublic(); $inDB->orderBy('p.pubdate', 'DESC'); $inDB->limit($cfg['maxitems']); $posts = $inBlog->getPosts(false, $model, true); if ($posts) { foreach($posts as $post){ $post['link'] = HOST . $post['url']; $post['description'] = mb_substr(strip_tags($post['content_html']), 0, 350). '...'; $post['comments'] = $post['link'].'#c'; $post['category'] = $post['blog_title']; $items[] = $post; } } return array('channel' => $channel, 'items' => $items); }
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_about($module_id, $cfg) { cmsCore::loadModel('content'); $model = new cms_model_content(); $articles = $model->getArticlesList3(true, '47'); cmsPage::initTemplate('modules', 'module_about.tpl')->assign('articles', $articles)->display('module_about.tpl'); return true; }
function mod_search($module_id, $cfg) { cmsCore::loadModel('search'); cmsCore::loadLanguage('components/search'); $model = cms_model_search::initModel(); cmsPage::initTemplate('modules', $cfg['tpl'])->assign('enable_components', $model->getEnableComponentsWithSupportSearch())->display($cfg['tpl']); return true; }
function rss_comments($item_id, $cfg) { if (!cmsCore::getInstance()->isComponentEnable('comments')) { return false; } $inDB = cmsDatabase::getInstance(); global $_LANG; cmsCore::loadModel('comments'); $model = new cms_model_comments(); $channel = array(); $items = array(); if ($item_id) { // Выделяем назначение и id назначения $target_array = explode('-', $item_id); $target_str = $target_array[0]; $target_id = (int) $target_array[1]; $target = $inDB->get_fields('cms_comment_targets', "target='{$target_str}'", '*'); if (!$target) { return false; } if (cmsCore::loadModel($target['component'])) { $model_class = 'cms_model_' . $target['component']; if (class_exists($model_class)) { $target_model = new $model_class(); } } if (!isset($target_model)) { return false; } $target_data = $target_model->getCommentTarget($target_str, $target_id); if (!$target_data) { return false; } $model->whereTargetIs($target_str, $target_id); $channel['title'] = $target_data['title']; $channel['description'] = $target['title']; $channel['link'] = HOST . $target_data['link']; } else { $channel['title'] = $_LANG['COMMENTS_ON_SITE']; $channel['description'] = $_LANG['COMMENTS_ON_SITE']; $channel['link'] = HOST . '/comments'; } $model->whereIsShow(); $inDB->orderBy('c.pubdate', 'DESC'); $inDB->limit($cfg['maxitems']); $comments = $model->getComments(true, false, true); if ($comments) { foreach ($comments as $comment) { $comment['title'] = $comment['content']; $comment['link'] = HOST . $comment['target_link'] . '#c' . $comment['id']; $comment['comments'] = HOST . $comment['target_link'] . '#c' . $comment['id']; $comment['category'] = $target_data['title']; $items[] = $comment; } } return array('channel' => $channel, 'items' => $items); }
function rss_clubs($item_id, $cfg) { if (!cmsCore::getInstance()->isComponentEnable('clubs')) { return false; } $inDB = cmsDatabase::getInstance(); global $_LANG; cmsCore::loadModel('clubs'); $model = new cms_model_clubs(); $inBlog = $model->initBlog(); $channel = array(); $items = array(); // Формируем канал if ($item_id) { $blog = $inBlog->getBlog($item_id); if (!$blog) { return false; } $club = $model->getClub($blog['user_id']); if (!$club) { return false; } if (!$club['enabled_blogs']) { return false; } if ($club['clubtype'] == 'private') { return false; } $inBlog->whereBlogIs($blog['id']); $channel['title'] = $blog['title']; $channel['description'] = $_LANG['NEW_POSTS_IN_CLUB_BLOG'] . ' ' . $club['title']; $channel['link'] = HOST . '/clubs/' . $club['id']; } else { $channel['title'] = $_LANG['NEW_POSTS_IN_CLUB_BLOGS']; $channel['description'] = $_LANG['NEW_POSTS_IN_CLUB_BLOGS']; $channel['link'] = HOST . '/clubs'; } // В RSS всегда только публичные посты $inBlog->whereOnlyPublic(); $inDB->orderBy('p.pubdate', 'DESC'); $inDB->limit($cfg['maxitems']); $inDB->addSelect('b.user_id as bloglink'); $posts = $inBlog->getPosts(false, $model, true); if ($posts) { foreach ($posts as $post) { $post['link'] = HOST . $post['url']; $post['description'] = mb_substr(strip_tags($post['content_html']), 0, 350) . '...'; $post['comments'] = $post['link'] . '#c'; $post['category'] = $post['blog_title']; $items[] = $post; } } return array('channel' => $channel, 'items' => $items); }
function cmsSubmitKarma($target, $item_id, $points) { $inUser = cmsUser::getInstance(); $inDB = cmsDatabase::getInstance(); $ip = cmsCore::strClear($_SERVER['REMOTE_ADDR']); $target = cmsCore::strClear($target); $points = (int) $points; $item_id = (int) $item_id; if (cmsAlreadyKarmed($target, $item_id, $inUser->id)) { return false; } //вставляем новый голос $sql = "INSERT INTO cms_ratings (item_id, points, ip, target, user_id, pubdate)\n VALUES ('{$item_id}', '{$points}', '{$ip}', '{$target}', '{$inUser->id}', NOW())"; $inDB->query($sql); //проверяем была ли сделана агрегация для этой цели ранее $is_agr = $inDB->rows_count('cms_ratings_total', "target='{$target}' AND item_id = '{$item_id}'", 1); //если была, то обновляем if ($is_agr) { $agr_sql = "UPDATE cms_ratings_total\n SET total_rating = total_rating + ({$points}),\n total_votes = total_votes + 1\n WHERE target='{$target}' AND item_id = '{$item_id}'"; } //если не было, то вставляем if (!$is_agr) { $agr_sql = "INSERT INTO cms_ratings_total (target, item_id, total_rating, total_votes)\n VALUES ('{$target}', '{$item_id}', '{$points}', '1')"; } $inDB->query($agr_sql); //получаем информацию о цели $info = $inDB->get_fields('cms_rating_targets', "target='{$target}'", '*'); //если нужно, изменяем рейтинг автора цели if ($info['is_user_affect'] && $info['user_weight'] && $info['target_table']) { $user_sql = "UPDATE cms_users u,\n {$info['target_table']} t\n SET u.rating = u.rating + ({$points}*{$info['user_weight']})\n WHERE t.user_id = u.id AND t.id = '{$item_id}'"; $inDB->query($user_sql); } //проверяем наличие метода updateRatingHook(target, item_id, points) в модели //компонента, ответственного за цель if ($info['component']) { cmsCore::loadModel($info['component']); if (class_exists('cms_model_' . $info['component'])) { $model_class = 'cms_model_' . $info['component']; $model = new $model_class(); // если метод есть, пользуемся им if (method_exists($model, 'updateRatingHook')) { $model->updateRatingHook($target, $item_id, $points); } else { if ($inDB->isFieldExists($info['target_table'], 'rating')) { $sql = "UPDATE {$info['target_table']}\n SET rating = rating + ({$points})\n WHERE id = '{$item_id}'"; $inDB->query($sql); } } } } return true; }
function module_works($module_id, $cfg) { cmsCore::loadModel('content'); $config = cmsConfig::getDefaultConfig(); $model = new cms_model_content(); $articless = $model->getArticlesListInFooter(false); $facebook = htmlspecialchars($config['facebook']); $vk = htmlspecialchars($config['vk']); $google = htmlspecialchars($config['google']); $yer = date('Y'); cmsPage::initTemplate('modules', 'module_works.tpl')->assign('facebook', $facebook)->assign('vk', $vk)->assign('Y', $yer)->assign('google', $google)->assign('articless', $articless)->display('module_works.tpl'); return true; }
function rss_content($item_id, $cfg) { if (!cmsCore::getInstance()->isComponentEnable('content')) { return false; } $inDB = cmsDatabase::getInstance(); global $_LANG; cmsCore::loadModel('content'); $model = new cms_model_content(); $channel = array(); $items = array(); if ($item_id) { $cat = $inDB->getNsCategory('cms_category', (int) $item_id); if (!$cat) { return false; } $cat = cmsCore::callEvent('GET_CONTENT_CAT', $cat); if (!$cat['published']) { return false; } if (!cmsCore::checkUserAccess('category', $cat['id'])) { return false; } $model->whereThisAndNestedCats($cat['NSLeft'], $cat['NSRight']); $channel['title'] = $cat['title']; $channel['description'] = $cat['description']; $channel['link'] = HOST . $model->getCategoryURL(0, $cat['seolink']); } else { $channel['title'] = $_LANG['NEW_MATERIALS']; $channel['description'] = $_LANG['LAST_ARTICLES_NEWS']; $channel['link'] = HOST . '/content'; } $inDB->where("con.showlatest = 1"); $inDB->orderBy('con.pubdate', 'DESC'); $inDB->limit($cfg['maxitems']); $content = $model->getArticlesList(); if ($content) { foreach ($content as $con) { $con['link'] = HOST . $con['url']; $con['comments'] = $con['link'] . '#c'; $con['category'] = $con['cat_title']; if ($con['image']) { $con['size'] = round(filesize(PATH . '/images/photos/small/' . $con['image'])); $con['image'] = HOST . '/images/photos/small/' . $con['image']; } $items[] = $con; } } return array('channel' => $channel, 'items' => $items); }
function mod_latest($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('content'); $model = new cms_model_content(); if (!isset($cfg['showrss'])) { $cfg['showrss'] = 1; } if (!isset($cfg['subs'])) { $cfg['subs'] = 1; } if (!isset($cfg['cat_id'])) { $cfg['cat_id'] = 1; } if (!isset($cfg['newscount'])) { $cfg['newscount'] = 5; } if (!isset($cfg['is_pag'])) { $cfg['is_pag'] = 0; } if (!isset($cfg['page'])) { $cfg['page'] = 1; } if ($cfg['cat_id']) { if (!$cfg['subs']) { //выбираем из категории $model->whereCatIs($cfg['cat_id']); } else { //выбираем из категории и подкатегорий $rootcat = $inDB->getNsCategory('cms_category', $cfg['cat_id']); if (!$rootcat) { return false; } $model->whereThisAndNestedCats($rootcat['NSLeft'], $rootcat['NSRight']); } } $inDB->where("con.showlatest = 1"); if ($cfg['is_pag']) { $total = $model->getArticlesCount(); } $inDB->orderBy('con.pubdate', 'DESC'); $inDB->limitPage($cfg['page'], $cfg['newscount']); $content_list = $model->getArticlesList(); if (!$content_list) { return false; } $pagebar = $cfg['is_pag'] ? cmsPage::getPagebar($total, $cfg['page'], $cfg['newscount'], 'javascript:conPage(%page%, ' . $module_id . ')') : ''; cmsPage::initTemplate('modules', 'mod_latest')->assign('articles', $content_list)->assign('pagebar_module', $pagebar)->assign('module_id', $module_id)->assign('cfg', $cfg)->display('mod_latest.tpl'); return true; }
function mod_arhive($module_id, $cfg) { cmsCore::loadModel('arhive'); $model = new cms_model_arhive(); $model->whereThisAndNestedCats(@$cfg['cat_id']); if ($model->year != 'all') { $model->whereYearIs(); } $items = $model->getArhiveContent(); if (!$items) { return false; } cmsPage::initTemplate('modules', 'mod_arhive')->assign('arhives', $items)->assign('date', array('year' => $model->year, 'month' => $model->month, 'day' => $model->day))->display('mod_arhive.tpl'); return true; }
function mod_polls($module_id, $cfg) { cmsCore::loadModel('polls'); $model = new cms_model_polls(); if ($cfg['poll_id'] > 0) { $poll = $model->getPoll($cfg['poll_id']); } else { $poll = $model->getPoll(0, 'RAND()'); } if (!$poll) { return false; } cmsPage::initTemplate('modules', 'mod_polls')->assign('poll', $poll)->assign('is_voted', $model->isUserVoted($poll['id']))->assign('module_id', $module_id)->assign('cfg', $cfg)->display('mod_polls.tpl'); return true; }
function module_ckatalog($module_id, $cfg) { cmsCore::loadModel('content'); //$model = new cms_model_content(); $inDB = cmsDatabase::getInstance(); $cat = $inDB->getNsCategory('cms_category', 17); $categories = array(); $categories[0] = $cat; module_ckatalog_getCategoriesData($categories[0], $cat); //вызов рекурсии с передачей id корневой категории //echo "<pre>";var_dump($categories);exit; // $categories = $model->getArticlesList2(true,'17'); cmsPage::initTemplate('modules', 'module_ckatalog.tpl')->assign('categories', $categories)->display('module_ckatalog.tpl'); return true; }
public function viewTab($user_id) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('content'); $model = new cms_model_content(); $model->whereUserIs($user_id); $total = $model->getArticlesCount(); $inDB->orderBy('con.pubdate', 'DESC'); $inDB->limitPage(1, (int) $this->config['PU_LIMIT']); $content_list = $total ? $model->getArticlesList() : array(); $inDB->resetConditions(); ob_start(); cmsPage::initTemplate('plugins', 'p_usertab.tpl')->assign('total', $total)->assign('articles', $content_list)->display('p_usertab.tpl'); return ob_get_clean(); }
function mod_lastreg($mod, $cfg) { $inDB = cmsDatabase::getInstance(); cmsCore::loadModel('users'); $model = new cms_model_users(); $inDB->orderBy('regdate', 'DESC'); $inDB->limitPage(1, $cfg['newscount']); $users = $model->getUsers(); if ($cfg['view_type'] == 'list') { $total_all = cmsUser::getCountAllUsers(); } else { $total_all = 0; } cmsPage::initTemplate('modules', $cfg['tpl'])->assign('usrs', $users)->assign('cfg', $cfg)->assign('total_all', $total_all)->assign('total', sizeof($users))->display($cfg['tpl']); return true; }
public function viewBloges($user_id) { $inDB = cmsDatabase::getInstance(); cmsCore::loadClass('blog'); cmsCore::loadModel('blogs'); $inBlog = cmsBlogs::getInstance(); $model = new cms_model_blogs(); $model->whereUserIs($user_id); $total = $inBlog->getPostsCount($inUser->is_admin); $inDB->orderBy('p.pubdate', 'DESC'); $inDB->limitPage(1, (int) $this->config['PU_LIMIT']); $posts = $inBlog->getPosts($inUser->is_admin, $model); ob_start(); cmsPage::initTemplate('plugins', 'p_bloges.tpl')->assign('posts', $posts)->display('p_bloges.tpl'); return ob_get_clean(); }
function module_slides($module_id, $cfg) { cmsCore::loadModel('content'); $inDB = cmsDatabase::getInstance(); $cat = $inDB->getNsCategory('cms_category', 48); $categori = array(); $categori[0] = $cat; foreach ($categori as $catData) { $categories['child'][$catData['id']] = $catData; } //echo "<pre>";var_dump($categories);exit; $model = new cms_model_content(); $articles = $model->getArticlesList2(true, '48'); cmsPage::initTemplate('modules', 'module_slides.tpl')->assign('categories', $categories)->assign('articles', $articles)->display('module_slides.tpl'); return true; }
public function __construct() { parent::__construct(); // Информация о плагине $this->info['plugin'] = 'p_loginza'; $this->info['title'] = 'Авторизация Loginza'; $this->info['description'] = 'Позволяет посетителям авторизоваться на сайте, используя аккаунты популярных социальных сетей'; $this->info['author'] = 'InstantCMS Team'; $this->info['version'] = '1.10.4'; // Настройки по-умолчанию $this->config['PL_PROVIDERS'] = 'vkontakte,facebook,mailruapi,google,yandex,openid,twitter,webmoney,rambler,flickr,mailru,loginza,myopenid,lastfm,verisign,aol,steam'; $this->config['PL_LANG'] = 'ru'; // События, которые будут отлавливаться плагином $this->events[] = 'LOGINZA_BUTTON'; $this->events[] = 'LOGINZA_AUTH'; cmsCore::loadModel('registration'); $this->reg_model = new cms_model_registration(); }
function search_clubs($query, $look) { $inDB = cmsDatabase::getInstance(); $searchModel = cms_model_search::initModel(); global $_LANG; cmsCore::loadModel('clubs'); $model = new cms_model_clubs(); /////// поиск по клубным блогам ////////// $sql = "SELECT con.*, cat.title cat_title, cat.id cat_id, cat.owner owner, cat.user_id, img.fileurl\r\n\t\t\tFROM cms_blog_posts con\r\n\t\t\tINNER JOIN cms_blogs cat ON cat.id = con.blog_id AND cat.allow_who = 'all' AND cat.owner = 'club'\r\n LEFT JOIN cms_upload_images img ON img.target_id = con.id AND img.target = 'blog_post' AND img.component = 'clubs'\r\n\t\t\tWHERE MATCH(con.title, con.content) AGAINST ('{$query}' IN BOOLEAN MODE) AND con.published = 1 LIMIT 100"; $result = $inDB->query($sql); if ($inDB->num_rows($result)) { while ($item = $inDB->fetch_assoc($result)) { $result_array = array(); $result_array['link'] = $model->getPostURL($item['user_id'], $item['seolink']); $result_array['place'] = ' «' . $item['cat_title'] . '»'; $result_array['placelink'] = $model->getBlogURL($item['user_id']); $result_array['description'] = $searchModel->getProposalWithSearchWord($item['content_html']); $result_array['title'] = $item['title']; $result_array['pubdate'] = $item['pubdate']; $result_array['imageurl'] = $item['fileurl']; $result_array['session_id'] = session_id(); $searchModel->addResult($result_array); } } /////// поиск по клубным фоткам ////////// $sql = "SELECT f.*, a.title as cat, a.id as cat_id\r\n\t\t\tFROM cms_photo_files f\r\n\t\t\tINNER JOIN cms_photo_albums a ON a.id = f.album_id AND a.published = 1 AND a.NSDiffer != ''\r\n\t\t\tWHERE MATCH(f.title, f.description) AGAINST ('{$query}' IN BOOLEAN MODE) AND f.published = 1"; $result = $inDB->query($sql); if ($inDB->num_rows($result)) { while ($item = $inDB->fetch_assoc($result)) { $result_array = array(); $result_array['link'] = "/clubs/photo" . $item['id'] . ".html"; $result_array['place'] = $_LANG['CLUBS_PHOTOALBUM'] . ' «' . $item['cat'] . '»'; $result_array['placelink'] = '/clubs/photoalbum' . $item['cat_id']; $result_array['description'] = $searchModel->getProposalWithSearchWord($item['description']); $result_array['title'] = $item['title']; $result_array['pubdate'] = $item['pubdate']; $result_array['imageurl'] = HOST . '/images/photos/medium/' . $item['file'] ? '/images/photos/medium/' . $item['file'] : ''; $result_array['session_id'] = session_id(); $searchModel->addResult($result_array); } } return; }
function mod_comments($module_id, $cfg) { $inDB = cmsDatabase::getInstance(); $inUser = cmsUser::getInstance(); if (!isset($cfg['showrss'])) { $cfg['showrss'] = 1; } if (!isset($cfg['minrate'])) { $cfg['minrate'] = 0; } if (!isset($cfg['showguest'])) { $cfg['showguest'] = 0; } if (!sizeof($cfg['targets'])) { return true; } cmsCore::loadModel('comments'); $model = new cms_model_comments(); $model->initAccess(); // Комментарии только нужного назначения $model->whereTargetIn($cfg['targets']); // Если не показывать гостей, добавляем условие if (!$cfg['showguest']) { $model->whereOnlyUsers(); } // Администраторам и админам показываем все комментарии if (!($inUser->is_admin || $model->is_can_moderate)) { $model->whereIsShow(); } // Комментарии в зависимости от рейтинга if ($cfg['minrate'] != 0) { $model->whereRatingOver($cfg['minrate']); } $inDB->orderBy('c.pubdate', 'DESC'); $inDB->limitPage(1, $cfg['shownum']); $comments = $model->getComments(true, false, true); if (!$comments) { return false; } cmsPage::initTemplate('modules', 'mod_comments')->assign('comments', $comments)->assign('cfg', $cfg)->display('mod_comments.tpl'); return true; }