<?php

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

$rekl = $db->super_query("SELECT COUNT(*) as count FROM rekl WHERE sel = '2'");
$rekl = $rekl['count'];
if ($rekl > 0) {
    rekl(2);
}
unset($rekl);

$query = $db->query("SELECT * FROM `menu` ORDER BY `pos` ASC");

#Плитка
if ($user['set_menu'] == 1) {
    echo "<br /><div>";
    while ($posts = $db->get_row($query)) {
        if ($posts['color_link'] != NULL) {
            $color = "<font color='$posts[color_link]'>";
            $color2 = "</font>";
        } else {
            $color = null;
            $color2 = null;
        }
        if ($posts['color_icon'] != NULL) {
            $color3 = "<font color='$posts[color_icon]'>";
            $color4 = "</font>";
        } else {
            $color3 = null;
            $color4 = null;
        }
        echo "<div class='menu_wrapeer'>";
        echo "<a class='menu_link_s' href='$posts[url]'>";
        echo "<span class='hint--bottom' data-hint='";

        if ($posts['counter'] != NULL && is_file(H . $posts['counter'])) {
            @include H . $posts['counter'];
        }
        echo "'>";
        echo "<div class='menu_picat'>";
        if (IS_WEB) {
            echo "$color3<i class='fa fa-$posts[icon] fa-3x'></i>$color4";
        } else {
            echo "$color3<i class='fa fa-$posts[icon] fa-2x'></i>$color4";
        }
        echo "</div><div class='menu_title_s'>";

        echo "$color " . lang($posts['name']) . "$color2<br />";
        echo "<small style='color: grey;'>$posts[opis]</small>";
        echo "</div>";
        echo "</span>";
        echo "</a>";
        echo "</div>";
    }
    #Кнопка добавления меню
    if (access('adm_menu')) {
        echo "<div class='menu_wrapeer'>";
        echo "<a href='/panel/menu.php' class='menu_link_s'>";
        echo "<div class='menu_picat'>";
        if (IS_WEB) {
            echo "$color3<i class='fa fa-plus fa-3x'></i>$color4";
        } else {
            echo "$color3<i class='fa fa-plus fa-2x'></i>$color4";
        }
        echo "</div><div class='menu_title_s'>";

        echo "$color " . lang('Добавить меню') . "$color2<br />";
        echo "<small style='color: grey;'>$posts[opis]</small>";
        echo "</div>";
        echo "</a>";
        echo "</div>";
    }

    echo "<div class='clear'></div>";
    echo "</div>";
}

#Список
if ($user['set_menu'] == 0) {

    while ($posts = $db->get_row($query)) {

        if ($posts['color_link'] != NULL) {
            $color = "<font color='$posts[color_link]'>";
            $color2 = "</font>";
        } else {
            $color = null;
            $color2 = null;
        }
        if ($posts['color_icon'] != NULL) {
            $color3 = "<font color='$posts[color_icon]'>";
            $color4 = "</font>";
        } else {
            $color3 = null;
            $color4 = null;
        }

        echo "<a href='$posts[url]' class='list-group-item-null list-group-item-grey dop'>";
        echo "$color3<i class='fa fa-$posts[icon] fa-fw fa-lg'></i>$color4 ";

        echo $color;
        echo lang($posts['name']);
        echo $color2;

        if ($posts['counter'] != NULL && is_file(H . $posts['counter'])) {
            echo "<span class='tag tag-info right'>";
            @include H . $posts['counter'];
            echo '</span>';
        }

        if ($posts['opis'] != null) {
            echo "<br /><small style='color: grey;'>$posts[opis]</small>";
        }
        echo "</a>";
    }
    unset($query);

    #Кнопка добавления меню
    if (access('adm_menu')) {
        echo "<a href='/panel/menu.php' class='list-group-item-null list-group-item-info dop'>";

        echo "$color3<i class='fa fa-plus fa-fw fa-lg'></i>$color4";

        echo "$color " . lang('Добавить меню') . "$color2";

        echo "</a>";
    }
}


