<?php
use yii\helpers\Html;
$profile = Yii::$app->user->identity->profile;
?>
<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="/manager/" class="brand-link">
        <img src="/img/icon-180x180.png" alt="Amitel Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
        <span class="brand-text font-weight-light">Amitel admin 3</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
        <!-- Sidebar user panel (optional) -->
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <div class="image">
                <?/*=Html::img($profile->getAvatarUrl($profile->gravatar_id), [
                    'class' => 'img-circle elevation-2',
                    'alt' => $profile->user->username,
                ]) */?>
            </div>
            <div class="info">
                <a href="#" class="d-block"><?=$profile->name?></a>
            </div>
        </div>

        <!-- SidebarSearch Form -->
        <!-- href be escaped -->
        <!-- <div class="form-inline">
            <div class="input-group" data-widget="sidebar-search">
                <input class="form-control form-control-sidebar" type="search" placeholder="Search" aria-label="Search">
                <div class="input-group-append">
                    <button class="btn btn-sidebar">
                        <i class="fas fa-search fa-fw"></i>
                    </button>
                </div>
            </div>
        </div> -->

        <!-- Sidebar Menu -->
        <nav class="mt-2 nav-flat">
            <?php
            echo \hail812\adminlte\widgets\Menu::widget([
				'options' => ['Class' => 'nav nav-pills nav-sidebar nav-child-indent flex-column'],
                'items' => [
                    ['label' => 'Login', 'url' => ['site/login'], 'icon' => 'sign-in-alt', 'visible' => Yii::$app->user->isGuest],
                    [
                        'label' => 'Новости',
                        'icon' => 'newspaper',
						'url' => ['/manager/news/list'],
//                        'badge' => '<span class="right badge badge-info">2</span>',
						'options' => ['class' => 'nav-item menu-open'],
                        'items' => [
                            ['label' => 'День', 'url' => ['/manager/news/list'], 'iconStyle' => 'far'],
                            ['label' => 'В очереди', 'url' => ['/manager/news/inactive'], 'iconStyle' => 'far', 'iconClassAdded'=>'fa-clock'],
                            ['label' => 'Создать', 'url' => ['/manager/news/create'], 'iconStyle' => 'fas', 'iconClassAdded'=>'','icon' => 'pen-nib'],
                        ]
                    ],
                    [
						'label' => 'Комментарии',
						'url' => ['/manager/comments/index'],
						'icon' => 'comments',
						'badge' => '<span class="right badge badge-danger">'.\manager\models\Comments::find()->andWhere(['visible'=>"N"])->count().'</span>',
                        'items' => [
                            ['label' => 'Настройки', 'url' => ['/manager/comments/conf'], 'iconStyle' => 'fa', 'iconClassAdded'=>'','icon' => 'wrench'],
                        ]
                    ],
                    [
                        'label' => 'Главная стр.',
                        'icon' => 'tachometer-alt',
						'url' => ['/manager/design/blocks'],
//                        'badge' => '<span class="right badge badge-info">2</span>',
                        'items' => [
                            ['label' => 'Блоки на главной', 'url' => ['/manager/design/blocks'], 'iconStyle' => 'far'],
							['label' => 'Создать Блок', 'url' => ['/manager/design/create'], 'iconStyle' => 'far'],
                            ['label' => 'КД блок', 'url' => ['/manager/kd'], 'iconStyle' => 'far', 'iconClass' => 'nav-icon far fa-circle text-warning'],
                            ['label' => 'НЧ блок ', 'url' => ['/manager/nh'], 'iconStyle' => 'far', 'iconClassAdded' => 'text-danger'],
                            ['label' => 'Слайдер', 'url' => ['/manager/top-slider'], 'iconStyle' => 'far', 'iconClassAdded' => 'text-primary'],
                            ['label' => 'Сброс кэша главной', 'url' => ['/manager/design/purge'], 'iconStyle' => 'fa', 'iconClassAdded' => 'fa-shower','badge' => '<span class="right badge badge-danger">New</span>'],
                        ]
                    ],
                    ['label' => 'Рубрики', 'icon' => 'th', 'url' => ['/manager/news/topiclist'],
                        'items' => [
                            ['label' => 'Список', 'url' => ['/manager/news/topiclist'], 'iconStyle' => 'far'],
                            ['label' => 'Создать', 'url' => ['/manager/news/topiccreate'], 'iconStyle' => 'far'],
                            ['label' => 'Все', 'url' => ['/manager/news/topicall'], 'iconStyle' => 'far'],
                        ]
                    ],
                    ['label' => 'Сюжеты', 'icon' => 'th', 'url' => ['/manager/news/storylist'],
                        'items' => [
                            ['label' => 'Список', 'url' => ['/manager/news/storylist'], 'iconStyle' => 'far'],
                            ['label' => 'Создать', 'url' => ['/manager/news/storycreate'], 'iconStyle' => 'far']
                        ]
                    ],
                    ['label' => 'Тэги', 'icon' => 'th', 'url' => ['/manager/tags/index'],
						'badge' => '<span class="right badge badge-danger">New</span>',
                        'items' => [
                            ['label' => 'Список', 'url' => ['/manager/tags/index'], 'iconStyle' => 'far'],
                            ['label' => 'Создать', 'url' => ['/manager/tags/create'], 'iconStyle' => 'far'],
                            ['label' => 'Меню', 'url' => ['/manager/tagsfilter/index'], 'iconStyle' => 'far', 'iconClass'=>'nav-icon fas fa-th-list']
                        ]
                    ],
                    ['label' => 'Статистика', 'icon' => 'th', 'url' => ['/manager/stats/index'],
                        'items' => [
                            ['label' => 'доска', 'url' => ['/manager/stats/index'], 'iconStyle' => 'far'],
                            ['label' => 'Авторы', 'url' => ['/manager/stats/authors'], 'iconStyle' => 'far']
                        ]
                    ],
                    ['label' => 'Персоны','icon' => 'user', 'url' => ['/manager/person/'],'badge' => '<span class="right badge badge-danger">New</span>',
					],
                    ['label' => 'Авторы','icon' => 'user', 'url' => ['/manager/authors/']
					],
                    ['label' => 'пользователи', 'icon' => 'user', 'url' => ['/user/admin/index'], 'visible' => Yii::$app->user->can('view_manage_users_page'),
						'items' => [
							['label' => 'Список', 'iconStyle' => 'far fa-solid fa-user', 'url' => ['/user/admin/index']],
							['label' => 'Новый', 'iconStyle' => 'far fa-user', 'url' => ['/user/admin/create']]
						]
					],
                    ['label' => 'Страницы', 'icon' => 'file', 'url' => ['/manager/page'],
					],
                    ['label' => 'Yii2 PROVIDED', 'header' => true],
                    ['label' => 'Gii',  'icon' => 'file-code', 'url' => ['/gii'], 'target' => '_blank'],
                    ['label' => 'Debug', 'icon' => 'bug', 'url' => ['/debug'], 'target' => '_blank'],
                    ['label' => 'Test', 'icon' => 'bug', 'url' => ['/manager/news/test'], 'target' => '_blank'],

                ],
            ]);
            ?>
        </nav>
        <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
</aside>
<script>
	var url = String(window.location);
	$('ul.nav-sidebar a').filter(function() {
	//	console.log(url+'-'+this.href.indexOf('kd')+':'+url.indexOf("design"));
	if( this.href.indexOf('design') >= 0 && ( url.indexOf("kd") >= 0 || url.indexOf("nh") >= 0 || url.indexOf("top-slider") >= 0 ) ) return true;
	if( this.href.indexOf('tags') >= 0 && ( url.indexOf("tagsfilter") >= 0  ) ) return true;

     return this.href == url;
}).parent().addClass('menu-open');
</script>
