0
0

main.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* @var $this \yii\web\View */
  3. /* @var $content string */
  4. use backend\assets\AppAsset;
  5. use yii\helpers\Html;
  6. use yii\bootstrap\Nav;
  7. use yii\bootstrap\NavBar;
  8. use yii\widgets\Breadcrumbs;
  9. use common\widgets\Alert;
  10. AppAsset::register($this);
  11. ?>
  12. <?php $this->beginPage() ?>
  13. <!DOCTYPE html>
  14. <html lang="<?= Yii::$app->language ?>">
  15. <head>
  16. <meta charset="<?= Yii::$app->charset ?>">
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  18. <meta name="viewport" content="width=device-width, initial-scale=1">
  19. <?= Html::csrfMetaTags() ?>
  20. <title><?= Html::encode($this->title) ?></title>
  21. <?php $this->head() ?>
  22. </head>
  23. <body>
  24. <?php $this->beginBody() ?>
  25. <div class="wrap">
  26. <?php
  27. NavBar::begin([
  28. 'brandLabel' => Yii::$app->name,
  29. 'brandUrl' => Yii::$app->homeUrl,
  30. 'options' => [
  31. 'class' => 'navbar-inverse navbar-fixed-top',
  32. ],
  33. ]);
  34. $menuItems = [
  35. ['label' => 'Home', 'url' => ['/site/index']],
  36. ];
  37. if (Yii::$app->user->isGuest) {
  38. $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
  39. } else {
  40. $menuItems[] = '<li>'
  41. . Html::beginForm(['/site/logout'], 'post')
  42. . Html::submitButton(
  43. 'Logout (' . Yii::$app->user->identity->username . ')',
  44. ['class' => 'btn btn-link logout']
  45. )
  46. . Html::endForm()
  47. . '</li>';
  48. }
  49. echo Nav::widget([
  50. 'options' => ['class' => 'navbar-nav navbar-right'],
  51. 'items' => $menuItems,
  52. ]);
  53. NavBar::end();
  54. ?>
  55. <div class="container">
  56. <?= Breadcrumbs::widget([
  57. 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
  58. ]) ?>
  59. <?= Alert::widget() ?>
  60. <?= $content ?>
  61. </div>
  62. </div>
  63. <footer class="footer">
  64. <div class="container">
  65. <p class="pull-left">&copy; <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p>
  66. <p class="pull-right"><?= Yii::powered() ?></p>
  67. </div>
  68. </footer>
  69. <?php $this->endBody() ?>
  70. </body>
  71. </html>
  72. <?php $this->endPage() ?>