PATH:
home
/
letacommog
/
letaweb
/
protected
/
modules
/
helpSystem
/
modules
/
admin
/
controllers
<?php /** * SectionController class file. * @author Digital Mesh <info@digitalmesh.com> * @copyright Copyright © Digital Mesh 2013- * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @package HelpSystem */ /** * SectionController Class is used to mange the CURD ot section */ class SectionController extends DMController{ /** * function to initialise the controller */ public function init(){ parent::init(); $this->setLayout(); } /** * set the layout for our controller */ private function setLayout(){ $this->layout= Yii::app()->getModule('helpSystem')->pageLayout; } /** * @return array action filters */ public function filters() { return array( 'accessControl', // perform access control for CRUD operations ); } /** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * @return array access control rules */ public function accessRules() { $rules = array(); $actions = array('index','update', 'delete'); $rules = AccessRules::getRuleArray($actions); return $rules; } /** * List all section */ public function actionIndex(){ $sectionModel = new Section(); $sectiontextModel = new SectionText() ; $sectionList = $this->getSectionList(); $bootstrapClass = new BootstrapClassFilter(); if(Yii::app()->request->isPostRequest){ $form = Yii::app()->request->getPost("SectionText"); if(DataManagement::createSection($form['Name'],$sectionModel,$sectiontextModel)){ $this->redirect(array("index")); } } $this->render("index", array("sectionModel"=>$sectionModel, "sectiontextModel"=>$sectiontextModel, "sectionList"=>$sectionList, "bootstrapClass"=>$bootstrapClass )); } /** * Updates a particular model. * If update is successful, the browser will be reload the page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $sectionModel = $this->loadModel($id); $sectionTextModel = SectionText::model()->findByPk($sectionModel->sectionTexts[0]->SectionTextId); $sectionList = $this->getSectionList(); $bootstrapClass = new BootstrapClassFilter(); if(Yii::app()->request->isPostRequest){ $form = Yii::app()->request->getPost("SectionText"); if(DataManagement::updateSection($form['Name'],$sectionTextModel,$id)){ $this->redirect(array("index")); } } $this->render("index", array("sectionModel"=>$sectionModel, "sectiontextModel"=>$sectionTextModel, "sectionList"=>$sectionList, "bootstrapClass"=>$bootstrapClass )); } /** * Deletes a particular model. * If deletion is successful, the browser will be reload page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if(Yii::app()->request->isPostRequest){ $sectionText = SectionText::model()->deleteAll( 'SectionId =:id',array(':id'=>$id)); $this->loadModel($id)->delete(); $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); } } /** * Returns the entire Section List as array * @return SectionList array */ private function getSectionList(){ $sectionList = Section::model()->findAll(); return $sectionList; } /** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded * @throws CHttpException * @return $model Object */ public function loadModel($id) { $model = Section::model()->findByPk($id); if($model===null){ throw new CHttpException(404,'The requested page does not exist.'); } return $model; } }
[+]
..
[-] SectionController.php
[edit]
[-] TopicController.php
[edit]