From 6014969c75603732bd782766a6621293e7a688c4 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 14 Nov 2016 17:41:53 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=83=98=E3=83=83=E3=83=80=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E3=83=95=E3=83=AC=E3=83=BC=E3=83=A0=E3=81=8C=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E3=81=97=E3=81=A6=E3=82=82=E8=A1=A8=E7=A4=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/CurrentFrame.php | 7 +++++++ Utility/CurrentPage.php | 22 +++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Utility/CurrentFrame.php b/Utility/CurrentFrame.php index 12cf8f44..da8199f2 100644 --- a/Utility/CurrentFrame.php +++ b/Utility/CurrentFrame.php @@ -37,6 +37,9 @@ class CurrentFrame { * @return void */ public function initialize() { + if (isset(Current::$current['Room'])) { + unset(Current::$current['Room']); + } if (isset(Current::$current['Frame'])) { unset(Current::$current['Frame']); } @@ -46,6 +49,9 @@ public function initialize() { if (isset(Current::$current['BlockRolePermission'])) { unset(Current::$current['BlockRolePermission']); } + if (isset(Current::$m17n['Room'])) { + unset(Current::$m17n['Room']); + } if (isset(Current::$m17n['Frame'])) { unset(Current::$m17n['Frame']); } @@ -85,6 +91,7 @@ public function setFrame($frameId = null) { $this->Frame = ClassRegistry::init('Frames.Frame'); $this->Box = ClassRegistry::init('Boxes.Box'); $this->Block = ClassRegistry::init('Blocks.Block'); +var_dump($frameId); if (isset($frameId)) { $result = $this->Frame->findById($frameId); diff --git a/Utility/CurrentPage.php b/Utility/CurrentPage.php index d7de26b3..8c42daa1 100644 --- a/Utility/CurrentPage.php +++ b/Utility/CurrentPage.php @@ -192,6 +192,23 @@ private function __getPageConditions() { return $conditions; } +/** + * ページ取得 + * + * @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 +216,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 +242,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), )); From 93fbec3854304914b759965d946dbaa0653f2c4e Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 15 Nov 2016 04:00:05 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Box=E3=81=AE=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88=E6=A9=9F=E8=83=BD=E3=81=AB=E3=82=88=E3=82=8B=E6=94=B9?= =?UTF-8?q?=E4=BF=AE=E6=BC=8F=E3=82=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/CurrentFrame.php | 42 +++++++++++++++++++--------------------- Utility/CurrentPage.php | 2 +- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Utility/CurrentFrame.php b/Utility/CurrentFrame.php index da8199f2..766fd4c1 100644 --- a/Utility/CurrentFrame.php +++ b/Utility/CurrentFrame.php @@ -37,27 +37,7 @@ class CurrentFrame { * @return void */ public function initialize() { - if (isset(Current::$current['Room'])) { - unset(Current::$current['Room']); - } - 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['Room'])) { - unset(Current::$m17n['Room']); - } - 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(); @@ -70,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 * @@ -91,7 +90,6 @@ public function setFrame($frameId = null) { $this->Frame = ClassRegistry::init('Frames.Frame'); $this->Box = ClassRegistry::init('Boxes.Box'); $this->Block = ClassRegistry::init('Blocks.Block'); -var_dump($frameId); if (isset($frameId)) { $result = $this->Frame->findById($frameId); diff --git a/Utility/CurrentPage.php b/Utility/CurrentPage.php index 8c42daa1..c2e8aa25 100644 --- a/Utility/CurrentPage.php +++ b/Utility/CurrentPage.php @@ -284,7 +284,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; } From 9fc526591aa0279a58dc7b6bfaad081f564307c3 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 15 Nov 2016 04:44:50 +0900 Subject: [PATCH 3/3] =?UTF-8?q?phpcs=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/CurrentPage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Utility/CurrentPage.php b/Utility/CurrentPage.php index c2e8aa25..c8db9655 100644 --- a/Utility/CurrentPage.php +++ b/Utility/CurrentPage.php @@ -195,6 +195,7 @@ private function __getPageConditions() { /** * ページ取得 * + * @param array $query クエリ * @return array 条件配列 */ private function __getPage($query) {