|
|
|
|
|
|
|
|
|
|
|
|
|
|
$userManager = UserManager::getInstance(); |
|
|
$userManager = UserManager::getInstance(); |
|
|
|
|
|
|
|
|
|
|
|
$producer = null; |
|
|
|
|
|
if ($userManager->isCurrentProducer()) { |
|
|
|
|
|
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
?> |
|
|
?> |
|
|
|
|
|
|
|
|
<section class="nav-user-top"> |
|
|
<section class="nav-user-top"> |
|
|
|
|
|
|
|
|
$itemsProducersArray = []; |
|
|
$itemsProducersArray = []; |
|
|
if (count($producersArray)) { |
|
|
if (count($producersArray)) { |
|
|
$itemsProducersArray[] = [ |
|
|
$itemsProducersArray[] = [ |
|
|
'options' => ['class' => 'dropdown-header'], |
|
|
|
|
|
'label' => 'Mes favoris', |
|
|
'label' => 'Mes favoris', |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
foreach($producersArray as $producerItem) { |
|
|
foreach($producersArray as $producerItem) { |
|
|
$itemsProducersArray[] = [ |
|
|
$itemsProducersArray[] = [ |
|
|
'label' => Html::encode($producerItem->name), |
|
|
'label' => Html::encode($producerItem->name), |
|
|
|
|
|
|
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$itemsProducersArray[] = [ |
|
|
|
|
|
'label' => 'Aucun producteur dans vos favoris.', |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$itemsProducersArray[] = [ |
|
|
$itemsProducersArray[] = [ |
|
|
'options' => ['class' => 'divider'], |
|
|
'options' => ['class' => 'divider'], |
|
|
|
|
|
|
|
|
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producers']) |
|
|
'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' => [ |
|
|
'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> |
|
|
</div> |
|
|
</nav> |
|
|
</nav> |