Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

nav_user_top.php 8.4KB

8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
8 månader sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. use common\helpers\GlobalParam;
  3. use domain\Producer\Producer\Producer;
  4. use domain\Producer\Producer\ProducerModule;
  5. use domain\User\User\UserModule;
  6. use yii\bootstrap5\Nav;
  7. use yii\helpers\Html;
  8. $userModule = UserModule::getInstance();
  9. $producerModule = ProducerModule::getInstance();
  10. $userCurrent = GlobalParam::getCurrentUser();
  11. $isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);
  12. $producer = null;
  13. if ($isUserCurrentGrantedAsProducer && $userCurrent->id_producer) {
  14. $producer = $producerModule->getRepository()->findOneProducerById($userCurrent->id_producer);
  15. }
  16. ?>
  17. <div class="container container-nav-user-top">
  18. <div class="nav-user-top">
  19. <nav class="navbar navbar-expand-lg">
  20. <div class="container-fluid">
  21. <?php
  22. $producersArray = Producer::find()
  23. ->joinWith(['userProducer user_producer'])
  24. ->where([
  25. 'user_producer.id_user' => GlobalParam::getCurrentUserId(),
  26. 'user_producer.bookmark' => 1,
  27. ])
  28. ->all();
  29. $itemsProducersArray = [];
  30. if (count($producersArray)) {
  31. /*$itemsProducersArray[] = [
  32. 'label' => 'Mes favoris',
  33. ];*/
  34. foreach ($producersArray as $producerItem) {
  35. $itemsProducersArray[] = [
  36. 'label' => Html::encode($producerItem->name),
  37. 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producerItem->slug]),
  38. ];
  39. }
  40. } else {
  41. $itemsProducersArray[] = [
  42. 'label' => 'Aucun producteur dans votre liste.',
  43. ];
  44. }
  45. $itemsProducersArray[] = '<hr class="dropdown-divider">';
  46. $itemsProducersArray[] = [
  47. 'label' => '<i class="bi bi-search"></i> Rechercher un producteur',
  48. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index'])
  49. ];
  50. // Items du menu
  51. $itemHome = [
  52. 'label' => '<i class="bi bi-house-door"></i> <span class="link-text">Accueil</span>',
  53. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']),
  54. 'linkOptions' => ['class' => '']
  55. ];
  56. $itemAdministration = [
  57. 'label' => '<i class="bi bi-gear"></i> <span class="link-text">Administration</span>',
  58. 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']),
  59. 'visible' => $isUserCurrentGrantedAsProducer,
  60. 'linkOptions' => ['class' => '']
  61. ];
  62. $itemProducerSpace = [
  63. 'label' => '<i class="bi bi-shop"></i> <span class="link-text">Ma boutique</span>',
  64. 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']),
  65. 'visible' => $isUserCurrentGrantedAsProducer,
  66. 'linkOptions' => ['class' => '']
  67. ];
  68. $itemProducers = [
  69. 'label' => '<i class="bi bi-bookmark-heart"></i> <span class="link-text">Producteurs</span>',
  70. 'url' => '#',
  71. 'items' => $itemsProducersArray,
  72. 'options' => ['class' => 'nav-item-producers'],
  73. 'linkOptions' => ['class' => ''],
  74. 'visible' => !Yii::$app->user->isGuest
  75. ];
  76. $itemsUserArray = [];
  77. if ($context == 'producer') {
  78. $itemsUserArray = [
  79. /*[
  80. 'label' => '<span class="glyphicon glyphicon-home"></span> Retour à l\'accueil',
  81. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']),
  82. ]*/
  83. ];
  84. }
  85. $itemsUserArray[] = [
  86. 'label' => '<i class="bi bi-person"></i> Mon profil',
  87. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['user/update']),
  88. ];
  89. $itemsUserArray[] = [
  90. 'label' => '<i class="bi bi-box-arrow-left"></i> Déconnexion',
  91. 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/logout']),
  92. ];
  93. $itemUser = [
  94. 'label' => '<i class="bi bi-person"></i> <span class="link-text">' .
  95. ((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1)) . '.') : '') .
  96. '</span>',
  97. 'options' => ['id' => 'label1'],
  98. 'url' => '#',
  99. 'linkOptions' => ['class' => ''],
  100. 'items' => $itemsUserArray,
  101. 'visible' => !Yii::$app->user->isGuest
  102. ];
  103. $itemConnexion = [
  104. 'label' => '<i class="bi bi-box-arrow-in-right"></i> Connexion',
  105. 'url' => ($context == 'producer')
  106. ? $this->getUrlManagerFrontend()->createAbsoluteUrl([
  107. 'site/producer',
  108. 'id' => $this->context->getProducerCurrent()->id,
  109. 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $this->context->getProducerCurrent()->slug])
  110. ])
  111. : $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/login']),
  112. 'linkOptions' => ['class' => ''],
  113. 'visible' => \Yii::$app->user->isGuest,
  114. 'active' => $this->getControllerAction() == 'site/login'
  115. ];
  116. $itemSignup = [
  117. 'label' => '<i class="bi bi-person-plus"></i> Inscription',
  118. 'url' => ($context == 'producer')
  119. ? $this->getUrlManagerFrontend()->createAbsoluteUrl([
  120. 'site/producer',
  121. 'id' => $this->context->getProducerCurrent()->id,
  122. 'return_url' => \Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $this->context->getProducerCurrent()->slug])
  123. ])
  124. : $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/signup']),
  125. 'linkOptions' => ['class' => ''],
  126. 'visible' => \Yii::$app->user->isGuest,
  127. 'active' => $this->getControllerAction() == 'site/signup'
  128. ];
  129. if ($context == 'frontend') {
  130. $itemsMenu = [
  131. $itemAdministration,
  132. $itemProducerSpace,
  133. $itemProducers,
  134. $itemUser,
  135. $itemConnexion,
  136. $itemSignup
  137. ];
  138. } elseif ($context == 'producer') {
  139. $itemsMenu = [
  140. $itemHome,
  141. $itemAdministration,
  142. $itemProducers,
  143. $itemUser,
  144. $itemConnexion,
  145. $itemSignup
  146. ];
  147. }
  148. echo Nav::widget([
  149. 'encodeLabels' => false,
  150. 'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'],
  151. 'items' => $itemsMenu
  152. ]);
  153. ?>
  154. </div>
  155. </nav>
  156. </div>
  157. </div>