Commit bc4324c0 authored by Carsten Brandt's avatar Carsten Brandt

Merge branch 'master' into redis

* master: (613 commits)
  fixed typo
  Fixes #1222: refactored jui/Widget, intorduced jui/Slider and jui/SliderInput
  Correct Nav.php comments/PHP doc to reflect BS3 dropdown support.
  Correct Nav.php comments/PHP doc to reflect BS3 dropdown support.
  Correct Nav.php comments/PHP doc to reflect BS3 dropdown support.
  Added example for dividers to bootstrap Nav
  Checkboxlist documentation fix
  Added "Using controller action to render errors"
  Fix doc
  Renamed DetailView attribute type to format
  encode email in Formatter
  Added default status code setting.
  "yii\swiftmailer\Mailer" transport setup has been advanced to support constructor arguments and plugins.
  fix rbac select statement
  Comments cleanup.
  Reverted closeButton
  Nomenclature and code realignment.
  better nginx config
  guide about using bootstrap less files
  Include Schema in new migrations by default
  ...

Conflicts:
	framework/yii/db/ActiveRecord.php
	framework/yii/db/ActiveRelation.php
	tests/unit/data/config.php
parents 179618c6 704f9105
...@@ -20,3 +20,6 @@ composer.phar ...@@ -20,3 +20,6 @@ composer.phar
# Mac DS_Store Files # Mac DS_Store Files
.DS_Store .DS_Store
# local phpunit config
/phpunit.xml
\ No newline at end of file
language: php language: php
php: php:
- 5.3
- 5.4 - 5.4
- 5.5 - 5.5
env:
- CUBRID_VERSION=9.1.0
services: services:
- redis-server - redis-server
- memcached - memcached
...@@ -22,7 +18,7 @@ before_script: ...@@ -22,7 +18,7 @@ before_script:
- tests/unit/data/travis/cubrid-setup.sh - tests/unit/data/travis/cubrid-setup.sh
script: script:
- phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml --verbose --exclude-group mssql,oci,wincache,xcache,zenddata - phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml --verbose --exclude-group mssql,oci,wincache,xcache,zenddata,vendor
after_script: after_script:
- php vendor/bin/coveralls - php vendor/bin/coveralls
The Yii framework is free software. It is released under the terms of The Yii framework is free software. It is released under the terms of
the following BSD License. the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com) Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
...@@ -33,7 +33,7 @@ DIRECTORY STRUCTURE ...@@ -33,7 +33,7 @@ DIRECTORY STRUCTURE
REQUIREMENTS REQUIREMENTS
------------ ------------
The minimum requirement by Yii is that your Web server supports PHP 5.3.?. The minimum requirement by Yii is that your Web server supports PHP 5.4.
DOCUMENTATION DOCUMENTATION
...@@ -42,7 +42,7 @@ DOCUMENTATION ...@@ -42,7 +42,7 @@ DOCUMENTATION
For 1.1 users, you may refer to [Upgrading from Yii 1.1](docs/guide/upgrade-from-v1.md) For 1.1 users, you may refer to [Upgrading from Yii 1.1](docs/guide/upgrade-from-v1.md)
to have a general idea of what has changed in 2.0. to have a general idea of what has changed in 2.0.
We are writing more documentation to get you started and learn more in depth. [Definitive Guide draft](docs/guide/index.md) is available. It's not complete yet but main parts are already OK.
HOW TO PARTICIPATE HOW TO PARTICIPATE
......
The Yii framework is free software. It is released under the terms of The Yii framework is free software. It is released under the terms of
the following BSD License. the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com) Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
...@@ -52,7 +52,7 @@ environments/ contains environment-based overrides ...@@ -52,7 +52,7 @@ environments/ contains environment-based overrides
REQUIREMENTS REQUIREMENTS
------------ ------------
The minimum requirement by Yii is that your Web server supports PHP 5.3.?. The minimum requirement by Yii is that your Web server supports PHP 5.4.0.
In order for captcha to work you need either GD2 extension or ImageMagick PHP extension. In order for captcha to work you need either GD2 extension or ImageMagick PHP extension.
...@@ -76,6 +76,13 @@ php composer.phar create-project --stability=dev yiisoft/yii2-app-advanced yii-a ...@@ -76,6 +76,13 @@ php composer.phar create-project --stability=dev yiisoft/yii2-app-advanced yii-a
Note that in order to install some dependencies you must have `php_openssl` extension enabled. Note that in order to install some dependencies you must have `php_openssl` extension enabled.
After the application is installed, switch to the project folder and run the following command
to initialize the application:
~~~
./init (init on Windows)
~~~
### Install from an Archive File ### Install from an Archive File
...@@ -103,9 +110,11 @@ GETTING STARTED ...@@ -103,9 +110,11 @@ GETTING STARTED
After you install the application, you have to conduct the following steps to initialize After you install the application, you have to conduct the following steps to initialize
the installed application. You only need to do these once for all. the installed application. You only need to do these once for all.
1. Execute the `init` command and select `dev` as environment. 1. Execute the `init` command and select `dev` as environment. Alternatively you can execute it as `init --env=Development`
or `init --env=Production`.
2. Create a new database. It is assumed that MySQL InnoDB is used. If not, adjust `console/migrations/m130524_201442_init.php`. 2. Create a new database. It is assumed that MySQL InnoDB is used. If not, adjust `console/migrations/m130524_201442_init.php`.
3. In `common/config/params.php` set your database details in `components.db` values. 3. In `common/config/params.php` set your database details in `components.db` values.
4. Apply migrations with `yii migrate`.
Now you should be able to access: Now you should be able to access:
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace frontend\config; namespace backend\assets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
...@@ -17,13 +17,10 @@ class AppAsset extends AssetBundle ...@@ -17,13 +17,10 @@ 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 = [];
); public $depends = [
public $js = array(
);
public $depends = array(
'yii\web\YiiAsset', 'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset', 'yii\bootstrap\BootstrapAsset',
); ];
} }
<?php <?php
$rootDir = __DIR__ . '/../..'; $rootDir = dirname(dirname(__DIR__));
$params = array_merge( $params = array_merge(
require($rootDir . '/common/config/params.php'), require($rootDir . '/common/config/params.php'),
...@@ -8,35 +8,36 @@ $params = array_merge( ...@@ -8,35 +8,36 @@ $params = array_merge(
require(__DIR__ . '/params-local.php') require(__DIR__ . '/params-local.php')
); );
return array( return [
'id' => 'app-backend', 'id' => 'app-backend',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'vendorPath' => $rootDir . '/vendor',
'preload' => array('log'), 'preload' => ['log'],
'controllerNamespace' => 'backend\controllers', 'controllerNamespace' => 'backend\controllers',
'modules' => array( 'modules' => [],
), 'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'),
'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( 'mail' => $params['components.mail'],
'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',
); ];
...@@ -10,32 +10,31 @@ class SiteController extends Controller ...@@ -10,32 +10,31 @@ 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', 'error'],
'allow' => true, 'allow' => true,
'roles' => array('?'), ],
), [
array( 'actions' => ['logout', 'index'],
'actions' => array('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()
...@@ -45,13 +44,17 @@ class SiteController extends Controller ...@@ -45,13 +44,17 @@ class SiteController extends Controller
public function actionLogin() public function actionLogin()
{ {
if (!\Yii::$app->user->isGuest) {
$this->goHome();
}
$model = new LoginForm(); $model = new LoginForm();
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goBack();
} else { } else {
return $this->render('login', array( return $this->render('login', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
......
<?php <?php
use backend\config\AppAsset; use backend\assets\AppAsset;
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;
/** /**
* @var $this \yii\base\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
AppAsset::register($this); AppAsset::register($this);
?> ?>
<?php $this->beginPage(); ?> <?php $this->beginPage(); ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="<?= Yii::$app->language ?>">
<head> <head>
<meta charset="<?php echo Yii::$app->charset; ?>"/> <meta charset="<?= Yii::$app->charset ?>"/>
<title><?php echo Html::encode($this->title); ?></title> <title><?= Html::encode($this->title) ?></title>
<?php $this->head(); ?> <?php $this->head(); ?>
</head> </head>
<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 navbar-right'],
'items' => $menuItems, 'items' => $menuItems,
)); ]);
NavBar::end(); NavBar::end();
?> ?>
<div class="container"> <div class="container">
<?php echo Breadcrumbs::widget(array( <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
)); ?> ]) ?>
<?php echo $content; ?> <?= $content ?>
</div> </div>
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
<p class="pull-left">&copy; My Company <?php echo date('Y'); ?></p> <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
<p class="pull-right"><?php echo Yii::powered(); ?></p> <p class="pull-right"><?= Yii::powered() ?></p>
</div> </div>
</footer> </footer>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var string $name * @var string $name
* @var string $message * @var string $message
* @var Exception $exception * @var Exception $exception
...@@ -13,10 +13,10 @@ $this->title = $name; ...@@ -13,10 +13,10 @@ $this->title = $name;
?> ?>
<div class="site-error"> <div class="site-error">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger"> <div class="alert alert-danger">
<?php echo nl2br(Html::encode($message)); ?> <?= nl2br(Html::encode($message)) ?>
</div> </div>
<p> <p>
......
<?php <?php
/** /**
* @var yii\base\View $this * @var yii\web\View $this
*/ */
$this->title = 'My Yii Application'; $this->title = 'My Yii Application';
?> ?>
......
...@@ -3,7 +3,7 @@ use yii\helpers\Html; ...@@ -3,7 +3,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var app\models\LoginForm $model * @var app\models\LoginForm $model
*/ */
...@@ -11,18 +11,18 @@ $this->title = 'Login'; ...@@ -11,18 +11,18 @@ $this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-login"> <div class="site-login">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out the following fields to login:</p> <p>Please fill out the following fields to login:</p>
<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'); ?> <?= $form->field($model, 'username') ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?= $form->field($model, 'password')->passwordInput() ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?= $form->field($model, 'rememberMe')->checkbox() ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -17,3 +17,24 @@ body { ...@@ -17,3 +17,24 @@ body {
font-size: 21px; font-size: 21px;
padding: 14px 24px; padding: 14px 24px;
} }
/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
padding-left: 5px;
}
a.asc:after { content: /*"\e113"*/"\e151"; }
a.desc:after { content: /*"\e114"*/"\e152"; }
.sort-numerical a.asc:after { content: "\e153"; }
.sort-numerical a.desc:after { content: "\e154"; }
.sort-ordinal a.asc:after { content: "\e155"; }
.sort-ordinal a.desc:after { content: "\e156"; }
<?php <?php
Yii::setAlias('common', __DIR__ . '/../'); Yii::setAlias('common', realpath(__DIR__ . '/../'));
Yii::setAlias('frontend', __DIR__ . '/../../frontend'); Yii::setAlias('frontend', realpath(__DIR__ . '/../../frontend'));
Yii::setAlias('backend', __DIR__ . '/../../backend'); Yii::setAlias('backend', realpath(__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.mail' => [
'class' => 'yii\swiftmailer\Mailer',
],
'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',
), ],
); ];
...@@ -14,19 +14,21 @@ class LoginForm extends Model ...@@ -14,19 +14,21 @@ class LoginForm extends Model
public $password; public $password;
public $rememberMe = true; public $rememberMe = true;
private $_user = false;
/** /**
* @return array the validation rules. * @return array the validation rules.
*/ */
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'],
); ];
} }
/** /**
...@@ -35,7 +37,7 @@ class LoginForm extends Model ...@@ -35,7 +37,7 @@ class LoginForm extends Model
*/ */
public function validatePassword() public function validatePassword()
{ {
$user = User::findByUsername($this->username); $user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) { if (!$user || !$user->validatePassword($this->password)) {
$this->addError('password', 'Incorrect username or password.'); $this->addError('password', 'Incorrect username or password.');
} }
...@@ -48,11 +50,22 @@ class LoginForm extends Model ...@@ -48,11 +50,22 @@ class LoginForm extends Model
public function login() public function login()
{ {
if ($this->validate()) { if ($this->validate()) {
$user = User::findByUsername($this->username); return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0);
return true;
} else { } else {
return false; return false;
} }
} }
/**
* Finds user by [[username]]
*
* @return User|null
*/
private function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByUsername($this->username);
}
return $this->_user;
}
} }
...@@ -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)
......
...@@ -14,17 +14,20 @@ ...@@ -14,17 +14,20 @@
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.4.0",
"yiisoft/yii2": "dev-master", "yiisoft/yii2": "dev-master",
"yiisoft/yii2-composer": "dev-master" "yiisoft/yii2-swiftmailer": "dev-master",
"yiisoft/yii2-bootstrap": "dev-master",
"yiisoft/yii2-debug": "dev-master",
"yiisoft/yii2-gii": "dev-master"
}, },
"scripts": { "scripts": {
"post-create-project-cmd": [ "post-create-project-cmd": [
"yii\\composer\\InstallHandler::setPermissions" "yii\\composer\\Installer::setPermission"
] ]
}, },
"extra": { "extra": {
"yii-install-writable": [ "writable": [
"backend/runtime", "backend/runtime",
"backend/web/assets", "backend/web/assets",
......
...@@ -8,24 +8,26 @@ $params = array_merge( ...@@ -8,24 +8,26 @@ $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( 'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
'components' => [
'db' => $params['components.db'], 'db' => $params['components.db'],
'cache' => $params['components.cache'], 'cache' => $params['components.cache'],
'log' => array( 'mail' => $params['components.mail'],
'targets' => array( 'log' => [
array( 'targets' => [
[
'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',
); ];
...@@ -9,7 +9,7 @@ class m130524_201442_init extends \yii\db\Migration ...@@ -9,7 +9,7 @@ class m130524_201442_init extends \yii\db\Migration
// MySQL-specific table options. Adjust if you plan working with another DBMS // MySQL-specific table options. Adjust if you plan working with another DBMS
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
$this->createTable('tbl_user', array( $this->createTable('tbl_user', [
'id' => Schema::TYPE_PK, 'id' => Schema::TYPE_PK,
'username' => Schema::TYPE_STRING.' NOT NULL', 'username' => Schema::TYPE_STRING.' NOT NULL',
'auth_key' => Schema::TYPE_STRING.'(32) NOT NULL', 'auth_key' => Schema::TYPE_STRING.'(32) NOT NULL',
...@@ -21,7 +21,7 @@ class m130524_201442_init extends \yii\db\Migration ...@@ -21,7 +21,7 @@ class m130524_201442_init extends \yii\db\Migration
'status' => 'tinyint NOT NULL DEFAULT 10', 'status' => 'tinyint NOT NULL DEFAULT 10',
'create_time' => Schema::TYPE_INTEGER.' NOT NULL', 'create_time' => Schema::TYPE_INTEGER.' NOT NULL',
'update_time' => Schema::TYPE_INTEGER.' NOT NULL', 'update_time' => Schema::TYPE_INTEGER.' NOT NULL',
), $tableOptions); ], $tableOptions);
} }
public function down() public function down()
......
<?php <?php
return array( return [
'preload' => array( 'preload' => [
//'debug', //'debug',
), ],
'modules' => array( 'modules' => [
// 'debug' => array( // 'debug' => [
// 'class' => 'yii\debug\Module', // 'class' => 'yii\debug\Module',
// ), // ],
), ],
); ];
<?php <?php
return array( return [
'preload' => array( 'preload' => [
//'debug', //'debug',
), ],
'modules' => array( 'modules' => [
// 'debug' => array( // 'debug' => [
// 'class' => 'yii\debug\Module', // 'class' => 'yii\debug\Module',
// ), // ],
), ],
); ];
...@@ -4,7 +4,6 @@ defined('YII_ENV') or define('YII_ENV', 'dev'); ...@@ -4,7 +4,6 @@ defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/../../vendor/composer/autoload_namespaces.php'));
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main.php'),
......
...@@ -16,7 +16,6 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); ...@@ -16,7 +16,6 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/vendor/composer/autoload_namespaces.php'));
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/console/config/main.php'), require(__DIR__ . '/console/config/main.php'),
...@@ -24,4 +23,5 @@ $config = yii\helpers\ArrayHelper::merge( ...@@ -24,4 +23,5 @@ $config = yii\helpers\ArrayHelper::merge(
); );
$application = new yii\console\Application($config); $application = new yii\console\Application($config);
return $application->run(); $exitCode = $application->run();
exit($exitCode);
...@@ -6,33 +6,33 @@ ...@@ -6,33 +6,33 @@
* format: * format:
* *
* ```php * ```php
* return array( * return [
* 'environment name' => array( * 'environment name' => [
* 'path' => 'directory storing the local files', * 'path' => 'directory storing the local files',
* 'writable' => array( * 'writable' => [
* // list of directories that should be set writable * // list of directories that should be set writable
* ), * ],
* ), * ],
* ); * ];
* ``` * ```
*/ */
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',
), ],
), ],
); ];
...@@ -4,7 +4,6 @@ defined('YII_ENV') or define('YII_ENV', 'prod'); ...@@ -4,7 +4,6 @@ defined('YII_ENV') or define('YII_ENV', 'prod');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/../../vendor/composer/autoload_namespaces.php'));
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main.php'),
......
...@@ -16,7 +16,6 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); ...@@ -16,7 +16,6 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/vendor/composer/autoload_namespaces.php'));
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/console/config/main.php'), require(__DIR__ . '/console/config/main.php'),
...@@ -24,4 +23,5 @@ $config = yii\helpers\ArrayHelper::merge( ...@@ -24,4 +23,5 @@ $config = yii\helpers\ArrayHelper::merge(
); );
$application = new yii\console\Application($config); $application = new yii\console\Application($config);
return $application->run(); $exitCode = $application->run();
exit($exitCode);
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace app\config; namespace frontend\assets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
...@@ -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,37 @@ $params = array_merge( ...@@ -8,35 +8,37 @@ $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' => $rootDir . '/vendor',
'controllerNamespace' => 'frontend\controllers', 'controllerNamespace' => 'frontend\controllers',
'modules' => array( 'modules' => [
'gii' => 'yii\gii\Module' 'gii' => 'yii\gii\Module'
), ],
'components' => array( 'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'),
'request' => array( 'components' => [
'request' => [
'enableCsrfValidation' => true, 'enableCsrfValidation' => true,
), ],
'db' => $params['components.db'], 'db' => $params['components.db'],
'cache' => $params['components.cache'], 'cache' => $params['components.cache'],
'user' => array( 'mail' => $params['components.mail'],
'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' => ['logout', 'signup'],
'rules' => array( 'rules' => [
array( [
'actions' => array('login', 'signup'), 'actions' => ['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()
...@@ -54,13 +54,17 @@ class SiteController extends Controller ...@@ -54,13 +54,17 @@ class SiteController extends Controller
public function actionLogin() public function actionLogin()
{ {
if (!\Yii::$app->user->isGuest) {
$this->goHome();
}
$model = new LoginForm(); $model = new LoginForm();
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goBack();
} else { } else {
return $this->render('login', array( return $this->render('login', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
...@@ -77,9 +81,9 @@ class SiteController extends Controller ...@@ -77,9 +81,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 +102,9 @@ class SiteController extends Controller ...@@ -98,9 +102,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 +119,17 @@ class SiteController extends Controller ...@@ -115,17 +119,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 +141,17 @@ class SiteController extends Controller ...@@ -137,17 +141,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;
...@@ -155,12 +159,13 @@ class SiteController extends Controller ...@@ -155,12 +159,13 @@ class SiteController extends Controller
$user->password_reset_token = Security::generateRandomKey(); $user->password_reset_token = Security::generateRandomKey();
if ($user->save(false)) { if ($user->save(false)) {
// todo: refactor it with mail component. pay attention to the arrangement of mail view files
$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";
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace frontend\models; namespace frontend\models;
use Yii;
use yii\base\Model; use yii\base\Model;
/** /**
...@@ -20,14 +21,14 @@ class ContactForm extends Model ...@@ -20,14 +21,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 +36,9 @@ class ContactForm extends Model ...@@ -35,9 +36,9 @@ class ContactForm extends Model
*/ */
public function attributeLabels() public function attributeLabels()
{ {
return array( return [
'verifyCode' => 'Verification Code', 'verifyCode' => 'Verification Code',
); ];
} }
/** /**
...@@ -48,13 +49,12 @@ class ContactForm extends Model ...@@ -48,13 +49,12 @@ class ContactForm extends Model
public function contact($email) public function contact($email)
{ {
if ($this->validate()) { if ($this->validate()) {
$name = '=?UTF-8?B?' . base64_encode($this->name) . '?='; Yii::$app->mail->compose()
$subject = '=?UTF-8?B?' . base64_encode($this->subject) . '?='; ->setTo($email)
$headers = "From: $name <{$this->email}>\r\n" . ->setFrom([$this->email => $this->name])
"Reply-To: {$this->email}\r\n" . ->setSubject($this->subject)
"MIME-Version: 1.0\r\n" . ->setTextBody($this->body)
"Content-type: text/plain; charset=UTF-8"; ->send();
mail($email, $subject, $this->body, $headers);
return true; return true;
} else { } else {
return false; return false;
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @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 <?= Html::encode($user->username) ?>,
Follow the link below to reset your password: Follow the link below to reset your password:
<?php echo Html::a(Html::encode($resetLink), $resetLink)?> <?= Html::a(Html::encode($resetLink), $resetLink) ?>
<?php <?php
use frontend\config\AppAsset;
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 frontend\assets\AppAsset;
use frontend\widgets\Alert; use frontend\widgets\Alert;
/** /**
* @var $this \yii\base\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
AppAsset::register($this); AppAsset::register($this);
?> ?>
<?php $this->beginPage(); ?> <?php $this->beginPage(); ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="<?= Yii::$app->language ?>">
<head> <head>
<meta charset="<?php echo Yii::$app->charset; ?>"/> <meta charset="<?= Yii::$app->charset ?>"/>
<title><?php echo Html::encode($this->title); ?></title> <title><?= Html::encode($this->title) ?></title>
<?php $this->head(); ?> <?php $this->head(); ?>
</head> </head>
<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 navbar-right'],
'items' => $menuItems, 'items' => $menuItems,
)); ]);
NavBar::end(); NavBar::end();
?> ?>
<div class="container"> <div class="container">
<?php echo Breadcrumbs::widget(array( <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
)); ?> ]) ?>
<?php echo Alert::widget()?> <?= Alert::widget() ?>
<?php echo $content; ?> <?= $content ?>
</div> </div>
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
<p class="pull-left">&copy; My Company <?php echo date('Y'); ?></p> <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
<p class="pull-right"><?php echo Yii::powered(); ?></p> <p class="pull-right"><?= Yii::powered() ?></p>
</div> </div>
</footer> </footer>
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
*/ */
$this->title = 'About'; $this->title = 'About';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-about"> <div class="site-about">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>This is the About page. You may modify the following file to customize its content:</p> <p>This is the About page. You may modify the following file to customize its content:</p>
<code><?php echo __FILE__; ?></code> <code><?= __FILE__ ?></code>
</div> </div>
...@@ -4,7 +4,7 @@ use yii\widgets\ActiveForm; ...@@ -4,7 +4,7 @@ use yii\widgets\ActiveForm;
use yii\captcha\Captcha; use yii\captcha\Captcha;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var app\models\ContactForm $model * @var app\models\ContactForm $model
*/ */
...@@ -12,7 +12,7 @@ $this->title = 'Contact'; ...@@ -12,7 +12,7 @@ $this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-contact"> <div class="site-contact">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<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. Thank you.
...@@ -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'); ?> <?= $form->field($model, 'name') ?>
<?php echo $form->field($model, 'email'); ?> <?= $form->field($model, 'email') ?>
<?php echo $form->field($model, 'subject'); ?> <?= $form->field($model, 'subject') ?>
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?> <?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
<?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array( <?= $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')); ?> <?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var string $name * @var string $name
* @var string $message * @var string $message
* @var Exception $exception * @var Exception $exception
...@@ -13,10 +13,10 @@ $this->title = $name; ...@@ -13,10 +13,10 @@ $this->title = $name;
?> ?>
<div class="site-error"> <div class="site-error">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger"> <div class="alert alert-danger">
<?php echo nl2br(Html::encode($message)); ?> <?= nl2br(Html::encode($message)) ?>
</div> </div>
<p> <p>
......
<?php <?php
/** /**
* @var yii\base\View $this * @var yii\web\View $this
*/ */
$this->title = 'My Yii Application'; $this->title = 'My Yii Application';
?> ?>
......
...@@ -3,7 +3,7 @@ use yii\helpers\Html; ...@@ -3,7 +3,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var app\models\LoginForm $model * @var app\models\LoginForm $model
*/ */
...@@ -11,21 +11,21 @@ $this->title = 'Login'; ...@@ -11,21 +11,21 @@ $this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-login"> <div class="site-login">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out the following fields to login:</p> <p>Please fill out the following fields to login:</p>
<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'); ?> <?= $form->field($model, 'username') ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?= $form->field($model, 'password')->passwordInput() ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?= $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 <?= 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')); ?> <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -3,7 +3,7 @@ use yii\helpers\Html; ...@@ -3,7 +3,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var common\models\User $model * @var common\models\User $model
*/ */
...@@ -11,16 +11,16 @@ $this->title = 'Request password reset'; ...@@ -11,16 +11,16 @@ $this->title = 'Request password reset';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-request-password-reset"> <div class="site-request-password-reset">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out your email. A link to reset password will be sent there.</p> <p>Please fill out your email. A link to reset password will be sent there.</p>
<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'); ?> <?= $form->field($model, 'email') ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Send', array('class' => 'btn btn-primary')); ?> <?= Html::submitButton('Send', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -3,7 +3,7 @@ use yii\helpers\Html; ...@@ -3,7 +3,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var common\models\User $model * @var common\models\User $model
*/ */
...@@ -11,16 +11,16 @@ $this->title = 'Reset password'; ...@@ -11,16 +11,16 @@ $this->title = 'Reset password';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-reset-password"> <div class="site-reset-password">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>Please choose your new password:</p> <p>Please choose your new password:</p>
<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(); ?> <?= $form->field($model, 'password')->passwordInput() ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Save', array('class' => 'btn btn-primary')); ?> <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -3,7 +3,7 @@ use yii\helpers\Html; ...@@ -3,7 +3,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var common\models\User $model * @var common\models\User $model
*/ */
...@@ -11,18 +11,18 @@ $this->title = 'Signup'; ...@@ -11,18 +11,18 @@ $this->title = 'Signup';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-signup"> <div class="site-signup">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out the following fields to signup:</p> <p>Please fill out the following fields to signup:</p>
<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'); ?> <?= $form->field($model, 'username') ?>
<?php echo $form->field($model, 'email'); ?> <?= $form->field($model, 'email') ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?= $form->field($model, 'password')->passwordInput() ?>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton('Signup', array('class' => 'btn btn-primary')); ?> <?= Html::submitButton('Signup', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -17,3 +17,24 @@ body { ...@@ -17,3 +17,24 @@ body {
font-size: 21px; font-size: 21px;
padding: 14px 24px; padding: 14px 24px;
} }
/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
padding-left: 5px;
}
a.asc:after { content: /*"\e113"*/"\e151"; }
a.desc:after { content: /*"\e114"*/"\e152"; }
.sort-numerical a.asc:after { content: "\e153"; }
.sort-numerical a.desc:after { content: "\e154"; }
.sort-ordinal a.asc:after { content: "\e155"; }
.sort-ordinal a.desc:after { content: "\e156"; }
...@@ -7,42 +7,60 @@ ...@@ -7,42 +7,60 @@
namespace frontend\widgets; namespace frontend\widgets;
use yii\helpers\Html;
/** /**
* Alert widget renders a message from session flash. You can set message as following: * Alert widget renders a message from session flash. All flash messages are displayed
* in the sequence they were assigned using setFlash. You can set message as following:
* *
* - \Yii::$app->getSession()->setFlash('error', 'This is the message'); * - \Yii::$app->getSession()->setFlash('error', 'This is the message');
* - \Yii::$app->getSession()->setFlash('success', 'This is the message'); * - \Yii::$app->getSession()->setFlash('success', 'This is the message');
* - \Yii::$app->getSession()->setFlash('info', 'This is the message'); * - \Yii::$app->getSession()->setFlash('info', 'This is the message');
* *
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @author Alexander Makarov <sam@rmcerative.ru> * @author Alexander Makarov <sam@rmcerative.ru>
*/ */
class Alert extends \yii\bootstrap\Alert class Alert extends \yii\bootstrap\Widget
{ {
private $_doNotRender = false; /**
* @var array the alert types configuration for the flash messages.
* This array is setup as $key => $value, where:
* - $key is the name of the session flash variable
* - $value is the bootstrap alert type (i.e. danger, success, info, warning)
*/
public $alertTypes = [
'error' => 'danger',
'danger' => 'danger',
'success' => 'success',
'info' => 'info',
'warning' => 'warning'
];
/**
* @var array the options for rendering the close button tag.
*/
public $closeButton = [];
public function init() public function init()
{ {
if ($this->body = \Yii::$app->getSession()->getFlash('error', null, true)) {
Html::addCssClass($this->options, 'alert-danger');
} elseif ($this->body = \Yii::$app->getSession()->getFlash('success', null, true)) {
Html::addCssClass($this->options, 'alert-success');
} elseif ($this->body = \Yii::$app->getSession()->getFlash('info', null, true)) {
Html::addCssClass($this->options, 'alert-info');
} elseif ($this->body = \Yii::$app->getSession()->getFlash('warning', null, true)) {
Html::addCssClass($this->options, 'alert-warning');
} else {
$this->_doNotRender = true;
return;
}
parent::init(); parent::init();
}
public function run() $session = \Yii::$app->getSession();
{ $flashes = $session->getAllFlashes();
if (!$this->_doNotRender) { $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
parent::run();
foreach ($flashes as $type => $message) {
/* initialize css class for each alert box */
$this->options['class'] = 'alert-' . $this->alertTypes[$type] . $appendCss;
/* assign unique id to each alert box */
$this->options['id'] = $this->getId() . '-' . $type;
echo \yii\bootstrap\Alert::widget([
'body' => $message,
'closeButton' => $this->closeButton,
'options' => $this->options
]);
$session->removeFlash($type);
} }
} }
} }
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
$params = getParams();
$root = str_replace('\\', '/', __DIR__); $root = str_replace('\\', '/', __DIR__);
$envs = require("$root/environments/index.php"); $envs = require("$root/environments/index.php");
$envNames = array_keys($envs); $envNames = array_keys($envs);
echo "Yii Application Init Tool v1.0\n\n"; echo "Yii Application Initialization Tool v1.0\n\n";
echo "Which environment do you want the application to be initialized in?\n\n";
foreach ($envNames as $i => $name) { $envName = null;
echo " [$i] $name\n"; if (empty($params['env'])) {
echo "Which environment do you want the application to be initialized in?\n\n";
foreach ($envNames as $i => $name) {
echo " [$i] $name\n";
}
echo "\n Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] ';
$answer = trim(fgets(STDIN));
if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) {
echo "\n Quit initialization.\n";
exit(0);
}
if (isset($envNames[$answer])) {
$envName = $envNames[$answer];
}
}
else {
$envName = $params['env'];
} }
echo "\n Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] ';
$answer = trim(fgets(STDIN)); if (!in_array($envName, $envNames)) {
if (!ctype_digit($answer) || !isset($envNames[$answer])) { $envsList = implode(', ', $envNames);
echo "\n Quit initialization.\n"; echo "\n $envName is not a valid environment. Try one of the following: $envsList. \n";
return; exit(2);
} }
$env = $envs[$envNames[$answer]]; $env = $envs[$envName];
echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] ";
$answer = trim(fgets(STDIN)); if (empty($params['env'])) {
if (strncasecmp($answer, 'y', 1)) { echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] ";
echo "\n Quit initialization.\n"; $answer = trim(fgets(STDIN));
return; if (strncasecmp($answer, 'y', 1)) {
echo "\n Quit initialization.\n";
exit(0);
}
} }
echo "\n Start initialization ...\n\n"; echo "\n Start initialization ...\n\n";
...@@ -51,7 +73,7 @@ echo "\n ... initialization completed.\n\n"; ...@@ -51,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 === '..') {
...@@ -110,3 +132,23 @@ function copyFile($root, $source, $target, &$all) ...@@ -110,3 +132,23 @@ function copyFile($root, $source, $target, &$all)
file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source));
return true; return true;
} }
function getParams()
{
$rawParams = [];
if (isset($_SERVER['argv'])) {
$rawParams = $_SERVER['argv'];
array_shift($rawParams);
}
$params = [];
foreach ($rawParams as $param) {
if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) {
$name = $matches[1];
$params[$name] = isset($matches[3]) ? $matches[3] : true;
} else {
$params[] = $param;
}
}
return $params;
}
...@@ -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'),
'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();
The Yii framework is free software. It is released under the terms of The Yii framework is free software. It is released under the terms of
the following BSD License. the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com) Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
...@@ -31,7 +31,7 @@ DIRECTORY STRUCTURE ...@@ -31,7 +31,7 @@ DIRECTORY STRUCTURE
REQUIREMENTS REQUIREMENTS
------------ ------------
The minimum requirement by Yii is that your Web server supports PHP 5.3.?. The minimum requirement by Yii is that your Web server supports PHP 5.4.0.
In order for captcha to work you need either GD2 extension or ImageMagick PHP extension. In order for captcha to work you need either GD2 extension or ImageMagick PHP extension.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace backend\config; namespace app\assets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
...@@ -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',
); ];
} }
...@@ -6,7 +6,6 @@ paths: ...@@ -6,7 +6,6 @@ paths:
settings: settings:
bootstrap: _bootstrap.php bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M memory_limit: 1024M
log: true log: true
modules: modules:
......
...@@ -14,21 +14,24 @@ ...@@ -14,21 +14,24 @@
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.4.0",
"yiisoft/yii2": "dev-master", "yiisoft/yii2": "dev-master",
"yiisoft/yii2-composer": "dev-master" "yiisoft/yii2-swiftmailer": "dev-master",
"yiisoft/yii2-bootstrap": "dev-master",
"yiisoft/yii2-debug": "dev-master",
"yiisoft/yii2-gii": "dev-master"
}, },
"scripts": { "scripts": {
"post-create-project-cmd": [ "post-create-project-cmd": [
"yii\\composer\\InstallHandler::setPermissions" "yii\\composer\\Installer::setPermission"
] ]
}, },
"extra": { "extra": {
"yii-install-writable": [ "writable": [
"runtime", "runtime",
"web/assets" "web/assets"
], ],
"yii-install-executable": [ "executable": [
"yii" "yii"
] ]
} }
......
<?php <?php
$params = require(__DIR__ . '/params.php'); $params = require(__DIR__ . '/params.php');
return array( return [
'id' => 'bootstrap-console', 'id' => 'basic-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' => array( 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
), 'components' => [
'components' => array( 'cache' => [
'cache' => array(
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',
), ],
'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
$params = require(__DIR__ . '/params.php'); $params = require(__DIR__ . '/params.php');
$config = array( $config = [
'id' => 'bootstrap', 'id' => 'basic',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'components' => array( 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
'request' => array( 'components' => [
'request' => [
'enableCsrfValidation' => true, 'enableCsrfValidation' => true,
), ],
'cache' => array( 'cache' => [
'class' => 'yii\caching\FileCache', 'class' => 'yii\caching\FileCache',
), ],
'user' => array( 'user' => [
'identityClass' => 'app\models\User', 'identityClass' => 'app\models\User',
), ],
'errorHandler' => array( 'errorHandler' => [
'errorAction' => 'site/error', 'errorAction' => 'site/error',
), ],
'log' => array( 'mail' => [
'class' => 'yii\swiftmailer\Mailer',
],
'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'],
), ],
), ],
), ],
), ],
'params' => $params, 'params' => $params,
); ];
if (YII_ENV_DEV) { if (YII_ENV_DEV) {
$config['preload'][] = 'debug'; $config['preload'][] = 'debug';
......
...@@ -13,43 +13,38 @@ class SiteController extends Controller ...@@ -13,43 +13,38 @@ class SiteController extends Controller
{ {
public function behaviors() public function behaviors()
{ {
return array( return [
'access' => array( 'access' => [
'class' => AccessControl::className(), 'class' => AccessControl::className(),
'only' => array('login', 'logout'), 'only' => ['logout'],
'rules' => array( 'rules' => [
array( [
'actions' => array('login'), 'actions' => ['logout'],
'allow' => true, 'allow' => true,
'roles' => array('?'), 'roles' => ['@'],
), ],
array( ],
'actions' => array('logout'), ],
'allow' => true, 'verbs' => [
'roles' => array('@'),
),
),
),
'verbs' => array(
'class' => VerbFilter::className(), 'class' => VerbFilter::className(),
'actions' => array( 'actions' => [
'logout' => array('post'), 'logout' => ['post'],
), ],
), ],
); ];
} }
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()
...@@ -59,13 +54,17 @@ class SiteController extends Controller ...@@ -59,13 +54,17 @@ class SiteController extends Controller
public function actionLogin() public function actionLogin()
{ {
if (!\Yii::$app->user->isGuest) {
$this->goHome();
}
$model = new LoginForm(); $model = new LoginForm();
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goBack();
} else { } else {
return $this->render('login', array( return $this->render('login', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
...@@ -82,9 +81,9 @@ class SiteController extends Controller ...@@ -82,9 +81,9 @@ class SiteController extends Controller
Yii::$app->session->setFlash('contactFormSubmitted'); Yii::$app->session->setFlash('contactFormSubmitted');
return $this->refresh(); return $this->refresh();
} else { } else {
return $this->render('contact', array( return $this->render('contact', [
'model' => $model, 'model' => $model,
)); ]);
} }
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace app\models; namespace app\models;
use Yii;
use yii\base\Model; use yii\base\Model;
/** /**
...@@ -20,14 +21,14 @@ class ContactForm extends Model ...@@ -20,14 +21,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 +36,9 @@ class ContactForm extends Model ...@@ -35,9 +36,9 @@ class ContactForm extends Model
*/ */
public function attributeLabels() public function attributeLabels()
{ {
return array( return [
'verifyCode' => 'Verification Code', 'verifyCode' => 'Verification Code',
); ];
} }
/** /**
...@@ -48,13 +49,12 @@ class ContactForm extends Model ...@@ -48,13 +49,12 @@ class ContactForm extends Model
public function contact($email) public function contact($email)
{ {
if ($this->validate()) { if ($this->validate()) {
$name = '=?UTF-8?B?' . base64_encode($this->name) . '?='; Yii::$app->mail->compose()
$subject = '=?UTF-8?B?' . base64_encode($this->subject) . '?='; ->setTo($email)
$headers = "From: $name <{$this->email}>\r\n" . ->setFrom([$this->email => $this->name])
"Reply-To: {$this->email}\r\n" . ->setSubject($this->subject)
"MIME-Version: 1.0\r\n" . ->setTextBody($this->body)
"Content-type: text/plain; charset=UTF-8"; ->send();
mail($email, $subject, $this->body, $headers);
return true; return true;
} else { } else {
return false; return false;
......
...@@ -14,19 +14,21 @@ class LoginForm extends Model ...@@ -14,19 +14,21 @@ class LoginForm extends Model
public $password; public $password;
public $rememberMe = true; public $rememberMe = true;
private $_user = false;
/** /**
* @return array the validation rules. * @return array the validation rules.
*/ */
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'],
); ];
} }
/** /**
...@@ -35,7 +37,7 @@ class LoginForm extends Model ...@@ -35,7 +37,7 @@ class LoginForm extends Model
*/ */
public function validatePassword() public function validatePassword()
{ {
$user = User::findByUsername($this->username); $user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) { if (!$user || !$user->validatePassword($this->password)) {
$this->addError('password', 'Incorrect username or password.'); $this->addError('password', 'Incorrect username or password.');
} }
...@@ -48,11 +50,22 @@ class LoginForm extends Model ...@@ -48,11 +50,22 @@ class LoginForm extends Model
public function login() public function login()
{ {
if ($this->validate()) { if ($this->validate()) {
$user = User::findByUsername($this->username); return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0);
return true;
} else { } else {
return false; return false;
} }
} }
/**
* Finds user by [[username]]
*
* @return User|null
*/
private function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByUsername($this->username);
}
return $this->_user;
}
} }
...@@ -9,31 +9,31 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface ...@@ -9,31 +9,31 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
public $password; public $password;
public $authKey; public $authKey;
private static $users = array( private static $users = [
'100' => array( '100' => [
'id' => '100', 'id' => '100',
'username' => 'admin', 'username' => 'admin',
'password' => 'admin', 'password' => 'admin',
'authKey' => 'test100key', 'authKey' => 'test100key',
), ],
'101' => array( '101' => [
'id' => '101', 'id' => '101',
'username' => 'demo', 'username' => 'demo',
'password' => 'demo', 'password' => 'demo',
'authKey' => 'test101key', 'authKey' => 'test101key',
), ],
); ];
public static function findIdentity($id) public static function findIdentity($id)
{ {
return isset(self::$users[$id]) ? new self(self::$users[$id]) : null; return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
} }
public static function findByUsername($username) public static function findByUsername($username)
{ {
foreach (self::$users as $user) { foreach (self::$users as $user) {
if (strcasecmp($user['username'], $username) === 0) { if (strcasecmp($user['username'], $username) === 0) {
return new self($user); return new static($user);
} }
} }
return null; return null;
......
...@@ -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'),
'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();
This folder contains various tests for the basic application.
These tests are developed with [Codeception PHP Testing Framework](http://codeception.com/).
To run the tests, follow these steps:
1. [Install Codeception](http://codeception.com/quickstart) if you do not have it yet.
2. Create test configuration files based on your environment:
- Copy `acceptance.suite.dist.yml` to `acceptance.suite.yml` and customize it;
- Copy `functional.suite.dist.yml` to `functional.suite.yml` and customize it;
- Copy `unit.suite.dist.yml` to `unit.suite.yml` and customize it.
3. Switch to the parent folder and run tests:
```
cd ..
php codecept.phar build // rebuild test scripts, only need to be run once
php codecept.phar run // run all available tests
```
Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for
more details about writing acceptance, functional and unit tests.
...@@ -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)');
This diff is collapsed.
...@@ -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)');
This diff is collapsed.
<?php <?php
// This class was automatically generated by build task // This class was automatically generated by build task
// You can change it manually, but it will be overwritten on next build // You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile // @codingStandardsIgnoreFile
use Codeception\Maybe;
use \Codeception\Maybe;
use Codeception\Module\CodeHelper; use Codeception\Module\CodeHelper;
/** /**
* Inherited methods * Inherited methods
* @method void execute($callable)
* @method void wantToTest($text) * @method void wantToTest($text)
* @method void wantTo($text) * @method void wantTo($text)
* @method void amTesting($method)
* @method void amTestingMethod($method)
* @method void testMethod($signature)
* @method void expectTo($prediction) * @method void expectTo($prediction)
* @method void expect($prediction) * @method void expect($prediction)
* @method void amGoingTo($argumentation) * @method void amGoingTo($argumentation)
* @method void am($role) * @method void am($role)
* @method void lookForwardTo($role) * @method void lookForwardTo($achieveValue)
* @method void offsetGet($offset)
* @method void offsetSet($offset, $value)
* @method void offsetExists($offset)
* @method void offsetUnset($offset)
*/ */
class CodeGuy extends \Codeception\AbstractGuy class CodeGuy extends \Codeception\AbstractGuy
......
...@@ -3,58 +3,59 @@ use yii\helpers\Html; ...@@ -3,58 +3,59 @@ 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;
/** /**
* @var $this \yii\base\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
app\config\AppAsset::register($this); AppAsset::register($this);
?> ?>
<?php $this->beginPage(); ?> <?php $this->beginPage(); ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="<?= Yii::$app->language ?>">
<head> <head>
<meta charset="<?php echo Yii::$app->charset; ?>"/> <meta charset="<?= Yii::$app->charset ?>"/>
<title><?php echo Html::encode($this->title); ?></title> <title><?= Html::encode($this->title) ?></title>
<?php $this->head(); ?> <?php $this->head(); ?>
</head> </head>
<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 navbar-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( <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
)); ?> ]) ?>
<?php echo $content; ?> <?= $content ?>
</div> </div>
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
<p class="pull-left">&copy; My Company <?php echo date('Y'); ?></p> <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
<p class="pull-right"><?php echo Yii::powered(); ?></p> <p class="pull-right"><?= Yii::powered() ?></p>
</div> </div>
</footer> </footer>
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
*/ */
$this->title = 'About'; $this->title = 'About';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-about"> <div class="site-about">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<p> <p>
This is the About page. You may modify the following file to customize its content: This is the About page. You may modify the following file to customize its content:
</p> </p>
<code><?php echo __FILE__; ?></code> <code><?= __FILE__ ?></code>
</div> </div>
...@@ -4,7 +4,7 @@ use yii\widgets\ActiveForm; ...@@ -4,7 +4,7 @@ use yii\widgets\ActiveForm;
use yii\captcha\Captcha; use yii\captcha\Captcha;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var app\models\ContactForm $model * @var app\models\ContactForm $model
*/ */
...@@ -12,7 +12,7 @@ $this->title = 'Contact'; ...@@ -12,7 +12,7 @@ $this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-contact"> <div class="site-contact">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?> <?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
...@@ -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'); ?> <?= $form->field($model, 'name') ?>
<?php echo $form->field($model, 'email'); ?> <?= $form->field($model, 'email') ?>
<?php echo $form->field($model, 'subject'); ?> <?= $form->field($model, 'subject') ?>
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?> <?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
<?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array( <?= $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')); ?> <?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var string $name * @var string $name
* @var string $message * @var string $message
* @var Exception $exception * @var Exception $exception
...@@ -13,10 +13,10 @@ $this->title = $name; ...@@ -13,10 +13,10 @@ $this->title = $name;
?> ?>
<div class="site-error"> <div class="site-error">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger"> <div class="alert alert-danger">
<?php echo nl2br(Html::encode($message)); ?> <?= nl2br(Html::encode($message)) ?>
</div> </div>
<p> <p>
......
<?php <?php
/** /**
* @var yii\base\View $this * @var yii\web\View $this
*/ */
$this->title = 'My Yii Application'; $this->title = 'My Yii Application';
?> ?>
......
...@@ -3,7 +3,7 @@ use yii\helpers\Html; ...@@ -3,7 +3,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\web\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var app\models\LoginForm $model * @var app\models\LoginForm $model
*/ */
...@@ -11,30 +11,30 @@ $this->title = 'Login'; ...@@ -11,30 +11,30 @@ $this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<div class="site-login"> <div class="site-login">
<h1><?php echo Html::encode($this->title); ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<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'); ?> <?= $form->field($model, 'username') ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?= $form->field($model, 'password')->passwordInput() ?>
<?php echo $form->field($model, 'rememberMe', array( <?= $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')); ?> <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>
</div> </div>
</div> </div>
......
...@@ -18,3 +18,24 @@ body { ...@@ -18,3 +18,24 @@ body {
font-size: 21px; font-size: 21px;
padding: 14px 24px; padding: 14px 24px;
} }
/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
padding-left: 5px;
}
a.asc:after { content: /*"\e113"*/"\e151"; }
a.desc:after { content: /*"\e114"*/"\e152"; }
.sort-numerical a.asc:after { content: "\e153"; }
.sort-numerical a.desc:after { content: "\e154"; }
.sort-ordinal a.asc:after { content: "\e155"; }
.sort-ordinal a.desc:after { content: "\e156"; }
<?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.');
} }
...@@ -10,9 +10,15 @@ defined('YII_ENV') or define('YII_ENV', 'test'); ...@@ -10,9 +10,15 @@ defined('YII_ENV') or define('YII_ENV', 'test');
require_once(__DIR__ . '/../vendor/autoload.php'); require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php'); require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/../vendor/composer/autoload_namespaces.php'));
$config = require(__DIR__ . '/../config/web-test.php'); $config = require(__DIR__ . '/../config/web-test.php');
$application = new yii\web\Application($config); if (isset($this)) {
$application->run(); // run in functional tests
$config['class'] = 'yii\web\Application';
return $config;
} else {
// run in acceptance tests
$application = new yii\web\Application($config);
$application->run();
}
...@@ -6,7 +6,6 @@ defined('YII_ENV') or define('YII_ENV', 'dev'); ...@@ -6,7 +6,6 @@ defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/../vendor/composer/autoload_namespaces.php'));
$config = require(__DIR__ . '/../config/web.php'); $config = require(__DIR__ . '/../config/web.php');
......
...@@ -15,7 +15,6 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); ...@@ -15,7 +15,6 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php');
Yii::importNamespaces(require(__DIR__ . '/vendor/composer/autoload_namespaces.php'));
$config = require(__DIR__ . '/config/console.php'); $config = require(__DIR__ . '/config/console.php');
......
The Yii framework is free software. It is released under the terms of The Yii framework is free software. It is released under the terms of
the following BSD License. the following BSD License.
Copyright © 2008-2013 by Yii Software LLC (http://www.yiisoft.com) Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ...@@ -29,4 +29,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
...@@ -27,7 +27,7 @@ DIRECTORY STRUCTURE ...@@ -27,7 +27,7 @@ DIRECTORY STRUCTURE
REQUIREMENTS REQUIREMENTS
------------ ------------
The minimum requirement by Yii is that your Web server supports PHP 5.3.?. The minimum requirement by Yii is that your Web server supports PHP 5.4.0.
INSTALLATION INSTALLATION
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.4.0",
"yiisoft/yii2": "dev-master" "yiisoft/yii2": "dev-master"
} }
} }
...@@ -4,15 +4,15 @@ defined('YII_DEBUG') or define('YII_DEBUG', false); ...@@ -4,15 +4,15 @@ defined('YII_DEBUG') or define('YII_DEBUG', false);
require(__DIR__ . '/protected/vendor/yiisoft/yii2/yii/Yii.php'); require(__DIR__ . '/protected/vendor/yiisoft/yii2/yii/Yii.php');
$config = array( $config = [
'id' => 'benchmark', 'id' => 'benchmark',
'basePath' => __DIR__ . '/protected', 'basePath' => __DIR__ . '/protected',
'components' => array( 'components' => [
'urlManager' => array( 'urlManager' => [
'enablePrettyUrl' => true, 'enablePrettyUrl' => true,
), ],
) ],
); ];
$application = new yii\web\Application($config); $application = new yii\web\Application($config);
$application->run(); $application->run();
...@@ -13,9 +13,9 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); ...@@ -13,9 +13,9 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/../framework/yii/Yii.php'); require(__DIR__ . '/../framework/yii/Yii.php');
$application = new yii\console\Application(array( $application = new yii\console\Application([
'id' => 'yii-build', 'id' => 'yii-build',
'basePath' => __DIR__, 'basePath' => __DIR__,
'controllerNamespace' => 'yii\build\controllers', 'controllerNamespace' => 'yii\build\controllers',
)); ]);
$application->run(); $application->run();
...@@ -265,7 +265,7 @@ Please update yiisite/common/data/versions.php file with the following code: ...@@ -265,7 +265,7 @@ Please update yiisite/common/data/versions.php file with the following code:
where &lt;target name&gt; can be one of the following: where &lt;target name&gt; can be one of the following:
- sync : synchronize yiilite.php and YiiBase.php - sync : synchronize yiilite.php and BaseYii.php
- message : extract i18n messages of the framework - message : extract i18n messages of the framework
- src : build source release - src : build source release
- doc : build documentation release (Windows only) - doc : build documentation release (Windows only)
......
...@@ -32,7 +32,7 @@ class ClassmapController extends Controller ...@@ -32,7 +32,7 @@ class ClassmapController extends Controller
if ($mapFile === null) { if ($mapFile === null) {
$mapFile = YII_PATH . '/classes.php'; $mapFile = YII_PATH . '/classes.php';
} }
$options = array( $options = [
'filter' => function ($path) { 'filter' => function ($path) {
if (is_file($path)) { if (is_file($path)) {
$file = basename($path); $file = basename($path);
...@@ -42,18 +42,15 @@ class ClassmapController extends Controller ...@@ -42,18 +42,15 @@ class ClassmapController extends Controller
} }
return null; return null;
}, },
'only' => array('.php'), 'only' => ['.php'],
'except' => array( 'except' => [
'Yii.php', 'Yii.php',
'YiiBase.php', 'BaseYii.php',
'/debug/',
'/console/', '/console/',
'/test/', ],
'/gii/', ];
),
);
$files = FileHelper::findFiles($root, $options); $files = FileHelper::findFiles($root, $options);
$map = array(); $map = [];
foreach ($files as $file) { foreach ($files as $file) {
if (($pos = strpos($file, $root)) !== 0) { if (($pos = strpos($file, $root)) !== 0) {
die("Something wrong: $file\n"); die("Something wrong: $file\n");
...@@ -76,9 +73,9 @@ class ClassmapController extends Controller ...@@ -76,9 +73,9 @@ class ClassmapController extends Controller
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
return array( return [
$map $map
); ];
EOD; EOD;
if (is_file($mapFile) && file_get_contents($mapFile) === $output) { if (is_file($mapFile) && file_get_contents($mapFile) === $output) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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