SiteController
| Package | application.controllers.SiteController |
|---|---|
| Inheritance | class SiteController » Controller » SBaseController » CController » CBaseController » CComponent |
| Views | about, admin, contact, error, fileManager, help, index, login, redirectLogin |
| Source Code | app/controllers/SiteController.php |
SiteController defines site actions, communicates between models and views.
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| action | CAction | the action currently being executed, null if no active action. | CController |
| back | Controller | ||
| breadcrumbs | array | the breadcrumbs of the current page. | Controller |
| cachingStack | CStack | stack of COutputCache objects | CController |
| clips | CMap | Returns the list of clips. | CController |
| defaultAction | string | the name of the default action. | CController |
| id | string | ID of the controller | CController |
| layout | string | the default layout for the controller view. | Controller |
| menu | array | context menu items. | Controller |
| module | CWebModule | the module that this controller belongs to. | CController |
| pageTitle | string | the page title. | CController |
| roots | Controller | ||
| route | string | the route (module ID, controller ID and action ID) of the current request. | CController |
| selectedTA | Controller | ||
| tree | Controller | ||
| uniqueId | string | the controller ID that is prefixed with the module ID (if any). | CController |
| viewPath | string | Returns the directory containing view files for this controller. | CController |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __call() | Calls the named method which is not a class method. | CComponent |
| __construct() | CController | |
| __get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
| __isset() | Checks if a property value is null. | CComponent |
| __set() | Sets value of a component property. | CComponent |
| __unset() | Sets a component property to be null. | CComponent |
| accessRules() | Returns the access rules for this controller. | CController |
| actionAbout() | Displays about page | SiteController |
| actionAdmin() | Display the admin page | SiteController |
| actionContact() | Displays the contact page | SiteController |
| actionError() | Displays error page | SiteController |
| actionFileManager() | Displays the digital file library | SiteController |
| actionHelp() | Displays help page | SiteController |
| actionIndex() | This is the default 'index' action that is invoked | SiteController |
| actionLogin() | Displays the login page | SiteController |
| actionLogout() | Logout the current user and redirect to homepage. | SiteController |
| actionRedirectLogin() | Redirects user to login page if user doesn't have permission or their session expires | SiteController |
| actions() | Declares class-based actions. | SiteController |
| asa() | Returns the named behavior object. | CComponent |
| attachBehavior() | Attaches a behavior to this component. | CComponent |
| attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
| attachEventHandler() | Attaches an event handler to an event. | CComponent |
| beginCache() | Begins fragment caching. | CBaseController |
| beginClip() | Begins recording a clip. | CBaseController |
| beginContent() | Begins the rendering of content that is to be decorated by the specified view. | CBaseController |
| beginWidget() | Creates a widget and executes it. | CBaseController |
| behaviors() | Returns a list of behaviors that this controller should behave as. | CController |
| canGetProperty() | Determines whether a property can be read. | CComponent |
| canSetProperty() | Determines whether a property can be set. | CComponent |
| clearPageStates() | Removes all page states. | CController |
| createAbsoluteUrl() | Creates an absolute URL for the specified action defined in this controller. | CController |
| createAction() | Creates the action instance based on the action name. | CController |
| createUrl() | Creates a relative URL for the specified action defined in this controller. | CController |
| createWidget() | Creates a widget and initializes it. | CBaseController |
| detachBehavior() | Detaches a behavior from the component. | CComponent |
| detachBehaviors() | Detaches all behaviors from the component. | CComponent |
| detachEventHandler() | Detaches an existing event handler. | CComponent |
| disableBehavior() | Disables an attached behavior. | CComponent |
| disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
| enableBehavior() | Enables an attached behavior. | CComponent |
| enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
| endCache() | Ends fragment caching. | CBaseController |
| endClip() | Ends recording a clip. | CBaseController |
| endContent() | Ends the rendering of content. | CBaseController |
| endWidget() | Ends the execution of the named widget. | CBaseController |
| evaluateExpression() | Evaluates a PHP expression or callback under the context of this component. | CComponent |
| filterAccessControl() | The filter method for 'accessControl' filter. | CController |
| filterAjaxOnly() | The filter method for 'ajaxOnly' filter. | CController |
| filterPostOnly() | The filter method for 'postOnly' filter. | CController |
| filters() | Returns the filter configurations. | CController |
| forward() | Processes the request using another controller action. | CController |
| getAction() | Returns the action currently being executed, null if no active action. | CController |
| getCachingStack() | Returns stack of COutputCache objects | CController |
| getClips() | Returns the list of clips. | CController |
| getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
| getId() | Returns ID of the controller | CController |
| getLayoutFile() | Looks for the layout view script based on the layout name. | CController |
| getModule() | Returns the module that this controller belongs to. It returns null if the controller does not belong to any module | CController |
| getPageState() | Returns a persistent page state value. | CController |
| getPageTitle() | Returns the page title. Defaults to the controller name and the action name. | CController |
| getRoute() | Returns the route (module ID, controller ID and action ID) of the current request. | CController |
| getUniqueId() | Returns the controller ID that is prefixed with the module ID (if any). | CController |
| getViewFile() | Looks for the view file according to the given view name. | CController |
| getViewPath() | Returns the directory containing view files for this controller. | CController |
| hasEvent() | Determines whether an event is defined. | CComponent |
| hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
| hasProperty() | Determines whether a property is defined. | CComponent |
| init() | Initializes the controller. | CController |
| isCachingStackEmpty() | CController | |
| missingAction() | Handles the request whose action is not recognized. | CController |
| paginate() | Generates pagination information. | CController |
| processDynamicOutput() | Postprocesses the dynamic output. | CController |
| processOutput() | Postprocesses the output generated by render(). | CController |
| raiseEvent() | Raises an event. | CComponent |
| recordCachingAction() | Records a method call when an output cache is in effect. | CController |
| redirect() | Redirects the browser to the specified URL or route (controller/action). | CController |
| refresh() | Refreshes the current page. | CController |
| render() | Renders a view with a layout. | CController |
| renderDynamic() | Renders dynamic content returned by the specified callback. | CController |
| renderDynamicInternal() | This method is internally used. | CController |
| renderFile() | Renders a view file. | CBaseController |
| renderInternal() | Renders a view file. | CBaseController |
| renderPartial() | Renders a view. | CController |
| renderPartialWithHisOwnClientScript() | Controller | |
| renderText() | Renders a static text string. | CController |
| resolveViewFile() | Finds a view file based on its name. | CController |
| run() | Runs the named action. | CController |
| runAction() | Runs the action after passing through all filters. | CController |
| runActionWithFilters() | Runs an action with the specified filters. | CController |
| setAction() | Sets the action currently being executed. | CController |
| setPageState() | Saves a persistent page state value. | CController |
| setPageTitle() | Sets the page title. | CController |
| widget() | Creates a widget and executes it. | CBaseController |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| afterAction() | This method is invoked right after an action is executed. | CController |
| allowedAccess() | The auth items that access is always allowed. Configured in srbac module's | SBaseController |
| beforeAction() | Checks if srbac access is granted for the current user | SBaseController |
| createActionFromMap() | Creates the action instance based on the action map. | CController |
| loadPageStates() | Loads page states from a hidden input. | CController |
| onUnauthorizedAccess() | SBaseController | |
| replaceDynamicOutput() | Replaces the dynamic content placeholders with actual content. | CController |
| savePageStates() | Saves page states as a base64 string. | CController |
Method Details
actionAbout()
method
|
public void actionAbout()
|
Source Code: app/controllers/SiteController.php#222 (show)
public function actionAbout(){
$this->render('about');
}
Displays about page
actionAdmin()
method
|
public void actionAdmin()
|
Source Code: app/controllers/SiteController.php#190 (show)
public function actionAdmin(){
if(Yii::app()->user->checkAccess("UserAdmin")){
$this->render('admin');
}else
$this->redirect(array('site/redirectlogin'));
}
Display the admin page
actionContact()
method
|
public void actionContact()
|
Source Code: app/controllers/SiteController.php#84 (show)
public function actionContact()
{
$contact=new ContactForm;
if(isset($_POST['ContactForm']))
{
$contact->attributes=$_POST['ContactForm'];
if($contact->validate())
{
$headers="From: {$contact->email}\r\nReply-To: {$contact->email}";
mail(Yii::app()->params['adminEmail'],$contact->subject,$contact->body,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact',array('contact'=>$contact));
}
Displays the contact page
actionError()
method
|
public void actionError()
|
Source Code: app/controllers/SiteController.php#200 (show)
public function actionError(){
$error = Yii::app()->errorHandler->error;
if ($error!=null)
//if($error['code']==403)
// $this->redirect(array('site/redirectlogin'));
//else
$this->render('error', array('error'=>$error));
else
throw new CHttpException(404, 'Page not found.');
}
Displays error page
actionFileManager()
method
|
public void actionFileManager()
|
Source Code: app/controllers/SiteController.php#183 (show)
public function actionFileManager(){
$this->render('fileManager');
}
Displays the digital file library
actionHelp()
method
|
public void actionHelp()
|
Source Code: app/controllers/SiteController.php#214 (show)
public function actionHelp(){
$this->render('help');
}
Displays help page
actionIndex()
method
|
public void actionIndex()
|
Source Code: app/controllers/SiteController.php#27 (show)
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
//$this->render('index');
if(!Yii::app()->user->isGuest)
$this->render('index');
else{
$form=new LoginForm;
// collect user input data
if(isset($_POST['LoginForm']))
{
$form->attributes=$_POST['LoginForm'];
// validate user input and redirect to previous page if valid
if($form->validate()){
#begin AjaXplorer auth
global $AJXP_GLUE_GLOBALS;
if(!isSet($AJXP_GLUE_GLOBALS)){
$AJXP_GLUE_GLOBALS = array();
}
$AJXP_GLUE_GLOBALS["checkPassord"] = TRUE;
$AJXP_GLUE_GLOBALS["secret"] = "myprivatesecret";
//global $plugInAction, $result, $user, $login;
$result = FALSE;
$ajxpHookFile = Yii::app()->params['ajPath']."/plugins/auth.remote/glueCode.php";
if (file_exists($ajxpHookFile))
{
$AJXP_GLUE_GLOBALS["plugInAction"] = "login";
$reset = $deleteData;
$right="";
if(Yii::app()->user->checkAccess("UserAdmin"))
$right = "admin";
$AJXP_GLUE_GLOBALS["login"] = array("id"=>Yii::app()->user->id, "name"=>$form->username, "password"=>md5($form->password), "right"=>$right);
$AJXP_GLUE_GLOBALS["user"] = array("id"=>$form->username, "name"=>$form->username, "password"=>md5($form->password), "right"=>$right);
global $CURRENTPATH;
$CURRENTPATH = dirname($ajxpHookFile);
require($ajxpHookFile);
spl_autoload_register(array('YiiBase','autoload'));
// Check $result, it's TRUE on success
}
#end AjaXplorer auth
if(Yii::app()->user->returnUrl)
$this->redirect(Yii::app()->user->returnUrl);
else
$this->render('index');
return;
}
}
$this->render('login',array('form'=>$form));
}
// display the login form
}
This is the default 'index' action that is invoked when an action is not explicitly requested by users.
actionLogin()
method
|
public void actionLogin()
|
Source Code: app/controllers/SiteController.php#104 (show)
public function actionLogin()
{
$form=new LoginForm;
// collect user input data
if(isset($_POST['LoginForm']))
{
$form->attributes=$_POST['LoginForm'];
// validate user input and redirect to previous page if valid
if($form->validate()){
#begin AjaXplorer auth
global $AJXP_GLUE_GLOBALS;
if(!isset($AJXP_GLUE_GLOBALS)){
$AJXP_GLUE_GLOBALS = array();
}
$AJXP_GLUE_GLOBALS["checkPassord"] = TRUE;
$AJXP_GLUE_GLOBALS["secret"] = "myprivatesecret";
//global $plugInAction, $result, $user, $login;
$result = FALSE;
$ajxpHookFile = Yii::app()->params['ajPath']."/plugins/auth.remote/glueCode.php";
if (file_exists($ajxpHookFile))
{
$AJXP_GLUE_GLOBALS["plugInAction"] = "login";
$reset = $deleteData;
$right="";
if(Yii::app()->user->checkAccess("UserAdmin"))
$right = "admin";
$AJXP_GLUE_GLOBALS["login"] = array("id"=>Yii::app()->user->id, "name"=>$form->username, "password"=>md5($form->password), "right"=>$right);
$AJXP_GLUE_GLOBALS["user"] = array("id"=>$form->username, "name"=>$form->username, "password"=>md5($form->password), "right"=>$right);
global $CURRENTPATH;
$CURRENTPATH = dirname($ajxpHookFile);
require($ajxpHookFile);
spl_autoload_register(array('YiiBase','autoload'));
// Check $result, it's TRUE on success
}
#end AjaXplorer auth
$this->redirect(Yii::app()->user->returnUrl);
}
}
// display the login form
$this->render('login',array('form'=>$form));
}
Displays the login page
actionLogout()
method
|
public void actionLogout()
|
Source Code: app/controllers/SiteController.php#159 (show)
public function actionLogout()
{
Yii::app()->user->logout();
#begin AjaXplorer auth
global $AJXP_GLUE_GLOBALS, $result;
$AJXP_GLUE_GLOBALS["secret"] = "myprivatesecret";
$AJXP_GLUE_GLOBALS["plugInAction"] = "logout";
$result = FALSE;
$ajxpHookFile = Yii::app()->params['ajPath']."/plugins/auth.remote/glueCode.php";
if (file_exists($ajxpHookFile))
{
//$plugInAction = "logout";
$reset = $deleteData;
global $CURRENTPATH;
$CURRENTPATH = dirname($ajxpHookFile);
require($ajxpHookFile);
spl_autoload_register(array('YiiBase','autoload'));
}
#end AjaXplorer auth
$this->redirect(Yii::app()->homeUrl);
}
Logout the current user and redirect to homepage.
actionRedirectLogin()
method
|
public void actionRedirectLogin()
|
Source Code: app/controllers/SiteController.php#150 (show)
public function actionRedirectLogin(){
//$this->redirect("/occams/index.php?r=site/login");
$this->render('redirectLogin');
}
Redirects user to login page if user doesn't have permission or their session expires
actions()
method
|
public void actions()
|
Source Code: app/controllers/SiteController.php#11 (show)
public function actions()
{
return array(
// captcha action renders the CAPTCHA image
// this is used by the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xEBF4FB,
),
);
}
Declares class-based actions.