<?php
echo '<div class="phdr"><b>Yangi maqolalar</b></div>';
$kmess = '10';
$total = $db->query("SELECT COUNT(*) FROM `library_texts` WHERE `time` AND `premod` = 1")->fetchColumn();
$page = $page >= ceil($total / $kmess) ?
ceil($total / $kmess) : $page; $start = $page == 1 ? 0 : ($page - 1) * $kmess;
$req = $db->query(
"SELECT `id`, `name`, `time`, `uploader`, `uploader_id`, `count_views`, `comments`, `comm_count`, `cat_id`, `announce` FROM `library_texts` WHERE `premod` = 1
ORDER BY `time` DESC
LIMIT " . $start . ', ' . $user->config->kmess
);
'pagination' => $tools->displayPagination('?act=new&', $start, $total, $user->config->kmess),
'total' => $total,
'list' =>
static function () use ($req, $tools, $config, $db) {
while ($res = $req->fetch()) {
$res['cover'] = file_exists(UPLOAD_PATH
. '/library/images/small/' . $res['id'] . '.png');
$obj = new Hashtags($res['id']);
$res['tags'] = $obj->getAllStatTags() ? $obj->getAllStatTags(1) : null;
$rate = new Rating($res['id']);
$res['ratingView'] = $rate->viewRate(1);
$uploader = $res['uploader_id']
? '<a href="' . $config['homeurl'] . '/profile/?user=' . $res['uploader_id'] . '">' . $tools->checkout($res['uploader']) . '</a>'
: $tools->checkout($res['uploader']);
$res['who'] = $uploader . ' (' . $tools->displayDate($res['time']) . ')';
$res['name'] = $tools->checkout($res['name']);
$res['announce'] = $tools->checkout($res['announce'], 0, 0);
$catalog = $db->query('SELECT `id`, `name` FROM `library_cats` WHERE `id` = ' . $res['cat_id'] . ' LIMIT 1')->fetch();
$res['catalog_name'] = $tools->checkout($catalog['name']);
yield $res;
}
},
]
);
?>