|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
-
- use common\helpers\GlobalParam;
- use common\logic\Producer\Producer\Model\Producer;
- use common\logic\User\User\Wrapper\UserManager;
- use yii\bootstrap\Nav;
- use yii\helpers\Html;
-
- $userManager = UserManager::getInstance();
-
- $producer = null;
- if ($userManager->isCurrentProducer()) {
- $producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]);
- }
-
- ?>
-
- <div class="nav-user-top">
- <nav class="navbar navbar-default">
- <div class="container">
-
- <?php
-
- $producersArray = Producer::find()
- ->joinWith(['userProducer user_producer'])
- ->where([
- 'user_producer.id_user' => GlobalParam::getCurrentUserId(),
- 'user_producer.bookmark' => 1,
- ])
- ->all();
-
- $itemsProducersArray = [];
- if (count($producersArray)) {
- $itemsProducersArray[] = [
- 'label' => 'Mes favoris',
- ];
- foreach($producersArray as $producerItem) {
- $itemsProducersArray[] = [
- 'label' => Html::encode($producerItem->name),
- 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producerItem->slug]),
- ];
- }
- }
- else {
- $itemsProducersArray[] = [
- 'label' => 'Aucun producteur dans vos favoris.',
- ];
- }
-
- $itemsProducersArray[] = [
- 'options' => ['class' => 'divider'],
- 'label' => ''
- ];
- $itemsProducersArray[] = [
- 'label' => '<span class="glyphicon glyphicon-search"></span> Rechercher un producteur',
- 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producers'])
- ];
-
- // Items du menu
- $itemAdministration = [
- 'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>',
- 'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']),
- 'visible' => $userManager->isCurrentProducer(),
- 'linkOptions' => ['class' => 'btn btn-default navbar-btn']
- ];
- $itemProducerSpace = [
- //'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">'.Html::encode($producer->name).'</span>',
- 'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">Mon espace producteur</span>',
- 'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']),
- 'visible' => $userManager->isCurrentProducer(),
- 'linkOptions' => ['class' => 'btn btn-default navbar-btn']
- ];
- $itemProducers = [
- 'label' => '<span class="glyphicon glyphicon-star"></span> <span class="link-text">Mes producteurs</span>',
- 'url' => '#',
- 'items' => $itemsProducersArray,
- 'linkOptions' => ['class' => 'btn btn-default navbar-btn'],
- 'visible' => !Yii::$app->user->isGuest
- ];
-
- $itemsUserArray = [];
- if($context == 'producer') {
- $itemsUserArray = [
- [
- 'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
- 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/index']),
- ]
- ];
- }
-
- $itemsUserArray[] = [
- 'label' => '<span class="glyphicon glyphicon-user"></span> Mon profil',
- 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['user/update']),
- ];
- $itemsUserArray[] = [
- 'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion',
- 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/logout']),
- ];
-
- $itemUser = [
- '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)).'.') : '') .
- //($producer ? ' ('.Html::encode($producer->name).')' : '').
- '</span>',
- 'options' => ['id' => 'label1'],
- 'url' => '#',
- 'linkOptions' => ['class' => 'btn btn-default navbar-btn'],
- 'items' => $itemsUserArray,
- 'visible' => !Yii::$app->user->isGuest
- ];
- $itemConnexion = [
- 'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
- 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/login']),
- 'linkOptions' => ['class' => 'btn btn-default navbar-btn'],
- 'visible' => \Yii::$app->user->isGuest,
- 'active' => $this->getControllerAction() == 'site/login'
- ];
- $itemSignup = [
- 'label' => '<span class="glyphicon glyphicon-user"></span> Inscription',
- 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/signup']),
- 'linkOptions' => ['class' => 'btn btn-default navbar-btn'],
- 'visible' => \Yii::$app->user->isGuest,
- 'active' => $this->getControllerAction() == 'site/signup'
- ];
-
- if($context == 'frontend') {
- $itemsMenu = [
- $itemAdministration,
- $itemProducerSpace,
- $itemProducers,
- $itemUser,
- $itemConnexion,
- $itemSignup
- ];
- }
- elseif($context == 'producer') {
- $itemsMenu = [
- $itemAdministration,
- $itemProducers,
- $itemUser,
- $itemConnexion,
- $itemSignup
- ];
- }
-
- echo Nav::widget([
- 'encodeLabels' => false,
- 'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'],
- 'items' => $itemsMenu
- ]);
- ?>
- </div>
- </nav>
- </div>
|