Phundament App Class Reference
  • Package
  • Class
  • Tree

Packages

  • bootstrap
    • widgets
      • input
  • Image
  • None
  • p3admin
  • p3extensions
    • behaviors
    • commands
    • components
    • helpers
    • widgets
  • p3media
    • actions
    • controllers
    • models
  • p3pages
    • models
  • p3widgets
    • components
    • models
  • PHP
  • system
    • db
      • ar
    • gii
    • web
      • auth
      • helpers
      • widgets
  • yiiext
    • widgets
      • fancybox
      • lipsum
  • zii
    • widgets
      • grid

Classes

  • ActivationController
  • AdminController
  • AssignmentController
  • AssignmentForm
  • AuthChildForm
  • AuthItemController
  • AuthItemForm
  • BaseP3Widget
  • BaseP3WidgetMeta
  • BaseP3WidgetTranslation
  • Bootstrap
  • CImageComponent
  • CKEditor
  • CodeProvider
  • DefaultController
  • EChosen
  • EDbMigration
  • EditableField
  • EditableSaver
  • EMigrateCommand
  • ESelect2
  • EUserFlash
  • FullCrudFieldProvider
  • GenerateForm
  • IdentificationColumnValidator
  • InstallController
  • JSONEditorView
  • JuiJSONEditorInput
  • LoginController
  • LogoutController
  • Metadata
  • P3CrudFieldProvider
  • P3MediaController
  • P3MediaMetaController
  • P3MediaSelect
  • P3PageController
  • P3PageMetaController
  • P3PageTranslationController
  • P3Widget
  • P3WidgetController
  • P3WidgetMetaController
  • P3WidgetTranslation
  • P3WidgetTranslationController
  • ProfileController
  • ProfileFieldController
  • RAuthItemBehavior
  • RAuthItemChildDataProvider
  • RAuthItemDataProvider
  • RAuthItemParentDataProvider
  • RAuthorizer
  • RController
  • RDbAuthManager
  • RecoveryController
  • RegistrationController
  • RegistrationForm
  • RGenerator
  • Rights
  • RightsFilter
  • RightsModule
  • RInstaller
  • RPermissionDataProvider
  • RUserBehavior
  • RWebUser
  • UActiveForm
  • UploadHandler
  • UserChangePassword
  • UserController
  • UserIdentity
  • UserLogin
  • UserModule
  • UserRecoveryForm
  • UWdropDownDep
  • UWfile
  • UWjuiAutoComplete
  • UWjuidate
  • UWrelBelongsTo
  • WebUserBehavior
  1 <?php
  2 
  3 class P3MediaMetaController extends Controller
  4 {
  5     #public $layout='//layouts/column2';
  6     public $defaultAction = "admin";
  7     public $scenario = "crud";
  8 
  9 public function filters() {
 10     return array(
 11             'accessControl',
 12             );
 13 }
 14 
 15 public function accessRules() {
 16     return array(
 17             array('allow',
 18                 'actions'=>array('create','ajaxUpdate','update','delete','admin','view'),
 19                 'roles'=>array('P3media.P3MediaMeta.*'),
 20                 ),
 21             array('deny',
 22                 'users'=>array('*'),
 23                 ),
 24             );
 25 }
 26 
 27     public function beforeAction($action){
 28         parent::beforeAction($action);
 29         // map identifcationColumn to id
 30         if (!isset($_GET['id']) && isset($_GET['id'])) {
 31             $model=P3MediaMeta::model()->find('id = :id', array(
 32             ':id' => $_GET['id']));
 33             if ($model !== null) {
 34                 $_GET['id'] = $model->id;
 35             } else {
 36                 throw new CHttpException(400);
 37             }
 38         }
 39         if ($this->module !== null) {
 40             $this->breadcrumbs[$this->module->Id] = array('/'.$this->module->Id);
 41         }
 42         return true;
 43     }
 44 
 45     public function actionView($id)
 46     {
 47         $model = $this->loadModel($id);
 48         $this->render('view',array(
 49             'model' => $model,
 50         ));
 51     }
 52 
 53     public function actionCreate()
 54     {
 55         $model = new P3MediaMeta;
 56         $model->scenario = $this->scenario;
 57 
 58                 $this->performAjaxValidation($model, 'p3-media-meta-form');
 59     
 60         if(isset($_POST['P3MediaMeta'])) {
 61             $model->attributes = $_POST['P3MediaMeta'];
 62 
 63             try {
 64                 if($model->save()) {
 65                     if (isset($_GET['returnUrl'])) {
 66                         $this->redirect($_GET['returnUrl']);
 67                     } else {
 68                         $this->redirect(array('view','id'=>$model->id));
 69                     }
 70                 }
 71             } catch (Exception $e) {
 72                 $model->addError('id', $e->getMessage());
 73             }
 74         } elseif(isset($_GET['P3MediaMeta'])) {
 75                 $model->attributes = $_GET['P3MediaMeta'];
 76         }
 77 
 78         $this->render('create',array( 'model'=>$model));
 79     }
 80 
 81 
 82     public function actionUpdate($id)
 83     {
 84         $model = $this->loadModel($id);
 85         $model->scenario = $this->scenario;
 86 
 87                 $this->performAjaxValidation($model, 'p3-media-meta-form');
 88         
 89         if(isset($_POST['P3MediaMeta']))
 90         {
 91             $model->attributes = $_POST['P3MediaMeta'];
 92 
 93 
 94             try {
 95                 if($model->save()) {
 96                     if (isset($_GET['returnUrl'])) {
 97                         $this->redirect($_GET['returnUrl']);
 98                     } else {
 99                         $this->redirect(array('view','id'=>$model->id));
100                     }
101                 }
102             } catch (Exception $e) {
103                 $model->addError('id', $e->getMessage());
104             }
105         }
106 
107         $this->render('update',array(
108                     'model'=>$model,
109                     ));
110     }
111 
112     public function actionAjaxUpdate()
113     {
114         Yii::import('EditableSaver'); //or you can add import 'ext.editable.*' to config
115         $es = new EditableSaver('P3MediaMeta');  // classname of model to be updated
116         $es->update();
117     }
118 
119     public function actionDelete($id)
120     {
121         if(Yii::app()->request->isPostRequest)
122         {
123             try {
124                 $this->loadModel($id)->delete();
125             } catch (Exception $e) {
126                 throw new CHttpException(500,$e->getMessage());
127             }
128 
129             if(!isset($_GET['ajax']))
130             {
131                 if (isset($_GET['returnUrl'])) {
132                     $this->redirect($_GET['returnUrl']);
133                 } else {
134                     $this->redirect(array('admin'));
135                 }
136             }
137         }
138         else
139             throw new CHttpException(400,
140                     Yii::t('app', 'Invalid request. Please do not repeat this request again.'));
141     }
142 
143     public function actionIndex()
144     {
145         $dataProvider=new CActiveDataProvider('P3MediaMeta');
146         $this->render('index',array(
147             'dataProvider'=>$dataProvider,
148         ));
149     }
150 
151     public function actionAdmin()
152     {
153         $model=new P3MediaMeta('search');
154         $model->unsetAttributes();
155 
156         if(isset($_GET['P3MediaMeta']))
157             $model->attributes = $_GET['P3MediaMeta'];
158 
159         $this->render('admin',array(
160             'model'=>$model,
161         ));
162     }
163 
164     public function loadModel($id)
165     {
166         $model=P3MediaMeta::model()->findByPk($id);
167         if($model===null)
168             throw new CHttpException(404,Yii::t('app', 'The requested page does not exist.'));
169         return $model;
170     }
171 
172     protected function performAjaxValidation($model)
173     {
174         if(isset($_POST['ajax']) && $_POST['ajax']==='p3-media-meta-form')
175         {
176             echo CActiveForm::validate($model);
177             Yii::app()->end();
178         }
179     }
180 }
181 
Phundament App Class Reference API documentation generated by ApiGen 2.8.0