You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
4.6KB

  1. <?php
  2. use common\helpers\GlobalParam;
  3. use common\logic\Producer\Producer\Model\Producer;
  4. use common\logic\User\User\Wrapper\UserManager;
  5. use yii\bootstrap\Nav;
  6. use yii\helpers\Html;
  7. $userManager = UserManager::getInstance();
  8. ?>
  9. <section class="nav-user-top">
  10. <nav class="navbar navbar-default">
  11. <div class="container">
  12. <?php
  13. $producersArray = Producer::find()
  14. ->joinWith(['userProducer user_producer'])
  15. ->where([
  16. 'user_producer.id_user' => GlobalParam::getCurrentUserId(),
  17. 'user_producer.bookmark' => 1,
  18. ])
  19. ->all();
  20. $itemsProducersArray = [];
  21. if (count($producersArray)) {
  22. $itemsProducersArray[] = [
  23. 'options' => ['class' => 'dropdown-header'],
  24. 'label' => 'Mes favoris',
  25. ];
  26. foreach($producersArray as $producerItem) {
  27. $itemsProducersArray[] = [
  28. 'label' => Html::encode($producerItem->name),
  29. 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producerItem->slug]),
  30. ];
  31. }
  32. }
  33. $itemsProducersArray[] = [
  34. 'options' => ['class' => 'divider'],
  35. 'label' => ''
  36. ];
  37. $itemsProducersArray[] = [
  38. 'label' => '<span class="glyphicon glyphicon-search"></span> Rechercher un producteur',
  39. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producers'])
  40. ];
  41. echo Nav::widget([
  42. 'encodeLabels' => false,
  43. 'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'],
  44. 'items' => [
  45. [
  46. 'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>',
  47. 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']),
  48. 'visible' => $userManager->isCurrentProducer()
  49. ],
  50. [
  51. 'label' => '<span class="glyphicon glyphicon-star"></span> <span class="link-text">Producteurs</span>',
  52. 'url' => '#',
  53. 'items' => $itemsProducersArray,
  54. 'visible' => !Yii::$app->user->isGuest
  55. ],
  56. [
  57. 'label' => '<span class="glyphicon glyphicon-user"></span> <span class="link-text">' . ((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '') . '. </span>',
  58. 'options' => ['id' => 'label1'],
  59. 'url' => '#',
  60. 'items' => [
  61. [
  62. 'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
  63. 'url' => $this->getUrlManagerFrontend()->createUrl(['site/index']),
  64. ],
  65. [
  66. 'label' => '<span class="glyphicon glyphicon-user"></span> Mon profil',
  67. 'url' => $this->getUrlManagerFrontend()->createUrl(['user/update']),
  68. ],
  69. [
  70. 'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion',
  71. 'url' => $this->getUrlManagerFrontend()->createUrl(['site/logout']),
  72. ]
  73. ],
  74. 'visible' => !Yii::$app->user->isGuest
  75. ],
  76. [
  77. 'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
  78. 'url' => $this->getUrlManagerFrontend()->createUrl(['site/login']),
  79. 'visible' => \Yii::$app->user->isGuest,
  80. 'active' => $this->getControllerAction() == 'site/login'
  81. ],
  82. [
  83. 'label' => '<span class="glyphicon glyphicon-user"></span> Inscription',
  84. 'url' => $this->getUrlManagerFrontend()->createUrl(['site/signup']),
  85. 'visible' => \Yii::$app->user->isGuest,
  86. 'active' => $this->getControllerAction() == 'site/signup'
  87. ],
  88. ]]);
  89. ?>
  90. </div>
  91. </nav>
  92. </section>