Qiang Xue
11 years ago
1143 changed files with 1953 additions and 150347 deletions
@ -1,4 +0,0 @@
|
||||
service_name: travis-ci |
||||
src_dir: framework/yii |
||||
coverage_clover: tests/unit/runtime/coveralls/clover.xml |
||||
json_path: tests/unit/runtime/coveralls/coveralls-upload.json |
@ -1,23 +0,0 @@
|
||||
# Autodetect text files |
||||
* text=auto |
||||
|
||||
# ...Unless the name matches the following overriding patterns |
||||
|
||||
# Definitively text files |
||||
*.php text |
||||
*.css text |
||||
*.js text |
||||
*.txt text |
||||
*.md text |
||||
*.xml text |
||||
*.json text |
||||
*.bat text |
||||
*.sql text |
||||
*.xml text |
||||
*.yml text |
||||
|
||||
# Ensure those won't be messed up with |
||||
*.png binary |
||||
*.jpg binary |
||||
*.gif binary |
||||
*.ttf binary |
@ -1,29 +0,0 @@
|
||||
# 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 |
||||
# composer.lock should not be committed as we always want the latest versions |
||||
/composer.lock |
||||
|
||||
# Mac DS_Store Files |
||||
.DS_Store |
||||
|
||||
# phpunit itself is not needed |
||||
phpunit.phar |
||||
# local phpunit config |
||||
/phpunit.xml |
@ -1,41 +0,0 @@
|
||||
language: php |
||||
|
||||
php: |
||||
- 5.4 |
||||
- 5.5 |
||||
# - hhvm # commented until composer or hhvm get fixed: https://github.com/facebook/hhvm/issues/1347 |
||||
|
||||
services: |
||||
- redis-server |
||||
- memcached |
||||
- elasticsearch |
||||
- mongodb |
||||
|
||||
install: |
||||
- composer self-update && composer --version |
||||
# core framework: |
||||
# - composer require satooshi/php-coveralls 0.6.* --dev --prefer-dist |
||||
- composer install --prefer-dist |
||||
- tests/unit/data/travis/mongodb-setup.sh |
||||
- tests/unit/data/travis/apc-setup.sh |
||||
- tests/unit/data/travis/memcache-setup.sh |
||||
- tests/unit/data/travis/cubrid-setup.sh |
||||
# basic application: |
||||
- composer install --dev --prefer-dist -d apps/basic |
||||
- cd apps/basic && php vendor/bin/codecept build && cd ../.. |
||||
- cd apps && php -S localhost:8080 & |
||||
|
||||
before_script: |
||||
- echo 'elasticsearch version ' && curl http://localhost:9200/ |
||||
- mysql -e 'CREATE DATABASE yiitest;'; |
||||
- psql -U postgres -c 'CREATE DATABASE yiitest;'; |
||||
- tests/unit/data/travis/sphinx-setup.sh |
||||
- mongo yii2test --eval 'db.addUser("travis", "test");' |
||||
|
||||
script: |
||||
# - vendor/bin/phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml --verbose --exclude-group mssql,oci,wincache,xcache,zenddata,vendor |
||||
- vendor/bin/phpunit --verbose --exclude-group mssql,oci,wincache,xcache,zenddata,vendor |
||||
- cd apps/basic && php vendor/bin/codecept run |
||||
|
||||
#after_script: |
||||
# - php vendor/bin/coveralls |
@ -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,70 +1,32 @@
|
||||
Yii PHP Framework Version 2 |
||||
=========================== |
||||
Twitter Bootstrap Extension for Yii 2 |
||||
===================================== |
||||
|
||||
Thank you for choosing Yii 2 - a modern PHP framework designed for professional Web development. |
||||
This is the Twitter Bootstrap extension for Yii 2. It encapsulates Bootstrap components |
||||
and plugins in terms of Yii widgets, and thus makes using Bootstrap components/plugins |
||||
in Yii applications extremely easy. For example, the following |
||||
single line of code in a view file would render a Bootstrap Progress plugin: |
||||
|
||||
Yii 2 is a complete rewrite of its previous version Yii 1.1 which is one of the most popular PHP frameworks. |
||||
Yii 2 inherits the main spirit behind Yii for being simple, fast and highly extensible. |
||||
Yii 2 requires PHP 5.4 and embraces best practices and protocols found in modern Web application development. |
||||
```php |
||||
<?= yii\bootstrap\Progress::widget(['percent' => 60, 'label' => 'test']) ?> |
||||
``` |
||||
|
||||
|
||||
**Yii 2 is not ready for production use yet.** We may make significant changes without prior notices. |
||||
We expect to make the first stable release of Yii 2 in early 2014. |
||||
|
||||
If you mainly want to learn Yii with no real project development requirement, we highly recommend |
||||
you start with Yii 2 as it will be our main focus for the next few years. |
||||
|
||||
If you have a real project with tight schedule, you should stick to [Yii 1.1](https://github.com/yiisoft/yii) |
||||
which is the latest stable release of Yii. |
||||
|
||||
|
||||
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2/v/stable.png)](https://packagist.org/packages/yiisoft/yii2) |
||||
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2/downloads.png)](https://packagist.org/packages/yiisoft/yii2) |
||||
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2) |
||||
[![Dependency Status](https://www.versioneye.com/php/yiisoft:yii2/dev-master/badge.png)](https://www.versioneye.com/php/yiisoft:yii2/dev-master) |
||||
|
||||
|
||||
DIRECTORY STRUCTURE |
||||
------------------- |
||||
|
||||
apps/ ready-to-use application templates |
||||
advanced/ a template suitable for building sophisticated Web applications |
||||
basic/ a template suitable for building simple Web applications |
||||
benchmark/ an application demonstrating the performance of Yii |
||||
build/ internally used build tools |
||||
docs/ documentation |
||||
extensions/ extensions |
||||
framework/ core framework code |
||||
tests/ tests of the core framework code |
||||
|
||||
|
||||
REQUIREMENTS |
||||
Installation |
||||
------------ |
||||
|
||||
The minimum requirement by Yii is that your Web server supports PHP 5.4. |
||||
|
||||
|
||||
DOCUMENTATION |
||||
------------- |
||||
|
||||
A draft of the [Definitive Guide](docs/guide/index.md) is available. |
||||
|
||||
For 1.1 users, you may refer to [Upgrading from Yii 1.1](docs/guide/upgrade-from-v1.md) |
||||
to have a general idea of what has changed in 2.0. |
||||
|
||||
The preferred way to install this extension is through [composer](http://getcomposer.org/download/). |
||||
|
||||
HOW TO PARTICIPATE |
||||
------------------ |
||||
Either run |
||||
|
||||
**Your participation to Yii 2 development is very welcome!** |
||||
``` |
||||
php composer.phar require --prefer-dist yiisoft/yii2-bootstrap "*" |
||||
``` |
||||
|
||||
You may participate in the following ways: |
||||
or add |
||||
|
||||
* [Report issues](https://github.com/yiisoft/yii2/issues) |
||||
* [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/) |
||||
* Fix issues, develop features, write/polish documentation |
||||
- Before you start, please adopt an existing issue (labelled with "ready for adoption") or start a new one to avoid duplicated efforts. |
||||
- Please submit a merge request after you finish development. |
||||
``` |
||||
"yiisoft/yii2-bootstrap": "*" |
||||
``` |
||||
|
||||
In order to make it easier we've prepared [special `yii2-dev` Composer package](https://github.com/yiisoft/yii2/blob/master/docs/internals/getting-started.md). |
||||
to the require section of your `composer.json` file. |
||||
|
||||
|
@ -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,89 +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 |
||||
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 |
||||
vendor/ contains dependent 3rd-party packages |
||||
environments/ contains environment-based overrides |
||||
``` |
||||
|
||||
|
||||
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 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/params-local.php` accordingly. |
||||
3. Apply migrations with console command `yii migrate`. |
||||
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/` |
@ -1,26 +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,41 +0,0 @@
|
||||
<?php |
||||
$rootDir = dirname(dirname(__DIR__)); |
||||
|
||||
$params = array_merge( |
||||
require($rootDir . '/common/config/params.php'), |
||||
require($rootDir . '/common/config/params-local.php'), |
||||
require(__DIR__ . '/params.php'), |
||||
require(__DIR__ . '/params-local.php') |
||||
); |
||||
|
||||
return [ |
||||
'id' => 'app-backend', |
||||
'basePath' => dirname(__DIR__), |
||||
'vendorPath' => $rootDir . '/vendor', |
||||
'preload' => ['log'], |
||||
'controllerNamespace' => 'backend\controllers', |
||||
'modules' => [], |
||||
'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'), |
||||
'components' => [ |
||||
'db' => $params['components.db'], |
||||
'cache' => $params['components.cache'], |
||||
'mail' => $params['components.mail'], |
||||
'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,66 +0,0 @@
|
||||
<?php |
||||
|
||||
namespace backend\controllers; |
||||
|
||||
use Yii; |
||||
use yii\web\Controller; |
||||
use common\models\LoginForm; |
||||
|
||||
class SiteController extends Controller |
||||
{ |
||||
public function behaviors() |
||||
{ |
||||
return [ |
||||
'access' => [ |
||||
'class' => \yii\web\AccessControl::className(), |
||||
'rules' => [ |
||||
[ |
||||
'actions' => ['login', 'error'], |
||||
'allow' => true, |
||||
], |
||||
[ |
||||
'actions' => ['logout', 'index'], |
||||
'allow' => true, |
||||
'roles' => ['@'], |
||||
], |
||||
], |
||||
], |
||||
]; |
||||
} |
||||
|
||||
public function actions() |
||||
{ |
||||
return [ |
||||
'error' => [ |
||||
'class' => 'yii\web\ErrorAction', |
||||
], |
||||
]; |
||||
} |
||||
|
||||
public function actionIndex() |
||||
{ |
||||
return $this->render('index'); |
||||
} |
||||
|
||||
public function actionLogin() |
||||
{ |
||||
if (!\Yii::$app->user->isGuest) { |
||||
$this->goHome(); |
||||
} |
||||
|
||||
$model = new LoginForm(); |
||||
if ($model->load($_POST) && $model->login()) { |
||||
return $this->goBack(); |
||||
} else { |
||||
return $this->render('login', [ |
||||
'model' => $model, |
||||
]); |
||||
} |
||||
} |
||||
|
||||
public function actionLogout() |
||||
{ |
||||
Yii::$app->user->logout(); |
||||
return $this->goHome(); |
||||
} |
||||
} |
@ -1,65 +0,0 @@
|
||||
<?php |
||||
use backend\assets\AppAsset; |
||||
use yii\helpers\Html; |
||||
use yii\bootstrap\Nav; |
||||
use yii\bootstrap\NavBar; |
||||
use yii\widgets\Breadcrumbs; |
||||
|
||||
/** |
||||
* @var \yii\web\View $this |
||||
* @var string $content |
||||
*/ |
||||
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"> |
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?> |
||||
</head> |
||||
<body> |
||||
<?php $this->beginBody() ?> |
||||
<?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']]; |
||||
} |
||||
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> |
||||
|
||||
<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,29 +0,0 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var string $name |
||||
* @var string $message |
||||
* @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,53 +0,0 @@
|
||||
<?php |
||||
/** |
||||
* @var yii\web\View $this |
||||
*/ |
||||
$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,30 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var yii\widgets\ActiveForm $form |
||||
* @var app\models\LoginForm $model |
||||
*/ |
||||
$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']) ?> |
||||
</div> |
||||
<?php ActiveForm::end(); ?> |
||||
</div> |
||||
</div> |
||||
</div> |
@ -1,2 +0,0 @@
|
||||
* |
||||
!.gitignore |
@ -1,79 +0,0 @@
|
||||
body { |
||||
padding-top: 70px; |
||||
} |
||||
|
||||
.footer { |
||||
border-top: 1px solid #ddd; |
||||
margin-top: 30px; |
||||
padding-top: 15px; |
||||
padding-bottom: 30px; |
||||
} |
||||
|
||||
.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: 1.1 KiB |
@ -1,20 +0,0 @@
|
||||
<?php |
||||
|
||||
Yii::setAlias('common', realpath(__DIR__ . '/../')); |
||||
Yii::setAlias('frontend', realpath(__DIR__ . '/../../frontend')); |
||||
Yii::setAlias('backend', realpath(__DIR__ . '/../../backend')); |
||||
Yii::setAlias('console', realpath(__DIR__ . '/../../console')); |
||||
|
||||
return [ |
||||
'adminEmail' => 'admin@example.com', |
||||
'supportEmail' => 'support@example.com', |
||||
|
||||
'components.cache' => [ |
||||
'class' => 'yii\caching\FileCache', |
||||
], |
||||
|
||||
'components.mail' => [ |
||||
'class' => 'yii\swiftmailer\Mailer', |
||||
'viewPath' => '@common/mails', |
||||
], |
||||
]; |
@ -1,24 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\mail\BaseMessage; |
||||
|
||||
/** |
||||
* @var \yii\web\View $this |
||||
* @var BaseMessage $content |
||||
*/ |
||||
?> |
||||
<?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,16 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var common\models\User $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,71 +0,0 @@
|
||||
<?php |
||||
|
||||
namespace common\models; |
||||
|
||||
use Yii; |
||||
use yii\base\Model; |
||||
|
||||
/** |
||||
* LoginForm is the model behind the login form. |
||||
*/ |
||||
class LoginForm extends Model |
||||
{ |
||||
public $username; |
||||
public $password; |
||||
public $rememberMe = true; |
||||
|
||||
private $_user = false; |
||||
|
||||
/** |
||||
* @return array the validation rules. |
||||
*/ |
||||
public function rules() |
||||
{ |
||||
return [ |
||||
// username and password are both required |
||||
[['username', 'password'], 'required'], |
||||
// password is validated by validatePassword() |
||||
['password', 'validatePassword'], |
||||
// rememberMe must be a boolean value |
||||
['rememberMe', 'boolean'], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* Validates the password. |
||||
* This method serves as the inline validation for password. |
||||
*/ |
||||
public function validatePassword() |
||||
{ |
||||
$user = $this->getUser(); |
||||
if (!$user || !$user->validatePassword($this->password)) { |
||||
$this->addError('password', 'Incorrect username or password.'); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Logs in a user using the provided username and password. |
||||
* @return boolean whether the user is logged in successfully |
||||
*/ |
||||
public function login() |
||||
{ |
||||
if ($this->validate()) { |
||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Finds user by [[username]] |
||||
* |
||||
* @return User|null |
||||
*/ |
||||
private function getUser() |
||||
{ |
||||
if ($this->_user === false) { |
||||
$this->_user = User::findByUsername($this->username); |
||||
} |
||||
return $this->_user; |
||||
} |
||||
} |
@ -1,150 +0,0 @@
|
||||
<?php |
||||
namespace common\models; |
||||
|
||||
use yii\db\ActiveRecord; |
||||
use yii\helpers\Security; |
||||
use yii\web\IdentityInterface; |
||||
|
||||
/** |
||||
* Class User |
||||
* @package common\models |
||||
* |
||||
* @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 $create_time |
||||
* @property integer $update_time |
||||
*/ |
||||
class User extends ActiveRecord implements IdentityInterface |
||||
{ |
||||
/** |
||||
* @var string the raw password. Used to collect password input and isn't saved in database |
||||
*/ |
||||
public $password; |
||||
|
||||
const STATUS_DELETED = 0; |
||||
const STATUS_ACTIVE = 10; |
||||
|
||||
const ROLE_USER = 10; |
||||
|
||||
public function behaviors() |
||||
{ |
||||
return [ |
||||
'timestamp' => [ |
||||
'class' => 'yii\behaviors\AutoTimestamp', |
||||
'attributes' => [ |
||||
ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'], |
||||
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time', |
||||
], |
||||
], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* Finds an identity by the given ID. |
||||
* |
||||
* @param string|integer $id the ID to be looked for |
||||
* @return IdentityInterface|null the identity object that matches the given ID. |
||||
*/ |
||||
public static function findIdentity($id) |
||||
{ |
||||
return static::find($id); |
||||
} |
||||
|
||||
/** |
||||
* Finds user by username |
||||
* |
||||
* @param string $username |
||||
* @return null|User |
||||
*/ |
||||
public static function findByUsername($username) |
||||
{ |
||||
return static::find(['username' => $username, 'status' => static::STATUS_ACTIVE]); |
||||
} |
||||
|
||||
/** |
||||
* @return int|string|array current user ID |
||||
*/ |
||||
public function getId() |
||||
{ |
||||
return $this->getPrimaryKey(); |
||||
} |
||||
|
||||
/** |
||||
* @return string current user auth key |
||||
*/ |
||||
public function getAuthKey() |
||||
{ |
||||
return $this->auth_key; |
||||
} |
||||
|
||||
/** |
||||
* @param string $authKey |
||||
* @return boolean if auth key is valid for current user |
||||
*/ |
||||
public function validateAuthKey($authKey) |
||||
{ |
||||
return $this->getAuthKey() === $authKey; |
||||
} |
||||
|
||||
/** |
||||
* @param string $password password to validate |
||||
* @return bool if password provided is valid for current user |
||||
*/ |
||||
public function validatePassword($password) |
||||
{ |
||||
return Security::validatePassword($password, $this->password_hash); |
||||
} |
||||
|
||||
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]], |
||||
|
||||
['username', 'filter', 'filter' => 'trim'], |
||||
['username', 'required'], |
||||
['username', 'string', 'min' => 2, 'max' => 255], |
||||
|
||||
['email', 'filter', 'filter' => 'trim'], |
||||
['email', 'required'], |
||||
['email', 'email'], |
||||
['email', 'unique', 'message' => 'This email address has already been taken.', 'on' => 'signup'], |
||||
['email', 'exist', 'message' => 'There is no user with such email.', 'on' => 'requestPasswordResetToken'], |
||||
|
||||
['password', 'required'], |
||||
['password', 'string', 'min' => 6], |
||||
]; |
||||
} |
||||
|
||||
public function scenarios() |
||||
{ |
||||
return [ |
||||
'signup' => ['username', 'email', 'password', '!status', '!role'], |
||||
'resetPassword' => ['password'], |
||||
'requestPasswordResetToken' => ['email'], |
||||
]; |
||||
} |
||||
|
||||
public function beforeSave($insert) |
||||
{ |
||||
if (parent::beforeSave($insert)) { |
||||
if (($this->isNewRecord || $this->getScenario() === 'resetPassword') && !empty($this->password)) { |
||||
$this->password_hash = Security::generatePasswordHash($this->password); |
||||
} |
||||
if ($this->isNewRecord) { |
||||
$this->auth_key = Security::generateRandomKey(); |
||||
} |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -1,46 +0,0 @@
|
||||
{ |
||||
"name": "yiisoft/yii2-app-advanced", |
||||
"description": "Yii 2 Advanced Application Template", |
||||
"keywords": ["yii", "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": "dev", |
||||
"require": { |
||||
"php": ">=5.4.0", |
||||
"yiisoft/yii2": "*", |
||||
"yiisoft/yii2-bootstrap": "*", |
||||
"yiisoft/yii2-swiftmailer": "*" |
||||
}, |
||||
"require-dev": { |
||||
"yiisoft/yii2-debug": "*", |
||||
"yiisoft/yii2-gii": "*" |
||||
}, |
||||
"scripts": { |
||||
"post-create-project-cmd": [ |
||||
"yii\\composer\\Installer::setPermission" |
||||
] |
||||
}, |
||||
"config": { |
||||
"process-timeout": 1800 |
||||
}, |
||||
"extra": { |
||||
"writable": [ |
||||
"backend/runtime", |
||||
"backend/web/assets", |
||||
|
||||
"console/runtime", |
||||
"console/migrations", |
||||
|
||||
"frontend/runtime", |
||||
"frontend/web/assets" |
||||
] |
||||
} |
||||
} |
@ -1,2 +0,0 @@
|
||||
main-local.php |
||||
params-local.php |
@ -1,33 +0,0 @@
|
||||
<?php |
||||
$rootDir = __DIR__ . '/../..'; |
||||
|
||||
$params = array_merge( |
||||
require($rootDir . '/common/config/params.php'), |
||||
require($rootDir . '/common/config/params-local.php'), |
||||
require(__DIR__ . '/params.php'), |
||||
require(__DIR__ . '/params-local.php') |
||||
); |
||||
|
||||
return [ |
||||
'id' => 'app-console', |
||||
'basePath' => dirname(__DIR__), |
||||
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
||||
'controllerNamespace' => 'console\controllers', |
||||
'modules' => [ |
||||
], |
||||
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'), |
||||
'components' => [ |
||||
'db' => $params['components.db'], |
||||
'cache' => $params['components.cache'], |
||||
'mail' => $params['components.mail'], |
||||
'log' => [ |
||||
'targets' => [ |
||||
[ |
||||
'class' => 'yii\log\FileTarget', |
||||
'levels' => ['error', 'warning'], |
||||
], |
||||
], |
||||
], |
||||
], |
||||
'params' => $params, |
||||
]; |
@ -1,4 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
'adminEmail' => 'admin@example.com', |
||||
]; |
@ -1,33 +0,0 @@
|
||||
<?php |
||||
|
||||
use yii\db\Schema; |
||||
|
||||
class m130524_201442_init extends \yii\db\Migration |
||||
{ |
||||
public function up() |
||||
{ |
||||
$tableOptions = null; |
||||
if ($this->db->driverName === 'mysql') { |
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; |
||||
} |
||||
|
||||
$this->createTable('tbl_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 . '(32)', |
||||
'email' => Schema::TYPE_STRING . ' NOT NULL', |
||||
'role' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', |
||||
|
||||
'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10', |
||||
'create_time' => Schema::TYPE_INTEGER.' NOT NULL', |
||||
'update_time' => Schema::TYPE_INTEGER.' NOT NULL', |
||||
], $tableOptions); |
||||
} |
||||
|
||||
public function down() |
||||
{ |
||||
$this->dropTable('tbl_user'); |
||||
} |
||||
} |
@ -1,10 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
'preload' => [ |
||||
//'debug', |
||||
], |
||||
'modules' => [ |
||||
// 'debug' => 'yii\debug\Module', |
||||
// 'gii' => 'yii\gii\Module', |
||||
], |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,14 +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/Yii.php'); |
||||
|
||||
$config = yii\helpers\ArrayHelper::merge( |
||||
require(__DIR__ . '/../config/main.php'), |
||||
require(__DIR__ . '/../config/main-local.php') |
||||
); |
||||
|
||||
$application = new yii\web\Application($config); |
||||
$application->run(); |
@ -1,10 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
'components.db' => [ |
||||
'class' => 'yii\db\Connection', |
||||
'dsn' => 'mysql:host=localhost;dbname=yii2advanced', |
||||
'username' => 'root', |
||||
'password' => '', |
||||
'charset' => 'utf8', |
||||
], |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,10 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
'preload' => [ |
||||
//'debug', |
||||
], |
||||
'modules' => [ |
||||
// 'debug' => 'yii\debug\Module', |
||||
// 'gii' => 'yii\gii\Module', |
||||
], |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,14 +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/Yii.php'); |
||||
|
||||
$config = yii\helpers\ArrayHelper::merge( |
||||
require(__DIR__ . '/../config/main.php'), |
||||
require(__DIR__ . '/../config/main-local.php') |
||||
); |
||||
|
||||
$application = new yii\web\Application($config); |
||||
$application->run(); |
@ -1,27 +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 defined by default |
||||
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); |
||||
|
||||
require(__DIR__ . '/vendor/autoload.php'); |
||||
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); |
||||
|
||||
$config = yii\helpers\ArrayHelper::merge( |
||||
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,38 +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', |
||||
* 'writable' => [ |
||||
* // list of directories that should be set writable |
||||
* ], |
||||
* ], |
||||
* ]; |
||||
* ``` |
||||
*/ |
||||
return [ |
||||
'Development' => [ |
||||
'path' => 'dev', |
||||
'writable' => [ |
||||
// handled by composer.json already |
||||
], |
||||
'executable' => [ |
||||
'yii', |
||||
], |
||||
], |
||||
'Production' => [ |
||||
'path' => 'prod', |
||||
'writable' => [ |
||||
// handled by composer.json already |
||||
], |
||||
'executable' => [ |
||||
'yii', |
||||
], |
||||
], |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,14 +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/Yii.php'); |
||||
|
||||
$config = yii\helpers\ArrayHelper::merge( |
||||
require(__DIR__ . '/../config/main.php'), |
||||
require(__DIR__ . '/../config/main-local.php') |
||||
); |
||||
|
||||
$application = new yii\web\Application($config); |
||||
$application->run(); |
@ -1,10 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
'components.db' => [ |
||||
'class' => 'yii\db\Connection', |
||||
'dsn' => 'mysql:host=localhost;dbname=yii2advanced', |
||||
'username' => 'root', |
||||
'password' => '', |
||||
'charset' => 'utf8', |
||||
], |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,3 +0,0 @@
|
||||
<?php |
||||
return [ |
||||
]; |
@ -1,14 +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/Yii.php'); |
||||
|
||||
$config = yii\helpers\ArrayHelper::merge( |
||||
require(__DIR__ . '/../config/main.php'), |
||||
require(__DIR__ . '/../config/main-local.php') |
||||
); |
||||
|
||||
$application = new yii\web\Application($config); |
||||
$application->run(); |
@ -1,27 +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 defined by default |
||||
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); |
||||
|
||||
require(__DIR__ . '/vendor/autoload.php'); |
||||
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); |
||||
|
||||
$config = yii\helpers\ArrayHelper::merge( |
||||
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,39 +0,0 @@
|
||||
<?php |
||||
$rootDir = __DIR__ . '/../..'; |
||||
|
||||
$params = array_merge( |
||||
require($rootDir . '/common/config/params.php'), |
||||
require($rootDir . '/common/config/params-local.php'), |
||||
require(__DIR__ . '/params.php'), |
||||
require(__DIR__ . '/params-local.php') |
||||
); |
||||
|
||||
return [ |
||||
'id' => 'app-frontend', |
||||
'basePath' => dirname(__DIR__), |
||||
'vendorPath' => $rootDir . '/vendor', |
||||
'controllerNamespace' => 'frontend\controllers', |
||||
'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'), |
||||
'components' => [ |
||||
'db' => $params['components.db'], |
||||
'cache' => $params['components.cache'], |
||||
'mail' => $params['components.mail'], |
||||
'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 yii\web\Controller; |
||||
use common\models\LoginForm; |
||||
use frontend\models\ContactForm; |
||||
use common\models\User; |
||||
use yii\web\BadRequestHttpException; |
||||
use yii\helpers\Security; |
||||
|
||||
class SiteController extends Controller |
||||
{ |
||||
public function behaviors() |
||||
{ |
||||
return [ |
||||
'access' => [ |
||||
'class' => \yii\web\AccessControl::className(), |
||||
'only' => ['logout', 'signup'], |
||||
'rules' => [ |
||||
[ |
||||
'actions' => ['signup'], |
||||
'allow' => true, |
||||
'roles' => ['?'], |
||||
], |
||||
[ |
||||
'actions' => ['logout'], |
||||
'allow' => true, |
||||
'roles' => ['@'], |
||||
], |
||||
], |
||||
], |
||||
]; |
||||
} |
||||
|
||||
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) { |
||||
$this->goHome(); |
||||
} |
||||
|
||||
$model = new LoginForm(); |
||||
if ($model->load($_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($_POST) && $model->contact(Yii::$app->params['adminEmail'])) { |
||||
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); |
||||
return $this->refresh(); |
||||
} else { |
||||
return $this->render('contact', [ |
||||
'model' => $model, |
||||
]); |
||||
} |
||||
} |
||||
|
||||
public function actionAbout() |
||||
{ |
||||
return $this->render('about'); |
||||
} |
||||
|
||||
public function actionSignup() |
||||
{ |
||||
$model = new User(); |
||||
$model->setScenario('signup'); |
||||
if ($model->load($_POST) && $model->save()) { |
||||
if (Yii::$app->getUser()->login($model)) { |
||||
return $this->goHome(); |
||||
} |
||||
} |
||||
|
||||
return $this->render('signup', [ |
||||
'model' => $model, |
||||
]); |
||||
} |
||||
|
||||
public function actionRequestPasswordReset() |
||||
{ |
||||
$model = new User(); |
||||
$model->scenario = 'requestPasswordResetToken'; |
||||
if ($model->load($_POST) && $model->validate()) { |
||||
if ($this->sendPasswordResetEmail($model->email)) { |
||||
Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.'); |
||||
return $this->goHome(); |
||||
} else { |
||||
Yii::$app->getSession()->setFlash('error', 'There was an error sending email.'); |
||||
} |
||||
} |
||||
return $this->render('requestPasswordResetToken', [ |
||||
'model' => $model, |
||||
]); |
||||
} |
||||
|
||||
public function actionResetPassword($token) |
||||
{ |
||||
$model = User::find([ |
||||
'password_reset_token' => $token, |
||||
'status' => User::STATUS_ACTIVE, |
||||
]); |
||||
|
||||
if (!$model) { |
||||
throw new BadRequestHttpException('Wrong password reset token.'); |
||||
} |
||||
|
||||
$model->scenario = 'resetPassword'; |
||||
if ($model->load($_POST) && $model->save()) { |
||||
Yii::$app->getSession()->setFlash('success', 'New password was saved.'); |
||||
return $this->goHome(); |
||||
} |
||||
|
||||
return $this->render('resetPassword', [ |
||||
'model' => $model, |
||||
]); |
||||
} |
||||
|
||||
private function sendPasswordResetEmail($email) |
||||
{ |
||||
$user = User::find([ |
||||
'status' => User::STATUS_ACTIVE, |
||||
'email' => $email, |
||||
]); |
||||
|
||||
if (!$user) { |
||||
return false; |
||||
} |
||||
|
||||
$user->password_reset_token = Security::generateRandomKey(); |
||||
if ($user->save(false)) { |
||||
return \Yii::$app->mail->compose('passwordResetToken', ['user' => $user]) |
||||
->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) |
||||
->setTo($email) |
||||
->setSubject('Password reset for ' . \Yii::$app->name) |
||||
->send(); |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
} |
@ -1,63 +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; |
||||
|
||||
/** |
||||
* @return array the validation rules. |
||||
*/ |
||||
public function rules() |
||||
{ |
||||
return [ |
||||
// name, email, subject and body are required |
||||
[['name', 'email', 'subject', 'body'], 'required'], |
||||
// email has to be a valid email address |
||||
['email', 'email'], |
||||
// verifyCode needs to be entered correctly |
||||
['verifyCode', 'captcha'], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @return array customized attribute labels |
||||
*/ |
||||
public function attributeLabels() |
||||
{ |
||||
return [ |
||||
'verifyCode' => 'Verification Code', |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* Sends an email to the specified email address using the information collected by this model. |
||||
* @param string $email the target email address |
||||
* @return boolean whether the model passes validation |
||||
*/ |
||||
public function contact($email) |
||||
{ |
||||
if ($this->validate()) { |
||||
Yii::$app->mail->compose() |
||||
->setTo($email) |
||||
->setFrom([$this->email => $this->name]) |
||||
->setSubject($this->subject) |
||||
->setTextBody($this->body) |
||||
->send(); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -1,2 +0,0 @@
|
||||
* |
||||
!.gitignore |
@ -1,70 +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 \yii\web\View $this |
||||
* @var string $content |
||||
*/ |
||||
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"> |
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?> |
||||
</head> |
||||
<body> |
||||
<?php $this->beginBody() ?> |
||||
<?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']]; |
||||
} |
||||
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> |
||||
|
||||
<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,16 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
*/ |
||||
$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,38 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
use yii\captcha\Captcha; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var yii\widgets\ActiveForm $form |
||||
* @var app\models\ContactForm $model |
||||
*/ |
||||
$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']) ?> |
||||
</div> |
||||
<?php ActiveForm::end(); ?> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
@ -1,29 +0,0 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var string $name |
||||
* @var string $message |
||||
* @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,53 +0,0 @@
|
||||
<?php |
||||
/** |
||||
* @var yii\web\View $this |
||||
*/ |
||||
$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,33 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var yii\widgets\ActiveForm $form |
||||
* @var app\models\LoginForm $model |
||||
*/ |
||||
$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']) ?> |
||||
</div> |
||||
<?php ActiveForm::end(); ?> |
||||
</div> |
||||
</div> |
||||
</div> |
@ -1,28 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var yii\widgets\ActiveForm $form |
||||
* @var common\models\User $model |
||||
*/ |
||||
$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,28 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var yii\widgets\ActiveForm $form |
||||
* @var common\models\User $model |
||||
*/ |
||||
$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,30 +0,0 @@
|
||||
<?php |
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
|
||||
/** |
||||
* @var yii\web\View $this |
||||
* @var yii\widgets\ActiveForm $form |
||||
* @var common\models\User $model |
||||
*/ |
||||
$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']) ?> |
||||
</div> |
||||
<?php ActiveForm::end(); ?> |
||||
</div> |
||||
</div> |
||||
</div> |
@ -1,2 +0,0 @@
|
||||
* |
||||
!.gitignore |
@ -1,79 +0,0 @@
|
||||
body { |
||||
padding-top: 70px; |
||||
} |
||||
|
||||
.footer { |
||||
border-top: 1px solid #ddd; |
||||
margin-top: 30px; |
||||
padding-top: 15px; |
||||
padding-bottom: 30px; |
||||
} |
||||
|
||||
.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: 1.1 KiB |
@ -1,66 +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: |
||||
* |
||||
* - \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'); |
||||
* |
||||
* @author Kartik Visweswaran <kartikv2@gmail.com> |
||||
* @author Alexander Makarov <sam@rmcerative.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' => 'danger', |
||||
'danger' => 'danger', |
||||
'success' => 'success', |
||||
'info' => 'info', |
||||
'warning' => '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 => $message) { |
||||
/* initialize css class for each alert box */ |
||||
$this->options['class'] = 'alert-' . $this->alertTypes[$type] . $appendCss; |
||||
|
||||
/* assign unique id to each alert box */ |
||||
$this->options['id'] = $this->getId() . '-' . $type; |
||||
|
||||
echo \yii\bootstrap\Alert::widget([ |
||||
'body' => $message, |
||||
'closeButton' => $this->closeButton, |
||||
'options' => $this->options |
||||
]); |
||||
|
||||
$session->removeFlash($type); |
||||
} |
||||
} |
||||
} |
@ -1,154 +0,0 @@
|
||||
#!/usr/bin/env php |
||||
<?php |
||||
$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'])) { |
||||
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)) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (isset($env['writable'])) { |
||||
foreach ($env['writable'] as $writable) { |
||||
echo " chmod 0777 $writable\n"; |
||||
@chmod("$root/$writable", 0777); |
||||
} |
||||
} |
||||
|
||||
if (isset($env['executable'])) { |
||||
foreach ($env['executable'] as $executable) { |
||||
echo " chmod 0755 $executable\n"; |
||||
@chmod("$root/$executable", 0755); |
||||
} |
||||
} |
||||
|
||||
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) |
||||
{ |
||||
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 = 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; |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue