SiteController
| Package | application |
|---|---|
| Inheritance | class SiteController » Controller » CController » CBaseController » CComponent |
| Source Code |
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| action | CAction | the action currently being executed, null if no active action. | CController |
| actionParams | array | Returns the request parameters that will be used for action parameter binding. | CController |
| breadcrumbs | array | the breadcrumbs of the current page. | Controller |
| cachingStack | CStack | stack of COutputCache objects | CController |
| catalogActivated | Controller | ||
| catalogId | Controller | ||
| catalogName | Controller | ||
| clips | CMap | Returns the list of clips. | CController |
| defaultAction | string | the name of the default action. | CController |
| id | string | ID of the controller | CController |
| lastActivatedCatalog | Controller | ||
| 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 |
| route | string | the route (module ID, controller ID and action ID) of the current request. | CController |
| showCatalog | 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 |
| actionContact() | Displays the contact page | SiteController |
| actionError() | This is the action to handle external exceptions. | SiteController |
| actionGetMajors() | SiteController | |
| actionGetTerms() | SiteController | |
| actionGetTracks() | SiteController | |
| actionIndex() | This is the default 'index' action that is invoked | SiteController |
| actionListMajorPerDgu() | SiteController | |
| actionLogout() | Logs out the current user and redirect to homepage. | SiteController |
| actionManage() | 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 |
| getActionParams() | Returns the request parameters that will be used for action parameter binding. | 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 |
| getLastActivatedCatalog() | Controller | |
| 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() | Controller | |
| invalidActionParams() | This method is invoked when the request parameters do not satisfy the requirement of the specified action. | CController |
| isCachingStackEmpty() | Returns whether the caching stack is empty. | CController |
| missingAction() | Handles the request whose action is not recognized. | 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 |
| renderClip() | Renders a named clip with the supplied parameters. | 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 |
| 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 |
| afterRender() | This method is invoked after the specified is rendered by calling render(). | CController |
| beforeAction() | This method is invoked right before an action is to be executed (after all possible filters.) | CController |
| beforeRender() | This method is invoked at the beginning of render(). | CController |
| createActionFromMap() | Creates the action instance based on the action map. | CController |
| loadPageStates() | Loads page states from a hidden input. | CController |
| replaceDynamicOutput() | Replaces the dynamic content placeholders with actual content. | CController |
| savePageStates() | Saves page states as a base64 string. | CController |
Method Details
actionContact()
method
|
public void actionContact()
|
Source Code: (show)
public function actionContact() {
$model = new ContactForm;
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
$subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
$headers = "From: $name <{$model->email}>\r\n" .
"Reply-To: {$model->email}\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=UTF-8";
mail(Yii::app()->params['adminEmail'], $subject, $model->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('model' => $model));
}
Displays the contact page
actionError()
method
|
public void actionError()
|
Source Code: (show)
public function actionError() {
if ($error = Yii::app()->errorHandler->error) {
if (Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
This is the action to handle external exceptions.
actionGetMajors()
method
|
public void actionGetMajors()
|
Source Code: (show)
public function actionGetMajors(){
if(Yii::app()->request->isAjaxRequest && isset($_GET['q']))
{
/* q is the default GET variable name that is used by
/ the autocomplete widget to pass in user input
*/
$major = $_GET['q'];
// this was set with the "max" attribute of the CAutoComplete widget
$limit = min($_GET['limit'], 50);
$criteria = new CDbCriteria;
$criteria->condition = "name LIKE :input";
$criteria->params = array(":input"=>"%$major%");
$criteria->limit = $limit;
$majorArray = CurrMajor::model()->findAll($criteria);
//$returnVal = array();
$returnVal = '';
foreach($majorArray as $singleMajor)
{
//$returnVal[$singleMajor->getAttribute('user_id')] = $singleMajor->getAttribute('name');
$returnVal .= $singleMajor->getAttribute('name').'|'
.$singleMajor->getAttribute('id')."\n";
}
echo $returnVal;
}
}
actionGetTerms()
method
|
public void actionGetTerms()
|
Source Code: (show)
public function actionGetTerms(){
// // OA-USE MODEL
// $data = array('1'=>'Spring-2012', '2'=>'Summer-2012', '3'=>'Fall-2012');
//
// foreach($data as $value=>$name)
// {
// echo CHtml::tag('option',
// array('value'=>$value),CHtml::encode($name),true);
// }
}
actionGetTracks()
method
|
public void actionGetTracks()
|
Source Code: (show)
public function actionGetTracks(){
if(isset($_POST['MajorSelectionForm']['major']))
$majorId = $_POST['MajorSelectionForm']['major'];
elseif(isset ($_POST['EditorSelectionForm']['major']))
$majorId = $_POST['EditorSelectionForm']['major'];
else
echo "No major is set";
$data= CurrMajorByTrack::model()->with('track')->findAll(
'major_id=:majorId',
array(':majorId'=>$majorId));
if($data == null)
CHtml::tag('option',
array('value'=>NULL),CHtml::encode('No track'),false);
else
echo CHtml::tag('option',
array('value'=>''),CHtml::encode('Select a Track'),true);
$data=CHtml::listData($data,'track_id','track.name');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
return ;
}
actionIndex()
method
|
public void actionIndex()
|
Source Code: (show)
public function actionIndex() {
$model = new MajorSelectionForm;
//enable ajax-based validation
if(isset($_POST['ajax']) && $_POST['ajax']==='major-selection-form-index-form'){
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['MajorSelectionForm'])) {
$model->attributes = $_POST['MajorSelectionForm'];
if ($model->validate()) {
//Set it into the session.
$catalog = Catalog::model()->findByPk($model->term);
$_SESSION['catalogId'] = $catalog->id;
$_SESSION['catalogName'] = $catalog->name;
$_SESSION['catalogActivated'] = $catalog->activated;
$this->catalogId = $_SESSION['catalogId'];
$this->catalogName= $_SESSION['catalogName'];
$this->catalogActivated = $_SESSION['catalogActivated'];
$degreeInfo = new DegreeInfo($model->major, $model->track, $model->term);
$this->render('majorRequirements', array('info'=>$degreeInfo));
Yii::app()->end();
}
}
//reset majorName
$model->majorName = '';
$this->render('index', array('model' => $model));
}
This is the default 'index' action that is invoked when an action is not explicitly requested by users.
actionListMajorPerDgu()
method
|
public void actionListMajorPerDgu()
|
Source Code: (show)
public function actionListMajorPerDgu(){
if(isset ($_POST['EditorSelectionForm']['dgu'])) {
$dguId = $_POST['EditorSelectionForm']['dgu'];
echo "dguId = ".$dguId;
} else {
echo "No dgu is set";
}
$data= HisMajor::model()->with('dgu', 'identifier')->findAll(
'dgu_id=:dguId and t.catalog_id=:catalogId',
array(':dguId'=>$dguId, ':catalogId'=>$this->catalogId));
if($data == null) {
CHtml::tag('option',
array('value'=>NULL),CHtml::encode('No dgu'),false);
} else {
echo CHtml::tag('option',
array('value'=>'-1'),CHtml::encode('Select a Major'),true);
$data=CHtml::listData($data,'id','identifier.name');
foreach($data as $value=>$name)
{
//echo CHtml::tag('option',
// array('value'=>$value),CHtml::encode($name),true);
}
}
return ;
}
actionLogout()
method
|
public void actionLogout()
|
Source Code: (show)
public function actionLogout() {
Yii::app()->user->logout();
$this->redirect(Yii::app()->homeUrl);
}
Logs out the current user and redirect to homepage.
actionManage()
method
|
public void actionManage()
|
Source Code: (show)
public function actionManage()
{
$model=new EditorSelectionForm;
if(isset($_POST['ajax']) && $_POST['ajax']==='editor-selection-form-manage-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['EditorSelectionForm']))
{
$model->attributes=$_POST['EditorSelectionForm'];
if($model->validate())
{
//Set it into the session.
$catalog = Catalog::model()->findByPk($model->catalog);
$_SESSION['catalogId'] = $catalog->id;
$_SESSION['catalogName'] = $catalog->name;
$_SESSION['catalogActivated'] = $catalog->activated;
$this->catalogId = $_SESSION['catalogId'];
$this->catalogName= $_SESSION['catalogName'];
$this->catalogActivated = $_SESSION['catalogActivated'];
$degreeInfo = new DegreeInfo($model->major, $model->track, $model->catalog);
$this->render('editorRequirements', array('info'=>$degreeInfo));
Yii::app()->end();
return;
}
}
$this->render('manage',array('model'=>$model));
}
actions()
method
|
public void actions()
|
Source Code: (show)
public function actions() {
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
),
// page action renders "static" pages stored under 'protected/views/site/pages'
// They can be accessed via: index.php?r=site/page&view=FileName
'page' => array(
'class' => 'CViewAction',
),
);
}
Declares class-based actions.