diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-04-13 23:11:05 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-04-13 23:11:05 +0200 |
| commit | 341cc4dd9c53ffbfb863e026dd58549c1082c7a7 (patch) | |
| tree | 1bbbed20313bafb9b063b6b4d894fe580d8b000f /framework/gii/controllers/DefaultController.php | |
Diffstat (limited to 'framework/gii/controllers/DefaultController.php')
| -rw-r--r-- | framework/gii/controllers/DefaultController.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/framework/gii/controllers/DefaultController.php b/framework/gii/controllers/DefaultController.php new file mode 100644 index 0000000..44815b5 --- /dev/null +++ b/framework/gii/controllers/DefaultController.php @@ -0,0 +1,58 @@ +<?php + +class DefaultController extends CController +{ + public $layout='/layouts/column1'; + + public function getPageTitle() + { + if($this->action->id==='index') + return 'Gii: a Web-based code generator for Yii'; + else + return 'Gii - '.ucfirst($this->action->id).' Generator'; + } + + public function actionIndex() + { + $this->render('index'); + } + + public function actionError() + { + if($error=Yii::app()->errorHandler->error) + { + if(Yii::app()->request->isAjaxRequest) + echo $error['message']; + else + $this->render('error', $error); + } + } + + /** + * Displays the login page + */ + public function actionLogin() + { + $model=Yii::createComponent('gii.models.LoginForm'); + + // collect user input data + if(isset($_POST['LoginForm'])) + { + $model->attributes=$_POST['LoginForm']; + // validate user input and redirect to the previous page if valid + if($model->validate() && $model->login()) + $this->redirect(Yii::app()->createUrl('gii/default/index')); + } + // display the login form + $this->render('login',array('model'=>$model)); + } + + /** + * Logs out the current user and redirect to homepage. + */ + public function actionLogout() + { + Yii::app()->user->logout(false); + $this->redirect(Yii::app()->createUrl('gii/default/index')); + } +}
\ No newline at end of file |
