╃巡洋艦㊣
9 years ago
1483 changed files with 68232 additions and 53476 deletions
@ -1,30 +0,0 @@ |
|||||||
# yii console command |
|
||||||
/yii |
|
||||||
|
|
||||||
# phpstorm project files |
|
||||||
.idea |
|
||||||
|
|
||||||
# netbeans project files |
|
||||||
nbproject |
|
||||||
|
|
||||||
# zend studio for eclipse project files |
|
||||||
.buildpath |
|
||||||
.project |
|
||||||
.settings |
|
||||||
|
|
||||||
# windows thumbnail cache |
|
||||||
Thumbs.db |
|
||||||
|
|
||||||
# composer vendor dir |
|
||||||
/vendor |
|
||||||
|
|
||||||
# composer itself is not needed |
|
||||||
composer.phar |
|
||||||
|
|
||||||
# Mac DS_Store Files |
|
||||||
.DS_Store |
|
||||||
|
|
||||||
# phpunit itself is not needed |
|
||||||
phpunit.phar |
|
||||||
# local phpunit config |
|
||||||
/phpunit.xml |
|
@ -1,32 +0,0 @@ |
|||||||
The Yii framework is free software. It is released under the terms of |
|
||||||
the following BSD License. |
|
||||||
|
|
||||||
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) |
|
||||||
All rights reserved. |
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without |
|
||||||
modification, are permitted provided that the following conditions |
|
||||||
are met: |
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright |
|
||||||
notice, this list of conditions and the following disclaimer. |
|
||||||
* Redistributions in binary form must reproduce the above copyright |
|
||||||
notice, this list of conditions and the following disclaimer in |
|
||||||
the documentation and/or other materials provided with the |
|
||||||
distribution. |
|
||||||
* Neither the name of Yii Software LLC nor the names of its |
|
||||||
contributors may be used to endorse or promote products derived |
|
||||||
from this software without specific prior written permission. |
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
||||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||||
POSSIBILITY OF SUCH DAMAGE. |
|
@ -1,97 +0,0 @@ |
|||||||
Yii 2 Advanced Application Template |
|
||||||
=================================== |
|
||||||
|
|
||||||
Yii 2 Advanced Application Template is a skeleton Yii 2 application best for |
|
||||||
developing complex Web applications with multiple tiers. |
|
||||||
|
|
||||||
The template includes three tiers: front end, back end, and console, each of which |
|
||||||
is a separate Yii application. |
|
||||||
|
|
||||||
The template is designed to work in a team development environment. It supports |
|
||||||
deploying the application in different environments. |
|
||||||
|
|
||||||
|
|
||||||
DIRECTORY STRUCTURE |
|
||||||
------------------- |
|
||||||
|
|
||||||
``` |
|
||||||
common |
|
||||||
config/ contains shared configurations |
|
||||||
mail/ contains view files for e-mails |
|
||||||
models/ contains model classes used in both backend and frontend |
|
||||||
console |
|
||||||
config/ contains console configurations |
|
||||||
controllers/ contains console controllers (commands) |
|
||||||
migrations/ contains database migrations |
|
||||||
models/ contains console-specific model classes |
|
||||||
runtime/ contains files generated during runtime |
|
||||||
backend |
|
||||||
assets/ contains application assets such as JavaScript and CSS |
|
||||||
config/ contains backend configurations |
|
||||||
controllers/ contains Web controller classes |
|
||||||
models/ contains backend-specific model classes |
|
||||||
runtime/ contains files generated during runtime |
|
||||||
views/ contains view files for the Web application |
|
||||||
web/ contains the entry script and Web resources |
|
||||||
frontend |
|
||||||
assets/ contains application assets such as JavaScript and CSS |
|
||||||
config/ contains frontend configurations |
|
||||||
controllers/ contains Web controller classes |
|
||||||
models/ contains frontend-specific model classes |
|
||||||
runtime/ contains files generated during runtime |
|
||||||
views/ contains view files for the Web application |
|
||||||
web/ contains the entry script and Web resources |
|
||||||
widgets/ contains frontend widgets |
|
||||||
vendor/ contains dependent 3rd-party packages |
|
||||||
environments/ contains environment-based overrides |
|
||||||
tests contains various tests for the advanced application |
|
||||||
codeception/ contains tests developed with Codeception PHP Testing Framework |
|
||||||
``` |
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS |
|
||||||
------------ |
|
||||||
|
|
||||||
The minimum requirement by this application template that your Web server supports PHP 5.4.0. |
|
||||||
|
|
||||||
|
|
||||||
INSTALLATION |
|
||||||
------------ |
|
||||||
|
|
||||||
### Install from an Archive File |
|
||||||
|
|
||||||
Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to |
|
||||||
a directory named `advanced` that is directly under the Web root. |
|
||||||
|
|
||||||
Then follow the instructions given in "GETTING STARTED". |
|
||||||
|
|
||||||
|
|
||||||
### Install via Composer |
|
||||||
|
|
||||||
If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions |
|
||||||
at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). |
|
||||||
|
|
||||||
You can then install the application using the following command: |
|
||||||
|
|
||||||
~~~ |
|
||||||
php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta4" |
|
||||||
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced advanced |
|
||||||
~~~ |
|
||||||
|
|
||||||
|
|
||||||
GETTING STARTED |
|
||||||
--------------- |
|
||||||
|
|
||||||
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. |
|
||||||
|
|
||||||
1. Run command `init` to initialize the application with a specific environment. |
|
||||||
2. Create a new database and adjust the `components['db']` configuration in `common/config/main-local.php` accordingly. |
|
||||||
3. Apply migrations with console command `yii migrate`. This will create tables needed for the application to work. |
|
||||||
4. Set document roots of your Web server: |
|
||||||
|
|
||||||
- for frontend `/path/to/yii-application/frontend/web/` and using the URL `http://frontend/` |
|
||||||
- for backend `/path/to/yii-application/backend/web/` and using the URL `http://backend/` |
|
||||||
|
|
||||||
To login into the application, you need to first sign up, with any of your email address, username and password. |
|
||||||
Then, you can login into the application with same email address and password at any time. |
|
@ -1,29 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* @link http://www.yiiframework.com/ |
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
* @license http://www.yiiframework.com/license/ |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace backend\assets; |
|
||||||
|
|
||||||
use yii\web\AssetBundle; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Qiang Xue <qiang.xue@gmail.com> |
|
||||||
* @since 2.0 |
|
||||||
*/ |
|
||||||
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', |
|
||||||
]; |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
main-local.php |
|
||||||
params-local.php |
|
@ -1,34 +0,0 @@ |
|||||||
<?php |
|
||||||
$params = array_merge( |
|
||||||
require(__DIR__ . '/../../common/config/params.php'), |
|
||||||
require(__DIR__ . '/../../common/config/params-local.php'), |
|
||||||
require(__DIR__ . '/params.php'), |
|
||||||
require(__DIR__ . '/params-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
return [ |
|
||||||
'id' => 'app-backend', |
|
||||||
'basePath' => dirname(__DIR__), |
|
||||||
'controllerNamespace' => 'backend\controllers', |
|
||||||
'bootstrap' => ['log'], |
|
||||||
'modules' => [], |
|
||||||
'components' => [ |
|
||||||
'user' => [ |
|
||||||
'identityClass' => 'common\models\User', |
|
||||||
'enableAutoLogin' => true, |
|
||||||
], |
|
||||||
'log' => [ |
|
||||||
'traceLevel' => YII_DEBUG ? 3 : 0, |
|
||||||
'targets' => [ |
|
||||||
[ |
|
||||||
'class' => 'yii\log\FileTarget', |
|
||||||
'levels' => ['error', 'warning'], |
|
||||||
], |
|
||||||
], |
|
||||||
], |
|
||||||
'errorHandler' => [ |
|
||||||
'errorAction' => 'site/error', |
|
||||||
], |
|
||||||
], |
|
||||||
'params' => $params, |
|
||||||
]; |
|
@ -1,4 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'adminEmail' => 'admin@example.com', |
|
||||||
]; |
|
@ -1,83 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace backend\controllers; |
|
||||||
|
|
||||||
use Yii; |
|
||||||
use yii\filters\AccessControl; |
|
||||||
use yii\web\Controller; |
|
||||||
use common\models\LoginForm; |
|
||||||
use yii\filters\VerbFilter; |
|
||||||
|
|
||||||
/** |
|
||||||
* Site controller |
|
||||||
*/ |
|
||||||
class SiteController extends Controller |
|
||||||
{ |
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function behaviors() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
'access' => [ |
|
||||||
'class' => AccessControl::className(), |
|
||||||
'rules' => [ |
|
||||||
[ |
|
||||||
'actions' => ['login', 'error'], |
|
||||||
'allow' => true, |
|
||||||
], |
|
||||||
[ |
|
||||||
'actions' => ['logout', 'index'], |
|
||||||
'allow' => true, |
|
||||||
'roles' => ['@'], |
|
||||||
], |
|
||||||
], |
|
||||||
], |
|
||||||
'verbs' => [ |
|
||||||
'class' => VerbFilter::className(), |
|
||||||
'actions' => [ |
|
||||||
'logout' => ['post'], |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function actions() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
'error' => [ |
|
||||||
'class' => 'yii\web\ErrorAction', |
|
||||||
], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
public function actionIndex() |
|
||||||
{ |
|
||||||
return $this->render('index'); |
|
||||||
} |
|
||||||
|
|
||||||
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, |
|
||||||
]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public function actionLogout() |
|
||||||
{ |
|
||||||
Yii::$app->user->logout(); |
|
||||||
|
|
||||||
return $this->goHome(); |
|
||||||
} |
|
||||||
} |
|
@ -1,71 +0,0 @@ |
|||||||
<?php |
|
||||||
use backend\assets\AppAsset; |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\Nav; |
|
||||||
use yii\bootstrap\NavBar; |
|
||||||
use yii\widgets\Breadcrumbs; |
|
||||||
|
|
||||||
/* @var $this \yii\web\View */ |
|
||||||
/* @var $content string */ |
|
||||||
|
|
||||||
AppAsset::register($this); |
|
||||||
?> |
|
||||||
<?php $this->beginPage() ?> |
|
||||||
<!DOCTYPE html> |
|
||||||
<html lang="<?= Yii::$app->language ?>">
|
|
||||||
<head> |
|
||||||
<meta charset="<?= Yii::$app->charset ?>"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
||||||
<?= Html::csrfMetaTags() ?> |
|
||||||
<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', |
|
||||||
], |
|
||||||
]); |
|
||||||
$menuItems = [ |
|
||||||
['label' => 'Home', 'url' => ['/site/index']], |
|
||||||
]; |
|
||||||
if (Yii::$app->user->isGuest) { |
|
||||||
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; |
|
||||||
} else { |
|
||||||
$menuItems[] = [ |
|
||||||
'label' => 'Logout (' . Yii::$app->user->identity->username . ')', |
|
||||||
'url' => ['/site/logout'], |
|
||||||
'linkOptions' => ['data-method' => 'post'] |
|
||||||
]; |
|
||||||
} |
|
||||||
echo Nav::widget([ |
|
||||||
'options' => ['class' => 'navbar-nav navbar-right'], |
|
||||||
'items' => $menuItems, |
|
||||||
]); |
|
||||||
NavBar::end(); |
|
||||||
?> |
|
||||||
|
|
||||||
<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">© My Company <?= date('Y') ?></p>
|
|
||||||
<p class="pull-right"><?= Yii::powered() ?></p>
|
|
||||||
</div> |
|
||||||
</footer> |
|
||||||
|
|
||||||
<?php $this->endBody() ?> |
|
||||||
</body> |
|
||||||
</html> |
|
||||||
<?php $this->endPage() ?> |
|
@ -1,27 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
use yii\helpers\Html; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $name string */ |
|
||||||
/* @var $message string */ |
|
||||||
/* @var $exception Exception */ |
|
||||||
|
|
||||||
$this->title = $name; |
|
||||||
?> |
|
||||||
<div class="site-error"> |
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<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> |
|
||||||
|
|
||||||
</div> |
|
@ -1,52 +0,0 @@ |
|||||||
<?php |
|
||||||
/* @var $this yii\web\View */ |
|
||||||
|
|
||||||
$this->title = 'My Yii Application'; |
|
||||||
?> |
|
||||||
<div class="site-index"> |
|
||||||
|
|
||||||
<div class="jumbotron"> |
|
||||||
<h1>Congratulations!</h1> |
|
||||||
|
|
||||||
<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> |
|
||||||
|
|
||||||
<div class="body-content"> |
|
||||||
|
|
||||||
<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><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</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><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</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><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,29 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\ActiveForm; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $form yii\bootstrap\ActiveForm */ |
|
||||||
/* @var $model \common\models\LoginForm */ |
|
||||||
|
|
||||||
$this->title = 'Login'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-login"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<p>Please fill out the following fields to login:</p> |
|
||||||
|
|
||||||
<div class="row"> |
|
||||||
<div class="col-lg-5"> |
|
||||||
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?> |
|
||||||
<?= $form->field($model, 'username') ?> |
|
||||||
<?= $form->field($model, 'password')->passwordInput() ?> |
|
||||||
<?= $form->field($model, 'rememberMe')->checkbox() ?> |
|
||||||
<div class="form-group"> |
|
||||||
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> |
|
||||||
</div> |
|
||||||
<?php ActiveForm::end(); ?> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,2 +0,0 @@ |
|||||||
/index.php |
|
||||||
/index-test.php |
|
@ -1,2 +0,0 @@ |
|||||||
* |
|
||||||
!.gitignore |
|
@ -1,91 +0,0 @@ |
|||||||
html, |
|
||||||
body { |
|
||||||
height: 100%; |
|
||||||
} |
|
||||||
|
|
||||||
.wrap { |
|
||||||
min-height: 100%; |
|
||||||
height: auto; |
|
||||||
margin: 0 auto -60px; |
|
||||||
padding: 0 0 60px; |
|
||||||
} |
|
||||||
|
|
||||||
.wrap > .container { |
|
||||||
padding: 70px 15px 20px; |
|
||||||
} |
|
||||||
|
|
||||||
.footer { |
|
||||||
height: 60px; |
|
||||||
background-color: #f5f5f5; |
|
||||||
border-top: 1px solid #ddd; |
|
||||||
padding-top: 20px; |
|
||||||
} |
|
||||||
|
|
||||||
.jumbotron { |
|
||||||
text-align: center; |
|
||||||
background-color: transparent; |
|
||||||
} |
|
||||||
|
|
||||||
.jumbotron .btn { |
|
||||||
font-size: 21px; |
|
||||||
padding: 14px 24px; |
|
||||||
} |
|
||||||
|
|
||||||
.not-set { |
|
||||||
color: #c55; |
|
||||||
font-style: italic; |
|
||||||
} |
|
||||||
|
|
||||||
/* 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"; |
|
||||||
} |
|
||||||
|
|
||||||
.grid-view th { |
|
||||||
white-space: nowrap; |
|
||||||
} |
|
||||||
|
|
||||||
.hint-block { |
|
||||||
display: block; |
|
||||||
margin-top: 5px; |
|
||||||
color: #999; |
|
||||||
} |
|
||||||
|
|
||||||
.error-summary { |
|
||||||
color: #a94442; |
|
||||||
background: #fdf7f7; |
|
||||||
border-left: 3px solid #eed3d7; |
|
||||||
padding: 10px 20px; |
|
||||||
margin: 0 0 15px 0; |
|
||||||
} |
|
Before Width: | Height: | Size: 318 B |
@ -1,2 +0,0 @@ |
|||||||
main-local.php |
|
||||||
params-local.php |
|
@ -1,5 +0,0 @@ |
|||||||
<?php |
|
||||||
Yii::setAlias('common', dirname(__DIR__)); |
|
||||||
Yii::setAlias('frontend', dirname(dirname(__DIR__)) . '/frontend'); |
|
||||||
Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend'); |
|
||||||
Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console'); |
|
@ -1,9 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
|
||||||
'components' => [ |
|
||||||
'cache' => [ |
|
||||||
'class' => 'yii\caching\FileCache', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
@ -1,6 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'adminEmail' => 'admin@example.com', |
|
||||||
'supportEmail' => 'support@example.com', |
|
||||||
'user.passwordResetTokenExpire' => 3600, |
|
||||||
]; |
|
@ -1,22 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
|
|
||||||
/* @var $this \yii\web\View view component instance */ |
|
||||||
/* @var $message \yii\mail\MessageInterface the message being composed */ |
|
||||||
/* @var $content string main view render result */ |
|
||||||
?> |
|
||||||
<?php $this->beginPage() ?> |
|
||||||
<!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() ?> |
|
||||||
</head> |
|
||||||
<body> |
|
||||||
<?php $this->beginBody() ?> |
|
||||||
<?= $content ?> |
|
||||||
<?php $this->endBody() ?> |
|
||||||
</body> |
|
||||||
</html> |
|
||||||
<?php $this->endPage() ?> |
|
@ -1,14 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $user common\models\User */ |
|
||||||
|
|
||||||
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); |
|
||||||
?> |
|
||||||
|
|
||||||
Hello <?= Html::encode($user->username) ?>,
|
|
||||||
|
|
||||||
Follow the link below to reset your password: |
|
||||||
|
|
||||||
<?= Html::a(Html::encode($resetLink), $resetLink) ?> |
|
@ -1,78 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace common\models; |
|
||||||
|
|
||||||
use Yii; |
|
||||||
use yii\base\Model; |
|
||||||
|
|
||||||
/** |
|
||||||
* Login form |
|
||||||
*/ |
|
||||||
class LoginForm extends Model |
|
||||||
{ |
|
||||||
public $username; |
|
||||||
public $password; |
|
||||||
public $rememberMe = true; |
|
||||||
|
|
||||||
private $_user = false; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
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. |
|
||||||
* |
|
||||||
* @param string $attribute the attribute currently being validated |
|
||||||
* @param array $params the additional name-value pairs given in the rule |
|
||||||
*/ |
|
||||||
public function validatePassword($attribute, $params) |
|
||||||
{ |
|
||||||
if (!$this->hasErrors()) { |
|
||||||
$user = $this->getUser(); |
|
||||||
if (!$user || !$user->validatePassword($this->password)) { |
|
||||||
$this->addError($attribute, '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; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds user by [[username]] |
|
||||||
* |
|
||||||
* @return User|null |
|
||||||
*/ |
|
||||||
public function getUser() |
|
||||||
{ |
|
||||||
if ($this->_user === false) { |
|
||||||
$this->_user = User::findByUsername($this->username); |
|
||||||
} |
|
||||||
|
|
||||||
return $this->_user; |
|
||||||
} |
|
||||||
} |
|
@ -1,193 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace common\models; |
|
||||||
|
|
||||||
use Yii; |
|
||||||
use yii\base\NotSupportedException; |
|
||||||
use yii\behaviors\TimestampBehavior; |
|
||||||
use yii\db\ActiveRecord; |
|
||||||
use yii\web\IdentityInterface; |
|
||||||
|
|
||||||
/** |
|
||||||
* User model |
|
||||||
* |
|
||||||
* @property integer $id |
|
||||||
* @property string $username |
|
||||||
* @property string $password_hash |
|
||||||
* @property string $password_reset_token |
|
||||||
* @property string $email |
|
||||||
* @property string $auth_key |
|
||||||
* @property integer $role |
|
||||||
* @property integer $status |
|
||||||
* @property integer $created_at |
|
||||||
* @property integer $updated_at |
|
||||||
* @property string $password write-only password |
|
||||||
*/ |
|
||||||
class User extends ActiveRecord implements IdentityInterface |
|
||||||
{ |
|
||||||
const STATUS_DELETED = 0; |
|
||||||
const STATUS_ACTIVE = 10; |
|
||||||
const ROLE_USER = 10; |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public static function tableName() |
|
||||||
{ |
|
||||||
return '{{%user}}'; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function behaviors() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
TimestampBehavior::className(), |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function rules() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
['status', 'default', 'value' => self::STATUS_ACTIVE], |
|
||||||
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]], |
|
||||||
|
|
||||||
['role', 'default', 'value' => self::ROLE_USER], |
|
||||||
['role', 'in', 'range' => [self::ROLE_USER]], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public static function findIdentity($id) |
|
||||||
{ |
|
||||||
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public static function findIdentityByAccessToken($token, $type = null) |
|
||||||
{ |
|
||||||
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds user by username |
|
||||||
* |
|
||||||
* @param string $username |
|
||||||
* @return static|null |
|
||||||
*/ |
|
||||||
public static function findByUsername($username) |
|
||||||
{ |
|
||||||
return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds user by password reset token |
|
||||||
* |
|
||||||
* @param string $token password reset token |
|
||||||
* @return static|null |
|
||||||
*/ |
|
||||||
public static function findByPasswordResetToken($token) |
|
||||||
{ |
|
||||||
if (!static::isPasswordResetTokenValid($token)) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
return static::findOne([ |
|
||||||
'password_reset_token' => $token, |
|
||||||
'status' => self::STATUS_ACTIVE, |
|
||||||
]); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds out if password reset token is valid |
|
||||||
* |
|
||||||
* @param string $token password reset token |
|
||||||
* @return boolean |
|
||||||
*/ |
|
||||||
public static function isPasswordResetTokenValid($token) |
|
||||||
{ |
|
||||||
if (empty($token)) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
$expire = Yii::$app->params['user.passwordResetTokenExpire']; |
|
||||||
$parts = explode('_', $token); |
|
||||||
$timestamp = (int) end($parts); |
|
||||||
return $timestamp + $expire >= time(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function getId() |
|
||||||
{ |
|
||||||
return $this->getPrimaryKey(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function getAuthKey() |
|
||||||
{ |
|
||||||
return $this->auth_key; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function validateAuthKey($authKey) |
|
||||||
{ |
|
||||||
return $this->getAuthKey() === $authKey; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Validates password |
|
||||||
* |
|
||||||
* @param string $password password to validate |
|
||||||
* @return boolean if password provided is valid for current user |
|
||||||
*/ |
|
||||||
public function validatePassword($password) |
|
||||||
{ |
|
||||||
return Yii::$app->security->validatePassword($password, $this->password_hash); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Generates password hash from password and sets it to the model |
|
||||||
* |
|
||||||
* @param string $password |
|
||||||
*/ |
|
||||||
public function setPassword($password) |
|
||||||
{ |
|
||||||
$this->password_hash = Yii::$app->security->generatePasswordHash($password); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Generates "remember me" authentication key |
|
||||||
*/ |
|
||||||
public function generateAuthKey() |
|
||||||
{ |
|
||||||
$this->auth_key = Yii::$app->security->generateRandomString(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Generates new password reset token |
|
||||||
*/ |
|
||||||
public function generatePasswordResetToken() |
|
||||||
{ |
|
||||||
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Removes password reset token |
|
||||||
*/ |
|
||||||
public function removePasswordResetToken() |
|
||||||
{ |
|
||||||
$this->password_reset_token = null; |
|
||||||
} |
|
||||||
} |
|
@ -1,37 +0,0 @@ |
|||||||
{ |
|
||||||
"name": "yiisoft/yii2-app-advanced", |
|
||||||
"description": "Yii 2 Advanced Application Template", |
|
||||||
"keywords": ["yii2", "framework", "advanced", "application template"], |
|
||||||
"homepage": "http://www.yiiframework.com/", |
|
||||||
"type": "project", |
|
||||||
"license": "BSD-3-Clause", |
|
||||||
"support": { |
|
||||||
"issues": "https://github.com/yiisoft/yii2/issues?state=open", |
|
||||||
"forum": "http://www.yiiframework.com/forum/", |
|
||||||
"wiki": "http://www.yiiframework.com/wiki/", |
|
||||||
"irc": "irc://irc.freenode.net/yii", |
|
||||||
"source": "https://github.com/yiisoft/yii2" |
|
||||||
}, |
|
||||||
"minimum-stability": "stable", |
|
||||||
"require": { |
|
||||||
"php": ">=5.4.0", |
|
||||||
"yiisoft/yii2": "*", |
|
||||||
"yiisoft/yii2-bootstrap": "*", |
|
||||||
"yiisoft/yii2-swiftmailer": "*" |
|
||||||
}, |
|
||||||
"require-dev": { |
|
||||||
"yiisoft/yii2-codeception": "*", |
|
||||||
"yiisoft/yii2-debug": "*", |
|
||||||
"yiisoft/yii2-gii": "*", |
|
||||||
"yiisoft/yii2-faker": "*" |
|
||||||
}, |
|
||||||
"config": { |
|
||||||
"process-timeout": 1800 |
|
||||||
}, |
|
||||||
"extra": { |
|
||||||
"asset-installer-paths": { |
|
||||||
"npm-asset-library": "vendor/npm", |
|
||||||
"bower-asset-library": "vendor/bower" |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
main-local.php |
|
||||||
params-local.php |
|
@ -1,28 +0,0 @@ |
|||||||
<?php |
|
||||||
$params = array_merge( |
|
||||||
require(__DIR__ . '/../../common/config/params.php'), |
|
||||||
require(__DIR__ . '/../../common/config/params-local.php'), |
|
||||||
require(__DIR__ . '/params.php'), |
|
||||||
require(__DIR__ . '/params-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
return [ |
|
||||||
'id' => 'app-console', |
|
||||||
'basePath' => dirname(__DIR__), |
|
||||||
'bootstrap' => ['log', 'gii'], |
|
||||||
'controllerNamespace' => 'console\controllers', |
|
||||||
'modules' => [ |
|
||||||
'gii' => 'yii\gii\Module', |
|
||||||
], |
|
||||||
'components' => [ |
|
||||||
'log' => [ |
|
||||||
'targets' => [ |
|
||||||
[ |
|
||||||
'class' => 'yii\log\FileTarget', |
|
||||||
'levels' => ['error', 'warning'], |
|
||||||
], |
|
||||||
], |
|
||||||
], |
|
||||||
], |
|
||||||
'params' => $params, |
|
||||||
]; |
|
@ -1,4 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'adminEmail' => 'admin@example.com', |
|
||||||
]; |
|
@ -1,35 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
use yii\db\Schema; |
|
||||||
use yii\db\Migration; |
|
||||||
|
|
||||||
class m130524_201442_init extends Migration |
|
||||||
{ |
|
||||||
public function up() |
|
||||||
{ |
|
||||||
$tableOptions = null; |
|
||||||
if ($this->db->driverName === 'mysql') { |
|
||||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
|
||||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
|
||||||
} |
|
||||||
|
|
||||||
$this->createTable('{{%user}}', [ |
|
||||||
'id' => Schema::TYPE_PK, |
|
||||||
'username' => Schema::TYPE_STRING . ' NOT NULL', |
|
||||||
'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL', |
|
||||||
'password_hash' => Schema::TYPE_STRING . ' NOT NULL', |
|
||||||
'password_reset_token' => Schema::TYPE_STRING, |
|
||||||
'email' => Schema::TYPE_STRING . ' NOT NULL', |
|
||||||
'role' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', |
|
||||||
|
|
||||||
'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', |
|
||||||
'created_at' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
||||||
'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL', |
|
||||||
], $tableOptions); |
|
||||||
} |
|
||||||
|
|
||||||
public function down() |
|
||||||
{ |
|
||||||
$this->dropTable('{{%user}}'); |
|
||||||
} |
|
||||||
} |
|
@ -1,21 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
$config = [ |
|
||||||
'components' => [ |
|
||||||
'request' => [ |
|
||||||
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation |
|
||||||
'cookieValidationKey' => '', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
||||||
|
|
||||||
if (!YII_ENV_TEST) { |
|
||||||
// configuration adjustments for 'dev' environment |
|
||||||
$config['bootstrap'][] = 'debug'; |
|
||||||
$config['modules']['debug'] = 'yii\debug\Module'; |
|
||||||
|
|
||||||
$config['bootstrap'][] = 'gii'; |
|
||||||
$config['modules']['gii'] = 'yii\gii\Module'; |
|
||||||
} |
|
||||||
|
|
||||||
return $config; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,19 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
// 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.'); |
|
||||||
} |
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'test'); |
|
||||||
|
|
||||||
require(__DIR__ . '/../../vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/../../common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/../config/bootstrap.php'); |
|
||||||
|
|
||||||
|
|
||||||
$config = require(__DIR__ . '/../../tests/codeception/config/backend/acceptance.php'); |
|
||||||
|
|
||||||
(new yii\web\Application($config))->run(); |
|
@ -1,18 +0,0 @@ |
|||||||
<?php |
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'dev'); |
|
||||||
|
|
||||||
require(__DIR__ . '/../../vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/../../common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/../config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
|
||||||
require(__DIR__ . '/../../common/config/main.php'), |
|
||||||
require(__DIR__ . '/../../common/config/main-local.php'), |
|
||||||
require(__DIR__ . '/../config/main.php'), |
|
||||||
require(__DIR__ . '/../config/main-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\web\Application($config); |
|
||||||
$application->run(); |
|
@ -1,20 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'components' => [ |
|
||||||
'db' => [ |
|
||||||
'class' => 'yii\db\Connection', |
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2advanced', |
|
||||||
'username' => 'root', |
|
||||||
'password' => '', |
|
||||||
'charset' => 'utf8', |
|
||||||
], |
|
||||||
'mailer' => [ |
|
||||||
'class' => 'yii\swiftmailer\Mailer', |
|
||||||
'viewPath' => '@common/mail', |
|
||||||
// send all mails to a file by default. You have to set |
|
||||||
// 'useFileTransport' to false and configure a transport |
|
||||||
// for the mailer to send real emails. |
|
||||||
'useFileTransport' => true, |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,21 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
$config = [ |
|
||||||
'components' => [ |
|
||||||
'request' => [ |
|
||||||
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation |
|
||||||
'cookieValidationKey' => '', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
||||||
|
|
||||||
if (!YII_ENV_TEST) { |
|
||||||
// configuration adjustments for 'dev' environment |
|
||||||
$config['bootstrap'][] = 'debug'; |
|
||||||
$config['modules']['debug'] = 'yii\debug\Module'; |
|
||||||
|
|
||||||
$config['bootstrap'][] = 'gii'; |
|
||||||
$config['modules']['gii'] = 'yii\gii\Module'; |
|
||||||
} |
|
||||||
|
|
||||||
return $config; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,18 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
// 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.'); |
|
||||||
} |
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'test'); |
|
||||||
|
|
||||||
require(__DIR__ . '/../../vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/../../common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/../config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = require(__DIR__ . '/../../tests/codeception/config/frontend/acceptance.php'); |
|
||||||
|
|
||||||
(new yii\web\Application($config))->run(); |
|
@ -1,18 +0,0 @@ |
|||||||
<?php |
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'dev'); |
|
||||||
|
|
||||||
require(__DIR__ . '/../../vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/../../common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/../config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
|
||||||
require(__DIR__ . '/../../common/config/main.php'), |
|
||||||
require(__DIR__ . '/../../common/config/main-local.php'), |
|
||||||
require(__DIR__ . '/../config/main.php'), |
|
||||||
require(__DIR__ . '/../config/main-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\web\Application($config); |
|
||||||
$application->run(); |
|
@ -1,32 +0,0 @@ |
|||||||
#!/usr/bin/env php |
|
||||||
<?php |
|
||||||
/** |
|
||||||
* Yii console bootstrap file. |
|
||||||
* |
|
||||||
* @link http://www.yiiframework.com/ |
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
* @license http://www.yiiframework.com/license/ |
|
||||||
*/ |
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'dev'); |
|
||||||
|
|
||||||
// fcgi doesn't have STDIN and STDOUT defined by default |
|
||||||
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); |
|
||||||
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); |
|
||||||
|
|
||||||
require(__DIR__ . '/vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/console/config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
|
||||||
require(__DIR__ . '/common/config/main.php'), |
|
||||||
require(__DIR__ . '/common/config/main-local.php'), |
|
||||||
require(__DIR__ . '/console/config/main.php'), |
|
||||||
require(__DIR__ . '/console/config/main-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\console\Application($config); |
|
||||||
$exitCode = $application->run(); |
|
||||||
exit($exitCode); |
|
@ -1,61 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* The manifest of files that are local to specific environment. |
|
||||||
* This file returns a list of environments that the application |
|
||||||
* may be installed under. The returned data must be in the following |
|
||||||
* format: |
|
||||||
* |
|
||||||
* ```php |
|
||||||
* return [ |
|
||||||
* 'environment name' => [ |
|
||||||
* 'path' => 'directory storing the local files', |
|
||||||
* 'setWritable' => [ |
|
||||||
* // list of directories that should be set writable |
|
||||||
* ], |
|
||||||
* 'setExecutable' => [ |
|
||||||
* // list of directories that should be set executable |
|
||||||
* ], |
|
||||||
* 'setCookieValidationKey' => [ |
|
||||||
* // list of config files that need to be inserted with automatically generated cookie validation keys |
|
||||||
* ], |
|
||||||
* 'createSymlink' => [ |
|
||||||
* // list of symlinks to be created. Keys are symlinks, and values are the targets. |
|
||||||
* ], |
|
||||||
* ], |
|
||||||
* ]; |
|
||||||
* ``` |
|
||||||
*/ |
|
||||||
return [ |
|
||||||
'Development' => [ |
|
||||||
'path' => 'dev', |
|
||||||
'setWritable' => [ |
|
||||||
'backend/runtime', |
|
||||||
'backend/web/assets', |
|
||||||
'frontend/runtime', |
|
||||||
'frontend/web/assets', |
|
||||||
], |
|
||||||
'setExecutable' => [ |
|
||||||
'yii', |
|
||||||
], |
|
||||||
'setCookieValidationKey' => [ |
|
||||||
'backend/config/main-local.php', |
|
||||||
'frontend/config/main-local.php', |
|
||||||
], |
|
||||||
], |
|
||||||
'Production' => [ |
|
||||||
'path' => 'prod', |
|
||||||
'setWritable' => [ |
|
||||||
'backend/runtime', |
|
||||||
'backend/web/assets', |
|
||||||
'frontend/runtime', |
|
||||||
'frontend/web/assets', |
|
||||||
], |
|
||||||
'setExecutable' => [ |
|
||||||
'yii', |
|
||||||
], |
|
||||||
'setCookieValidationKey' => [ |
|
||||||
'backend/config/main-local.php', |
|
||||||
'frontend/config/main-local.php', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
@ -1,9 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'components' => [ |
|
||||||
'request' => [ |
|
||||||
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation |
|
||||||
'cookieValidationKey' => '', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,18 +0,0 @@ |
|||||||
<?php |
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', false); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'prod'); |
|
||||||
|
|
||||||
require(__DIR__ . '/../../vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/../../common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/../config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
|
||||||
require(__DIR__ . '/../../common/config/main.php'), |
|
||||||
require(__DIR__ . '/../../common/config/main-local.php'), |
|
||||||
require(__DIR__ . '/../config/main.php'), |
|
||||||
require(__DIR__ . '/../config/main-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\web\Application($config); |
|
||||||
$application->run(); |
|
@ -1,16 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'components' => [ |
|
||||||
'db' => [ |
|
||||||
'class' => 'yii\db\Connection', |
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2advanced', |
|
||||||
'username' => 'root', |
|
||||||
'password' => '', |
|
||||||
'charset' => 'utf8', |
|
||||||
], |
|
||||||
'mailer' => [ |
|
||||||
'class' => 'yii\swiftmailer\Mailer', |
|
||||||
'viewPath' => '@common/mail', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,9 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'components' => [ |
|
||||||
'request' => [ |
|
||||||
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation |
|
||||||
'cookieValidationKey' => '', |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
@ -1,3 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
]; |
|
@ -1,18 +0,0 @@ |
|||||||
<?php |
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', false); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'prod'); |
|
||||||
|
|
||||||
require(__DIR__ . '/../../vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/../../common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/../config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
|
||||||
require(__DIR__ . '/../../common/config/main.php'), |
|
||||||
require(__DIR__ . '/../../common/config/main-local.php'), |
|
||||||
require(__DIR__ . '/../config/main.php'), |
|
||||||
require(__DIR__ . '/../config/main-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\web\Application($config); |
|
||||||
$application->run(); |
|
@ -1,32 +0,0 @@ |
|||||||
#!/usr/bin/env php |
|
||||||
<?php |
|
||||||
/** |
|
||||||
* Yii console bootstrap file. |
|
||||||
* |
|
||||||
* @link http://www.yiiframework.com/ |
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
* @license http://www.yiiframework.com/license/ |
|
||||||
*/ |
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', false); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'prod'); |
|
||||||
|
|
||||||
// fcgi doesn't have STDIN and STDOUT defined by default |
|
||||||
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); |
|
||||||
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); |
|
||||||
|
|
||||||
require(__DIR__ . '/vendor/autoload.php'); |
|
||||||
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require(__DIR__ . '/common/config/bootstrap.php'); |
|
||||||
require(__DIR__ . '/console/config/bootstrap.php'); |
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge( |
|
||||||
require(__DIR__ . '/common/config/main.php'), |
|
||||||
require(__DIR__ . '/common/config/main-local.php'), |
|
||||||
require(__DIR__ . '/console/config/main.php'), |
|
||||||
require(__DIR__ . '/console/config/main-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
$application = new yii\console\Application($config); |
|
||||||
$exitCode = $application->run(); |
|
||||||
exit($exitCode); |
|
@ -1,29 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* @link http://www.yiiframework.com/ |
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
* @license http://www.yiiframework.com/license/ |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace frontend\assets; |
|
||||||
|
|
||||||
use yii\web\AssetBundle; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Qiang Xue <qiang.xue@gmail.com> |
|
||||||
* @since 2.0 |
|
||||||
*/ |
|
||||||
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', |
|
||||||
]; |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
main-local.php |
|
||||||
params-local.php |
|
@ -1,33 +0,0 @@ |
|||||||
<?php |
|
||||||
$params = array_merge( |
|
||||||
require(__DIR__ . '/../../common/config/params.php'), |
|
||||||
require(__DIR__ . '/../../common/config/params-local.php'), |
|
||||||
require(__DIR__ . '/params.php'), |
|
||||||
require(__DIR__ . '/params-local.php') |
|
||||||
); |
|
||||||
|
|
||||||
return [ |
|
||||||
'id' => 'app-frontend', |
|
||||||
'basePath' => dirname(__DIR__), |
|
||||||
'bootstrap' => ['log'], |
|
||||||
'controllerNamespace' => 'frontend\controllers', |
|
||||||
'components' => [ |
|
||||||
'user' => [ |
|
||||||
'identityClass' => 'common\models\User', |
|
||||||
'enableAutoLogin' => true, |
|
||||||
], |
|
||||||
'log' => [ |
|
||||||
'traceLevel' => YII_DEBUG ? 3 : 0, |
|
||||||
'targets' => [ |
|
||||||
[ |
|
||||||
'class' => 'yii\log\FileTarget', |
|
||||||
'levels' => ['error', 'warning'], |
|
||||||
], |
|
||||||
], |
|
||||||
], |
|
||||||
'errorHandler' => [ |
|
||||||
'errorAction' => 'site/error', |
|
||||||
], |
|
||||||
], |
|
||||||
'params' => $params, |
|
||||||
]; |
|
@ -1,4 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'adminEmail' => 'admin@example.com', |
|
||||||
]; |
|
@ -1,171 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace frontend\controllers; |
|
||||||
|
|
||||||
use Yii; |
|
||||||
use common\models\LoginForm; |
|
||||||
use frontend\models\PasswordResetRequestForm; |
|
||||||
use frontend\models\ResetPasswordForm; |
|
||||||
use frontend\models\SignupForm; |
|
||||||
use frontend\models\ContactForm; |
|
||||||
use yii\base\InvalidParamException; |
|
||||||
use yii\web\BadRequestHttpException; |
|
||||||
use yii\web\Controller; |
|
||||||
use yii\filters\VerbFilter; |
|
||||||
use yii\filters\AccessControl; |
|
||||||
|
|
||||||
/** |
|
||||||
* Site controller |
|
||||||
*/ |
|
||||||
class SiteController extends Controller |
|
||||||
{ |
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function behaviors() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
'access' => [ |
|
||||||
'class' => AccessControl::className(), |
|
||||||
'only' => ['logout', 'signup'], |
|
||||||
'rules' => [ |
|
||||||
[ |
|
||||||
'actions' => ['signup'], |
|
||||||
'allow' => true, |
|
||||||
'roles' => ['?'], |
|
||||||
], |
|
||||||
[ |
|
||||||
'actions' => ['logout'], |
|
||||||
'allow' => true, |
|
||||||
'roles' => ['@'], |
|
||||||
], |
|
||||||
], |
|
||||||
], |
|
||||||
'verbs' => [ |
|
||||||
'class' => VerbFilter::className(), |
|
||||||
'actions' => [ |
|
||||||
'logout' => ['post'], |
|
||||||
], |
|
||||||
], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
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 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, |
|
||||||
]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public function actionLogout() |
|
||||||
{ |
|
||||||
Yii::$app->user->logout(); |
|
||||||
|
|
||||||
return $this->goHome(); |
|
||||||
} |
|
||||||
|
|
||||||
public function actionContact() |
|
||||||
{ |
|
||||||
$model = new ContactForm(); |
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
||||||
if ($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
||||||
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); |
|
||||||
} else { |
|
||||||
Yii::$app->session->setFlash('error', 'There was an error sending email.'); |
|
||||||
} |
|
||||||
|
|
||||||
return $this->refresh(); |
|
||||||
} else { |
|
||||||
return $this->render('contact', [ |
|
||||||
'model' => $model, |
|
||||||
]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public function actionAbout() |
|
||||||
{ |
|
||||||
return $this->render('about'); |
|
||||||
} |
|
||||||
|
|
||||||
public function actionSignup() |
|
||||||
{ |
|
||||||
$model = new SignupForm(); |
|
||||||
if ($model->load(Yii::$app->request->post())) { |
|
||||||
if ($user = $model->signup()) { |
|
||||||
if (Yii::$app->getUser()->login($user)) { |
|
||||||
return $this->goHome(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return $this->render('signup', [ |
|
||||||
'model' => $model, |
|
||||||
]); |
|
||||||
} |
|
||||||
|
|
||||||
public function actionRequestPasswordReset() |
|
||||||
{ |
|
||||||
$model = new PasswordResetRequestForm(); |
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
||||||
if ($model->sendEmail()) { |
|
||||||
Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.'); |
|
||||||
|
|
||||||
return $this->goHome(); |
|
||||||
} else { |
|
||||||
Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return $this->render('requestPasswordResetToken', [ |
|
||||||
'model' => $model, |
|
||||||
]); |
|
||||||
} |
|
||||||
|
|
||||||
public function actionResetPassword($token) |
|
||||||
{ |
|
||||||
try { |
|
||||||
$model = new ResetPasswordForm($token); |
|
||||||
} catch (InvalidParamException $e) { |
|
||||||
throw new BadRequestHttpException($e->getMessage()); |
|
||||||
} |
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { |
|
||||||
Yii::$app->getSession()->setFlash('success', 'New password was saved.'); |
|
||||||
|
|
||||||
return $this->goHome(); |
|
||||||
} |
|
||||||
|
|
||||||
return $this->render('resetPassword', [ |
|
||||||
'model' => $model, |
|
||||||
]); |
|
||||||
} |
|
||||||
} |
|
@ -1,59 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace frontend\models; |
|
||||||
|
|
||||||
use Yii; |
|
||||||
use yii\base\Model; |
|
||||||
|
|
||||||
/** |
|
||||||
* ContactForm is the model behind the contact form. |
|
||||||
*/ |
|
||||||
class ContactForm extends Model |
|
||||||
{ |
|
||||||
public $name; |
|
||||||
public $email; |
|
||||||
public $subject; |
|
||||||
public $body; |
|
||||||
public $verifyCode; |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
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'], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
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 email was sent |
|
||||||
*/ |
|
||||||
public function sendEmail($email) |
|
||||||
{ |
|
||||||
return Yii::$app->mailer->compose() |
|
||||||
->setTo($email) |
|
||||||
->setFrom([$this->email => $this->name]) |
|
||||||
->setSubject($this->subject) |
|
||||||
->setTextBody($this->body) |
|
||||||
->send(); |
|
||||||
} |
|
||||||
} |
|
@ -1,60 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace frontend\models; |
|
||||||
|
|
||||||
use common\models\User; |
|
||||||
use yii\base\Model; |
|
||||||
|
|
||||||
/** |
|
||||||
* Password reset request form |
|
||||||
*/ |
|
||||||
class PasswordResetRequestForm extends Model |
|
||||||
{ |
|
||||||
public $email; |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function rules() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
['email', 'filter', 'filter' => 'trim'], |
|
||||||
['email', 'required'], |
|
||||||
['email', 'email'], |
|
||||||
['email', 'exist', |
|
||||||
'targetClass' => '\common\models\User', |
|
||||||
'filter' => ['status' => User::STATUS_ACTIVE], |
|
||||||
'message' => 'There is no user with such email.' |
|
||||||
], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sends an email with a link, for resetting the password. |
|
||||||
* |
|
||||||
* @return boolean whether the email was send |
|
||||||
*/ |
|
||||||
public function sendEmail() |
|
||||||
{ |
|
||||||
/* @var $user User */ |
|
||||||
$user = User::findOne([ |
|
||||||
'status' => User::STATUS_ACTIVE, |
|
||||||
'email' => $this->email, |
|
||||||
]); |
|
||||||
|
|
||||||
if ($user) { |
|
||||||
if (!User::isPasswordResetTokenValid($user->password_reset_token)) { |
|
||||||
$user->generatePasswordResetToken(); |
|
||||||
} |
|
||||||
|
|
||||||
if ($user->save()) { |
|
||||||
return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user]) |
|
||||||
->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) |
|
||||||
->setTo($this->email) |
|
||||||
->setSubject('Password reset for ' . \Yii::$app->name) |
|
||||||
->send(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
@ -1,65 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace frontend\models; |
|
||||||
|
|
||||||
use common\models\User; |
|
||||||
use yii\base\InvalidParamException; |
|
||||||
use yii\base\Model; |
|
||||||
use Yii; |
|
||||||
|
|
||||||
/** |
|
||||||
* Password reset form |
|
||||||
*/ |
|
||||||
class ResetPasswordForm extends Model |
|
||||||
{ |
|
||||||
public $password; |
|
||||||
|
|
||||||
/** |
|
||||||
* @var \common\models\User |
|
||||||
*/ |
|
||||||
private $_user; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a form model given a token. |
|
||||||
* |
|
||||||
* @param string $token |
|
||||||
* @param array $config name-value pairs that will be used to initialize the object properties |
|
||||||
* @throws \yii\base\InvalidParamException if token is empty or not valid |
|
||||||
*/ |
|
||||||
public function __construct($token, $config = []) |
|
||||||
{ |
|
||||||
if (empty($token) || !is_string($token)) { |
|
||||||
throw new InvalidParamException('Password reset token cannot be blank.'); |
|
||||||
} |
|
||||||
$this->_user = User::findByPasswordResetToken($token); |
|
||||||
if (!$this->_user) { |
|
||||||
throw new InvalidParamException('Wrong password reset token.'); |
|
||||||
} |
|
||||||
parent::__construct($config); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function rules() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
['password', 'required'], |
|
||||||
['password', 'string', 'min' => 6], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Resets password. |
|
||||||
* |
|
||||||
* @return boolean if password was reset. |
|
||||||
*/ |
|
||||||
public function resetPassword() |
|
||||||
{ |
|
||||||
$user = $this->_user; |
|
||||||
$user->password = $this->password; |
|
||||||
$user->removePasswordResetToken(); |
|
||||||
|
|
||||||
return $user->save(); |
|
||||||
} |
|
||||||
} |
|
@ -1,57 +0,0 @@ |
|||||||
<?php |
|
||||||
namespace frontend\models; |
|
||||||
|
|
||||||
use common\models\User; |
|
||||||
use yii\base\Model; |
|
||||||
use Yii; |
|
||||||
|
|
||||||
/** |
|
||||||
* Signup form |
|
||||||
*/ |
|
||||||
class SignupForm extends Model |
|
||||||
{ |
|
||||||
public $username; |
|
||||||
public $email; |
|
||||||
public $password; |
|
||||||
|
|
||||||
/** |
|
||||||
* @inheritdoc |
|
||||||
*/ |
|
||||||
public function rules() |
|
||||||
{ |
|
||||||
return [ |
|
||||||
['username', 'filter', 'filter' => 'trim'], |
|
||||||
['username', 'required'], |
|
||||||
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], |
|
||||||
['username', 'string', 'min' => 2, 'max' => 255], |
|
||||||
|
|
||||||
['email', 'filter', 'filter' => 'trim'], |
|
||||||
['email', 'required'], |
|
||||||
['email', 'email'], |
|
||||||
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'], |
|
||||||
|
|
||||||
['password', 'required'], |
|
||||||
['password', 'string', 'min' => 6], |
|
||||||
]; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Signs user up. |
|
||||||
* |
|
||||||
* @return User|null the saved model or null if saving fails |
|
||||||
*/ |
|
||||||
public function signup() |
|
||||||
{ |
|
||||||
if ($this->validate()) { |
|
||||||
$user = new User(); |
|
||||||
$user->username = $this->username; |
|
||||||
$user->email = $this->email; |
|
||||||
$user->setPassword($this->password); |
|
||||||
$user->generateAuthKey(); |
|
||||||
$user->save(); |
|
||||||
return $user; |
|
||||||
} |
|
||||||
|
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
* |
|
||||||
!.gitignore |
|
@ -1,76 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\Nav; |
|
||||||
use yii\bootstrap\NavBar; |
|
||||||
use yii\widgets\Breadcrumbs; |
|
||||||
use frontend\assets\AppAsset; |
|
||||||
use frontend\widgets\Alert; |
|
||||||
|
|
||||||
/* @var $this \yii\web\View */ |
|
||||||
/* @var $content string */ |
|
||||||
|
|
||||||
AppAsset::register($this); |
|
||||||
?> |
|
||||||
<?php $this->beginPage() ?> |
|
||||||
<!DOCTYPE html> |
|
||||||
<html lang="<?= Yii::$app->language ?>">
|
|
||||||
<head> |
|
||||||
<meta charset="<?= Yii::$app->charset ?>"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
||||||
<?= Html::csrfMetaTags() ?> |
|
||||||
<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', |
|
||||||
], |
|
||||||
]); |
|
||||||
$menuItems = [ |
|
||||||
['label' => 'Home', 'url' => ['/site/index']], |
|
||||||
['label' => 'About', 'url' => ['/site/about']], |
|
||||||
['label' => 'Contact', 'url' => ['/site/contact']], |
|
||||||
]; |
|
||||||
if (Yii::$app->user->isGuest) { |
|
||||||
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; |
|
||||||
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; |
|
||||||
} else { |
|
||||||
$menuItems[] = [ |
|
||||||
'label' => 'Logout (' . Yii::$app->user->identity->username . ')', |
|
||||||
'url' => ['/site/logout'], |
|
||||||
'linkOptions' => ['data-method' => 'post'] |
|
||||||
]; |
|
||||||
} |
|
||||||
echo Nav::widget([ |
|
||||||
'options' => ['class' => 'navbar-nav navbar-right'], |
|
||||||
'items' => $menuItems, |
|
||||||
]); |
|
||||||
NavBar::end(); |
|
||||||
?> |
|
||||||
|
|
||||||
<div class="container"> |
|
||||||
<?= Breadcrumbs::widget([ |
|
||||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], |
|
||||||
]) ?> |
|
||||||
<?= Alert::widget() ?> |
|
||||||
<?= $content ?> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<footer class="footer"> |
|
||||||
<div class="container"> |
|
||||||
<p class="pull-left">© My Company <?= date('Y') ?></p>
|
|
||||||
<p class="pull-right"><?= Yii::powered() ?></p>
|
|
||||||
</div> |
|
||||||
</footer> |
|
||||||
|
|
||||||
<?php $this->endBody() ?> |
|
||||||
</body> |
|
||||||
</html> |
|
||||||
<?php $this->endPage() ?> |
|
@ -1,14 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
$this->title = 'About'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-about"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<p>This is the About page. You may modify the following file to customize its content:</p> |
|
||||||
|
|
||||||
<code><?= __FILE__ ?></code>
|
|
||||||
</div> |
|
@ -1,37 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\ActiveForm; |
|
||||||
use yii\captcha\Captcha; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $form yii\bootstrap\ActiveForm */ |
|
||||||
/* @var $model \frontend\models\ContactForm */ |
|
||||||
|
|
||||||
$this->title = 'Contact'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-contact"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<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> |
|
||||||
|
|
||||||
</div> |
|
@ -1,27 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
use yii\helpers\Html; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $name string */ |
|
||||||
/* @var $message string */ |
|
||||||
/* @var $exception Exception */ |
|
||||||
|
|
||||||
$this->title = $name; |
|
||||||
?> |
|
||||||
<div class="site-error"> |
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<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> |
|
||||||
|
|
||||||
</div> |
|
@ -1,51 +0,0 @@ |
|||||||
<?php |
|
||||||
/* @var $this yii\web\View */ |
|
||||||
$this->title = 'My Yii Application'; |
|
||||||
?> |
|
||||||
<div class="site-index"> |
|
||||||
|
|
||||||
<div class="jumbotron"> |
|
||||||
<h1>Congratulations!</h1> |
|
||||||
|
|
||||||
<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> |
|
||||||
|
|
||||||
<div class="body-content"> |
|
||||||
|
|
||||||
<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><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</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><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</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><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,32 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\ActiveForm; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $form yii\bootstrap\ActiveForm */ |
|
||||||
/* @var $model \common\models\LoginForm */ |
|
||||||
|
|
||||||
$this->title = 'Login'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-login"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<p>Please fill out the following fields to login:</p> |
|
||||||
|
|
||||||
<div class="row"> |
|
||||||
<div class="col-lg-5"> |
|
||||||
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?> |
|
||||||
<?= $form->field($model, 'username') ?> |
|
||||||
<?= $form->field($model, 'password')->passwordInput() ?> |
|
||||||
<?= $form->field($model, 'rememberMe')->checkbox() ?> |
|
||||||
<div style="color:#999;margin:1em 0"> |
|
||||||
If you forgot your password you can <?= Html::a('reset it', ['site/request-password-reset']) ?>.
|
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?> |
|
||||||
</div> |
|
||||||
<?php ActiveForm::end(); ?> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,27 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\ActiveForm; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $form yii\bootstrap\ActiveForm */ |
|
||||||
/* @var $model \frontend\models\PasswordResetRequestForm */ |
|
||||||
|
|
||||||
$this->title = 'Request password reset'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-request-password-reset"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<p>Please fill out your email. A link to reset password will be sent there.</p> |
|
||||||
|
|
||||||
<div class="row"> |
|
||||||
<div class="col-lg-5"> |
|
||||||
<?php $form = ActiveForm::begin(['id' => 'request-password-reset-form']); ?> |
|
||||||
<?= $form->field($model, 'email') ?> |
|
||||||
<div class="form-group"> |
|
||||||
<?= Html::submitButton('Send', ['class' => 'btn btn-primary']) ?> |
|
||||||
</div> |
|
||||||
<?php ActiveForm::end(); ?> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,27 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\ActiveForm; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $form yii\bootstrap\ActiveForm */ |
|
||||||
/* @var $model \frontend\models\ResetPasswordForm */ |
|
||||||
|
|
||||||
$this->title = 'Reset password'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-reset-password"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<p>Please choose your new password:</p> |
|
||||||
|
|
||||||
<div class="row"> |
|
||||||
<div class="col-lg-5"> |
|
||||||
<?php $form = ActiveForm::begin(['id' => 'reset-password-form']); ?> |
|
||||||
<?= $form->field($model, 'password')->passwordInput() ?> |
|
||||||
<div class="form-group"> |
|
||||||
<?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?> |
|
||||||
</div> |
|
||||||
<?php ActiveForm::end(); ?> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,29 +0,0 @@ |
|||||||
<?php |
|
||||||
use yii\helpers\Html; |
|
||||||
use yii\bootstrap\ActiveForm; |
|
||||||
|
|
||||||
/* @var $this yii\web\View */ |
|
||||||
/* @var $form yii\bootstrap\ActiveForm */ |
|
||||||
/* @var $model \frontend\models\SignupForm */ |
|
||||||
|
|
||||||
$this->title = 'Signup'; |
|
||||||
$this->params['breadcrumbs'][] = $this->title; |
|
||||||
?> |
|
||||||
<div class="site-signup"> |
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
|
||||||
|
|
||||||
<p>Please fill out the following fields to signup:</p> |
|
||||||
|
|
||||||
<div class="row"> |
|
||||||
<div class="col-lg-5"> |
|
||||||
<?php $form = ActiveForm::begin(['id' => 'form-signup']); ?> |
|
||||||
<?= $form->field($model, 'username') ?> |
|
||||||
<?= $form->field($model, 'email') ?> |
|
||||||
<?= $form->field($model, 'password')->passwordInput() ?> |
|
||||||
<div class="form-group"> |
|
||||||
<?= Html::submitButton('Signup', ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?> |
|
||||||
</div> |
|
||||||
<?php ActiveForm::end(); ?> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</div> |
|
@ -1,2 +0,0 @@ |
|||||||
/index.php |
|
||||||
/index-test.php |
|
@ -1,2 +0,0 @@ |
|||||||
* |
|
||||||
!.gitignore |
|
@ -1,91 +0,0 @@ |
|||||||
html, |
|
||||||
body { |
|
||||||
height: 100%; |
|
||||||
} |
|
||||||
|
|
||||||
.wrap { |
|
||||||
min-height: 100%; |
|
||||||
height: auto; |
|
||||||
margin: 0 auto -60px; |
|
||||||
padding: 0 0 60px; |
|
||||||
} |
|
||||||
|
|
||||||
.wrap > .container { |
|
||||||
padding: 70px 15px 20px; |
|
||||||
} |
|
||||||
|
|
||||||
.footer { |
|
||||||
height: 60px; |
|
||||||
background-color: #f5f5f5; |
|
||||||
border-top: 1px solid #ddd; |
|
||||||
padding-top: 20px; |
|
||||||
} |
|
||||||
|
|
||||||
.jumbotron { |
|
||||||
text-align: center; |
|
||||||
background-color: transparent; |
|
||||||
} |
|
||||||
|
|
||||||
.jumbotron .btn { |
|
||||||
font-size: 21px; |
|
||||||
padding: 14px 24px; |
|
||||||
} |
|
||||||
|
|
||||||
.not-set { |
|
||||||
color: #c55; |
|
||||||
font-style: italic; |
|
||||||
} |
|
||||||
|
|
||||||
/* 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"; |
|
||||||
} |
|
||||||
|
|
||||||
.grid-view th { |
|
||||||
white-space: nowrap; |
|
||||||
} |
|
||||||
|
|
||||||
.hint-block { |
|
||||||
display: block; |
|
||||||
margin-top: 5px; |
|
||||||
color: #999; |
|
||||||
} |
|
||||||
|
|
||||||
.error-summary { |
|
||||||
color: #a94442; |
|
||||||
background: #fdf7f7; |
|
||||||
border-left: 3px solid #eed3d7; |
|
||||||
padding: 10px 20px; |
|
||||||
margin: 0 0 15px 0; |
|
||||||
} |
|
Before Width: | Height: | Size: 318 B |
@ -1,79 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* @link http://www.yiiframework.com/ |
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
* @license http://www.yiiframework.com/license/ |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace frontend\widgets; |
|
||||||
|
|
||||||
/** |
|
||||||
* 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: |
|
||||||
* |
|
||||||
* ```php |
|
||||||
* \Yii::$app->getSession()->setFlash('error', 'This is the message'); |
|
||||||
* \Yii::$app->getSession()->setFlash('success', 'This is the message'); |
|
||||||
* \Yii::$app->getSession()->setFlash('info', 'This is the message'); |
|
||||||
* ``` |
|
||||||
* |
|
||||||
* Multiple messages could be set as follows: |
|
||||||
* |
|
||||||
* ```php |
|
||||||
* \Yii::$app->getSession()->setFlash('error', ['Error 1', 'Error 2']); |
|
||||||
* ``` |
|
||||||
* |
|
||||||
* @author Kartik Visweswaran <kartikv2@gmail.com> |
|
||||||
* @author Alexander Makarov <sam@rmcreative.ru> |
|
||||||
*/ |
|
||||||
class Alert extends \yii\bootstrap\Widget |
|
||||||
{ |
|
||||||
/** |
|
||||||
* @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' => 'alert-danger', |
|
||||||
'danger' => 'alert-danger', |
|
||||||
'success' => 'alert-success', |
|
||||||
'info' => 'alert-info', |
|
||||||
'warning' => 'alert-warning' |
|
||||||
]; |
|
||||||
|
|
||||||
/** |
|
||||||
* @var array the options for rendering the close button tag. |
|
||||||
*/ |
|
||||||
public $closeButton = []; |
|
||||||
|
|
||||||
public function init() |
|
||||||
{ |
|
||||||
parent::init(); |
|
||||||
|
|
||||||
$session = \Yii::$app->getSession(); |
|
||||||
$flashes = $session->getAllFlashes(); |
|
||||||
$appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : ''; |
|
||||||
|
|
||||||
foreach ($flashes as $type => $data) { |
|
||||||
if (isset($this->alertTypes[$type])) { |
|
||||||
$data = (array) $data; |
|
||||||
foreach ($data as $message) { |
|
||||||
/* initialize css class for each alert box */ |
|
||||||
$this->options['class'] = $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); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,205 +0,0 @@ |
|||||||
#!/usr/bin/env php |
|
||||||
<?php |
|
||||||
/** |
|
||||||
* Yii Application Initialization Tool |
|
||||||
* |
|
||||||
* In order to run in non-interactive mode: |
|
||||||
* |
|
||||||
* init --env=Development --overwrite=n |
|
||||||
* |
|
||||||
* @author Alexander Makarov <sam@rmcreative.ru> |
|
||||||
* |
|
||||||
* @link http://www.yiiframework.com/ |
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
* @license http://www.yiiframework.com/license/ |
|
||||||
*/ |
|
||||||
|
|
||||||
if (!extension_loaded('mcrypt')) { |
|
||||||
die('The mcrypt PHP extension is required by Yii2.'); |
|
||||||
} |
|
||||||
|
|
||||||
$params = getParams(); |
|
||||||
$root = str_replace('\\', '/', __DIR__); |
|
||||||
$envs = require("$root/environments/index.php"); |
|
||||||
$envNames = array_keys($envs); |
|
||||||
|
|
||||||
echo "Yii Application Initialization Tool v1.0\n\n"; |
|
||||||
|
|
||||||
$envName = null; |
|
||||||
if (empty($params['env']) || $params['env'] === '1') { |
|
||||||
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']; |
|
||||||
} |
|
||||||
|
|
||||||
if (!in_array($envName, $envNames)) { |
|
||||||
$envsList = implode(', ', $envNames); |
|
||||||
echo "\n $envName is not a valid environment. Try one of the following: $envsList. \n"; |
|
||||||
exit(2); |
|
||||||
} |
|
||||||
|
|
||||||
$env = $envs[$envName]; |
|
||||||
|
|
||||||
if (empty($params['env'])) { |
|
||||||
echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] "; |
|
||||||
$answer = trim(fgets(STDIN)); |
|
||||||
if (strncasecmp($answer, 'y', 1)) { |
|
||||||
echo "\n Quit initialization.\n"; |
|
||||||
exit(0); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
echo "\n Start initialization ...\n\n"; |
|
||||||
$files = getFileList("$root/environments/{$env['path']}"); |
|
||||||
$all = false; |
|
||||||
foreach ($files as $file) { |
|
||||||
if (!copyFile($root, "environments/{$env['path']}/$file", $file, $all, $params)) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
$callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable']; |
|
||||||
foreach ($callbacks as $callback) { |
|
||||||
if (!empty($env[$callback])) { |
|
||||||
$callback($root, $env[$callback]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
echo "\n ... initialization completed.\n\n"; |
|
||||||
|
|
||||||
function getFileList($root, $basePath = '') |
|
||||||
{ |
|
||||||
$files = []; |
|
||||||
$handle = opendir($root); |
|
||||||
while (($path = readdir($handle)) !== false) { |
|
||||||
if ($path === '.svn' || $path === '.' || $path === '..') { |
|
||||||
continue; |
|
||||||
} |
|
||||||
$fullPath = "$root/$path"; |
|
||||||
$relativePath = $basePath === '' ? $path : "$basePath/$path"; |
|
||||||
if (is_dir($fullPath)) { |
|
||||||
$files = array_merge($files, getFileList($fullPath, $relativePath)); |
|
||||||
} else { |
|
||||||
$files[] = $relativePath; |
|
||||||
} |
|
||||||
} |
|
||||||
closedir($handle); |
|
||||||
return $files; |
|
||||||
} |
|
||||||
|
|
||||||
function copyFile($root, $source, $target, &$all, $params) |
|
||||||
{ |
|
||||||
if (!is_file($root . '/' . $source)) { |
|
||||||
echo " skip $target ($source not exist)\n"; |
|
||||||
return true; |
|
||||||
} |
|
||||||
if (is_file($root . '/' . $target)) { |
|
||||||
if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) { |
|
||||||
echo " unchanged $target\n"; |
|
||||||
return true; |
|
||||||
} |
|
||||||
if ($all) { |
|
||||||
echo " overwrite $target\n"; |
|
||||||
} else { |
|
||||||
echo " exist $target\n"; |
|
||||||
echo " ...overwrite? [Yes|No|All|Quit] "; |
|
||||||
|
|
||||||
|
|
||||||
$answer = !empty($params['overwrite']) ? $params['overwrite'] : trim(fgets(STDIN)); |
|
||||||
if (!strncasecmp($answer, 'q', 1)) { |
|
||||||
return false; |
|
||||||
} else { |
|
||||||
if (!strncasecmp($answer, 'y', 1)) { |
|
||||||
echo " overwrite $target\n"; |
|
||||||
} else { |
|
||||||
if (!strncasecmp($answer, 'a', 1)) { |
|
||||||
echo " overwrite $target\n"; |
|
||||||
$all = true; |
|
||||||
} else { |
|
||||||
echo " skip $target\n"; |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); |
|
||||||
return true; |
|
||||||
} |
|
||||||
echo " generate $target\n"; |
|
||||||
@mkdir(dirname($root . '/' . $target), 0777, true); |
|
||||||
file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); |
|
||||||
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; |
|
||||||
} |
|
||||||
|
|
||||||
function setWritable($root, $paths) |
|
||||||
{ |
|
||||||
foreach ($paths as $writable) { |
|
||||||
echo " chmod 0777 $writable\n"; |
|
||||||
@chmod("$root/$writable", 0777); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
function setExecutable($root, $paths) |
|
||||||
{ |
|
||||||
foreach ($paths as $executable) { |
|
||||||
echo " chmod 0755 $executable\n"; |
|
||||||
@chmod("$root/$executable", 0755); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
function setCookieValidationKey($root, $paths) |
|
||||||
{ |
|
||||||
foreach ($paths as $file) { |
|
||||||
echo " generate cookie validation key in $file\n"; |
|
||||||
$file = $root . '/' . $file; |
|
||||||
$length = 32; |
|
||||||
$bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); |
|
||||||
$key = strtr(substr(base64_encode($bytes), 0, $length), '+/=', '_-.'); |
|
||||||
$content = preg_replace('/(("|\')cookieValidationKey("|\')\s*=>\s*)(""|\'\')/', "\\1'$key'", file_get_contents($file)); |
|
||||||
file_put_contents($file, $content); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
function createSymlink($links) |
|
||||||
{ |
|
||||||
foreach ($links as $link => $target) { |
|
||||||
echo " symlink $target as $link\n"; |
|
||||||
if (!is_link($link)) { |
|
||||||
symlink($target, $link); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,20 +0,0 @@ |
|||||||
@echo off |
|
||||||
|
|
||||||
rem ------------------------------------------------------------- |
|
||||||
rem Yii command line init script for Windows. |
|
||||||
rem |
|
||||||
rem @author Qiang Xue <qiang.xue@gmail.com> |
|
||||||
rem @link http://www.yiiframework.com/ |
|
||||||
rem @copyright Copyright (c) 2008 Yii Software LLC |
|
||||||
rem @license http://www.yiiframework.com/license/ |
|
||||||
rem ------------------------------------------------------------- |
|
||||||
|
|
||||||
@setlocal |
|
||||||
|
|
||||||
set YII_PATH=%~dp0 |
|
||||||
|
|
||||||
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe |
|
||||||
|
|
||||||
"%PHP_COMMAND%" "%YII_PATH%init" %* |
|
||||||
|
|
||||||
@endlocal |
|
@ -1,139 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* Application requirement checker script. |
|
||||||
* |
|
||||||
* In order to run this script use the following console command: |
|
||||||
* php requirements.php |
|
||||||
* |
|
||||||
* In order to run this script from the web, you should copy it to the web root. |
|
||||||
* If you are using Linux you can create a hard link instead, using the following command: |
|
||||||
* ln requirements.php ../requirements.php |
|
||||||
*/ |
|
||||||
|
|
||||||
// you may need to adjust this path to the correct Yii framework path |
|
||||||
$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>'; |
|
||||||
} |
|
||||||
|
|
||||||
require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); |
|
||||||
$requirementsChecker = new YiiRequirementChecker(); |
|
||||||
|
|
||||||
$gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; |
|
||||||
$gdOK = $imagickOK = false; |
|
||||||
|
|
||||||
if (extension_loaded('imagick')) { |
|
||||||
$imagick = new Imagick(); |
|
||||||
$imagickFormats = $imagick->queryFormats('PNG'); |
|
||||||
if (in_array('PNG', $imagickFormats)) { |
|
||||||
$imagickOK = true; |
|
||||||
} else { |
|
||||||
$imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (extension_loaded('gd')) { |
|
||||||
$gdInfo = gd_info(); |
|
||||||
if (!empty($gdInfo['FreeType Support'])) { |
|
||||||
$gdOK = true; |
|
||||||
} else { |
|
||||||
$gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Adjust requirements according to your application specifics. |
|
||||||
*/ |
|
||||||
$requirements = array( |
|
||||||
// Database : |
|
||||||
array( |
|
||||||
'name' => 'PDO extension', |
|
||||||
'mandatory' => true, |
|
||||||
'condition' => extension_loaded('pdo'), |
|
||||||
'by' => 'All DB-related classes', |
|
||||||
), |
|
||||||
array( |
|
||||||
'name' => 'PDO SQLite extension', |
|
||||||
'mandatory' => false, |
|
||||||
'condition' => extension_loaded('pdo_sqlite'), |
|
||||||
'by' => 'All DB-related classes', |
|
||||||
'memo' => 'Required for SQLite database.', |
|
||||||
), |
|
||||||
array( |
|
||||||
'name' => 'PDO MySQL extension', |
|
||||||
'mandatory' => false, |
|
||||||
'condition' => extension_loaded('pdo_mysql'), |
|
||||||
'by' => 'All DB-related classes', |
|
||||||
'memo' => 'Required for MySQL database.', |
|
||||||
), |
|
||||||
array( |
|
||||||
'name' => 'PDO PostgreSQL extension', |
|
||||||
'mandatory' => false, |
|
||||||
'condition' => extension_loaded('pdo_pgsql'), |
|
||||||
'by' => 'All DB-related classes', |
|
||||||
'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-2.0/yii-caching-memcache.html">MemCache</a>', |
|
||||||
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : '' |
|
||||||
), |
|
||||||
array( |
|
||||||
'name' => 'APC extension', |
|
||||||
'mandatory' => false, |
|
||||||
'condition' => extension_loaded('apc'), |
|
||||||
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>', |
|
||||||
), |
|
||||||
// CAPTCHA: |
|
||||||
array( |
|
||||||
'name' => 'GD PHP extension with FreeType support', |
|
||||||
'mandatory' => false, |
|
||||||
'condition' => $gdOK, |
|
||||||
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>', |
|
||||||
'memo' => $gdMemo, |
|
||||||
), |
|
||||||
array( |
|
||||||
'name' => 'ImageMagick PHP extension with PNG support', |
|
||||||
'mandatory' => false, |
|
||||||
'condition' => $imagickOK, |
|
||||||
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>', |
|
||||||
'memo' => $imagickMemo, |
|
||||||
), |
|
||||||
// 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(); |
|
@ -1,58 +0,0 @@ |
|||||||
This directory contains various tests for the advanced applications. |
|
||||||
|
|
||||||
Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/). |
|
||||||
|
|
||||||
After creating and setting up the advanced application, follow these steps to prepare for the tests: |
|
||||||
|
|
||||||
1. Install Codeception if it's not yet installed: |
|
||||||
|
|
||||||
``` |
|
||||||
composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" |
|
||||||
``` |
|
||||||
|
|
||||||
If you've never used Composer for global packages run `composer global status`. It should output: |
|
||||||
|
|
||||||
``` |
|
||||||
Changed current directory to <directory> |
|
||||||
``` |
|
||||||
|
|
||||||
Then add `<directory>/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command |
|
||||||
line globally. |
|
||||||
|
|
||||||
2. Install faker extension by running the following from template root directory where `composer.json` is: |
|
||||||
|
|
||||||
``` |
|
||||||
composer require --dev yiisoft/yii2-faker:* |
|
||||||
``` |
|
||||||
|
|
||||||
3. Create `yii2_advanced_tests` database then update it by applying migrations: |
|
||||||
|
|
||||||
``` |
|
||||||
codeception/bin/yii migrate |
|
||||||
``` |
|
||||||
|
|
||||||
4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in |
|
||||||
webserver. In the root directory where `common`, `frontend` etc. are execute the following: |
|
||||||
|
|
||||||
``` |
|
||||||
php -S localhost:8080 |
|
||||||
``` |
|
||||||
|
|
||||||
5. Now you can run the tests with the following commands, assuming you are in the `tests/codeception` directory: |
|
||||||
|
|
||||||
``` |
|
||||||
# frontend tests |
|
||||||
cd frontend |
|
||||||
codecept build |
|
||||||
codecept run |
|
||||||
|
|
||||||
# backend tests |
|
||||||
|
|
||||||
cd backend |
|
||||||
codecept build |
|
||||||
codecept run |
|
||||||
|
|
||||||
# etc. |
|
||||||
``` |
|
||||||
|
|
||||||
If you already have run `codecept build` for each application, you can skip that step and run all tests by a single `codecept run`. |
|
@ -1,11 +0,0 @@ |
|||||||
include: |
|
||||||
- codeception/common |
|
||||||
- codeception/console |
|
||||||
- codeception/backend |
|
||||||
- codeception/frontend |
|
||||||
|
|
||||||
paths: |
|
||||||
log: codeception/_output |
|
||||||
|
|
||||||
settings: |
|
||||||
colors: true |
|
@ -1,2 +0,0 @@ |
|||||||
* |
|
||||||
!.gitignore |
|
@ -1,4 +0,0 @@ |
|||||||
# these files are auto generated by codeception build |
|
||||||
/unit/UnitTester.php |
|
||||||
/functional/FunctionalTester.php |
|
||||||
/acceptance/AcceptanceTester.php |
|
@ -1,23 +0,0 @@ |
|||||||
<?php |
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true); |
|
||||||
defined('YII_ENV') or define('YII_ENV', 'test'); |
|
||||||
|
|
||||||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); |
|
||||||
|
|
||||||
defined('YII_BACKEND_TEST_ENTRY_URL') or define('YII_BACKEND_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH)); |
|
||||||
defined('YII_TEST_BACKEND_ENTRY_FILE') or define('YII_TEST_BACKEND_ENTRY_FILE', YII_APP_BASE_PATH . '/backend/web/index-test.php'); |
|
||||||
|
|
||||||
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); |
|
||||||
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); |
|
||||||
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); |
|
||||||
require_once(YII_APP_BASE_PATH . '/backend/config/bootstrap.php'); |
|
||||||
|
|
||||||
// set correct script paths |
|
||||||
|
|
||||||
// the entry script file path for functional and acceptance tests |
|
||||||
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_BACKEND_ENTRY_FILE; |
|
||||||
$_SERVER['SCRIPT_NAME'] = YII_BACKEND_TEST_ENTRY_URL; |
|
||||||
$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST); |
|
||||||
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80'; |
|
||||||
|
|
||||||
Yii::setAlias('@tests', dirname(dirname(__DIR__))); |
|
@ -1,2 +0,0 @@ |
|||||||
* |
|
||||||
!.gitignore |
|
@ -1,28 +0,0 @@ |
|||||||
# Codeception Test Suite Configuration |
|
||||||
|
|
||||||
# suite for acceptance tests. |
|
||||||
# perform tests in browser using the Selenium-like tools. |
|
||||||
# powered by Mink (http://mink.behat.org). |
|
||||||
# (tip: that's what your customer will see). |
|
||||||
# (tip: test your ajax and javascript by one of Mink drivers). |
|
||||||
|
|
||||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. |
|
||||||
|
|
||||||
class_name: AcceptanceTester |
|
||||||
modules: |
|
||||||
enabled: |
|
||||||
- PhpBrowser |
|
||||||
- tests\codeception\common\_support\FixtureHelper |
|
||||||
# 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, |
|
||||||
# it is useful if you want to login in your app in each test. |
|
||||||
# - WebDriver |
|
||||||
config: |
|
||||||
PhpBrowser: |
|
||||||
# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO |
|
||||||
url: http://localhost:8080 |
|
||||||
# WebDriver: |
|
||||||
# url: http://localhost:8080 |
|
||||||
# browser: firefox |
|
||||||
# restart: true |
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue