layout = Yii::app()->controller->module->layout; return true; } public function accessRules() { return array( array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','index','create','view','update','delete'), 'users'=>array('admin'), ), array('deny', // deny all users 'users'=>array('*'), ), ); } public function actionSearch() { $q = new CDbCriteria(); $q->addSearchCondition('content',$_POST['search']); $results = Sitecontent::model()->findAll($q); $q = new CDbCriteria(); $q->addSearchCondition('beschreibung',$_POST['search']); $results = Verein::model()->findAll($q); $this->render('results', array( 'results' => $results, 'search' => $_POST['search'])); } public static function getContent($id) { if($model = Sitecontent::model()->findByPk($id)) { return $model->content; } } public function filters() { return array( 'accessControl', // perform access control for CRUD operations ); } public function actionView() { $model = $this->loadContent(); $this->breadcrumbs = array($model->title); if($model->depth == 1) { $this->menu = CMS::getMenuPoints($model->id); } elseif ($model->depth == 2){ $this->menu = CMS::getMenuPoints($model->oparent->id); } $this->render('view', array( 'sitecontent' => $model, )); } public function actionCreate() { $model=new Sitecontent; $this->performAjaxValidation($model); if(isset($_POST['Sitecontent'])) { $model->attributes=$_POST['Sitecontent']; $model->createtime = time(); $model->updatetime = time(); if(isset(Yii::app()->user->id)) $model->authorid = Yii::app()->user->id; if($model->save()) $this->redirect(array('admin')); } if(isset($_GET['position'])) $model->position = $_GET['position']; $this->render('create',array( 'model'=>$model, )); } public function actionUpdate() { $model=$this->loadContent(); $this->performAjaxValidation($model); if(isset($_POST['Sitecontent'])) { $model->attributes=$_POST['Sitecontent']; $model->updatetime = time(); if($model->save()) $this->redirect(array('admin')); } $this->render('update',array( 'model'=>$model, )); } public function actionDelete() { if(Yii::app()->request->isPostRequest) { $this->loadContent()->delete(); if(!isset($_POST['ajax'])) $this->redirect(array('index')); } else throw new CHttpException(400,Yii::t('App','Invalid request. Please do not repeat this request again.')); } public function actionIndex() { $dataProvider=new CActiveDataProvider('Sitecontent'); $this->render('index',array( 'dataProvider'=>$dataProvider, )); } public function actionAdmin() { $model=new Sitecontent('search'); if(isset($_GET['Sitecontent'])) $model->attributes=$_GET['Sitecontent']; $this->render('admin',array( 'model'=>$model, )); } public function loadContent() { if($this->_model===null) { if(isset($_GET['id']) && is_array(@$_GET['id'])) $this->_model = Sitecontent::model()->find('id = :id and language = :language', array( ':id' => $_GET['id']['id'], ':language' => $_GET['id']['language'], )); if(isset($_GET['id']) && !is_array($_GET['id'])) $this->_model = Sitecontent::model()->find('id = :id', array( ':id' => $_GET['id'], )); if($this->_model === null) $this->_model = Sitecontent::model()->find("title_url = :page", array( ':page' => $_GET['page'])); if($this->_model===null) throw new CHttpException(404,Yii::t('App','We are sorry. The requested page does not exist.')); } return $this->_model; } protected function performAjaxValidation($model) { if(isset($_POST['ajax']) && $_POST['ajax']==='sitecontent-form') { echo CActiveForm::validate($model); Yii::app()->end(); } } }