소스 검색

Reformat code te be PSR-2 compatible

SonicGD 12 년 전
부모
커밋
93cc82c4bf

+ 11 - 11
assets/AppAsset.php

@@ -15,15 +15,15 @@ use yii\web\AssetBundle;
  */
 class AppAsset extends AssetBundle
 {
-	public $basePath = '@webroot';
-	public $baseUrl = '@web';
-	public $css = [
-		'css/site.css',
-	];
-	public $js = [
-	];
-	public $depends = [
-		'yii\web\YiiAsset',
-		'yii\bootstrap\BootstrapAsset',
-	];
+    public $basePath = '@webroot';
+    public $baseUrl = '@web';
+    public $css = [
+        'css/site.css',
+    ];
+    public $js = [
+    ];
+    public $depends = [
+        'yii\web\YiiAsset',
+        'yii\bootstrap\BootstrapAsset',
+    ];
 }

+ 8 - 8
commands/HelloController.php

@@ -19,12 +19,12 @@ use yii\console\Controller;
  */
 class HelloController extends Controller
 {
-	/**
-	 * This command echoes what you have entered as the message.
-	 * @param string $message the message to be echoed.
-	 */
-	public function actionIndex($message = 'hello world')
-	{
-		echo $message . "\n";
-	}
+    /**
+     * This command echoes what you have entered as the message.
+     * @param string $message the message to be echoed.
+     */
+    public function actionIndex($message = 'hello world')
+    {
+        echo $message . "\n";
+    }
 }

+ 20 - 20
config/console.php

@@ -6,24 +6,24 @@ $params = require(__DIR__ . '/params.php');
 $db = require(__DIR__ . '/db.php');
 
 return [
-	'id' => 'basic-console',
-	'basePath' => dirname(__DIR__),
-	'preload' => ['log'],
-	'controllerNamespace' => 'app\commands',
-	'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
-	'components' => [
-		'cache' => [
-			'class' => 'yii\caching\FileCache',
-		],
-		'log' => [
-			'targets' => [
-				[
-					'class' => 'yii\log\FileTarget',
-					'levels' => ['error', 'warning'],
-				],
-			],
-		],
-		'db' => $db,
-	],
-	'params' => $params,
+    'id' => 'basic-console',
+    'basePath' => dirname(__DIR__),
+    'preload' => ['log'],
+    'controllerNamespace' => 'app\commands',
+    'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
+    'components' => [
+        'cache' => [
+            'class' => 'yii\caching\FileCache',
+        ],
+        'log' => [
+            'targets' => [
+                [
+                    'class' => 'yii\log\FileTarget',
+                    'levels' => ['error', 'warning'],
+                ],
+            ],
+        ],
+        'db' => $db,
+    ],
+    'params' => $params,
 ];

+ 5 - 5
config/db.php

@@ -1,9 +1,9 @@
 <?php
 
 return [
-	'class' => 'yii\db\Connection',
-	'dsn' => 'mysql:host=localhost;dbname=yii2basic',
-	'username' => 'root',
-	'password' => '',
-	'charset' => 'utf8',
+    'class' => 'yii\db\Connection',
+    'dsn' => 'mysql:host=localhost;dbname=yii2basic',
+    'username' => 'root',
+    'password' => '',
+    'charset' => 'utf8',
 ];

+ 1 - 1
config/params.php

@@ -1,5 +1,5 @@
 <?php
 
 return [
-	'adminEmail' => 'admin@example.com',
+    'adminEmail' => 'admin@example.com',
 ];

+ 34 - 34
config/web.php

@@ -4,43 +4,43 @@ $params = require(__DIR__ . '/params.php');
 $db = require(__DIR__ . '/db.php');
 
 $config = [
-	'id' => 'basic',
-	'basePath' => dirname(__DIR__),
-	'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
-	'components' => [
-		'cache' => [
-			'class' => 'yii\caching\FileCache',
-		],
-		'user' => [
-			'identityClass' => 'app\models\User',
-			'enableAutoLogin' => true,
-		],
-		'errorHandler' => [
-			'errorAction' => 'site/error',
-		],
-		'mail' => [
-			'class' => 'yii\swiftmailer\Mailer',
-			'useFileTransport' => true,
-		],
-		'log' => [
-			'traceLevel' => YII_DEBUG ? 3 : 0,
-			'targets' => [
-				[
-					'class' => 'yii\log\FileTarget',
-					'levels' => ['error', 'warning'],
-				],
-			],
-		],
-		'db' => $db,
-	],
-	'params' => $params,
+    'id' => 'basic',
+    'basePath' => dirname(__DIR__),
+    'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
+    'components' => [
+        'cache' => [
+            'class' => 'yii\caching\FileCache',
+        ],
+        'user' => [
+            'identityClass' => 'app\models\User',
+            'enableAutoLogin' => true,
+        ],
+        'errorHandler' => [
+            'errorAction' => 'site/error',
+        ],
+        'mail' => [
+            'class' => 'yii\swiftmailer\Mailer',
+            'useFileTransport' => true,
+        ],
+        'log' => [
+            'traceLevel' => YII_DEBUG ? 3 : 0,
+            'targets' => [
+                [
+                    'class' => 'yii\log\FileTarget',
+                    'levels' => ['error', 'warning'],
+                ],
+            ],
+        ],
+        'db' => $db,
+    ],
+    'params' => $params,
 ];
 
 if (YII_ENV_DEV) {
-	// configuration adjustments for 'dev' environment
-	$config['preload'][] = 'debug';
-	$config['modules']['debug'] = 'yii\debug\Module';
-	$config['modules']['gii'] = 'yii\gii\Module';
+    // configuration adjustments for 'dev' environment
+    $config['preload'][] = 'debug';
+    $config['modules']['debug'] = 'yii\debug\Module';
+    $config['modules']['gii'] = 'yii\gii\Module';
 }
 
 return $config;

+ 75 - 73
controllers/SiteController.php

