Файл: Arhmobi_esdcms/sys/widgets/news/index.php
Строк: 33
<?php
defined('DCMS') or die;
$db = DB::me();
$listing = new listing();
$post = $listing->post();
$post->highlight = true;
$post->icon('news');
$post->url = '/news/';
$post->title = __('Hовости');
$res = $db->query("SELECT COUNT(*) FROM `news`");
$sh = $res->fetchColumn();
$post->counter = $sh;
if ($dcms->widget_items_count) {
$week = mktime(0, 0, 0, date('n'), -7);
$q = $db->prepare("SELECT * FROM `news` WHERE `time` > ? ORDER BY `id` DESC LIMIT 0");
$q->execute(Array($week));
while ($news = $q->fetch()) {
$post = $listing->post();
$post->icon('news_new');
$post->title = text::toValue($news['title']);
$post->url = '/news/comments.php?id=' . $news['id'];
$post->time = misc::when($news['time']);
$post->highlight = $news['time'] > NEW_TIME;
$res = $db->prepare("SELECT COUNT(*) FROM `news_comments` WHERE `id_news` = ?");
$res->execute(Array($news['id']));
$post->bottom = 'Комментариев: '.$res->fetchColumn();
}
}
$listing->display();