Commit dfb6e1f4 by Yakir Sitbon

Convert to short syntax [2].

parent 5391b209
...@@ -10,32 +10,32 @@ class SiteController extends Controller ...@@ -10,32 +10,32 @@ class SiteController extends Controller
{ {
public function behaviors() public function behaviors()
{ {
return array( return [
'access' => array( 'access' => [
'class' => \yii\web\AccessControl::className(), 'class' => \yii\web\AccessControl::className(),
'rules' => array( 'rules' => [
array( [
'actions' => array('login'), 'actions' => ['login'],
'allow' => true, 'allow' => true,
'roles' => array('?'), 'roles' => ['?'],
), ],
array( [
'actions' => array('logout', 'index'), 'actions' => ['logout', 'index'],
'allow' => true, 'allow' => true,
'roles' => array('@'), 'roles' => ['@'],
), ],
), ],
), ],
); ];
} }
public function actions() public function actions()
{ {
return array( return [
'error' => array( 'error' => [
'class' => 'yii\web\ErrorAction', 'class' => 'yii\web\ErrorAction',
), ],
); ];
} }
public function actionIndex() public function actionIndex()
...@@ -49,9 +49,9 @@ class SiteController extends Controller ...@@ -49,9 +49,9 @@ class SiteController extends Controller
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goHome();
} else { } else {
return $this->render('login', array( return $this->render('login', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
......
...@@ -22,32 +22,32 @@ AppAsset::register($this); ...@@ -22,32 +22,32 @@ AppAsset::register($this);
<body> <body>
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<?php <?php
NavBar::begin(array( NavBar::begin([
'brandLabel' => 'My Company', 'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl, 'brandUrl' => Yii::$app->homeUrl,
'options' => array( 'options' => [
'class' => 'navbar-inverse navbar-fixed-top', 'class' => 'navbar-inverse navbar-fixed-top',
), ],
)); ]);
$menuItems = array( $menuItems = [
array('label' => 'Home', 'url' => array('/site/index')), ['label' => 'Home', 'url' => ['/site/index']],
); ];
if (Yii::$app->user->isGuest) { if (Yii::$app->user->isGuest) {
$menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else { } else {
$menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => ['/site/logout']];
} }
echo Nav::widget(array( echo Nav::widget([
'options' => array('class' => 'navbar-nav pull-right'), 'options' => ['class' => 'navbar-nav pull-right'],
'items' => $menuItems, 'items' => $menuItems,
)); ]);
NavBar::end(); NavBar::end();
?> ?>
<div class="container"> <div class="container">
<?php echo Breadcrumbs::widget(array( <?php echo Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
)); ?> ]); ?>
<?php echo $content; ?> <?php echo $content; ?>
</div> </div>
......
...@@ -17,12 +17,12 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -17,12 +17,12 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'login-form')); ?> <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'username'); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Login', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -4,19 +4,19 @@ Yii::setAlias('common', __DIR__ . '/../'); ...@@ -4,19 +4,19 @@ Yii::setAlias('common', __DIR__ . '/../');
Yii::setAlias('frontend', __DIR__ . '/../../frontend'); Yii::setAlias('frontend', __DIR__ . '/../../frontend');
Yii::setAlias('backend', __DIR__ . '/../../backend'); Yii::setAlias('backend', __DIR__ . '/../../backend');
return array( return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com', 'supportEmail' => 'support@example.com',
'components.cache' => array( 'components.cache' => [
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',
), ],
'components.db' => array( 'components.db' => [
'class' => 'yii\db\Connection', 'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced', 'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root', 'username' => 'root',
'password' => '', 'password' => '',
'charset' => 'utf8', 'charset' => 'utf8',
), ],
); ];
...@@ -19,14 +19,14 @@ class LoginForm extends Model ...@@ -19,14 +19,14 @@ class LoginForm extends Model
*/ */
public function rules() public function rules()
{ {
return array( return [
// username and password are both required // username and password are both required
array('username, password', 'required'), ['username, password', 'required'],
// password is validated by validatePassword() // password is validated by validatePassword()
array('password', 'validatePassword'), ['password', 'validatePassword'],
// rememberMe must be a boolean value // rememberMe must be a boolean value
array('rememberMe', 'boolean'), ['rememberMe', 'boolean'],
); ];
} }
/** /**
......
...@@ -34,15 +34,15 @@ class User extends ActiveRecord implements IdentityInterface ...@@ -34,15 +34,15 @@ class User extends ActiveRecord implements IdentityInterface
public function behaviors() public function behaviors()
{ {
return array( return [
'timestamp' => array( 'timestamp' => [
'class' => 'yii\behaviors\AutoTimestamp', 'class' => 'yii\behaviors\AutoTimestamp',
'attributes' => array( 'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => array('create_time', 'update_time'), ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time', ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
), ],
), ],
); ];
} }
/** /**
...@@ -64,7 +64,7 @@ class User extends ActiveRecord implements IdentityInterface ...@@ -64,7 +64,7 @@ class User extends ActiveRecord implements IdentityInterface
*/ */
public static function findByUsername($username) public static function findByUsername($username)
{ {
return static::find(array('username' => $username, 'status' => static::STATUS_ACTIVE)); return static::find(['username' => $username, 'status' => static::STATUS_ACTIVE]);
} }
/** /**
...@@ -103,29 +103,29 @@ class User extends ActiveRecord implements IdentityInterface ...@@ -103,29 +103,29 @@ class User extends ActiveRecord implements IdentityInterface
public function rules() public function rules()
{ {
return array( return [
array('username', 'filter', 'filter' => 'trim'), ['username', 'filter', 'filter' => 'trim'],
array('username', 'required'), ['username', 'required'],
array('username', 'string', 'min' => 2, 'max' => 255), ['username', 'string', 'min' => 2, 'max' => 255],
array('email', 'filter', 'filter' => 'trim'), ['email', 'filter', 'filter' => 'trim'],
array('email', 'required'), ['email', 'required'],
array('email', 'email'), ['email', 'email'],
array('email', 'unique', 'message' => 'This email address has already been taken.', 'on' => 'signup'), ['email', 'unique', 'message' => 'This email address has already been taken.', 'on' => 'signup'],
array('email', 'exist', 'message' => 'There is no user with such email.', 'on' => 'requestPasswordResetToken'), ['email', 'exist', 'message' => 'There is no user with such email.', 'on' => 'requestPasswordResetToken'],
array('password', 'required'), ['password', 'required'],
array('password', 'string', 'min' => 6), ['password', 'string', 'min' => 6],
); ];
} }
public function scenarios() public function scenarios()
{ {
return array( return [
'signup' => array('username', 'email', 'password'), 'signup' => ['username', 'email', 'password'],
'resetPassword' => array('password'), 'resetPassword' => ['password'],
'requestPasswordResetToken' => array('email'), 'requestPasswordResetToken' => ['email'],
); ];
} }
public function beforeSave($insert) public function beforeSave($insert)
......
...@@ -8,24 +8,24 @@ $params = array_merge( ...@@ -8,24 +8,24 @@ $params = array_merge(
require(__DIR__ . '/params-local.php') require(__DIR__ . '/params-local.php')
); );
return array( return [
'id' => 'app-console', 'id' => 'app-console',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'controllerNamespace' => 'console\controllers', 'controllerNamespace' => 'console\controllers',
'modules' => array( 'modules' => [
), ],
'components' => array( 'components' => [
'db' => $params['components.db'], 'db' => $params['components.db'],
'cache' => $params['components.cache'], 'cache' => $params['components.cache'],
'log' => array( 'log' => [
'targets' => array( 'targets' => [
array( [
'class' => 'yii\log\FileTarget', 'class' => 'yii\log\FileTarget',
'levels' => array('error', 'warning'), 'levels' => ['error', 'warning'],
), ],
), ],
), ],
), ],
'params' => $params, 'params' => $params,
); ];
<?php <?php
return array( return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
); ];
<?php <?php
return array( return [
'preload' => array( 'preload' => [
//'debug', //'debug',
), ],
'modules' => array( 'modules' => [
// 'debug' => array( // 'debug' => array(
// 'class' => 'yii\debug\Module', // 'class' => 'yii\debug\Module',
// ), // ),
), ],
); ];
<?php <?php
return array( return [
'preload' => array( 'preload' => [
//'debug', //'debug',
), ],
'modules' => array( 'modules' => [
// 'debug' => array( // 'debug' => array(
// 'class' => 'yii\debug\Module', // 'class' => 'yii\debug\Module',
// ), // ),
), ],
); ];
...@@ -16,23 +16,23 @@ ...@@ -16,23 +16,23 @@
* ); * );
* ``` * ```
*/ */
return array( return [
'Development' => array( 'Development' => [
'path' => 'dev', 'path' => 'dev',
'writable' => array( 'writable' => [
// handled by composer.json already // handled by composer.json already
), ],
'executable' => array( 'executable' => [
'yii', 'yii',
), ],
), ],
'Production' => array( 'Production' => [
'path' => 'prod', 'path' => 'prod',
'writable' => array( 'writable' => [
// handled by composer.json already // handled by composer.json already
), ],
'executable' => array( 'executable' => [
'yii', 'yii',
), ],
), ],
); ];
...@@ -17,13 +17,13 @@ class AppAsset extends AssetBundle ...@@ -17,13 +17,13 @@ class AppAsset extends AssetBundle
{ {
public $basePath = '@webroot'; public $basePath = '@webroot';
public $baseUrl = '@web'; public $baseUrl = '@web';
public $css = array( public $css = [
'css/site.css', 'css/site.css',
); ];
public $js = array( public $js = [
); ];
public $depends = array( public $depends = [
'yii\web\YiiAsset', 'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset', 'yii\bootstrap\BootstrapAsset',
); ];
} }
...@@ -8,35 +8,35 @@ $params = array_merge( ...@@ -8,35 +8,35 @@ $params = array_merge(
require(__DIR__ . '/params-local.php') require(__DIR__ . '/params-local.php')
); );
return array( return [
'id' => 'app-frontend', 'id' => 'app-frontend',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'controllerNamespace' => 'frontend\controllers', 'controllerNamespace' => 'frontend\controllers',
'modules' => array( 'modules' => [
'gii' => 'yii\gii\Module' 'gii' => 'yii\gii\Module'
), ],
'components' => array( 'components' => [
'request' => array( 'request' => [
'enableCsrfValidation' => true, 'enableCsrfValidation' => true,
), ],
'db' => $params['components.db'], 'db' => $params['components.db'],
'cache' => $params['components.cache'], 'cache' => $params['components.cache'],
'user' => array( 'user' => [
'identityClass' => 'common\models\User', 'identityClass' => 'common\models\User',
), ],
'log' => array( 'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0, 'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => array( 'targets' => [
array( [
'class' => 'yii\log\FileTarget', 'class' => 'yii\log\FileTarget',
'levels' => array('error', 'warning'), 'levels' => ['error', 'warning'],
), ],
), ],
), ],
'errorHandler' => array( 'errorHandler' => [
'errorAction' => 'site/error', 'errorAction' => 'site/error',
), ],
), ],
'params' => $params, 'params' => $params,
); ];
<?php <?php
return array( return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
); ];
...@@ -14,37 +14,37 @@ class SiteController extends Controller ...@@ -14,37 +14,37 @@ class SiteController extends Controller
{ {
public function behaviors() public function behaviors()
{ {
return array( return [
'access' => array( 'access' => [
'class' => \yii\web\AccessControl::className(), 'class' => \yii\web\AccessControl::className(),
'only' => array('login', 'logout', 'signup'), 'only' => ['login', 'logout', 'signup'],
'rules' => array( 'rules' => [
array( [
'actions' => array('login', 'signup'), 'actions' => ['login', 'signup'],
'allow' => true, 'allow' => true,
'roles' => array('?'), 'roles' => ['?'],
), ],
array( [
'actions' => array('logout'), 'actions' => ['logout'],
'allow' => true, 'allow' => true,
'roles' => array('@'), 'roles' => ['@'],
), ],
), ],
), ],
); ];
} }
public function actions() public function actions()
{ {
return array( return [
'error' => array( 'error' => [
'class' => 'yii\web\ErrorAction', 'class' => 'yii\web\ErrorAction',
), ],
'captcha' => array( 'captcha' => [
'class' => 'yii\captcha\CaptchaAction', 'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
), ],
); ];
} }
public function actionIndex() public function actionIndex()
...@@ -58,9 +58,9 @@ class SiteController extends Controller ...@@ -58,9 +58,9 @@ class SiteController extends Controller
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goHome();
} else { } else {
return $this->render('login', array( return $this->render('login', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
...@@ -77,9 +77,9 @@ class SiteController extends Controller ...@@ -77,9 +77,9 @@ class SiteController extends Controller
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
return $this->refresh(); return $this->refresh();
} else { } else {
return $this->render('contact', array( return $this->render('contact', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
...@@ -98,9 +98,9 @@ class SiteController extends Controller ...@@ -98,9 +98,9 @@ class SiteController extends Controller
} }
} }
return $this->render('signup', array( return $this->render('signup', [
'model' => $model, 'model' => $model,
)); ]);
} }
public function actionRequestPasswordReset() public function actionRequestPasswordReset()
...@@ -115,17 +115,17 @@ class SiteController extends Controller ...@@ -115,17 +115,17 @@ class SiteController extends Controller
Yii::$app->getSession()->setFlash('error', 'There was an error sending email.'); Yii::$app->getSession()->setFlash('error', 'There was an error sending email.');
} }
} }
return $this->render('requestPasswordResetToken', array( return $this->render('requestPasswordResetToken', [
'model' => $model, 'model' => $model,
)); ]);
} }
public function actionResetPassword($token) public function actionResetPassword($token)
{ {
$model = User::find(array( $model = User::find([
'password_reset_token' => $token, 'password_reset_token' => $token,
'status' => User::STATUS_ACTIVE, 'status' => User::STATUS_ACTIVE,
)); ]);
if (!$model) { if (!$model) {
throw new HttpException(400, 'Wrong password reset token.'); throw new HttpException(400, 'Wrong password reset token.');
...@@ -137,17 +137,17 @@ class SiteController extends Controller ...@@ -137,17 +137,17 @@ class SiteController extends Controller
return $this->goHome(); return $this->goHome();
} }
return $this->render('resetPassword', array( return $this->render('resetPassword', [
'model' => $model, 'model' => $model,
)); ]);
} }
private function sendPasswordResetEmail($email) private function sendPasswordResetEmail($email)
{ {
$user = User::find(array( $user = User::find([
'status' => User::STATUS_ACTIVE, 'status' => User::STATUS_ACTIVE,
'email' => $email, 'email' => $email,
)); ]);
if (!$user) { if (!$user) {
return false; return false;
...@@ -158,9 +158,9 @@ class SiteController extends Controller ...@@ -158,9 +158,9 @@ class SiteController extends Controller
$fromEmail = \Yii::$app->params['supportEmail']; $fromEmail = \Yii::$app->params['supportEmail'];
$name = '=?UTF-8?B?' . base64_encode(\Yii::$app->name . ' robot') . '?='; $name = '=?UTF-8?B?' . base64_encode(\Yii::$app->name . ' robot') . '?=';
$subject = '=?UTF-8?B?' . base64_encode('Password reset for ' . \Yii::$app->name) . '?='; $subject = '=?UTF-8?B?' . base64_encode('Password reset for ' . \Yii::$app->name) . '?=';
$body = $this->renderPartial('/emails/passwordResetToken', array( $body = $this->renderPartial('/emails/passwordResetToken', [
'user' => $user, 'user' => $user,
)); ]);
$headers = "From: $name <{$fromEmail}>\r\n" . $headers = "From: $name <{$fromEmail}>\r\n" .
"MIME-Version: 1.0\r\n" . "MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=UTF-8"; "Content-type: text/plain; charset=UTF-8";
......
...@@ -20,14 +20,14 @@ class ContactForm extends Model ...@@ -20,14 +20,14 @@ class ContactForm extends Model
*/ */
public function rules() public function rules()
{ {
return array( return [
// name, email, subject and body are required // name, email, subject and body are required
array('name, email, subject, body', 'required'), ['name, email, subject, body', 'required'],
// email has to be a valid email address // email has to be a valid email address
array('email', 'email'), ['email', 'email'],
// verifyCode needs to be entered correctly // verifyCode needs to be entered correctly
array('verifyCode', 'captcha'), ['verifyCode', 'captcha'],
); ];
} }
/** /**
...@@ -35,9 +35,9 @@ class ContactForm extends Model ...@@ -35,9 +35,9 @@ class ContactForm extends Model
*/ */
public function attributeLabels() public function attributeLabels()
{ {
return array( return [
'verifyCode' => 'Verification Code', 'verifyCode' => 'Verification Code',
); ];
} }
/** /**
......
...@@ -6,7 +6,7 @@ use yii\helpers\Html; ...@@ -6,7 +6,7 @@ use yii\helpers\Html;
* @var common\models\User $user; * @var common\models\User $user;
*/ */
$resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', array('token' => $user->password_reset_token)); $resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', ['token' => $user->password_reset_token]);
?> ?>
Hello <?php echo Html::encode($user->username)?>, Hello <?php echo Html::encode($user->username)?>,
......
...@@ -23,35 +23,35 @@ AppAsset::register($this); ...@@ -23,35 +23,35 @@ AppAsset::register($this);
<body> <body>
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<?php <?php
NavBar::begin(array( NavBar::begin([
'brandLabel' => 'My Company', 'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl, 'brandUrl' => Yii::$app->homeUrl,
'options' => array( 'options' => [
'class' => 'navbar-inverse navbar-fixed-top', 'class' => 'navbar-inverse navbar-fixed-top',
), ],
)); ]);
$menuItems = array( $menuItems = [
array('label' => 'Home', 'url' => array('/site/index')), ['label' => 'Home', 'url' => ['/site/index']],
array('label' => 'About', 'url' => array('/site/about')), ['label' => 'About', 'url' => ['/site/about']],
array('label' => 'Contact', 'url' => array('/site/contact')), ['label' => 'Contact', 'url' => ['/site/contact']],
); ];
if (Yii::$app->user->isGuest) { if (Yii::$app->user->isGuest) {
$menuItems[] = array('label' => 'Signup', 'url' => array('/site/signup')); $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else { } else {
$menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => ['/site/logout']];
} }
echo Nav::widget(array( echo Nav::widget([
'options' => array('class' => 'navbar-nav pull-right'), 'options' => ['class' => 'navbar-nav pull-right'],
'items' => $menuItems, 'items' => $menuItems,
)); ]);
NavBar::end(); NavBar::end();
?> ?>
<div class="container"> <div class="container">
<?php echo Breadcrumbs::widget(array( <?php echo Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
)); ?> ]); ?>
<?php echo Alert::widget()?> <?php echo Alert::widget()?>
<?php echo $content; ?> <?php echo $content; ?>
</div> </div>
......
...@@ -20,17 +20,17 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -20,17 +20,17 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'contact-form')); ?> <?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
<?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'name'); ?>
<?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'email'); ?>
<?php echo $form->field($model, 'subject'); ?> <?php echo $form->field($model, 'subject'); ?>
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?> <?php echo $form->field($model, 'body')->textArea(['rows' => 6]); ?>
<?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array( <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), [
'options' => array('class' => 'form-control'), 'options' => ['class' => 'form-control'],
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
)); ?> ]); ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Submit', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Submit', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -17,15 +17,15 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -17,15 +17,15 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'login-form')); ?> <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'username'); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<div style="color:#999;margin:1em 0"> <div style="color:#999;margin:1em 0">
If you forgot your password you can <?php echo Html::a('reset it', array('site/request-password-reset'))?>. If you forgot your password you can <?php echo Html::a('reset it', ['site/request-password-reset'])?>.
</div> </div>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Login', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -17,10 +17,10 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -17,10 +17,10 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'request-password-reset-form')); ?> <?php $form = ActiveForm::begin(['id' => 'request-password-reset-form']); ?>
<?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'email'); ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Send', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Send', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -17,10 +17,10 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -17,10 +17,10 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'reset-password-form')); ?> <?php $form = ActiveForm::begin(['id' => 'reset-password-form']); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Save', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Save', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -17,12 +17,12 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -17,12 +17,12 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'form-signup')); ?> <?php $form = ActiveForm::begin(['id' => 'form-signup']); ?>
<?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'username'); ?>
<?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'email'); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Signup', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Signup', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -73,7 +73,7 @@ echo "\n ... initialization completed.\n\n"; ...@@ -73,7 +73,7 @@ echo "\n ... initialization completed.\n\n";
function getFileList($root, $basePath = '') function getFileList($root, $basePath = '')
{ {
$files = array(); $files = [];
$handle = opendir($root); $handle = opendir($root);
while (($path = readdir($handle)) !== false) { while (($path = readdir($handle)) !== false) {
if ($path === '.svn' || $path === '.' || $path === '..') { if ($path === '.svn' || $path === '.' || $path === '..') {
...@@ -135,13 +135,13 @@ function copyFile($root, $source, $target, &$all) ...@@ -135,13 +135,13 @@ function copyFile($root, $source, $target, &$all)
function getParams() function getParams()
{ {
$rawParams = array(); $rawParams = [];
if (isset($_SERVER['argv'])) { if (isset($_SERVER['argv'])) {
$rawParams = $_SERVER['argv']; $rawParams = $_SERVER['argv'];
array_shift($rawParams); array_shift($rawParams);
} }
$params = array(); $params = [];
foreach ($rawParams as $param) { foreach ($rawParams as $param) {
if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) {
$name = $matches[1]; $name = $matches[1];
......
...@@ -26,78 +26,78 @@ $requirementsChecker = new YiiRequirementChecker(); ...@@ -26,78 +26,78 @@ $requirementsChecker = new YiiRequirementChecker();
/** /**
* Adjust requirements according to your application specifics. * Adjust requirements according to your application specifics.
*/ */
$requirements = array( $requirements = [
// Database : // Database :
array( [
'name' => 'PDO extension', 'name' => 'PDO extension',
'mandatory' => true, 'mandatory' => true,
'condition' => extension_loaded('pdo'), 'condition' => extension_loaded('pdo'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
), ],
array( [
'name' => 'PDO SQLite extension', 'name' => 'PDO SQLite extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_sqlite'), 'condition' => extension_loaded('pdo_sqlite'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
'memo' => 'Required for SQLite database.', 'memo' => 'Required for SQLite database.',
), ],
array( [
'name' => 'PDO MySQL extension', 'name' => 'PDO MySQL extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_mysql'), 'condition' => extension_loaded('pdo_mysql'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
'memo' => 'Required for MySQL database.', 'memo' => 'Required for MySQL database.',
), ],
// Cache : // Cache :
array( [
'name' => 'Memcache extension', 'name' => 'Memcache extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>',
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : '' 'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : ''
), ],
array( [
'name' => 'APC extension', 'name' => 'APC extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('apc') || extension_loaded('apc'), 'condition' => extension_loaded('apc') || extension_loaded('apc'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
), ],
// Additional PHP extensions : // Additional PHP extensions :
array( [
'name' => 'Mcrypt extension', 'name' => 'Mcrypt extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('mcrypt'), 'condition' => extension_loaded('mcrypt'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>', 'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
'memo' => 'Required by encrypt and decrypt methods.' 'memo' => 'Required by encrypt and decrypt methods.'
), ],
// PHP ini : // PHP ini :
'phpSafeMode' => array( 'phpSafeMode' => [
'name' => 'PHP safe mode', 'name' => 'PHP safe mode',
'mandatory' => false, 'mandatory' => false,
'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
'by' => 'File uploading and console command execution', 'by' => 'File uploading and console command execution',
'memo' => '"safe_mode" should be disabled at php.ini', 'memo' => '"safe_mode" should be disabled at php.ini',
), ],
'phpExposePhp' => array( 'phpExposePhp' => [
'name' => 'Expose PHP', 'name' => 'Expose PHP',
'mandatory' => false, 'mandatory' => false,
'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
'by' => 'Security reasons', 'by' => 'Security reasons',
'memo' => '"expose_php" should be disabled at php.ini', 'memo' => '"expose_php" should be disabled at php.ini',
), ],
'phpAllowUrlInclude' => array( 'phpAllowUrlInclude' => [
'name' => 'PHP allow url include', 'name' => 'PHP allow url include',
'mandatory' => false, 'mandatory' => false,
'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
'by' => 'Security reasons', 'by' => 'Security reasons',
'memo' => '"allow_url_include" should be disabled at php.ini', 'memo' => '"allow_url_include" should be disabled at php.ini',
), ],
'phpSmtp' => array( 'phpSmtp' => [
'name' => 'PHP mail SMTP', 'name' => 'PHP mail SMTP',
'mandatory' => false, 'mandatory' => false,
'condition' => strlen(ini_get('SMTP'))>0, 'condition' => strlen(ini_get('SMTP'))>0,
'by' => 'Email sending', 'by' => 'Email sending',
'memo' => 'PHP mail SMTP server required', 'memo' => 'PHP mail SMTP server required',
), ],
); ];
$requirementsChecker->checkYii()->check($requirements)->render(); $requirementsChecker->checkYii()->check($requirements)->render();
...@@ -3,7 +3,7 @@ $params = require(__DIR__ . '/params.php'); ...@@ -3,7 +3,7 @@ $params = require(__DIR__ . '/params.php');
return [ return [
'id' => 'bootstrap-console', 'id' => 'bootstrap-console',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'preload' => array('log'), 'preload' => ['log'],
'controllerPath' => dirname(__DIR__) . '/commands', 'controllerPath' => dirname(__DIR__) . '/commands',
'controllerNamespace' => 'app\commands', 'controllerNamespace' => 'app\commands',
'modules' => [ 'modules' => [
......
...@@ -26,78 +26,78 @@ $requirementsChecker = new YiiRequirementChecker(); ...@@ -26,78 +26,78 @@ $requirementsChecker = new YiiRequirementChecker();
/** /**
* Adjust requirements according to your application specifics. * Adjust requirements according to your application specifics.
*/ */
$requirements = array( $requirements = [
// Database : // Database :
array( [
'name' => 'PDO extension', 'name' => 'PDO extension',
'mandatory' => true, 'mandatory' => true,
'condition' => extension_loaded('pdo'), 'condition' => extension_loaded('pdo'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
), ],
array( [
'name' => 'PDO SQLite extension', 'name' => 'PDO SQLite extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_sqlite'), 'condition' => extension_loaded('pdo_sqlite'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
'memo' => 'Required for SQLite database.', 'memo' => 'Required for SQLite database.',
), ],
array( [
'name' => 'PDO MySQL extension', 'name' => 'PDO MySQL extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('pdo_mysql'), 'condition' => extension_loaded('pdo_mysql'),
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', 'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
'memo' => 'Required for MySQL database.', 'memo' => 'Required for MySQL database.',
), ],
// Cache : // Cache :
array( [
'name' => 'Memcache extension', 'name' => 'Memcache extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>',
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : '' 'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : ''
), ],
array( [
'name' => 'APC extension', 'name' => 'APC extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('apc') || extension_loaded('apc'), 'condition' => extension_loaded('apc') || extension_loaded('apc'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>', 'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
), ],
// Additional PHP extensions : // Additional PHP extensions :
array( [
'name' => 'Mcrypt extension', 'name' => 'Mcrypt extension',
'mandatory' => false, 'mandatory' => false,
'condition' => extension_loaded('mcrypt'), 'condition' => extension_loaded('mcrypt'),
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>', 'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
'memo' => 'Required by encrypt and decrypt methods.' 'memo' => 'Required by encrypt and decrypt methods.'
), ],
// PHP ini : // PHP ini :
'phpSafeMode' => array( 'phpSafeMode' => [
'name' => 'PHP safe mode', 'name' => 'PHP safe mode',
'mandatory' => false, 'mandatory' => false,
'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
'by' => 'File uploading and console command execution', 'by' => 'File uploading and console command execution',
'memo' => '"safe_mode" should be disabled at php.ini', 'memo' => '"safe_mode" should be disabled at php.ini',
), ],
'phpExposePhp' => array( 'phpExposePhp' => [
'name' => 'Expose PHP', 'name' => 'Expose PHP',
'mandatory' => false, 'mandatory' => false,
'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
'by' => 'Security reasons', 'by' => 'Security reasons',
'memo' => '"expose_php" should be disabled at php.ini', 'memo' => '"expose_php" should be disabled at php.ini',
), ],
'phpAllowUrlInclude' => array( 'phpAllowUrlInclude' => [
'name' => 'PHP allow url include', 'name' => 'PHP allow url include',
'mandatory' => false, 'mandatory' => false,
'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
'by' => 'Security reasons', 'by' => 'Security reasons',
'memo' => '"allow_url_include" should be disabled at php.ini', 'memo' => '"allow_url_include" should be disabled at php.ini',
), ],
'phpSmtp' => array( 'phpSmtp' => [
'name' => 'PHP mail SMTP', 'name' => 'PHP mail SMTP',
'mandatory' => false, 'mandatory' => false,
'condition' => strlen(ini_get('SMTP'))>0, 'condition' => strlen(ini_get('SMTP'))>0,
'by' => 'Email sending', 'by' => 'Email sending',
'memo' => 'PHP mail SMTP server required', 'memo' => 'PHP mail SMTP server required',
), ],
); ];
$requirementsChecker->checkYii()->check($requirements)->render(); $requirementsChecker->checkYii()->check($requirements)->render();
...@@ -4,7 +4,7 @@ $I->wantTo('ensure that contact works'); ...@@ -4,7 +4,7 @@ $I->wantTo('ensure that contact works');
$I->amOnPage('?r=site/contact'); $I->amOnPage('?r=site/contact');
$I->see('Contact', 'h1'); $I->see('Contact', 'h1');
$I->submitForm('#contact-form', array()); $I->submitForm('#contact-form', []);
$I->see('Contact', 'h1'); $I->see('Contact', 'h1');
$I->see('Name cannot be blank'); $I->see('Name cannot be blank');
$I->see('Email cannot be blank'); $I->see('Email cannot be blank');
...@@ -12,25 +12,25 @@ $I->see('Subject cannot be blank'); ...@@ -12,25 +12,25 @@ $I->see('Subject cannot be blank');
$I->see('Body cannot be blank'); $I->see('Body cannot be blank');
$I->see('The verification code is incorrect'); $I->see('The verification code is incorrect');
$I->submitForm('#contact-form', array( $I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester', 'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester.email', 'ContactForm[email]' => 'tester.email',
'ContactForm[subject]' => 'test subject', 'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content', 'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme', 'ContactForm[verifyCode]' => 'testme',
)); ]);
$I->dontSee('Name cannot be blank', '.help-inline'); $I->dontSee('Name cannot be blank', '.help-inline');
$I->see('Email is not a valid email address.'); $I->see('Email is not a valid email address.');
$I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Subject cannot be blank', '.help-inline');
$I->dontSee('Body cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-inline');
$I->dontSee('The verification code is incorrect', '.help-inline'); $I->dontSee('The verification code is incorrect', '.help-inline');
$I->submitForm('#contact-form', array( $I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester', 'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester@example.com', 'ContactForm[email]' => 'tester@example.com',
'ContactForm[subject]' => 'test subject', 'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content', 'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme', 'ContactForm[verifyCode]' => 'testme',
)); ]);
$I->dontSeeElement('#contact-form'); $I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
...@@ -4,20 +4,20 @@ $I->wantTo('ensure that login works'); ...@@ -4,20 +4,20 @@ $I->wantTo('ensure that login works');
$I->amOnPage('?r=site/login'); $I->amOnPage('?r=site/login');
$I->see('Login', 'h1'); $I->see('Login', 'h1');
$I->submitForm('#login-form', array()); $I->submitForm('#login-form', []);
$I->dontSee('Logout (admin)'); $I->dontSee('Logout (admin)');
$I->see('Username cannot be blank'); $I->see('Username cannot be blank');
$I->see('Password cannot be blank'); $I->see('Password cannot be blank');
$I->submitForm('#login-form', array( $I->submitForm('#login-form', [
'LoginForm[username]' => 'admin', 'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'wrong', 'LoginForm[password]' => 'wrong',
)); ]);
$I->dontSee('Logout (admin)'); $I->dontSee('Logout (admin)');
$I->see('Incorrect username or password'); $I->see('Incorrect username or password');
$I->submitForm('#login-form', array( $I->submitForm('#login-form', [
'LoginForm[username]' => 'admin', 'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'admin', 'LoginForm[password]' => 'admin',
)); ]);
$I->see('Logout (admin)'); $I->see('Logout (admin)');
...@@ -4,7 +4,7 @@ $I->wantTo('ensure that contact works'); ...@@ -4,7 +4,7 @@ $I->wantTo('ensure that contact works');
$I->amOnPage('?r=site/contact'); $I->amOnPage('?r=site/contact');
$I->see('Contact', 'h1'); $I->see('Contact', 'h1');
$I->submitForm('#contact-form', array()); $I->submitForm('#contact-form', []);
$I->see('Contact', 'h1'); $I->see('Contact', 'h1');
$I->see('Name cannot be blank'); $I->see('Name cannot be blank');
$I->see('Email cannot be blank'); $I->see('Email cannot be blank');
...@@ -12,25 +12,25 @@ $I->see('Subject cannot be blank'); ...@@ -12,25 +12,25 @@ $I->see('Subject cannot be blank');
$I->see('Body cannot be blank'); $I->see('Body cannot be blank');
$I->see('The verification code is incorrect'); $I->see('The verification code is incorrect');
$I->submitForm('#contact-form', array( $I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester', 'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester.email', 'ContactForm[email]' => 'tester.email',
'ContactForm[subject]' => 'test subject', 'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content', 'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme', 'ContactForm[verifyCode]' => 'testme',
)); ]);
$I->dontSee('Name cannot be blank', '.help-inline'); $I->dontSee('Name cannot be blank', '.help-inline');
$I->see('Email is not a valid email address.'); $I->see('Email is not a valid email address.');
$I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Subject cannot be blank', '.help-inline');
$I->dontSee('Body cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-inline');
$I->dontSee('The verification code is incorrect', '.help-inline'); $I->dontSee('The verification code is incorrect', '.help-inline');
$I->submitForm('#contact-form', array( $I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester', 'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester@example.com', 'ContactForm[email]' => 'tester@example.com',
'ContactForm[subject]' => 'test subject', 'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content', 'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme', 'ContactForm[verifyCode]' => 'testme',
)); ]);
$I->dontSeeElement('#contact-form'); $I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
...@@ -4,20 +4,20 @@ $I->wantTo('ensure that login works'); ...@@ -4,20 +4,20 @@ $I->wantTo('ensure that login works');
$I->amOnPage('?r=site/login'); $I->amOnPage('?r=site/login');
$I->see('Login', 'h1'); $I->see('Login', 'h1');
$I->submitForm('#login-form', array()); $I->submitForm('#login-form', []);
$I->dontSee('Logout (admin)'); $I->dontSee('Logout (admin)');
$I->see('Username cannot be blank'); $I->see('Username cannot be blank');
$I->see('Password cannot be blank'); $I->see('Password cannot be blank');
$I->submitForm('#login-form', array( $I->submitForm('#login-form', [
'LoginForm[username]' => 'admin', 'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'wrong', 'LoginForm[password]' => 'wrong',
)); ]);
$I->dontSee('Logout (admin)'); $I->dontSee('Logout (admin)');
$I->see('Incorrect username or password'); $I->see('Incorrect username or password');
$I->submitForm('#login-form', array( $I->submitForm('#login-form', [
'LoginForm[username]' => 'admin', 'LoginForm[username]' => 'admin',
'LoginForm[password]' => 'admin', 'LoginForm[password]' => 'admin',
)); ]);
$I->see('Logout (admin)'); $I->see('Logout (admin)');
...@@ -21,33 +21,33 @@ app\config\AppAsset::register($this); ...@@ -21,33 +21,33 @@ app\config\AppAsset::register($this);
<body> <body>
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<?php <?php
NavBar::begin(array( NavBar::begin([
'brandLabel' => 'My Company', 'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl, 'brandUrl' => Yii::$app->homeUrl,
'options' => array( 'options' => [
'class' => 'navbar-inverse navbar-fixed-top', 'class' => 'navbar-inverse navbar-fixed-top',
), ],
)); ]);
echo Nav::widget(array( echo Nav::widget([
'options' => array('class' => 'navbar-nav pull-right'), 'options' => ['class' => 'navbar-nav pull-right'],
'items' => array( 'items' => [
array('label' => 'Home', 'url' => array('/site/index')), ['label' => 'Home', 'url' => ['/site/index']],
array('label' => 'About', 'url' => array('/site/about')), ['label' => 'About', 'url' => ['/site/about']],
array('label' => 'Contact', 'url' => array('/site/contact')), ['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ? Yii::$app->user->isGuest ?
array('label' => 'Login', 'url' => array('/site/login')) : ['label' => 'Login', 'url' => ['/site/login']] :
array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , ['label' => 'Logout (' . Yii::$app->user->identity->username .')' ,
'url' => array('/site/logout'), 'url' => ['/site/logout'],
'linkOptions' => array('data-method' => 'post')), 'linkOptions' => ['data-method' => 'post']],
), ],
)); ]);
NavBar::end(); NavBar::end();
?> ?>
<div class="container"> <div class="container">
<?php echo Breadcrumbs::widget(array( <?php echo Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
)); ?> ]); ?>
<?php echo $content; ?> <?php echo $content; ?>
</div> </div>
......
...@@ -28,17 +28,17 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -28,17 +28,17 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="row"> <div class="row">
<div class="col-lg-5"> <div class="col-lg-5">
<?php $form = ActiveForm::begin(array('id' => 'contact-form')); ?> <?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
<?php echo $form->field($model, 'name'); ?> <?php echo $form->field($model, 'name'); ?>
<?php echo $form->field($model, 'email'); ?> <?php echo $form->field($model, 'email'); ?>
<?php echo $form->field($model, 'subject'); ?> <?php echo $form->field($model, 'subject'); ?>
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?> <?php echo $form->field($model, 'body')->textArea(['rows' => 6]); ?>
<?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array( <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), [
'options' => array('class' => 'form-control'), 'options' => ['class' => 'form-control'],
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
)); ?> ]); ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Submit', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Submit', ['class' => 'btn btn-primary']); ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -15,26 +15,26 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -15,26 +15,26 @@ $this->params['breadcrumbs'][] = $this->title;
<p>Please fill out the following fields to login:</p> <p>Please fill out the following fields to login:</p>
<?php $form = ActiveForm::begin(array( <?php $form = ActiveForm::begin([
'id' => 'login-form', 'id' => 'login-form',
'options' => array('class' => 'form-horizontal'), 'options' => ['class' => 'form-horizontal'],
'fieldConfig' => array( 'fieldConfig' => [
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
'labelOptions' => array('class' => 'col-lg-1 control-label'), 'labelOptions' => ['class' => 'col-lg-1 control-label'],
), ],
)); ?> ]); ?>
<?php echo $form->field($model, 'username'); ?> <?php echo $form->field($model, 'username'); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo $form->field($model, 'rememberMe', array( <?php echo $form->field($model, 'rememberMe', [
'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
))->checkbox(); ?> ])->checkbox(); ?>
<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">
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Login', ['class' => 'btn btn-primary']); ?>
</div> </div>
</div> </div>
......
<?php <?php
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.'); die('You are not allowed to access this file.');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment