~fusonic/chive/1.1

« back to all changes in this revision

Viewing changes to yii/cli/views/webapp/protected/controllers/SiteController.php

  • Committer: Matthias Burtscher
  • Date: 2010-02-12 09:12:35 UTC
  • Revision ID: matthias.burtscher@fusonic.net-20100212091235-jqxrb62klx872ajc
* Updated Yii to 1.1.0
* Removed CodePress and CodeMirror
* Updated jQuery and some plugins
* Cleaned some code ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
class SiteController extends CController
 
3
class SiteController extends Controller
4
4
{
5
5
        /**
6
6
         * Declares class-based actions.
8
8
        public function actions()
9
9
        {
10
10
                return array(
11
 
                        // captcha action renders the CAPTCHA image
12
 
                        // this is used by the contact page
 
11
                        // captcha action renders the CAPTCHA image displayed on the contact page
13
12
                        'captcha'=>array(
14
13
                                'class'=>'CCaptchaAction',
15
 
                                'backColor'=>0xEBF4FB,
 
14
                                'backColor'=>0xFFFFFF,
 
15
                        ),
 
16
                        // page action renders "static" pages stored under 'protected/views/site/pages'
 
17
                        // They can be accessed via: index.php?r=site/page&view=FileName
 
18
                        'page'=>array(
 
19
                                'class'=>'CViewAction',
16
20
                        ),
17
21
                );
18
22
        }
29
33
        }
30
34
 
31
35
        /**
 
36
         * This is the action to handle external exceptions.
 
37
         */
 
38
        public function actionError()
 
39
        {
 
40
            if($error=Yii::app()->errorHandler->error)
 
41
            {
 
42
                if(Yii::app()->request->isAjaxRequest)
 
43
                        echo $error['message'];
 
44
                else
 
45
                        $this->render('error', $error);
 
46
            }
 
47
        }
 
48
 
 
49
        /**
32
50
         * Displays the contact page
33
51
         */
34
52
        public function actionContact()
35
53
        {
36
 
                $contact=new ContactForm;
 
54
                $model=new ContactForm;
37
55
                if(isset($_POST['ContactForm']))
38
56
                {
39
 
                        $contact->attributes=$_POST['ContactForm'];
40
 
                        if($contact->validate())
 
57
                        $model->attributes=$_POST['ContactForm'];
 
58
                        if($model->validate())
41
59
                        {
42
 
                                $headers="From: {$contact->email}\r\nReply-To: {$contact->email}";
43
 
                                mail(Yii::app()->params['adminEmail'],$contact->subject,$contact->body,$headers);
 
60
                                $headers="From: {$model->email}\r\nReply-To: {$model->email}";
 
61
                                mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);
44
62
                                Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
45
63
                                $this->refresh();
46
64
                        }
47
65
                }
48
 
                $this->render('contact',array('contact'=>$contact));
 
66
                $this->render('contact',array('model'=>$model));
49
67
        }
50
68
 
51
69
        /**
53
71
         */
54
72
        public function actionLogin()
55
73
        {
56
 
                $form=new LoginForm;
 
74
                $model=new LoginForm;
57
75
                // collect user input data
58
76
                if(isset($_POST['LoginForm']))
59
77
                {
60
 
                        $form->attributes=$_POST['LoginForm'];
61
 
                        // validate user input and redirect to previous page if valid
62
 
                        if($form->validate())
 
78
                        $model->attributes=$_POST['LoginForm'];
 
79
                        // validate user input and redirect to the previous page if valid
 
80
                        if($model->validate())
63
81
                                $this->redirect(Yii::app()->user->returnUrl);
64
82
                }
65
83
                // display the login form
66
 
                $this->render('login',array('form'=>$form));
 
84
                $this->render('login',array('model'=>$model));
67
85
        }
68
86
 
69
87
        /**
70
 
         * Logout the current user and redirect to homepage.
 
88
         * Logs out the current user and redirect to homepage.
71
89
         */
72
90
        public function actionLogout()
73
91
        {