|
|
@@ -8,6 +8,11 @@ use yii\helpers\Html; |
|
|
|
|
|
|
|
$userManager = UserManager::getInstance(); |
|
|
|
|
|
|
|
$producer = null; |
|
|
|
if ($userManager->isCurrentProducer()) { |
|
|
|
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); |
|
|
|
} |
|
|
|
|
|
|
|
?> |
|
|
|
|
|
|
|
<section class="nav-user-top"> |
|
|
@@ -26,10 +31,8 @@ $userManager = UserManager::getInstance(); |
|
|
|
$itemsProducersArray = []; |
|
|
|
if (count($producersArray)) { |
|
|
|
$itemsProducersArray[] = [ |
|
|
|
'options' => ['class' => 'dropdown-header'], |
|
|
|
'label' => 'Mes favoris', |
|
|
|
]; |
|
|
|
|
|
|
|
foreach($producersArray as $producerItem) { |
|
|
|
$itemsProducersArray[] = [ |
|
|
|
'label' => Html::encode($producerItem->name), |
|
|
@@ -37,6 +40,11 @@ $userManager = UserManager::getInstance(); |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
$itemsProducersArray[] = [ |
|
|
|
'label' => 'Aucun producteur dans vos favoris.', |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
$itemsProducersArray[] = [ |
|
|
|
'options' => ['class' => 'divider'], |
|
|
@@ -47,54 +55,81 @@ $userManager = UserManager::getInstance(); |
|
|
|
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producers']) |
|
|
|
]; |
|
|
|
|
|
|
|
echo Nav::widget([ |
|
|
|
'encodeLabels' => false, |
|
|
|
'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'], |
|
|
|
// 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() |
|
|
|
]; |
|
|
|
$itemProducerSpace = [ |
|
|
|
'label' => '<span class="glyphicon glyphicon-grain"></span> <span class="link-text">Espace producteur</span>', |
|
|
|
'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), |
|
|
|
'visible' => $userManager->isCurrentProducer() |
|
|
|
]; |
|
|
|
$itemProducers = [ |
|
|
|
'label' => '<span class="glyphicon glyphicon-star"></span> <span class="link-text">Producteurs</span>', |
|
|
|
'url' => '#', |
|
|
|
'items' => $itemsProducersArray, |
|
|
|
'visible' => !Yii::$app->user->isGuest |
|
|
|
]; |
|
|
|
$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))) : '') . '. </span>', |
|
|
|
'options' => ['id' => 'label1'], |
|
|
|
'url' => '#', |
|
|
|
'items' => [ |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>', |
|
|
|
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']), |
|
|
|
'visible' => $userManager->isCurrentProducer() |
|
|
|
], |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-star"></span> <span class="link-text">Producteurs</span>', |
|
|
|
'url' => '#', |
|
|
|
'items' => $itemsProducersArray, |
|
|
|
'visible' => !Yii::$app->user->isGuest |
|
|
|
], |
|
|
|
[ |
|
|
|
'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>', |
|
|
|
'options' => ['id' => 'label1'], |
|
|
|
'url' => '#', |
|
|
|
'items' => [ |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/index']), |
|
|
|
], |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-user"></span> Mon profil', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['user/update']), |
|
|
|
], |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/logout']), |
|
|
|
] |
|
|
|
], |
|
|
|
'visible' => !Yii::$app->user->isGuest |
|
|
|
'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/index']), |
|
|
|
], |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/login']), |
|
|
|
'visible' => \Yii::$app->user->isGuest, |
|
|
|
'active' => $this->getControllerAction() == 'site/login' |
|
|
|
'label' => '<span class="glyphicon glyphicon-user"></span> Mon profil', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['user/update']), |
|
|
|
], |
|
|
|
[ |
|
|
|
'label' => '<span class="glyphicon glyphicon-user"></span> Inscription', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/signup']), |
|
|
|
'visible' => \Yii::$app->user->isGuest, |
|
|
|
'active' => $this->getControllerAction() == 'site/signup' |
|
|
|
], |
|
|
|
]]); |
|
|
|
'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/logout']), |
|
|
|
] |
|
|
|
], |
|
|
|
'visible' => !Yii::$app->user->isGuest |
|
|
|
]; |
|
|
|
$itemConnexion = [ |
|
|
|
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/login']), |
|
|
|
'visible' => \Yii::$app->user->isGuest, |
|
|
|
'active' => $this->getControllerAction() == 'site/login' |
|
|
|
]; |
|
|
|
$itemSignup = [ |
|
|
|
'label' => '<span class="glyphicon glyphicon-user"></span> Inscription', |
|
|
|
'url' => $this->getUrlManagerFrontend()->createUrl(['site/signup']), |
|
|
|
'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> |