<?php

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

$rekl = mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `sel` = '2'"), 0);
if ($rekl > 0) {
    rekl(2);
}
$qs = mysql_query("SELECT * FROM `menu` ORDER BY `pos` ASC");

#Плитка
if ($user['set_menu'] == 1) {
    echo "<br /><div>";
    while ($posts = mysql_fetch_assoc($qs)) {
        if (!isset($posts['icon'])) {
            mysql_query('ALTER TABLE `menu` ADD `icon` VARCHAR( 32 ) NULL DEFAULT NULL');
        }
        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 = mysql_fetch_assoc($qs)) {

        if (!isset($posts['icon'])) {
            mysql_query('ALTER TABLE `menu` ADD `icon` VARCHAR( 32 ) NULL DEFAULT NULL');
        }
        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'>";
        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='count'>";
            @include H . $posts['counter'];
            echo '</span>';
        }

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

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

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

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

        echo "</a>";
    }
}


