sidebar.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. use yii\helpers\Html;
  3. $profile = Yii::$app->user->identity->profile;
  4. $photo = "/images/users/".Yii::$app->user->id."_sm.jpg";
  5. if( !file_exists( Yii::getAlias('@webroot').$photo ) ){
  6. $photo = "";
  7. }
  8. ?>
  9. <aside class="main-sidebar sidebar-dark-primary elevation-4">
  10. <!-- Brand Logo -->
  11. <a href="/control/" class="brand-link">
  12. <img src="/img/icon-180x180.png" alt="Amitel Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
  13. <span class="brand-text font-weight-light">Amitel admin 3</span>
  14. </a>
  15. <!-- Sidebar -->
  16. <div class="sidebar">
  17. <!-- Sidebar user panel (optional) -->
  18. <div class="user-panel mt-3 pb-3 mb-3 d-flex">
  19. <div class="image">
  20. <?=Html::img($photo, [
  21. 'class' => 'img-circle elevation-2',
  22. 'alt' => $profile->user->username,
  23. ])?>
  24. </div>
  25. <div class="info">
  26. <a href="#" class="d-block"><?=$profile->name?></a>
  27. </div>
  28. </div>
  29. <!-- SidebarSearch Form -->
  30. <!-- href be escaped -->
  31. <!-- <div class="form-inline">
  32. <div class="input-group" data-widget="sidebar-search">
  33. <input class="form-control form-control-sidebar" type="search" placeholder="Search" aria-label="Search">
  34. <div class="input-group-append">
  35. <button class="btn btn-sidebar">
  36. <i class="fas fa-search fa-fw"></i>
  37. </button>
  38. </div>
  39. </div>
  40. </div> -->
  41. <!-- Sidebar Menu -->
  42. <nav class="mt-2 nav-flat">
  43. <?php
  44. echo \hail812\adminlte\widgets\Menu::widget([
  45. 'options' => ['Class' => 'nav nav-pills nav-sidebar nav-child-indent flex-column'],
  46. 'items' => [
  47. ['label' => 'Login', 'url' => ['site/login'], 'icon' => 'sign-in-alt', 'visible' => Yii::$app->user->isGuest],
  48. [
  49. 'label' => 'Комментарии',
  50. 'url' => ['/control/comments/index'],
  51. 'icon' => 'comments',
  52. 'badge' => '<span class="right badge badge-danger">'.\manager\models\Comments::find()->andWhere(['visible'=>"N"])->count().'</span>',
  53. 'items' => [
  54. ['label' => 'rss', 'url' => ['/control/comments/rss'], 'iconStyle' => 'fa', 'iconClassAdded'=>'','icon' => 'wrench'],
  55. ]
  56. ],
  57. ],
  58. ]);
  59. ?>
  60. </nav>
  61. <!-- /.sidebar-menu -->
  62. </div>
  63. <!-- /.sidebar -->
  64. </aside>
  65. <script>
  66. var url = String(window.location);
  67. $('ul.nav-sidebar a').filter(function() {
  68. // console.log(url+'-'+this.href.indexOf('kd')+':'+url.indexOf("design"));
  69. if( this.href.indexOf('design') >= 0 && ( url.indexOf("kd") >= 0 || url.indexOf("nh") >= 0 || url.indexOf("top-slider") >= 0 ) ) return true;
  70. if( this.href.indexOf('tags') >= 0 && ( url.indexOf("tagsfilter") >= 0 ) ) return true;
  71. if( this.href.indexOf('comments') >= 0 && ( url.indexOf("comments-filter") >= 0 ) ) return true;
  72. if( this.href.indexOf('stats') >= 0 && ( url.indexOf("analytics") >= 0 ) ) return true;
  73. return this.href == url;
  74. }).parent().addClass('menu-open');
  75. </script>