<?php
define('NTLCMS', 1);
$module = 'news';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Новости - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if ($set['news'] == '1' && $_USER['admin'] != '1'){
echo '<div class="title"><b>'.razd.' Новости клуба</b></div>';
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Модуль закрыт администратором!</center></div>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
exit;
}
echo '<div class="title"><b>'.razd.' Новости клуба</b></div>';
$k_post = DB :: run() -> querySingle("select count(`id`) from `news`");
$k_page = k_page($k_post, $onpage); 
$page = page($k_page); 
$start = $onpage * $page - $onpage;
if ($k_post == 0) {
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Новостей еще нет!</center></div>';
} else {
$sql = DB :: run() -> query("select `id`, `name`, `text`, `date` from `news` order by `id` desc limit ".$start.", ".$onpage);
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
$newsTitle = checkout($row -> name);
$newsUrl = URL.'/feed_review'.ints($row -> id);
$newsDate = date('d.m.Y H:i', $row -> date);
$plainText = strip_tags(outtext($row->text, 1, 0, 0));
$description = mb_substr($plainText, 0, 150);
if (mb_strlen($plainText) > 150) $description .= '...';
echo '
<article class="menu" itemscope itemtype="https://schema.org/NewsArticle">
<i class="fa fa-feed fa-fw"></i> 
<h5 itemprop="headline" style="display:inline;">
<a href="'.$newsUrl.'" 
title="Читать новость: '.$newsTitle.'" 
aria-label="Читать новость '.$newsTitle.'" 
itemprop="url">'.$newsTitle.'</a>
</h5>
<meta itemprop="datePublished" content="'.date('c', $row->date).'">
<meta itemprop="description" content="'.$description.'">
<meta name="description" content="'.$description.'">
<span class="news-date">('.$newsDate.')</span>
</article>';
}
if ($k_page > 1) navigation(URL.'/feed?', $k_page, $page);
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> '.(isset($active) ? '<a href="'.URL.'/cabinet">В кабинет</a>' : '<a href="'.URL.'">На главную</a>').'</div>';
include ('../system/foot.php');
?>