@@ -11,84 +11,86 @@ use app\models\ContactForm;
 
 class SiteController extends Controller
 {
-	public function behaviors()
-	{
-		return [
-			'access' => [
-				'class' => AccessControl::className(),
-				'only' => ['logout'],
-				'rules' => [
-					[
-						'actions' => ['logout'],
-						'allow' => true,
-						'roles' => ['@'],
-					],
-				],
-			],
-			'verbs' => [
-				'class' => VerbFilter::className(),
-				'actions' => [
-					'logout' => ['post'],
-				],
-			],
-		];
-	}
+    public function behaviors()
+    {
+        return [
+            'access' => [
+                'class' => AccessControl::className(),
+                'only' => ['logout'],
+                'rules' => [
+                    [
+                        'actions' => ['logout'],
+                        'allow' => true,
+                        'roles' => ['@'],
+                    ],
+                ],
+            ],
+            'verbs' => [
+                'class' => VerbFilter::className(),
+                'actions' => [
+                    'logout' => ['post'],
+                ],
+            ],
+        ];
+    }
 
-	public function actions()
-	{
-		return [
-			'error' => [
-				'class' => 'yii\web\ErrorAction',
-			],
-			'captcha' => [
-				'class' => 'yii\captcha\CaptchaAction',
-				'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
-			],
-		];
-	}
+    public function actions()
+    {
+        return [
+            'error' => [
+                'class' => 'yii\web\ErrorAction',
+            ],
+            'captcha' => [
+                'class' => 'yii\captcha\CaptchaAction',
+                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
+            ],
+        ];
+    }
 
-	public function actionIndex()
-	{
-		return $this->render('index');
-	}
+    public function actionIndex()
+    {
+        return $this->render('index');
+    }
 
-	public function actionLogin()
-	{
-		if (!\Yii::$app->user->isGuest) {
-			return $this->goHome();
-		}
+    public function actionLogin()
+    {
+        if (!\Yii::$app->user->isGuest) {
+            return $this->goHome();
+        }
 
-		$model = new LoginForm();
-		if ($model->load(Yii::$app->request->post()) && $model->login()) {
-			return $this->goBack();
-		} else {
-			return $this->render('login', [
-				'model' => $model,
-			]);
-		}
-	}
+        $model = new LoginForm();
+        if ($model->load(Yii::$app->request->post()) && $model->login()) {
+            return $this->goBack();
+        } else {
+            return $this->render('login', [
+                'model' => $model,
+            ]);
+        }
+    }
 
-	public function actionLogout()
-	{
-		Yii::$app->user->logout();
-		return $this->goHome();
-	}
+    public function actionLogout()
+    {
+        Yii::$app->user->logout();
 
-	public function actionContact()
-	{
-		$model = new ContactForm();
-		if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
-			Yii::$app->session->setFlash('contactFormSubmitted');
-			return $this->refresh();
-		} else {
-			return $this->render('contact', [
-				'model' => $model,
-			]);
-		}
-	}
+        return $this->goHome();
+    }
 
-	public function actionAbout()
-	{
-		return $this->render('about');
-	}
+    public function actionContact()
+    {
+        $model = new ContactForm();
+        if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
+            Yii::$app->session->setFlash('contactFormSubmitted');
+
+            return $this->refresh();
+        } else {
+            return $this->render('contact', [
+                'model' => $model,
+            ]);
+        }
+    }
+
+    public function actionAbout()
+    {
+        return $this->render('about');
+    }
 }

+ 7 - 7
mail/layouts/html.php

@@ -10,14 +10,14 @@ use yii\helpers\Html;
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
-	<title><?= Html::encode($this->title) ?></title>
-	<?php $this->head() ?>
+    <meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
+    <title><?= Html::encode($this->title) ?></title>
+    <?php $this->head() ?>
 </head>
 <body>
-	<?php $this->beginBody() ?>
-	<?= $content ?>
-	<?php $this->endBody() ?>
+    <?php $this->beginBody() ?>
+    <?= $content ?>
+    <?php $this->endBody() ?>
 </body>
 </html>
-<?php $this->endPage() ?>
+<?php $this->endPage() ?>

+ 48 - 47
models/ContactForm.php

@@ -10,54 +10,55 @@ use yii\base\Model;
  */
 class ContactForm extends Model
 {
-	public $name;
-	public $email;
-	public $subject;
-	public $body;
-	public $verifyCode;
+    public $name;
+    public $email;
+    public $subject;
+    public $body;
+    public $verifyCode;
 
-	/**
-	 * @return array the validation rules.
-	 */
-	public function rules()
-	{
-		return [
-			// name, email, subject and body are required
-			[['name', 'email', 'subject', 'body'], 'required'],
-			// email has to be a valid email address
-			['email', 'email'],
-			// verifyCode needs to be entered correctly
-			['verifyCode', 'captcha'],
-		];
-	}
+    /**
+     * @return array the validation rules.
+     */
+    public function rules()
+    {
+        return [
+            // name, email, subject and body are required
+            [['name', 'email', 'subject', 'body'], 'required'],
+            // email has to be a valid email address
+            ['email', 'email'],
+            // verifyCode needs to be entered correctly
+            ['verifyCode', 'captcha'],
+        ];
+    }
 
-	/**
-	 * @return array customized attribute labels
-	 */
-	public function attributeLabels()
-	{
-		return [
-			'verifyCode' => 'Verification Code',
-		];
-	}
+    /**
+     * @return array customized attribute labels
+     */
+    public function attributeLabels()
+    {
+        return [
+            'verifyCode' => 'Verification Code',
+        ];
+    }
 
-	/**
-	 * Sends an email to the specified email address using the information collected by this model.
-	 * @param string $email the target email address
-	 * @return boolean whether the model passes validation
-	 */
-	public function contact($email)
-	{
-		if ($this->validate()) {
-			Yii::$app->mail->compose()
-				->setTo($email)
-				->setFrom([$this->email => $this->name])
-				->setSubject($this->subject)
-				->setTextBody($this->body)
-				->send();
-			return true;
-		} else {
-			return false;
-		}
-	}
+    /**
+     * Sends an email to the specified email address using the information collected by this model.
+     * @param  string  $email the target email address
+     * @return boolean whether the model passes validation
+     */
+    public function contact($email)
+    {
+        if ($this->validate()) {
+            Yii::$app->mail->compose()
+                ->setTo($email)
+                ->setFrom([$this->email => $this->name])
+                ->setSubject($this->subject)
+                ->setTextBody($this->body)
+                ->send();
+
+            return true;
+        } else {
+            return false;
+        }
+    }
 }

+ 56 - 55
models/LoginForm.php

