<?php
switch($act)
{
/* Просмотр списка категорий */
default:
$title = 'Категории';
$categoryes = $mysqli->query("SELECT `id`, `name`, `count` FROM `category` ORDER BY `id` ASC");
$data = array();
while($row = $categoryes->fetch_assoc())
{
$data[] = $row;
}
echo $twig->render('category/index.tpl',array('title' => $title, 'sait_name' => $set['name_sait'],'user_data' => $user_data, 'home' => $home, 'style' => $style, 'data' => $data));
break;
/* Просмотр категории */
case 'view':
$isCategory = $mysqli->query("SELECT `name` FROM `category` WHERE `id` = '".$id."'");
if($isCategory->num_rows > 0)
{
$rowCategory = $isCategory->fetch_assoc();
$title = $rowCategory['name'];
$saitsCount = $mysqli->query("SELECT `id` FROM `sait` WHERE `category` = '".$id."'")->num_rows;
if($saitsCount > 0)
{
$total = intval(($saitsCount-1)/$pages) + 1;
if(empty($page) OR $page < 0)
{
$page = 1;
}
if($page > $total)
{
$page = $total;
}
$past = intval($saitsCount/$pages);
$start = $page*$pages-$pages;
$top = $mysqli->query("SELECT `id`,`name`,`about`,`hosts`,`hits`,`in`,`out`,`url` FROM `sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0' AND `category` = '".$id."' ORDER BY `hosts` DESC LIMIT ".$start.",".$pages."");
while($row = $top->fetch_assoc())
{
$data[] = $row;
}
if($saitsCount > $pages)
{
$navigation = navigation($total, $page, 'http://'.$home.'/category;'.$id.';view;');
}
}
echo $twig->render('category/view.tpl',array('title' => $title, 'sait_name' => $set['name_sait'],'user_data' => $user_data, 'home' => $home, 'style' => $style, 'data' => $data, 'navigation' => $navigation, 'cname' => $rowCategory['name']));
}
else
{
$title = 'Ошибка';
echo $twig->render('system/error.tpl',array('title' => $title, 'sait_name' => $set['name_sait'],'user_data' => $user_data, 'home' => $home, 'style' => $style, 'error' => 'Ошибка. Категории нет.<br>', 'backLink' => 'http://'.$home.'/'));
}
break;
}
?>