Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #5

Merged
merged 32 commits into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e83a46a
test
trieyouth Dec 13, 2015
947b9ef
test
cxqz520 Dec 13, 2015
73fc7ec
User Model over
trieyouth Dec 13, 2015
5eea0a9
Merge remote-tracking branch 'origin/dev' into youth
trieyouth Dec 13, 2015
1c8c818
add loginform
cxqz520 Dec 13, 2015
d8e63cb
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 13, 2015
fb54674
loginForm -> LoginForm
trieyouth Dec 13, 2015
1ca6038
LoginForm LoginController
cxqz520 Dec 13, 2015
597c572
init login ui
trieyouth Dec 13, 2015
27d112f
LoginForm LoginController
cxqz520 Dec 13, 2015
54cd4f9
LoginForm LoginController
cxqz520 Dec 13, 2015
72aa91b
LoginForm LoginController
cxqz520 Dec 13, 2015
72b9fd4
日了狗的数据测试
trieyouth Dec 13, 2015
8e48d4f
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 13, 2015
3fa057c
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 13, 2015
fde3d6b
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 13, 2015
dabca46
日了狗的登陆
trieyouth Dec 13, 2015
dfd610f
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 13, 2015
e5a3248
初始化错误页
trieyouth Dec 15, 2015
f7fd760
login ui over
trieyouth Dec 15, 2015
660a49e
error 404 ui init
trieyouth Dec 15, 2015
673421e
error 404 over
trieyouth Dec 16, 2015
234e373
error 404 over
trieyouth Dec 16, 2015
9f328f5
better
trieyouth Dec 16, 2015
8a76f2b
make login better
trieyouth Dec 16, 2015
2ed6504
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 16, 2015
f0d47be
signup ui
trieyouth Dec 16, 2015
df1fe72
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 16, 2015
ee9c874
Merge branch 'dev' of github.com:trieyouth/basic into youth
trieyouth Dec 16, 2015
4abdaf3
Merge branch 'dev' of https://github.com/trieyouth/basic into dcc
cxqz520 Dec 16, 2015
cefa2b3
Merge branch 'dev' of github.com:trieyouth/basic into youth
trieyouth Dec 16, 2015
4951d7f
great home
trieyouth Dec 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions assets/AppAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ class AppAsset extends AssetBundle
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
'css/base.css',

];
public $js = [
'js/base.js',
'js/jquery.js',

];


Expand Down
29 changes: 29 additions & 0 deletions assets/ErrorAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: youth
* Date: 15-12-16
* Time: 下午1:19
*/
namespace app\assets;

class ErrorAsset extends \yii\web\AssetBundle{

public $basePath = '@webroot';
public $baseUrl = '@web';

public $css = [
'css/error.css',
'css/cloud-admin.css',
'css/font-awesome.min.css',
];
public $js = [

];


public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
16 changes: 16 additions & 0 deletions assets/FontAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: youth
* Date: 15-12-16
* Time: 下午9:28
*/
namespace app\assets;
use yii\web\AssetBundle;

class FontAsset extends AssetBundle{
public $sourcePath = '@vendor/fortawesome/font-awesome';
public $css = [
'css/font-awesome.css',
];
}
28 changes: 28 additions & 0 deletions assets/LayoutAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Created by PhpStorm.
* User: youth
* Date: 15-12-16
* Time: 下午4:09
*/
namespace app\assets;

use yii\web\AssetBundle;

class LayoutAsset extends AssetBundle{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/layout.css',
'css/common.css'
];
public $js = [

];

public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapThemeAsset',
];
}
30 changes: 30 additions & 0 deletions assets/LoginAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Created by PhpStorm.
* User: youth
* Date: 15-12-13
* Time: 下午6:47
*/
namespace app\assets;

use yii\web\AssetBundle;