@@ -10,65 +10,66 @@ use yii\base\Model;
  */
 class LoginForm extends Model
 {
-	public $username;
-	public $password;
-	public $rememberMe = true;
+    public $username;
+    public $password;
+    public $rememberMe = true;
 
-	private $_user = false;
+    private $_user = false;
 
-	/**
-	 * @return array the validation rules.
-	 */
-	public function rules()
-	{
-		return [
-			// username and password are both required
-			[['username', 'password'], 'required'],
-			// rememberMe must be a boolean value
-			['rememberMe', 'boolean'],
-			// password is validated by validatePassword()
-			['password', 'validatePassword'],
-		];
-	}
+    /**
+     * @return array the validation rules.
+     */
+    public function rules()
+    {
+        return [
+            // username and password are both required
+            [['username', 'password'], 'required'],
+            // rememberMe must be a boolean value
+            ['rememberMe', 'boolean'],
+            // password is validated by validatePassword()
+            ['password', 'validatePassword'],
+        ];
+    }
 
-	/**
-	 * Validates the password.
-	 * This method serves as the inline validation for password.
-	 */
-	public function validatePassword()
-	{
-		if (!$this->hasErrors()) {
-			$user = $this->getUser();
+    /**
+     * Validates the password.
+     * This method serves as the inline validation for password.
+     */
+    public function validatePassword()
+    {
+        if (!$this->hasErrors()) {
+            $user = $this->getUser();
 
-			if (!$user || !$user->validatePassword($this->password)) {
-				$this->addError('password', 'Incorrect username or password.');
-			}
-		}
-	}
+            if (!$user || !$user->validatePassword($this->password)) {
+                $this->addError('password', 'Incorrect username or password.');
+            }
+        }
+    }
 
-	/**
-	 * Logs in a user using the provided username and password.
-	 * @return boolean whether the user is logged in successfully
-	 */
-	public function login()
-	{
-		if ($this->validate()) {
-			return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
-		} else {
-			return false;
-		}
-	}
+    /**
+     * Logs in a user using the provided username and password.
+     * @return boolean whether the user is logged in successfully
+     */
+    public function login()
+    {
+        if ($this->validate()) {
+            return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
+        } else {
+            return false;
+        }
+    }
 
-	/**
-	 * Finds user by [[username]]
-	 *
-	 * @return User|null
-	 */
-	public function getUser()
-	{
-		if ($this->_user === false) {
-			$this->_user = User::findByUsername($this->username);
-		}
-		return $this->_user;
-	}
+    /**
+     * Finds user by [[username]]
+     *
+     * @return User|null
+     */
+    public function getUser()
+    {
+        if ($this->_user === false) {
+            $this->_user = User::findByUsername($this->username);
+        }
+
+        return $this->_user;
+    }
 }

+ 88 - 86
models/User.php

