From 0c452d762738975aeb7503494002020b428632fa Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 5 May 2018 11:37:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=9F=E5=BA=A6=E6=94=B9=E5=96=84?= =?UTF-8?q?=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AE=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?=E3=83=BBHash::extract=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/ControlPanelLayoutComponent.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Controller/Component/ControlPanelLayoutComponent.php b/Controller/Component/ControlPanelLayoutComponent.php index 1d6c31d..50c9385 100644 --- a/Controller/Component/ControlPanelLayoutComponent.php +++ b/Controller/Component/ControlPanelLayoutComponent.php @@ -66,17 +66,21 @@ public function beforeRender(Controller $controller) { $controller->set('pluginsMenu', $this->plugins); if (isset($this->settings['plugin'])) { - $plugin = $this->settings['plugin']; + $pluginKey = $this->settings['plugin']; } else { - $plugin = $controller->params['plugin']; + $pluginKey = $controller->params['plugin']; } - - $plugin = Hash::extract($this->plugins, '{n}.Plugin[key=' . $plugin . ']'); - if (isset($plugin[0]['name'])) { + 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', $plugin[0]['name']); + $controller->set('title', $pluginName); } - $controller->set('pageTitle', $plugin[0]['name']); + $controller->set('pageTitle', $pluginName); } } From 8ca17c81951bd645ad2cee613ed72b27a5b2c5f2 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 5 May 2018 13:20:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=9F=E5=BA=A6=E6=94=B9=E5=96=84?= =?UTF-8?q?=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AE=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?=E3=83=BB=E4=BD=BF=E7=94=A8=E3=81=97=E3=81=AA=E3=81=84=E3=82=AB?= =?UTF-8?q?=E3=83=A9=E3=83=A0=E3=81=AF=E5=8F=96=E5=BE=97=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Component/ControlPanelLayoutComponent.php | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/Controller/Component/ControlPanelLayoutComponent.php b/Controller/Component/ControlPanelLayoutComponent.php index 50c9385..de16a83 100644 --- a/Controller/Component/ControlPanelLayoutComponent.php +++ b/Controller/Component/ControlPanelLayoutComponent.php @@ -43,16 +43,45 @@ public function beforeRender(Controller $controller) { $controller->Plugin = ClassRegistry::init('PluginManager.Plugin', true); $controller->PluginsRole = ClassRegistry::init('PluginManager.PluginsRole', true); - $controlPanel = $controller->Plugin->create(array( + $controlPanel[$controller->Plugin->alias] = [ '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' - ); + $this->plugins = $controller->Plugin->find('all', array( + 'recursive' => -1, + 'fields' => array( + $controller->Plugin->alias . '.key', + $controller->Plugin->alias . '.name', + //$controller->Plugin->alias . '.weight', + //$controller->Plugin->alias . '.type', + $controller->Plugin->alias . '.default_action', + //$controller->PluginsRole->alias . '.role_key', + ), + 'joins' => array( + array( + 'table' => $controller->PluginsRole->table, + 'alias' => $controller->PluginsRole->alias, + 'type' => 'INNER', + 'conditions' => array( + $controller->Plugin->alias . '.key' . ' = ' . + $controller->PluginsRole->alias . ' .plugin_key', + ), + ), + ), + 'conditions' => array( + $controller->Plugin->alias . '.type' => [ + Plugin::PLUGIN_TYPE_FOR_SITE_MANAGER, Plugin::PLUGIN_TYPE_FOR_SYSTEM_MANGER + ], + $controller->Plugin->alias . '.language_id' => Current::read('Language.id'), + $controller->PluginsRole->alias . '.role_key' => Current::read('User.role_key'), + ), + 'order' => array( + $controller->Plugin->alias . '.weight' => 'asc', + $controller->Plugin->alias . '.id' => 'desc' + ), + )); array_unshift($this->plugins, $controlPanel);