~horux-dev/horux-webcli/thfo

« back to all changes in this revision

Viewing changes to yii/framework/gii/controllers/DefaultController.php

  • Committer: Thierry Forchelet
  • Date: 2011-02-25 13:30:15 UTC
  • Revision ID: thierry.forchelet@letux.ch-20110225133015-zxyj9w7sqv8ly971
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class DefaultController extends CController
 
4
{
 
5
        public $layout='/layouts/column1';
 
6
 
 
7
        public function getPageTitle()
 
8
        {
 
9
                if($this->action->id==='index')
 
10
                        return 'Gii: a Web-based code generator for Yii';
 
11
                else
 
12
                        return 'Gii - '.ucfirst($this->action->id).' Generator';
 
13
        }
 
14
 
 
15
        public function actionIndex()
 
16
        {
 
17
                $this->render('index');
 
18
        }
 
19
 
 
20
        public function actionError()
 
21
        {
 
22
            if($error=Yii::app()->errorHandler->error)
 
23
            {
 
24
                if(Yii::app()->request->isAjaxRequest)
 
25
                        echo $error['message'];
 
26
                else
 
27
                        $this->render('error', $error);
 
28
            }
 
29
        }
 
30
 
 
31
        /**
 
32
         * Displays the login page
 
33
         */
 
34
        public function actionLogin()
 
35
        {
 
36
                $model=Yii::createComponent('gii.models.LoginForm');
 
37
 
 
38
                // collect user input data
 
39
                if(isset($_POST['LoginForm']))
 
40
                {
 
41
                        $model->attributes=$_POST['LoginForm'];
 
42
                        // validate user input and redirect to the previous page if valid
 
43
                        if($model->validate() && $model->login())
 
44
                                $this->redirect(Yii::app()->createUrl('gii'));
 
45
                }
 
46
                // display the login form
 
47
                $this->render('login',array('model'=>$model));
 
48
        }
 
49
 
 
50
        /**
 
51
         * Logs out the current user and redirect to homepage.
 
52
         */
 
53
        public function actionLogout()
 
54
        {
 
55
                Yii::app()->user->logout(false);
 
56
                $this->redirect(Yii::app()->createUrl('gii'));
 
57
        }
 
58
}
 
 
b'\\ No newline at end of file'