@@ -4,98 +4,100 @@ namespace app\models;
 
 class User extends \yii\base\Object implements \yii\web\IdentityInterface
 {
-	public $id;
-	public $username;
-	public $password;
-	public $authKey;
-	public $accessToken;
+    public $id;
+    public $username;
+    public $password;
+    public $authKey;
+    public $accessToken;
 
-	private static $users = [
-		'100' => [
-			'id' => '100',
-			'username' => 'admin',
-			'password' => 'admin',
-			'authKey' => 'test100key',
-			'accessToken' => '100-token',
-		],
-		'101' => [
-			'id' => '101',
-			'username' => 'demo',
-			'password' => 'demo',
-			'authKey' => 'test101key',
-			'accessToken' => '101-token',
-		],
-	];
+    private static $users = [
+        '100' => [
+            'id' => '100',
+            'username' => 'admin',
+            'password' => 'admin',
+            'authKey' => 'test100key',
+            'accessToken' => '100-token',
+        ],
+        '101' => [
+            'id' => '101',
+            'username' => 'demo',
+            'password' => 'demo',
+            'authKey' => 'test101key',
+            'accessToken' => '101-token',
+        ],
+    ];
 
-	/**
-	 * @inheritdoc
-	 */
-	public static function findIdentity($id)
-	{
-		return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
-	}
+    /**
+     * @inheritdoc
+     */
+    public static function findIdentity($id)
+    {
+        return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
+    }
 
-	/**
-	 * @inheritdoc
-	 */
-	public static function findIdentityByAccessToken($token)
-	{
-		foreach (self::$users as $user) {
-			if ($user['accessToken'] === $token) {
-				return new static($user);
-			}
-		}
-		return null;
-	}
+    /**
+     * @inheritdoc
+     */
+    public static function findIdentityByAccessToken($token)
+    {
+        foreach (self::$users as $user) {
+            if ($user['accessToken'] === $token) {
+                return new static($user);
+            }
+        }
 
-	/**
-	 * Finds user by username
-	 *
-	 * @param string $username
-	 * @return static|null
-	 */
-	public static function findByUsername($username)
-	{
-		foreach (self::$users as $user) {
-			if (strcasecmp($user['username'], $username) === 0) {
-				return new static($user);
-			}
-		}
-		return null;
-	}
+        return null;
+    }
 
-	/**
-	 * @inheritdoc
-	 */
-	public function getId()
-	{
-		return $this->id;
-	}
+    /**
+     * Finds user by username
+     *
+     * @param  string      $username
+     * @return static|null
+     */
+    public static function findByUsername($username)
+    {
+        foreach (self::$users as $user) {
+            if (strcasecmp($user['username'], $username) === 0) {
+                return new static($user);
+            }
+        }
 
-	/**
-	 * @inheritdoc
-	 */
-	public function getAuthKey()
-	{
-		return $this->authKey;
-	}
+        return null;
+    }
 
-	/**
-	 * @inheritdoc
-	 */
-	public function validateAuthKey($authKey)
-	{
-		return $this->authKey === $authKey;
-	}
+    /**
+     * @inheritdoc
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
 
-	/**
-	 * Validates password
-	 *
-	 * @param string $password password to validate
-	 * @return boolean if password provided is valid for current user
-	 */
-	public function validatePassword($password)
-	{
-		return $this->password === $password;
-	}
+    /**
+     * @inheritdoc
+     */
+    public function getAuthKey()
+    {
+        return $this->authKey;
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function validateAuthKey($authKey)
+    {
+        return $this->authKey === $authKey;
+    }
+
+    /**
+     * Validates password
+     *
+     * @param  string  $password password to validate
+     * @return boolean if password provided is valid for current user
+     */
+    public function validatePassword($password)
+    {
+        return $this->password === $password;
+    }
 }

+ 83 - 83
requirements.php

@@ -14,10 +14,10 @@
 $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
 
 if (!is_dir($frameworkPath)) {
-	echo '<h1>Error</h1>';
-	echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
-	echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
-	echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
+    echo '<h1>Error</h1>';
+    echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
+    echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
+    echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
 }
 
 require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
@@ -27,84 +27,84 @@ $requirementsChecker = new YiiRequirementChecker();
  * Adjust requirements according to your application specifics.
  */
 $requirements = array(
-	// Database :
-	array(
-		'name' => 'PDO extension',
-		'mandatory' => true,
-		'condition' => extension_loaded('pdo'),
-		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
-	),
-	array(
-		'name' => 'PDO SQLite extension',
-		'mandatory' => false,
-		'condition' => extension_loaded('pdo_sqlite'),
-		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
-		'memo' => 'Required for SQLite database.',
-	),
-	array(
-		'name' => 'PDO MySQL extension',
-		'mandatory' => false,
-		'condition' => extension_loaded('pdo_mysql'),
-		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
-		'memo' => 'Required for MySQL database.',
-	),
-	array(
-		'name' => 'PDO PostgreSQL extension',
-		'mandatory' => false,
-		'condition' => extension_loaded('pdo_pgsql'),
-		'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
-		'memo' => 'Required for PostgreSQL database.',
-	),
-	// Cache :
-	array(
-		'name' => 'Memcache extension',
-		'mandatory' => false,
-		'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
-		'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>.' : ''
-	),
-	array(
-		'name' => 'APC extension',
-		'mandatory' => false,
-		'condition' => extension_loaded('apc'),
-		'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
-	),
-	// Additional PHP extensions :
-	array(
-		'name' => 'Mcrypt extension',
-		'mandatory' => false,
-		'condition' => extension_loaded('mcrypt'),
-		'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
-		'memo' => 'Required by encrypt and decrypt methods.'
-	),
-	// PHP ini :
-	'phpSafeMode' => array(
-		'name' => 'PHP safe mode',
-		'mandatory' => false,
-		'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
-		'by' => 'File uploading and console command execution',
-		'memo' => '"safe_mode" should be disabled at php.ini',
-	),
-	'phpExposePhp' => array(
-		'name' => 'Expose PHP',
-		'mandatory' => false,
-		'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
-		'by' => 'Security reasons',
-		'memo' => '"expose_php" should be disabled at php.ini',
-	),
-	'phpAllowUrlInclude' => array(
-		'name' => 'PHP allow url include',
-		'mandatory' => false,
-		'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
-		'by' => 'Security reasons',
-		'memo' => '"allow_url_include" should be disabled at php.ini',
-	),
-	'phpSmtp' => array(
-		'name' => 'PHP mail SMTP',
-		'mandatory' => false,
-		'condition' => strlen(ini_get('SMTP'))>0,
-		'by' => 'Email sending',
-		'memo' => 'PHP mail SMTP server required',
-	),
+    // Database :
+    array(
+        'name' => 'PDO extension',
+        'mandatory' => true,
+        'condition' => extension_loaded('pdo'),
+        'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
+    ),
+    array(
+        'name' => 'PDO SQLite extension',
+        'mandatory' => false,
+        'condition' => extension_loaded('pdo_sqlite'),
+        'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
+        'memo' => 'Required for SQLite database.',
+    ),
+    array(
+        'name' => 'PDO MySQL extension',
+        'mandatory' => false,
+        'condition' => extension_loaded('pdo_mysql'),
+        'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
+        'memo' => 'Required for MySQL database.',
+    ),
+    array(
+        'name' => 'PDO PostgreSQL extension',
+        'mandatory' => false,
+        'condition' => extension_loaded('pdo_pgsql'),
+        'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>',
+        'memo' => 'Required for PostgreSQL database.',
+    ),
+    // Cache :
+    array(
+        'name' => 'Memcache extension',
+        'mandatory' => false,
+        'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
+        '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>.' : ''
+    ),
+    array(
+        'name' => 'APC extension',
+        'mandatory' => false,
+        'condition' => extension_loaded('apc'),
+        'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
+    ),
+    // Additional PHP extensions :
+    array(
+        'name' => 'Mcrypt extension',
+        'mandatory' => false,
+        'condition' => extension_loaded('mcrypt'),
+        'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
+        'memo' => 'Required by encrypt and decrypt methods.'
+    ),
+    // PHP ini :
+    'phpSafeMode' => array(
+        'name' => 'PHP safe mode',
+        'mandatory' => false,
+        'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
+        'by' => 'File uploading and console command execution',
+        'memo' => '"safe_mode" should be disabled at php.ini',
+    ),
+    'phpExposePhp' => array(
+        'name' => 'Expose PHP',
+        'mandatory' => false,
+        'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
+        'by' => 'Security reasons',
+        'memo' => '"expose_php" should be disabled at php.ini',
+    ),
+    'phpAllowUrlInclude' => array(
+        'name' => 'PHP allow url include',
+        'mandatory' => false,
+        'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
+        'by' => 'Security reasons',
+        'memo' => '"allow_url_include" should be disabled at php.ini',
+    ),
+    'phpSmtp' => array(
+        'name' => 'PHP mail SMTP',
+        'mandatory' => false,
+        'condition' => strlen(ini_get('SMTP'))>0,
+        'by' => 'Email sending',
+        'memo' => 'PHP mail SMTP server required',
+    ),
 );
 $requirementsChecker->checkYii()->check($requirements)->render();

+ 8 - 8
tests/_config.php

@@ -3,12 +3,12 @@
  * application configurations shared by all test types
  */
 return [
-	'components' => [
-		'mail' => [
-			'useFileTransport' => true,
-		],
-		'urlManager' => [
-			'showScriptName' => true,
-		],
-	],
+    'components' => [
+        'mail' => [
+            'useFileTransport' => true,
+        ],
+        'urlManager' => [
+            'showScriptName' => true,
+        ],
+    ],
 ];

+ 1 - 1
tests/_helpers/CodeHelper.php

@@ -3,5 +3,5 @@ namespace Codeception\Module;
 
 class CodeHelper extends \Codeception\Module
 {
-	// here you can define custom methods for CodeGuy
+    // here you can define custom methods for CodeGuy
 }

+ 1 - 1
tests/_helpers/TestHelper.php

@@ -3,5 +3,5 @@ namespace Codeception\Module;
 
 class TestHelper extends \Codeception\Module
 {
-	// here you can define custom methods for TestGuy
+    // here you can define custom methods for TestGuy
 }

+ 1 - 1
tests/_helpers/WebHelper.php

@@ -3,5 +3,5 @@ namespace Codeception\Module;
 
 class WebHelper extends \Codeception\Module
 {
-	// here you can define custom methods for WebGuy
+    // here you can define custom methods for WebGuy
 }

+ 1 - 1
tests/_pages/AboutPage.php

@@ -6,5 +6,5 @@ use yii\codeception\BasePage;
 
 class AboutPage extends BasePage
 {
-	public $route = 'site/about';
+    public $route = 'site/about';
 }

+ 12 - 12
tests/_pages/ContactPage.php

@@ -6,17 +6,17 @@ use yii\codeception\BasePage;
 
 class ContactPage extends BasePage
 {
-	public $route = 'site/contact';
+    public $route = 'site/contact';
 
-	/**
-	 * @param array $contactData
-	 */
-	public function submit(array $contactData)
-	{
-		foreach ($contactData as $field => $value) {
-			$inputType = $field === 'body' ? 'textarea' : 'input';
-			$this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
-		}
-		$this->guy->click('contact-button');
-	}
+    /**
+     * @param array $contactData
+     */
+    public function submit(array $contactData)
+    {
+        foreach ($contactData as $field => $value) {
+            $inputType = $field === 'body' ? 'textarea' : 'input';
+            $this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
+        }
+        $this->guy->click('contact-button');
+    }
 }

+ 11 - 11
tests/_pages/LoginPage.php

@@ -6,16 +6,16 @@ use yii\codeception\BasePage;
 
 class LoginPage extends BasePage
 {
-	public $route = 'site/login';
+    public $route = 'site/login';
 
-	/**
-	 * @param string $username
-	 * @param string $password
-	 */
-	public function login($username, $password)
-	{
-		$this->guy->fillField('input[name="LoginForm[username]"]', $username);
-		$this->guy->fillField('input[name="LoginForm[password]"]', $password);
-		$this->guy->click('login-button');
-	}
+    /**
+     * @param string $username
+     * @param string $password
+     */
+    public function login($username, $password)
+    {
+        $this->guy->fillField('input[name="LoginForm[username]"]', $username);
+        $this->guy->fillField('input[name="LoginForm[password]"]', $password);
+        $this->guy->click('login-button');
+    }
 }

+ 1 - 1
tests/acceptance.suite.yml

@@ -15,7 +15,7 @@ modules:
         - PhpBrowser
 # you can use WebDriver instead of PhpBrowser to test javascript and ajax.
 # This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
-# "restart" option is used by the WebDriver to start each time per test-file new session and cookies, 
+# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
 # it is useful if you want to login in your app in each test.
 #        - WebDriver
     config:

+ 11 - 11
tests/acceptance/ContactCept.php

@@ -21,11 +21,11 @@ $I->see('The verification code is incorrect');
 
 $I->amGoingTo('submit contact form with not correct email');
 $contactPage->submit([
-	'name'			=>	'tester',
-	'email'			=>	'tester.email',
-	'subject'		=>	'test subject',
-	'body'			=>	'test content',
-	'verifyCode'	=>	'testme',
+    'name'			=>	'tester',
+    'email'			=>	'tester.email',
+    'subject'		=>	'test subject',
+    'body'			=>	'test content',
+    'verifyCode'	=>	'testme',
 ]);
 $I->expectTo('see that email adress is wrong');
 $I->dontSee('Name cannot be blank', '.help-inline');
@@ -36,14 +36,14 @@ $I->dontSee('The verification code is incorrect', '.help-inline');
 
 $I->amGoingTo('submit contact form with correct data');
 $contactPage->submit([
-	'name'			=>	'tester',
-	'email'			=>	'tester@example.com',
-	'subject'		=>	'test subject',
-	'body'			=>	'test content',
-	'verifyCode'	=>	'testme',
+    'name'			=>	'tester',
+    'email'			=>	'tester@example.com',
+    'subject'		=>	'test subject',
+    'body'			=>	'test content',
+    'verifyCode'	=>	'testme',
 ]);
 if (method_exists($I, 'wait')) {
-	$I->wait(3); // only for selenium
+    $I->wait(3); // only for selenium
 }
 $I->dontSeeElement('#contact-form');
 $I->see('Thank you for contacting us. We will respond to you as soon as possible.');

+ 1 - 1
tests/acceptance/LoginCept.php

@@ -23,7 +23,7 @@ $I->see('Incorrect username or password.');
 $I->amGoingTo('try to login with correct credentials');
 $loginPage->login('admin', 'admin');
 if (method_exists($I, 'wait')) {
-	$I->wait(3); // only for selenium
+    $I->wait(3); // only for selenium
 }
 $I->expectTo('see user info');
 $I->see('Logout (admin)');

+ 9 - 9
tests/acceptance/_config.php

@@ -1,13 +1,13 @@
 <?php
 
 return yii\helpers\ArrayHelper::merge(
-	require(__DIR__ . '/../../config/web.php'),
-	require(__DIR__ . '/../_config.php'),
-	[
-		'components' => [
-			'db' => [
-				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
-			],
-		],
-	]
+    require(__DIR__ . '/../../config/web.php'),
+    require(__DIR__ . '/../_config.php'),
+    [
+        'components' => [
+            'db' => [
+                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
+            ],
+        ],
+    ]
 );

+ 9 - 9
tests/acceptance/_console.php

@@ -1,13 +1,13 @@
 <?php
 
 return yii\helpers\ArrayHelper::merge(
-	require(__DIR__ . '/../../config/console.php'),
-	require(__DIR__ . '/../_config.php'),
-	[
-		'components' => [
-			'db' => [
-				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
-			],
-		],
-	]
+    require(__DIR__ . '/../../config/console.php'),
+    require(__DIR__ . '/../_config.php'),
+    [
+        'components' => [
+            'db' => [
+                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
+            ],
+        ],
+    ]
 );

+ 10 - 10
tests/functional/ContactCept.php

@@ -21,11 +21,11 @@ $I->see('The verification code is incorrect');
 
 $I->amGoingTo('submit contact form with not correct email');
 $contactPage->submit([
-	'name'			=>	'tester',
-	'email'			=>	'tester.email',
-	'subject'		=>	'test subject',
-	'body'			=>	'test content',
-	'verifyCode'	=>	'testme',
+    'name'			=>	'tester',
+    'email'			=>	'tester.email',
+    'subject'		=>	'test subject',
+    'body'			=>	'test content',
+    'verifyCode'	=>	'testme',
 ]);
 $I->expectTo('see that email adress is wrong');
 $I->dontSee('Name cannot be blank', '.help-inline');
@@ -36,11 +36,11 @@ $I->dontSee('The verification code is incorrect', '.help-inline');
 
 $I->amGoingTo('submit contact form with correct data');
 $contactPage->submit([
-	'name'			=>	'tester',
-	'email'			=>	'tester@example.com',
-	'subject'		=>	'test subject',
-	'body'			=>	'test content',
-	'verifyCode'	=>	'testme',
+    'name'			=>	'tester',
+    'email'			=>	'tester@example.com',
+    'subject'		=>	'test subject',
+    'body'			=>	'test content',
+    'verifyCode'	=>	'testme',
 ]);
 $I->dontSeeElement('#contact-form');
 $I->see('Thank you for contacting us. We will respond to you as soon as possible.');

+ 9 - 9
tests/functional/_config.php

@@ -5,13 +5,13 @@ $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
 $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
 
 return yii\helpers\ArrayHelper::merge(
-	require(__DIR__ . '/../../config/web.php'),
-	require(__DIR__ . '/../_config.php'),
-	[
-		'components' => [
-			'db' => [
-				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
-			],
-		],
-	]
+    require(__DIR__ . '/../../config/web.php'),
+    require(__DIR__ . '/../_config.php'),
+    [
+        'components' => [
+            'db' => [
+                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
+            ],
+        ],
+    ]
 );

+ 9 - 9
tests/functional/_console.php

@@ -1,13 +1,13 @@
 <?php
 
 return yii\helpers\ArrayHelper::merge(
-	require(__DIR__ . '/../../config/console.php'),
-	require(__DIR__ . '/../_config.php'),
-	[
-		'components' => [
-			'db' => [
-				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
-			],
-		],
-	]
+    require(__DIR__ . '/../../config/console.php'),
+    require(__DIR__ . '/../_config.php'),
+    [
+        'components' => [
+            'db' => [
+                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
+            ],
+        ],
+    ]
 );

+ 9 - 9
tests/unit/_config.php

@@ -1,13 +1,13 @@
 <?php
 
 return yii\helpers\ArrayHelper::merge(
-	require(__DIR__ . '/../../config/web.php'),
-	require(__DIR__ . '/../_config.php'),
-	[
-		'components' => [
-			'db' => [
-				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
-			],
-		],
-	]
+    require(__DIR__ . '/../../config/web.php'),
+    require(__DIR__ . '/../_config.php'),
+    [
+        'components' => [
+            'db' => [
+                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
+            ],
+        ],
+    ]
 );

+ 9 - 9
tests/unit/_console.php

@@ -1,13 +1,13 @@
 <?php
 
 return yii\helpers\ArrayHelper::merge(
-	require(__DIR__ . '/../../config/console.php'),
-	require(__DIR__ . '/../_config.php'),
-	[
-		'components' => [
-			'db' => [
-				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
-			],
-		],
-	]
+    require(__DIR__ . '/../../config/console.php'),
+    require(__DIR__ . '/../_config.php'),
+    [
+        'components' => [
+            'db' => [
+                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
+            ],
+        ],
+    ]
 );

+ 48 - 48
tests/unit/models/ContactFormTest.php

@@ -7,52 +7,52 @@ use yii\codeception\TestCase;
 
 class ContactFormTest extends TestCase
 {
-	use \Codeception\Specify;
-
-	protected function setUp()
-	{
-		parent::setUp();
-		Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
-			return 'testing_message.eml';
-		};
-	}
-
-	protected function tearDown()
-	{
-		unlink($this->getMessageFile());
-		parent::tearDown();
-	}
-
-	public function testContact()
-	{
-		$model = $this->getMock('app\models\ContactForm', ['validate']);
-		$model->expects($this->once())->method('validate')->will($this->returnValue(true));
-
-		$model->attributes = [
-			'name' => 'Tester',
-			'email' => 'tester@example.com',
-			'subject' => 'very important letter subject',
-			'body' => 'body of current message',
-		];
-
-		$model->contact('admin@example.com');
-
-		$this->specify('email should be send', function () {
-			expect('email file should exist', file_exists($this->getMessageFile()))->true();
-		});
-
-		$this->specify('message should contain correct data', function () use ($model) {
-			$emailMessage = file_get_contents($this->getMessageFile());
-
-			expect('email should contain user name', $emailMessage)->contains($model->name);
-			expect('email should contain sender email', $emailMessage)->contains($model->email);
-			expect('email should contain subject', $emailMessage)->contains($model->subject);
-			expect('email should contain body', $emailMessage)->contains($model->body);
-		});
-	}
-
-	private function getMessageFile()
-	{
-		return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
-	}
+    use \Codeception\Specify;
+
+    protected function setUp()
+    {
+        parent::setUp();
+        Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
+            return 'testing_message.eml';
+        };
+    }
+
+    protected function tearDown()
+    {
+        unlink($this->getMessageFile());
+        parent::tearDown();
+    }
+
+    public function testContact()
+    {
+        $model = $this->getMock('app\models\ContactForm', ['validate']);
+        $model->expects($this->once())->method('validate')->will($this->returnValue(true));
+
+        $model->attributes = [
+            'name' => 'Tester',
+            'email' => 'tester@example.com',
+            'subject' => 'very important letter subject',
+            'body' => 'body of current message',
+        ];
+
+        $model->contact('admin@example.com');
+
+        $this->specify('email should be send', function () {
+            expect('email file should exist', file_exists($this->getMessageFile()))->true();
+        });
+
+        $this->specify('message should contain correct data', function () use ($model) {
+            $emailMessage = file_get_contents($this->getMessageFile());
+
+            expect('email should contain user name', $emailMessage)->contains($model->name);
+            expect('email should contain sender email', $emailMessage)->contains($model->email);
+            expect('email should contain subject', $emailMessage)->contains($model->subject);
+            expect('email should contain body', $emailMessage)->contains($model->body);
+        });
+    }
+
+    private function getMessageFile()
+    {
+        return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
+    }
 }

