-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathControlPanelLayoutComponent.php
More file actions
116 lines (101 loc) · 3.25 KB
/
ControlPanelLayoutComponent.php
File metadata and controls
116 lines (101 loc) · 3.25 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* ControlPanelLayoutComponent
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('Component', 'Controller');
App::uses('DebugTimer', 'DebugKit.Lib');
/**
* ControlPanelLayoutComponent
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\ControlPanel\Controller
*/
class ControlPanelLayoutComponent extends Component {
/**
* Plugins data
*
* @var array
*/
public $plugins = null;
/**
* Called before the Controller::beforeFilter().
*
* TODO: 当処理は、管理画面測定用なので、masterブランチにはコミットしない
*
* @param Controller $controller Controller with components to initialize
* @return void
* @link https://book.cakephp.org/2.0/en/controllers/components.html#Component::initialize
*/
public function initialize(Controller $controller) {
DebugTimer::start('plugin_timer', $controller->request->here);
parent::initialize($controller);
}
/**
* Called after Controller::render() and before the output is printed to the browser.
*
* TODO: 当処理は、管理画面測定用なので、masterブランチにはコミットしない
*
* @param Controller $controller Controller with components to shutdown
* @return void
* @link https://book.cakephp.org/2.0/en/controllers/components.html#Component::shutdown
*/
public function shutdown(Controller $controller) {
parent::shutdown($controller);
DebugTimer::stop('plugin_timer');
}
/**
* beforeRender
*
* @param Controller $controller Controller
* @return void
* @throws NotFoundException
*/
public function beforeRender(Controller $controller) {
//RequestActionの場合、スキップする
if (! empty($controller->request->params['requested']) || $controller->request->is('ajax')) {
return;
}
//Pluginデータ取得
$controller->Plugin = ClassRegistry::init('PluginManager.Plugin', true);
$controller->PluginsRole = ClassRegistry::init('PluginManager.PluginsRole', true);
$controlPanel = $controller->Plugin->create(array(
'key' => 'control_panel',
'name' => __d('control_panel', 'Control Panel Top'),
'default_action' => 'control_panel/index'
));
$this->plugins = $controller->PluginsRole->getPlugins(
array(Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, Plugin::PLUGIN_TYPE_FOR_SYSTEM_MANGER),
Current::read('User.role_key'), 'INNER'
);
array_unshift($this->plugins, $controlPanel);
//Layoutのセット
$controller->layout = 'ControlPanel.default';
//cancelUrlをセット
$controller->set('cancelUrl', '/');
//ページHelperにセット
$controller->set('pluginsMenu', $this->plugins);
if (isset($this->settings['plugin'])) {
$pluginKey = $this->settings['plugin'];
} else {
$pluginKey = $controller->params['plugin'];
}
foreach ($this->plugins as $plugin) {
if ($plugin['Plugin']['key'] === $pluginKey) {
$pluginName = $plugin['Plugin']['name'];
break;
}
}
if (!empty($pluginName)) {
if (! isset($controller->viewVars['title'])) {
$controller->set('title', $pluginName);
}
$controller->set('pageTitle', $pluginName);
}
}
}