1 <?php
2
3 /**
4 * Class file.
5 *
6 * @author Tobias Munk <schmunk@usrbin.de>
7 * @link http://www.phundament.com/
8 * @copyright Copyright © 2005-2011 diemeisterei GmbH
9 * @license http://www.phundament.com/license/
10 */
11
12 /**
13 * Controller handling the views for ckeditor
14 *
15 * Detail description
16 *
17 * @author Tobias Munk <schmunk@usrbin.de>
18 * @package p3media.controllers
19 * @since 3.0.1
20 */
21 class CkeditorController extends Controller {
22
23 public $layout = "//layouts/popup";
24 private $_models;
25
26 public function filters() {
27 return array(
28 'accessControl',
29 );
30 }
31
32 public function accessRules() {
33 return array(
34 array('allow',
35 'actions' => array('index', 'image', 'flash', 'upload'),
36 'expression' => 'Yii::app()->user->checkAccess("P3media.Ckeditor.*")',
37 ),
38 array('deny',
39 'users' => array('*'),
40 ),
41 );
42 }
43
44 public function actionIndex() {
45 $model = new P3Media('search');
46 $model->unsetAttributes();
47
48 if (isset($_GET['P3Media']))
49 $model->attributes = $_GET['P3Media'];
50
51 $this->render('index', array('model' => $model));
52 }
53
54 public function actionImage() {
55 $model = new P3Media('search');
56 $model->unsetAttributes();
57 $model->attributes = array('mimeType' => 'image');
58
59 if (isset($_GET['P3Media'])) {
60 $model->scenario = "search";
61 $model->attributes = $_GET['P3Media'];
62 }
63
64 // TODO - remove public property?, see also P3MediaController
65 if (isset($_GET['P3Media']['treeParent'])) {
66 $model->treeParent = $_GET['P3Media']['treeParent'];
67 }
68
69 $model->dbCriteria->order = "id DESC";
70
71 $this->render('index', array('model' => $model));
72 }
73
74 public function actionFlash() {
75 $this->render('index', array('model' => $model));
76 }
77
78 private function loadModel() {
79 $criteria = new CDbCriteria();
80 $criteria->addSearchCondition('mime', 'image');
81
82 $this->_models = P3Media::model()->findAllByAttributes($criteria);
83 }
84
85 // -----------------------------------------------------------
86 // Uncomment the following methods and override them if needed
87 /*
88 public function filters()
89 {
90 // return the filter configuration for this controller, e.g.:
91 return array(
92 'inlineFilterName',
93 array(
94 'class'=>'path.to.FilterClass',
95 'propertyName'=>'propertyValue',
96 ),
97 );
98 }
99
100 public function actions()
101 {
102 // return external action classes, e.g.:
103 return array(
104 'action1'=>'path.to.ActionClass',
105 'action2'=>array(
106 'class'=>'path.to.AnotherActionClass',
107 'propertyName'=>'propertyValue',
108 ),
109 );
110 }
111 */
112 }