+ 45 - 44
tests/unit/models/LoginFormTest.php

@@ -8,59 +8,60 @@ use app\models\User;
 
 class LoginFormTest extends TestCase
 {
-	use \Codeception\Specify;
+    use \Codeception\Specify;
 
-	protected function tearDown()
-	{
-		Yii::$app->user->logout();
-		parent::tearDown();
-	}
+    protected function tearDown()
+    {
+        Yii::$app->user->logout();
+        parent::tearDown();
+    }
 
-	public function testLoginNoUser()
-	{
-		$model = $this->mockUser(null);
+    public function testLoginNoUser()
+    {
+        $model = $this->mockUser(null);
 
-		$model->username = 'some_username';
-		$model->password = 'some_password';
+        $model->username = 'some_username';
+        $model->password = 'some_password';
 
-		$this->specify('user should not be able to login, when there is no identity', function () use ($model) {
-			expect('model should not login user', $model->login())->false();
-			expect('user should not be logged in', Yii::$app->user->isGuest)->true();
-		});
-	}
+        $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
+            expect('model should not login user', $model->login())->false();
+            expect('user should not be logged in', Yii::$app->user->isGuest)->true();
+        });
+    }
 
-	public function testLoginWrongPassword()
-	{
-		$model = $this->mockUser(new User);
+    public function testLoginWrongPassword()
+    {
+        $model = $this->mockUser(new User);
 
-		$model->username = 'demo';
-		$model->password = 'wrong-password';
+        $model->username = 'demo';
+        $model->password = 'wrong-password';
 
-		$this->specify('user should not be able to login with wrong password', function () use ($model) {
-			expect('model should not login user', $model->login())->false();
-			expect('error message should be set', $model->errors)->hasKey('password');
-			expect('user should not be logged in', Yii::$app->user->isGuest)->true();
-		});
-	}
+        $this->specify('user should not be able to login with wrong password', function () use ($model) {
+            expect('model should not login user', $model->login())->false();
+            expect('error message should be set', $model->errors)->hasKey('password');
+            expect('user should not be logged in', Yii::$app->user->isGuest)->true();
+        });
+    }
 
