<?php

/* DCMS Special
 * Дата последнего редактирования 09.10.2016
 * Модифицировал densnet
 */

$k_post = $db->super_query("SELECT COUNT(*) as count FROM diary");
$k_post = $k_post['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$limit = $user['set_them_diary_num']; #Количество выводимых дневников.

$q = $db->query('SELECT * FROM `diary` ORDER BY `time` DESC LIMIT ' . $limit);

if ($k_post != 0) {
    echo "<div class='list-group-item-null list-group-item-info'><span style='float: right'><i class='fa fa-book fa-lg'></i></span>" . lang('Последние блоги') . "</div>";
    while ($dnev = $db->get_row($q)) {
        $ank = get_user($dnev['id_user']);
        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<i class='fa fa-book fa-fw'></i> <b>$dnev[name]</b><br />";
        echo "</div>";
        echo "<div class='list-group-item-null'>";

        echo "<span style='float:right;' id='hides'>";
        echo gradient("$ank[nick]", "$ank[ncolor]", "$ank[ncolor2]");
        echo "</span>";

        if (IS_WEB) {
            echo toOutput(cutStr($dnev['msg'], 300));
        } else {
            echo toOutput(cutStr($dnev['msg'], 100));
        }
        echo "<br /><a href='/modules/diary/$dnev[name]/'><font color='grey'>" . lang('Читать далее') . " &raquo;</font></a>";

        $comments = $db->super_query("SELECT COUNT(*) as count FROM `diary_komm` WHERE `id_diary` = '$dnev[id]'");

        echo "<span style='float:right;'>";
        echo "<i class='fa fa-comments fa-fw'></i> $comments[count]";
        echo "</span>";
        echo "</div>";
    }
}