View file modules/forum/view/my_themes.php

File size: 4.13Kb
<?php

/* SocCMS
 * Дата последнего редактирования 22.10.2016
 * Модифицировал densnet
 * Автор yadalay
 */

$set['title'] = lang('Мои темы');

require_once H . 'sys/inc/thead.php';

aut();

$k_post = $db->super_query("SELECT COUNT(*) as count FROM `forum_themes` WHERE `id_user` = '$user[id]'");
$k_page = k_page($k_post['count'], $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='" . DIR_FORUM . "'>" . lang('Форум') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Мои темы');
echo "</small></div>";

if ($k_post['count'] == 0) {
    echo "<br />";
    $doc->NoResult();
} else {
    echo "<div class='list-group-item-null-mini'>\n";
    $themes = $db->query('SELECT * FROM `forum_themes` WHERE `id_user` = ' . $user['id'] . ' ORDER BY `id` DESC LIMIT ' . $start . ', ' . $set['p_str']);
    while ($theme = mysqli_fetch_object($themes)) {
        $creater = mysqli_fetch_object($db->query('SELECT `id`, `nick` FROM `user` WHERE `id` = ' . $theme->id_user));
        $razdel = mysqli_fetch_object($db->query('SELECT `id`, `id_forum` FROM `forum_razdels` WHERE `id` = ' . $theme->id_razdel));
        $forum = mysqli_fetch_object($db->query('SELECT `id` FROM `forum` WHERE `id` = ' . $razdel->id_forum));
        $count_posts = $db->super_query("SELECT COUNT(*) as count FROM `forum_posts` WHERE `id_theme` = '$theme->id'");
        $hide = (access('forum_post_ed')) ? NULL : '`hide` = "0" AND';
        $last_post = mysqli_fetch_object($db->query('SELECT `id`, `hide`, `id_user`, `time` FROM `forum_posts` WHERE ' . $hide . ' `id_theme` = ' . $theme->id . ' ORDER BY `id` DESC'));
        $who = ($last_post && $last_post->id_user != 0) ? mysqli_fetch_object($db->query('SELECT `id`, `nick` FROM `user` WHERE `id` = ' . $last_post->id_user)) : array();
        $who_id = ($last_post && $last_post->id_user != 0) ? $who->id : 0;
        $who_nick = ($last_post && $last_post->id_user != 0) ? $who->nick : '' . lang('Система') . '';

        if ($theme->reason_close != NULL) {
            $type = "<i class='fa fa-file-text fa-fw'></i> " . toOutput($theme->name, 1, 1, 0, 0, 0) . " <i class='fa fa-lock fa-fw'></i>";
        } elseif ($theme->type == 1) {
            $type = "<i class='fa fa-file-text fa-fw'></i> " . toOutput($theme->name, 1, 1, 0, 0, 0) . " <i class='fa fa-thumb-tack fa-fw'></i>";
        } else {
            $type = "<i class='fa fa-file-text fa-fw'></i> " . toOutput($theme->name, 1, 1, 0, 0, 0) . "";
        }

        echo "<div class='card'>\n";
        echo "<div class='card-header'>\n";
        echo "<a href='" . DIR_FORUM . "$forum->id/$razdel->id/$theme->id.html'>$type</a>";
        echo "</div>\n";

        if ($last_post) {
            echo "<div class='card-block'>\n";
            $continue = (mb_strlen($theme->description) > 150) ? '...' : NULL;
            echo "<span style='color: #9197a3;'>";
            echo toOutput(mb_substr($theme->description, 0, 150), 1, 1, 0, 1, 1) . $continue;
            echo "</span><br /><small>";
            echo user($theme->id_user);
            echo " &#183; <i class='fa fa-comments fa-fw'></i> <b>$count_posts[count]</b> <span class='hint--top grey' data-hint='" . date::time($theme->time) . "'>&#183; " . date::timek($theme->time) . "</span>";
            echo "</small></div>";
        } else {
            echo "<div class='card-block'>\n";
            $continue = (mb_strlen($theme->description) > 150) ? '...' : NULL;
            echo "<span style='color: #9197a3;'>";
            echo toOutput(mb_substr($theme->description, 0, 150), 1, 1, 0, 1, 1) . $continue;
            echo "</span>";
            echo "</div>";
        }

        echo "</div>";
    }
    echo "</div>\n";
    if ($k_page > 1) {
        str(DIR_FORUM . 'my_themes/', $k_page, $page);
    }
}