-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fe5766
commit 16ef9b3
Showing
2 changed files
with
90 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Dektrium project. | ||
* | ||
* (c) Dektrium project <http://github.com/dektrium> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use yii\helpers\Html; | ||
use yii\widgets\Menu; | ||
|
||
/** | ||
* @var dektrium\user\models\User $user | ||
*/ | ||
|
||
$user = Yii::$app->user->identity; | ||
$networksVisible = count(Yii::$app->authClientCollection->clients) > 0; | ||
?> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"> | ||
<?= Html::img($user->profile->getAvatarUrl(24), [ | ||
'class' => 'img-rounded', | ||
'alt' => $user->username, | ||
]) ?> | ||
<?= $user->username ?> | ||
</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<?= Menu::widget([ | ||
'options' => [ | ||
'class' => 'nav nav-pills nav-stacked', | ||
], | ||
'items' => [ | ||
['label' => Yii::t('user', 'Profile'), 'url' => ['/user/settings/profile']], | ||
['label' => Yii::t('user', 'Account'), 'url' => ['/user/settings/account']], | ||
[ | ||
'label' => Yii::t('user', 'Networks'), | ||
'url' => ['/user/settings/networks'], | ||
'visible' => $networksVisible | ||
], | ||
], | ||
]) ?> | ||
</div> | ||
</div> | ||
<?php | ||
|
||
/* | ||
* This file is part of the Dektrium project. | ||
* | ||
* (c) Dektrium project <http://github.com/dektrium> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use yii\helpers\Html; | ||
use dektrium\user\widgets\UserMenu; | ||
|
||
/** | ||
* @var dektrium\user\models\User $user | ||
*/ | ||
|
||
$user = Yii::$app->user->identity; | ||
?> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"> | ||
<?= Html::img($user->profile->getAvatarUrl(24), [ | ||
'class' => 'img-rounded', | ||
'alt' => $user->username, | ||
]) ?> | ||
<?= $user->username ?> | ||
</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<?= UserMenu::widget() ?> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Dektrium project. | ||
* | ||
* (c) Dektrium project <http://github.com/dektrium> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace dektrium\user\widgets; | ||
|
||
use yii\widgets\Menu; | ||
use Yii; | ||
use yii\base\Widget; | ||
|
||
/** | ||
* User menu widget. | ||
*/ | ||
class UserMenu extends Widget | ||
{ | ||
|
||
/** @array \dektrium\user\models\RegistrationForm */ | ||
public $items; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
$networksVisible = count(Yii::$app->authClientCollection->clients) > 0; | ||
|
||
$this->items = [ | ||
['label' => Yii::t('user', 'Profile'), 'url' => ['/user/settings/profile']], | ||
['label' => Yii::t('user', 'Account'), 'url' => ['/user/settings/account']], | ||
[ | ||
'label' => Yii::t('user', 'Networks'), | ||
'url' => ['/user/settings/networks'], | ||
'visible' => $networksVisible | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function run() | ||
{ | ||
return Menu::widget([ | ||
'options' => [ | ||
'class' => 'nav nav-pills nav-stacked', | ||
], | ||
'items' => $this->items, | ||
]); | ||
} | ||
} |