-	public function testLoginCorrect()
-	{
-		$model = $this->mockUser(new User(['password' => 'demo']));
+    public function testLoginCorrect()
+    {
+        $model = $this->mockUser(new User(['password' => 'demo']));
 
-		$model->username = 'demo';
-		$model->password = 'demo';
+        $model->username = 'demo';
+        $model->password = 'demo';
 
-		$this->specify('user should be able to login with correct credentials', function () use ($model) {
-			expect('model should login user', $model->login())->true();
-			expect('error message should not be set', $model->errors)->hasntKey('password');
-			expect('user should be logged in', Yii::$app->user->isGuest)->false();
-		});
-	}
+        $this->specify('user should be able to login with correct credentials', function () use ($model) {
+            expect('model should login user', $model->login())->true();
+            expect('error message should not be set', $model->errors)->hasntKey('password');
+            expect('user should be logged in', Yii::$app->user->isGuest)->false();
+        });
+    }
 
-	private function mockUser($user)
-	{
-		$loginForm = $this->getMock('app\models\LoginForm', ['getUser']);
-		$loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
-		return $loginForm;
-	}
+    private function mockUser($user)
+    {
+        $loginForm = $this->getMock('app\models\LoginForm', ['getUser']);
+        $loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
+
+        return $loginForm;
+    }
 }

