Views match Yii2 View Code Style

close #18
This commit is contained in:
Alex Solomaha 2015-07-09 12:47:20 +03:00 committed by Carsten Brandt
parent 038192fe50
commit 72c2d75419
6 changed files with 108 additions and 88 deletions

View File

@ -1,13 +1,14 @@
<?php <?php
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
use yii\bootstrap\NavBar; use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
use app\assets\AppAsset; use app\assets\AppAsset;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this); AppAsset::register($this);
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
@ -21,47 +22,50 @@ AppAsset::register($this);
<?php $this->head() ?> <?php $this->head() ?>
</head> </head>
<body> <body>
<?php $this->beginBody() ?> <?php $this->beginBody() ?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] :
['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']],
],
]);
NavBar::end();
?>
<div class="container"> <div class="wrap">
<?= Breadcrumbs::widget([ <?php
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], NavBar::begin([
]) ?> 'brandLabel' => 'My Company',
<?= $content ?> 'brandUrl' => Yii::$app->homeUrl,
</div> 'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] :
[
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
],
],
]);
NavBar::end();
?>
<div class="container">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= $content ?>
</div> </div>
</div>
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
<p class="pull-left">&copy; My Company <?= date('Y') ?></p> <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div> <p class="pull-right"><?= Yii::powered() ?></p>
</footer> </div>
</footer>
<?php $this->endBody() ?> <?php $this->endBody() ?>
</body> </body>

View File

@ -1,7 +1,9 @@
<?php <?php
use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
use yii\helpers\Html;
$this->title = 'About'; $this->title = 'About';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>

View File

@ -1,12 +1,13 @@
<?php <?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */ /* @var $form yii\bootstrap\ActiveForm */
/* @var $model app\models\ContactForm */ /* @var $model app\models\ContactForm */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
$this->title = 'Contact'; $this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
@ -15,43 +16,53 @@ $this->params['breadcrumbs'][] = $this->title;
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?> <?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
<div class="alert alert-success"> <div class="alert alert-success">
Thank you for contacting us. We will respond to you as soon as possible. Thank you for contacting us. We will respond to you as soon as possible.
</div> </div>
<p> <p>
Note that if you turn on the Yii debugger, you should be able Note that if you turn on the Yii debugger, you should be able
to view the mail message on the mail panel of the debugger. to view the mail message on the mail panel of the debugger.
<?php if (Yii::$app->mailer->useFileTransport): ?> <?php if (Yii::$app->mailer->useFileTransport): ?>
Because the application is in development mode, the email is not sent but saved as Because the application is in development mode, the email is not sent but saved as
a file under <code><?= Yii::getAlias(Yii::$app->mailer->fileTransportPath) ?></code>. a file under <code><?= Yii::getAlias(Yii::$app->mailer->fileTransportPath) ?></code>.
Please configure the <code>useFileTransport</code> property of the <code>mail</code> Please configure the <code>useFileTransport</code> property of the <code>mail</code>
application component to be false to enable email sending. application component to be false to enable email sending.
<?php endif; ?> <?php endif; ?>
</p> </p>
<?php else: ?> <?php else: ?>
<p> <p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. If you have business inquiries or other questions, please fill out the following form to contact us.
</p> Thank you.
</p>
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
<?= $form->field($model, 'name') ?> <?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'subject') ?> <?= $form->field($model, 'name') ?>
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ <?= $form->field($model, 'email') ?>
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]) ?> <?= $form->field($model, 'subject') ?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?> <?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
</div>
<?php ActiveForm::end(); ?> <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
]) ?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
</div>
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@ -1,12 +1,12 @@
<?php <?php
use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $name string */ /* @var $name string */
/* @var $message string */ /* @var $message string */
/* @var $exception Exception */ /* @var $exception Exception */
use yii\helpers\Html;
$this->title = $name; $this->title = $name;
?> ?>
<div class="site-error"> <div class="site-error">

View File

@ -1,5 +1,7 @@
<?php <?php
/* @var $this yii\web\View */ /* @var $this yii\web\View */
$this->title = 'My Yii Application'; $this->title = 'My Yii Application';
?> ?>
<div class="site-index"> <div class="site-index">

View File

@ -1,11 +1,12 @@
<?php <?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */ /* @var $form yii\bootstrap\ActiveForm */
/* @var $model app\models\LoginForm */ /* @var $model app\models\LoginForm */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
$this->title = 'Login'; $this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
@ -23,19 +24,19 @@ $this->params['breadcrumbs'][] = $this->title;
], ],
]); ?> ]); ?>
<?= $form->field($model, 'username') ?> <?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password')->passwordInput() ?> <?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox([ <?= $form->field($model, 'rememberMe')->checkbox([
'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input} {label}</div>\n<div class=\"col-lg-8\">{error}</div>", 'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input} {label}</div>\n<div class=\"col-lg-8\">{error}</div>",
]) ?> ]) ?>
<div class="form-group"> <div class="form-group">
<div class="col-lg-offset-1 col-lg-11"> <div class="col-lg-offset-1 col-lg-11">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> <?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
</div>
</div> </div>
</div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>