Skip to content

Commit 5c65f92

Browse files
committed
#1
1 parent 054ce62 commit 5c65f92

File tree

221 files changed

+16470
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+16470
-0
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory" : "vendor/bower"
3+
}

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# yii console command
2+
/yii
3+
4+
# phpstorm project files
5+
.idea
6+
7+
# netbeans project files
8+
nbproject
9+
10+
# zend studio for eclipse project files
11+
.buildpath
12+
.project
13+
.settings
14+
15+
# windows thumbnail cache
16+
Thumbs.db
17+
18+
# composer vendor dir
19+
/vendor
20+
21+
# composer itself is not needed
22+
composer.phar
23+
24+
# Mac DS_Store Files
25+
.DS_Store
26+
27+
# phpunit itself is not needed
28+
phpunit.phar
29+
# local phpunit config
30+
/phpunit.xml

LICENSE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
The Yii framework is free software. It is released under the terms of
2+
the following BSD License.
3+
4+
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions
9+
are met:
10+
11+
* Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in
15+
the documentation and/or other materials provided with the
16+
distribution.
17+
* Neither the name of Yii Software LLC nor the names of its
18+
contributors may be used to endorse or promote products derived
19+
from this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

backend/assets/AppAsset.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* @link http://www.yiiframework.com/
4+
* @copyright Copyright (c) 2008 Yii Software LLC
5+
* @license http://www.yiiframework.com/license/
6+
*/
7+
8+
namespace backend\assets;
9+
10+
use yii\web\AssetBundle;
11+
12+
/**
13+
* @author Qiang Xue <[email protected]>
14+
* @since 2.0
15+
*/
16+
class AppAsset extends AssetBundle
17+
{
18+
public $basePath = '@webroot';
19+
public $baseUrl = '@web';
20+
public $css = [
21+
'css/site.css',
22+
];
23+
public $js = [
24+
];
25+
public $depends = [
26+
'yii\web\YiiAsset',
27+
'yii\bootstrap\BootstrapAsset',
28+
];
29+
}

backend/config/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main-local.php
2+
params-local.php

backend/config/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

backend/config/main.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
$params = array_merge(
3+
require(__DIR__ . '/../../common/config/params.php'),
4+
require(__DIR__ . '/../../common/config/params-local.php'),
5+
require(__DIR__ . '/params.php'),
6+
require(__DIR__ . '/params-local.php')
7+
);
8+
9+
return [
10+
'id' => 'app-backend',
11+
'basePath' => dirname(__DIR__),
12+
'controllerNamespace' => 'backend\controllers',
13+
'bootstrap' => ['log'],
14+
'modules' => [],
15+
'components' => [
16+
'user' => [
17+
'identityClass' => 'common\models\User',
18+
'enableAutoLogin' => true,
19+
],
20+
'log' => [
21+
'traceLevel' => YII_DEBUG ? 3 : 0,
22+
'targets' => [
23+
[
24+
'class' => 'yii\log\FileTarget',
25+
'levels' => ['error', 'warning'],
26+
],
27+
],
28+
],
29+
'errorHandler' => [
30+
'errorAction' => 'site/error',
31+
],
32+
],
33+
'params' => $params,
34+
];

backend/config/params.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
return [
3+
'adminEmail' => '[email protected]',
4+
];
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
namespace backend\controllers;
3+
4+
use Yii;
5+
use yii\filters\AccessControl;
6+
use yii\web\Controller;
7+
use common\models\LoginForm;
8+
use yii\filters\VerbFilter;
9+
10+
/**
11+
* Site controller
12+
*/
13+
class SiteController extends Controller
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
public function behaviors()
19+
{
20+
return [
21+
'access' => [
22+
'class' => AccessControl::className(),
23+
'rules' => [
24+
[
25+
'actions' => ['login', 'error'],
26+
'allow' => true,
27+
],
28+
[
29+
'actions' => ['logout', 'index'],
30+
'allow' => true,
31+
'roles' => ['@'],
32+
],
33+
],
34+
],
35+
'verbs' => [
36+
'class' => VerbFilter::className(),
37+
'actions' => [
38+
'logout' => ['post'],
39+
],
40+
],
41+
];
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function actions()
48+
{
49+
return [
50+
'error' => [
51+
'class' => 'yii\web\ErrorAction',
52+
],
53+
];
54+
}
55+
56+
public function actionIndex()
57+
{
58+
return $this->render('index');
59+
}
60+
61+
public function actionLogin()
62+
{
63+
if (!\Yii::$app->user->isGuest) {
64+
return $this->goHome();
65+
}
66+
67+
$model = new LoginForm();
68+
if ($model->load(Yii::$app->request->post()) && $model->login()) {
69+
return $this->goBack();
70+
} else {
71+
return $this->render('login', [
72+
'model' => $model,
73+
]);
74+
}
75+
}
76+
77+
public function actionLogout()
78+
{
79+
Yii::$app->user->logout();
80+
81+
return $this->goHome();
82+
}
83+
}

