-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathP3WidgetsModule.php
More file actions
85 lines (78 loc) · 2.49 KB
/
P3WidgetsModule.php
File metadata and controls
85 lines (78 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Class File
* @author Tobias Munk <schmunk@usrbin.de>
* @link http://www.phundament.com/
* @copyright Copyright © 2005-2010 diemeisterei GmbH
* @license http://www.phundament.com/license/
*/
/**
* Description ...
* Detailed info
* <pre>
* <?php
* $this->widget(
* 'p3widgets.components.P3WidgetContainer',
* array(
* 'id'=>'main',
* #'checkAccess'=>false //disables checkAccess feature
* )
* );
* ?>
* </pre>
* {@link DefaultController}
* @author Tobias Munk <schmunk@usrbin.de>
* @version $Id$
* @package p3widgets
* @since 3.0
*/
class P3WidgetsModule extends CWebModule
{
public $adminRole = 'admin';
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(
array(
'p3widgets.models.*',
'p3widgets.components.*',
)
);
}
public function buildWidgetMenuItems($widgetAttributes)
{
$items = array();
foreach (Yii::app()->getModule('p3widgets')->params['widgets'] AS $alias => $config) {
if (is_array($config)) {
if (isset($config['checkAccess']) && !Yii::app()->user->checkAccess($config['checkAccess'])) {
continue;
}
$name = $config['name'];
} else {
$name = $config;
}
$widgetAttributes = CMap::mergeArray($widgetAttributes,array('alias'=>$alias,));
$items[$name] = array(
'label' => $name,
'url' => array('/p3widgets/p3Widget/create', 'P3Widget' => $widgetAttributes, 'returnUrl' => Yii::app()->request->getUrl()),
'htmlOptions' => array(
'class' => 'create-widget',
//'data-widget-attributes' => CJSON::encode($widgetAttributes)
)
);
}
return $items;
}
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
// this method is called before any module controller action is performed
// you may place customized code here
return true;
} else {
return false;
}
}
}