+ 7 - 7
tests/unit/models/UserTest.php

@@ -6,12 +6,12 @@ use yii\codeception\TestCase;
 
 class UserTest extends TestCase
 {
-	protected function setUp()
-	{
-		parent::setUp();
-		// uncomment the following to load fixtures for table tbl_user
-		//$this->loadFixtures(['tbl_user']);
-	}
+    protected function setUp()
+    {
+        parent::setUp();
+        // uncomment the following to load fixtures for table tbl_user
+        //$this->loadFixtures(['tbl_user']);
+    }
 
-	// TODO add test methods here
+    // TODO add test methods here
 }

+ 41 - 41
views/layouts/main.php

@@ -15,53 +15,53 @@ AppAsset::register($this);
 <!DOCTYPE html>
 <html lang="<?= Yii::$app->language ?>">
 <head>
-	<meta charset="<?= Yii::$app->charset ?>"/>
-	<meta name="viewport" content="width=device-width, initial-scale=1">
-	<title><?= Html::encode($this->title) ?></title>
-	<?php $this->head() ?>
+    <meta charset="<?= Yii::$app->charset ?>"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title><?= Html::encode($this->title) ?></title>
+    <?php $this->head() ?>
 </head>
 <body>
 
 <?php $this->beginBody() ?>
-	<div class="wrap">
-		<?php
-			NavBar::begin([
-				'brandLabel' => 'My Company',
-				'brandUrl' => Yii::$app->homeUrl,
-				'options' => [
-					'class' => 'navbar-inverse navbar-fixed-top',
-				],
-			]);
-			echo Nav::widget([
-				'options' => ['class' => 'navbar-nav navbar-right'],
-				'items' => [
-					['label' => 'Home', 'url' => ['/site/index']],
-					['label' => 'About', 'url' => ['/site/about']],
-					['label' => 'Contact', 'url' => ['/site/contact']],
-					Yii::$app->user->isGuest ?
-						['label' => 'Login', 'url' => ['/site/login']] :
-						['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
-							'url' => ['/site/logout'],
-							'linkOptions' => ['data-method' => 'post']],
-				],
-			]);
-			NavBar::end();
-		?>
+    <div class="wrap">
+        <?php
+            NavBar::begin([
+                'brandLabel' => 'My Company',
+                'brandUrl' => Yii::$app->homeUrl,
+                'options' => [
+                    'class' => 'navbar-inverse navbar-fixed-top',
+                ],
+            ]);
+            echo Nav::widget([
+                'options' => ['class' => 'navbar-nav navbar-right'],
+                'items' => [
+                    ['label' => 'Home', 'url' => ['/site/index']],
+                    ['label' => 'About', 'url' => ['/site/about']],
+                    ['label' => 'Contact', 'url' => ['/site/contact']],
+                    Yii::$app->user->isGuest ?
+                        ['label' => 'Login', 'url' => ['/site/login']] :
+                        ['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
+                            'url' => ['/site/logout'],
+                            'linkOptions' => ['data-method' => 'post']],
+                ],
+            ]);
+            NavBar::end();
+        ?>
 