backend/models/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

backend/runtime/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

backend/views/layouts/main.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
use backend\assets\AppAsset;
3+
use yii\helpers\Html;
4+
use yii\bootstrap\Nav;
5+
use yii\bootstrap\NavBar;
6+
use yii\widgets\Breadcrumbs;
7+
8+
/* @var $this \yii\web\View */
9+
/* @var $content string */
10+
11+
AppAsset::register($this);
12+
?>
13+
<?php $this->beginPage() ?>
14+
<!DOCTYPE html>
15+
<html lang="<?= Yii::$app->language ?>">
16+
<head>
17+
<meta charset="<?= Yii::$app->charset ?>">
18+
<meta name="viewport" content="width=device-width, initial-scale=1">
19+
<?= Html::csrfMetaTags() ?>
20+
<title><?= Html::encode($this->title) ?></title>
21+
<?php $this->head() ?>
22+
</head>
23+
<body>
24+
<?php $this->beginBody() ?>
25+
<div class="wrap">
26+
<?php
27+
NavBar::begin([
28+
'brandLabel' => 'My Company',
29+
'brandUrl' => Yii::$app->homeUrl,
30+
'options' => [
31+
'class' => 'navbar-inverse navbar-fixed-top',
32+
],
33+
]);
34+
$menuItems = [
35+
['label' => 'Home', 'url' => ['/site/index']],
36+
];
37+
if (Yii::$app->user->isGuest) {
38+
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
39+
} else {
40+
$menuItems[] = [
41+
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
42+
'url' => ['/site/logout'],
43+
'linkOptions' => ['data-method' => 'post']
44+
];
45+
}
46+
echo Nav::widget([
47+
'options' => ['class' => 'navbar-nav navbar-right'],
48+
'items' => $menuItems,
49+
]);
50+
NavBar::end();
51+
?>
52+
53+
<div class="container">
54+
<?= Breadcrumbs::widget([
55+
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
56+
]) ?>
57+
<?= $content ?>
58+
</div>
59+
</div>
60+
61+
<footer class="footer">
62+
<div class="container">
63+
<p class="pull-left">&copy; My Company <?= date('Y') ?></p>
64+
<p class="pull-right"><?= Yii::powered() ?></p>
65+
</div>
66+
</footer>
67+
68+
<?php $this->endBody() ?>
69+
</body>
70+
</html>
71+
<?php $this->endPage() ?>

backend/views/site/error.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use yii\helpers\Html;
4+
5+
/* @var $this yii\web\View */
6+
/* @var $name string */
7+
/* @var $message string */
8+
/* @var $exception Exception */
9+
10+
$this->title = $name;
11+
?>
12+
<div class="site-error">
13+
14+
<h1><?= Html::encode($this->title) ?></h1>
15+
16+
<div class="alert alert-danger">
17+
<?= nl2br(Html::encode($message)) ?>
18+
</div>
19+
20+
<p>
21+
The above error occurred while the Web server was processing your request.
22+
</p>
23+
<p>
24+
Please contact us if you think this is a server error. Thank you.
25+
</p>
26+
27+
</div>

backend/views/site/index.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/* @var $this yii\web\View */
3+
4+
$this->title = 'My Yii Application';
5+
?>
6+
<div class="site-index">
7+
8+
<div class="jumbotron">
9+
<h1>Congratulations!</h1>
10+
11+
<p class="lead">You have successfully created your Yii-powered application.</p>
12+
13+
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
14+
</div>
15+
16+
<div class="body-content">
17+
18+
<div class="row">
19+
<div class="col-lg-4">
20+
<h2>Heading</h2>
21+
22+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
23+
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
24+
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
25+
fugiat nulla pariatur.</p>
26+
27+
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
28+
</div>
29+
<div class="col-lg-4">
30+
<h2>Heading</h2>
31+
32+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
33+
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
34+
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
35+
fugiat nulla pariatur.</p>
36+
37+
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
38+
</div>
39+
<div class="col-lg-4">
40+
<h2>Heading</h2>
41+
42+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
43+
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
44+
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
45+
fugiat nulla pariatur.</p>
46+
47+
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
48+
</div>
49+
</div>
50+
51+
</div>
52+
</div>

0 commit comments

Comments
 (0)