Файл: Arhmobi_esdcms/blog/cat.php
Строк: 38
<?php
include_once '../sys/inc/start.php';
$doc = new document();
$doc->title = __('Блоги');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
header('Refresh: 1; url=./');
$doc->err(__('Ошибка выбора раздела'));
exit;
}
$id_top = (int) $_GET['id'];
$q = $db->prepare("SELECT * FROM `blog_cat` WHERE `id` = ?");
$q->execute(Array($id_top));
if (!$topic = $q->fetch()) {
header('Refresh: 1; url=./');
$doc->err(__('Категория не доступна'));
exit;
}
$doc->title .= ' - ' . $topic['name'];
$res = $db->prepare("SELECT COUNT(*) FROM `blog_blog` WHERE `id_cat` = ?");
$res->execute(Array($topic['id']));
$pages = new pages;
$pages->posts = $res->fetchColumn(); // количество категорий
$pages->this_page(); // получаем текущую страницу
if ($user->id) {
$doc->act(__('Добавить запись'), 'new.blog.php?id_cat=' . $topic['id'] . "&return=" . URL);}
switch (@$_GET['sort']) {
case 'view':$order = 'view';
$sort = 'DESC';
break;
case 'id':$order = 'id';
$sort = 'DESC';
break;
case 'comm':$order = 'comm';
$sort = 'DESC';
break;
default:
$order = 'id';
$sort = 'DESC';
break;
}
$ord = array();
$ord[] = array("?id=".$topic['id']."&sort=id&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('Новые'), $order == 'id');
$ord[] = array("?id=".$topic['id']."&sort=view&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('По кол-ву просмотров'), $order == 'view');
$ord[] = array("?id=".$topic['id']."&sort=comm&page={$pages->this_page}" . (isset($search) ? '&search=' . urlencode($search) : ''), __('Обсуждаемые'), $order == 'comm');
$or = new design();
$or->assign('order', $ord);
$or->display('design.order.tpl');
$q = $db->prepare("SELECT * FROM `blog_blog` WHERE `id_cat` = ? ORDER BY `$order` ".$sort." LIMIT " . $pages->limit);
$q->execute(Array($topic['id']));
$listing = new listing();
while ($blog = $q->fetch()) {
$post = $listing->post();
$ank = new user((int) $blog['autor']);
if($blog['block']==1) {$post->icon('blog.X');}else{
$post->icon('blog');}
$post->hightlight = true;
$post->title = text::toValue($blog['name']);
$post->url = 'blog.php?blog=' . $blog['id'];
$post->time = misc::when($blog['time_create']);
$post->post .= '<img src="icons/blog_chat.png"/> Комментариев: '.$blog['comm'].'<br />';
$post->post .= '<img src="icons/blog_eye.png" class="icon"/> Просмотров: '.$blog['view'].'<br />';
}
$listing->display(__('Записей нет'));
$pages->display('cat.php?id=' . $topic['id'] . '&'); // вывод страниц
if ($topic['group_edit'] <= $user->group) {
$doc->act(__('Параметры раздела'), 'cat.edit.php?id=' . $topic['id'] . "&return=" . URL);
}
$doc->ret(__('Блоги'), './');
?>