-		<div class="container">
-			<?= Breadcrumbs::widget([
-				'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
-			]) ?>
-			<?= $content ?>
-		</div>
-	</div>
+        <div class="container">
+            <?= Breadcrumbs::widget([
+                'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
+            ]) ?>
+            <?= $content ?>
+        </div>
+    </div>
 
-	<footer class="footer">
-		<div class="container">
-			<p class="pull-left">&copy; My Company <?= date('Y') ?></p>
-			<p class="pull-right"><?= Yii::powered() ?></p>
-		</div>
-	</footer>
+    <footer class="footer">
+        <div class="container">
+            <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
+            <p class="pull-right"><?= Yii::powered() ?></p>
+        </div>
+    </footer>
 
 <?php $this->endBody() ?>
 </body>

+ 5 - 5
views/site/about.php

@@ -8,11 +8,11 @@ $this->title = 'About';
 $this->params['breadcrumbs'][] = $this->title;
 ?>
 <div class="site-about">
-	<h1><?= 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><?= __FILE__ ?></code>
+    <code><?= __FILE__ ?></code>
 </div>

+ 43 - 43
views/site/contact.php

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

+ 10 - 10
views/site/error.php

@@ -13,17 +13,17 @@ $this->title = $name;
 ?>
 <div class="site-error">
 
-	<h1><?= Html::encode($this->title) ?></h1>
+    <h1><?= Html::encode($this->title) ?></h1>
 
-	<div class="alert alert-danger">
-		<?= nl2br(Html::encode($message)) ?>
-	</div>
+    <div class="alert alert-danger">
+        <?= nl2br(Html::encode($message)) ?>
+    </div>
 
-	<p>
-		The above error occurred while the Web server was processing your request.
-	</p>
-	<p>
-		Please contact us if you think this is a server error. Thank you.
-	</p>
+    <p>
+        The above error occurred while the Web server was processing your request.
+    </p>
+    <p>
+        Please contact us if you think this is a server error. Thank you.
+    </p>
 
 </div>

+ 33 - 33
views/site/index.php

@@ -6,48 +6,48 @@ $this->title = 'My Yii Application';
 ?>
 <div class="site-index">
 
-	<div class="jumbotron">
-		<h1>Congratulations!</h1>
+    <div class="jumbotron">
+        <h1>Congratulations!</h1>
 
-		<p class="lead">You have successfully created your Yii-powered application.</p>
+        <p class="lead">You have successfully created your Yii-powered application.</p>
 
-		<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
-	</div>
+        <p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
+    </div>
 
-	<div class="body-content">
+    <div class="body-content">
 
-		<div class="row">
-			<div class="col-lg-4">
-				<h2>Heading</h2>
+        <div class="row">
+            <div class="col-lg-4">
+                <h2>Heading</h2>
 
-				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
-					dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
-					ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
-					fugiat nulla pariatur.</p>
+                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
+                    dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+                    ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+                    fugiat nulla pariatur.</p>
 
-				<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
-			</div>
-			<div class="col-lg-4">
-				<h2>Heading</h2>
+                <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
+            </div>
+            <div class="col-lg-4">
+                <h2>Heading</h2>
 
-				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
-					dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
-					ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
-					fugiat nulla pariatur.</p>
+                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
+                    dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+                    ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+                    fugiat nulla pariatur.</p>
 
-				<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
-			</div>
-			<div class="col-lg-4">
-				<h2>Heading</h2>
+                <p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
+            </div>
+            <div class="col-lg-4">
+                <h2>Heading</h2>
 
-				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
-					dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
-					ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
-					fugiat nulla pariatur.</p>
+                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
+                    dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+                    ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+                    fugiat nulla pariatur.</p>
 
-				<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
-			</div>
-		</div>
+                <p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
+            </div>
+        </div>
 
-	</div>
+    </div>
 </div>

+ 25 - 25
views/site/login.php

@@ -11,37 +11,37 @@ $this->title = 'Login';
 $this->params['breadcrumbs'][] = $this->title;
 ?>
 <div class="site-login">
-	<h1><?= 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([
-		'id' => 'login-form',
-		'options' => ['class' => 'form-horizontal'],
-		'fieldConfig' => [
-			'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
-			'labelOptions' => ['class' => 'col-lg-1 control-label'],
-		],
-	]); ?>
+    <?php $form = ActiveForm::begin([
+        'id' => 'login-form',
+        'options' => ['class' => 'form-horizontal'],
+        'fieldConfig' => [
+            'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
+            'labelOptions' => ['class' => 'col-lg-1 control-label'],
+        ],
+    ]); ?>
 
-	<?= $form->field($model, 'username') ?>
+    <?= $form->field($model, 'username') ?>
 
-	<?= $form->field($model, 'password')->passwordInput() ?>
+    <?= $form->field($model, 'password')->passwordInput() ?>
 
-	<?= $form->field($model, 'rememberMe', [
-		'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
-	])->checkbox() ?>
+    <?= $form->field($model, 'rememberMe', [
+        'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
+    ])->checkbox() ?>
 
-	<div class="form-group">
-		<div class="col-lg-offset-1 col-lg-11">
-			<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
-		</div>
-	</div>
+    <div class="form-group">
+        <div class="col-lg-offset-1 col-lg-11">
+            <?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
+        </div>
+    </div>
 
-	<?php ActiveForm::end(); ?>
+    <?php ActiveForm::end(); ?>
 
-	<div class="col-lg-offset-1" style="color:#999;">
-		You may login with <strong>admin/admin</strong> or <strong>demo/demo</strong>.<br>
-		To modify the username/password, please check out the code <code>app\models\User::$users</code>.
-	</div>
+    <div class="col-lg-offset-1" style="color:#999;">
+        You may login with <strong>admin/admin</strong> or <strong>demo/demo</strong>.<br>
+        To modify the username/password, please check out the code <code>app\models\User::$users</code>.
+    </div>
 </div>

+ 1 - 1
web/index-test.php

@@ -2,7 +2,7 @@
 
 // NOTE: Make sure this file is not accessible when deployed to production
 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.');
 }
 
 defined('YII_DEBUG') or define('YII_DEBUG', true);