class LoginAsset extends AssetBundle{

public $basePath = '@webroot';
public $baseUrl = '@web';

public $css = [
'css/login.css',
];
public $js = [

];


public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];

}
2 changes: 1 addition & 1 deletion config/params.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

return [
'adminEmail' => 'admin@example.com',
'adminEmail' => 'trieyouth@gmail.com',
];
2 changes: 1 addition & 1 deletion config/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
'errorAction' => 'common/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
Expand Down
27 changes: 27 additions & 0 deletions controllers/CommonController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Created by PhpStorm.
* User: youth
* Date: 15-12-15
* Time: 下午4:45
*/
namespace app\controllers;

use Yii;
use yii\base\Controller;

class CommonController extends Controller
{

public $layout = false;

public function actionError()
{
$exception = Yii::$app->errorHandler->exception;
if ($exception !== null) {
if(strcmp($exception->getMessage(),'Page not found.') == 0){
return $this->render('error_404');
}
}
}
}
25 changes: 24 additions & 1 deletion controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,36 @@
use app\util\IntentUtil;
use Yii;
use yii\base\Controller;
use yii\filters\AccessControl;

class HomeController extends Controller
{
public $layout = "@app/views/layouts/base.php";

public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['index'],
'rules' => [
[
'allow' => true,
'actions' => [],
'roles' => ['?'],
],
[
'allow' => true,
'actions' => ['index'],
'roles' => ['@'],
],
],
],
];
}

public function actionIndex()
{
$this->layout = "@app/views/layouts/base.php";
IntentUtil::sendParams('youth','@web/img/welcome.png');
return $this->render('index');
}
Expand Down
40 changes: 32 additions & 8 deletions controllers/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
namespace app\controllers;

use app\models\LoginForm;
use app\models\SignupForm;
use app\models\User;
use Yii;
use yii\base\Controller;
use yii\filters\AccessControl;
Expand All @@ -16,31 +19,30 @@ class LoginController extends Controller

public $layout = false;


public function behaviors()
public function behaviors()//行为验证 是登陆状态还是登出状态 要有什么操作
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['login', 'logout', 'signup'],
'denyCallback' => function ($rule, $action) {
if(strcmp($action->id,'logout')==0){
if (strcmp($action->id, 'logout') == 0) {
throw new \Exception('您还没有登陆');
}
if(strcmp($action->id,'login')==0 || strcmp($action->id,'signup')==0){
if (strcmp($action->id, 'login') == 0 || strcmp($action->id, 'signup') == 0) {
throw new \Exception('您已经登陆');
}
},
'rules' => [
[
'allow' => true,
'actions' => ['login', 'signup'],
'roles' => ['?'],
'roles' => ['?'],//游客身份
],
[
'allow' => true,
'actions' => ['logout'],
'roles' => ['@'],
'roles' => ['@'],//已登录的身份
],
],
],
Expand All @@ -55,16 +57,38 @@ public function actionIndex()
public function actionLogin()
{

if (!Yii::$app->user->isGuest) {
return Yii::$app->response->redirect(['home/index']);
}

$login = new LoginForm();

if ($login->load(Yii::$app->request->post()) && $login->login()) {
return Yii::$app->response->redirect(['home/index']);
} else {
return $this->render('login', [
'model' => $login,
]);//登陆失败就渲染布局
}
}

public function actionLogout()
{

Yii::app()->user->logout();
$this->redirect(['login/login']);//跳转的页面
}

public function actionSignUp()
public function actionSignup()
{
$register = new SignupForm();

if($register->load(YII::$app->request->post()) && $register->signup()){
return YII::$app->response->redirect(['login/login']);
}else{
return $this->render('signup', [
'model' => $register,
]);
}
}

}
94 changes: 94 additions & 0 deletions controllers/SiteController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace app\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;

class SiteController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}

public function 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();
}
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->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');

return $this->refresh();
}
return $this->render('contact', [
'model' => $model,
]);
}

public function actionAbout()
{
return $this->render('about');
}
}
Loading