Issues (75)

resources/views/layouts/main.php (1 issue)

Labels
Severity
1
<?php
2
3
/* @var $this \yii\web\View */
4
/* @var $content string */
5
6
use App\Http\Asset\AppAsset;
7
use App\Http\Widget\Alert;
8
use yii\helpers\Html;
9
use yii\bootstrap\Nav;
10
use yii\bootstrap\NavBar;
11
use yii\widgets\Breadcrumbs;
12
13
AppAsset::register($this);
14
?>
15
<?php $this->beginPage() ?>
16
<!DOCTYPE html>
17
<html lang="<?= Yii::$app->language ?>">
18
<head>
19
    <meta charset="<?= Yii::$app->charset ?>">
20
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
21
    <meta name="viewport" content="width=device-width, initial-scale=1">
22
    <?php $this->registerCsrfMetaTags() ?>
23
    <title><?= Html::encode($this->title . ' - ' . Yii::$app->name) ?></title>
24
    <?php $this->head() ?>
25
</head>
26
<body>
27
<?php $this->beginBody() ?>
28
29
<div class="wrap">
30
    <?php
31
    NavBar::begin([
32
        'brandLabel' => Yii::$app->name,
33
        'brandUrl' => Yii::$app->homeUrl,
34
        'options' => [
35
            'class' => 'navbar-inverse navbar-fixed-top',
36
        ],
37
    ]);
38
    $menuItems = [
39
        ['label' => Yii::t('app', 'Home'), 'url' => ['/site/index']],
40
        ['label' => Yii::t('app', 'Article'), 'url' => ['/article/index']],
41
        ['label' => Yii::t('app', 'About Us'), 'url' => ['/site/about']],
42
        ['label' => Yii::t('app', 'Contact Us'), 'url' => ['/site/contact']],
43
        ['label' => Yii::t('app', 'Console'), 'url' => Yii::$app->params['backend.url'], 'linkOptions' => ['target' => '_blank']],
44
    ];
45
    if (Yii::$app->user->isGuest) {
46
        $menuItems[] = ['label' => Yii::t('app', 'Login'), 'url' => ['/site/login']];
47
        $menuItems[] = ['label' => Yii::t('app', 'Sign Up'), 'url' => ['/site/signup']];
48
    } else {
49
        $menuItems[] = [
50
            'label' => Yii::$app->user->identity->name,
0 ignored issues
show
Accessing name on the interface yii\web\IdentityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
51
            'items' => [
52
                ['label' => Yii::t('app', 'Setting'), 'url' => '#'],
53
                '<li role="separator" class="divider"></li>',
54
                ['label' => Yii::t('app', 'Logout'), 'url' => 'javascript: $("#logout-form").submit();'],
55
            ],
56
        ];
57
    }
58
    echo Nav::widget([
59
        'options' => ['class' => 'navbar-nav navbar-right'],
60
        'items' => $menuItems,
61
    ]);
62
    NavBar::end();
63
    ?>
64
65
    <div class="container">
66
        <?= Breadcrumbs::widget([
67
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
68
        ]) ?>
69
        <?= Alert::widget() ?>
70
        <?= $content ?>
71
    </div>
72
</div>
73
74
<footer class="footer">
75
    <div class="container">
76
        <p class="pull-left"><?= Yii::$app->params['site.since'] . ' - ' . date('Y') ?> &copy; <?= Html::encode(Yii::$app->name) ?></p>
77
78
        <p class="pull-right">
79
            <?= \Yii::t('yii', 'Powered by {yii}', [
80
                'yii' => Html::a('Yii2 App Template', 'https://github.com/razonyang/yii2-app-template', ['target' => '_blank']),
81
            ]) ?>
82
        </p>
83
    </div>
84
</footer>
85
86
<?php if (!Yii::$app->user->isGuest): ?>
87
<?= Html::beginForm(['/logout'], 'post', ['id' => 'logout-form']) ?>
88
<?= Html::endForm() ?>
89
<?php endif; ?>
90
91
<?php $this->endBody() ?>
92
</body>
93
</html>
94
<?php $this->endPage() ?>
95