diff --git a/Utility/CurrentFrame.php b/Utility/CurrentFrame.php index 12cf8f44..766fd4c1 100644 --- a/Utility/CurrentFrame.php +++ b/Utility/CurrentFrame.php @@ -37,21 +37,7 @@ class CurrentFrame { * @return void */ public function initialize() { - if (isset(Current::$current['Frame'])) { - unset(Current::$current['Frame']); - } - if (isset(Current::$current['Block'])) { - unset(Current::$current['Block']); - } - if (isset(Current::$current['BlockRolePermission'])) { - unset(Current::$current['BlockRolePermission']); - } - if (isset(Current::$m17n['Frame'])) { - unset(Current::$m17n['Frame']); - } - if (isset(Current::$m17n['Block'])) { - unset(Current::$m17n['Block']); - } + $this->clear(); if (!in_array(Current::$request->params['plugin'], self::$skipFramePlugins, true)) { $this->setFrame(); @@ -64,6 +50,25 @@ public function initialize() { $this->setBlockRolePermissions(); } +/** + * setup current data + * + * @return void + */ + public function clear() { + foreach (['Room', 'Frame', 'Block'] as $model) { + if (isset(Current::$current[$model])) { + unset(Current::$current[$model]); + } + if (isset(Current::$m17n[$model])) { + unset(Current::$m17n[$model]); + } + } + if (isset(Current::$current['BlockRolePermission'])) { + unset(Current::$current['BlockRolePermission']); + } + } + /** * Set Frame * diff --git a/Utility/CurrentPage.php b/Utility/CurrentPage.php index d7de26b3..c8db9655 100644 --- a/Utility/CurrentPage.php +++ b/Utility/CurrentPage.php @@ -192,6 +192,24 @@ private function __getPageConditions() { return $conditions; } +/** + * ページ取得 + * + * @param array $query クエリ + * @return array 条件配列 + */ + private function __getPage($query) { + $this->Page = ClassRegistry::init('Pages.Page'); + + if (isset(Current::$current['Room'])) { + $this->Page->unbindModel(array( + 'belongsTo' => array('Room'), + ), true); + } + + return $this->Page->find('first', $query); + } + /** * Set Page * @@ -199,14 +217,13 @@ private function __getPageConditions() { */ public function setPage() { $this->Page = ClassRegistry::init('Pages.Page'); - if (isset(Current::$current['Page'])) { return; } $conditions = $this->__getPageConditions(); if ($conditions) { - $result = $this->Page->find('first', array( + $result = $this->__getPage(array( 'recursive' => 0, 'conditions' => $conditions, 'order' => array('Page.lft' => 'asc') @@ -226,7 +243,7 @@ public function setPage() { $pageId = null; } if ($pageId) { - $result = $this->Page->find('first', array( + $result = $this->__getPage(array( 'recursive' => 0, 'conditions' => array('Page.id' => $pageId), )); @@ -268,7 +285,7 @@ public function setPluginsRoom() { } $this->PluginsRoom = ClassRegistry::init('PluginManager.PluginsRoom'); - $result = $this->PluginsRoom->getPlugins(Current::read('Room.id'), Current::read('Language.id')); + $result = $this->PluginsRoom->getPlugins(Current::read('Room.id')); Current::$current['PluginsRoom'] = $result; }