From 20b48ff1aa5864397fd7f3b08d3d0d38eb71d945 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 20 Jan 2017 18:02:32 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E8=A9=B3=E7=B4=B0=E7=94=BB=E9=9D=A2=E3=81=A7?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=B8=E3=81=AE=E3=83=9C=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B=E3=81=A8?= =?UTF-8?q?=E3=83=88=E3=83=83=E3=83=97=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AB?= =?UTF-8?q?=E6=88=BB=E3=81=A3=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/CurrentPage.php | 24 ++++++++++++++++++++++++ Utility/NetCommonsUrl.php | 10 +++++++--- View/Helper/BackToHelper.php | 2 +- View/Helper/ButtonHelper.php | 4 ++-- View/Helper/LinkButtonHelper.php | 2 +- View/Helper/WizardHelper.php | 2 +- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Utility/CurrentPage.php b/Utility/CurrentPage.php index 765955c5..1fbc72cc 100644 --- a/Utility/CurrentPage.php +++ b/Utility/CurrentPage.php @@ -10,6 +10,7 @@ */ App::uses('CurrentFrame', 'NetCommons.Utility'); +App::uses('Space', 'Rooms.Space'); /** * CurrentPage Utility @@ -42,6 +43,7 @@ public function initialize() { } $this->setPage(); + $this->setTopPage(); $this->setPageByRoomPageTopId(); $this->setRolesRoomsUser(); $this->setDefaultRolePermissions(); @@ -194,6 +196,28 @@ private function __getPageConditions() { return $conditions; } +/** + * Set TopPage + * + * @return bool + */ + public function setTopPage() { + $this->Page = ClassRegistry::init('Pages.Page'); + if (isset(Current::$current['TopPage'])) { + return; + } + + $result = $this->__getPage(array( + 'recursive' => -1, + 'conditions' => array( + 'Page.room_id' => Space::getRoomIdRoot(Space::PUBLIC_SPACE_ID), + 'Page.parent_id NOT' => null, + ), + 'order' => array('Page.lft' => 'asc') + )); + Current::$current['TopPage'] = $result['Page']; + } + /** * ページ取得 * diff --git a/Utility/NetCommonsUrl.php b/Utility/NetCommonsUrl.php index 6ec6d583..8f05d774 100644 --- a/Utility/NetCommonsUrl.php +++ b/Utility/NetCommonsUrl.php @@ -17,6 +17,7 @@ * * @author Shohei Nakajima * @package NetCommons\NetCommons\Utility + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ class NetCommonsUrl { @@ -33,12 +34,15 @@ public static function backToPageUrl($settingMode = false, $full = false) { $url = '/'; if (! Current::isControlPanel()) { - if ($settingMode) { + if ($settingMode || $settingMode === null && Current::isSettingMode()) { $url .= Current::SETTING_MODE_WORD . '/'; } - if (Hash::get($page, 'Page.parent_id') === Page::PUBLIC_ROOT_PAGE_ID && - Hash::get($page, 'Page.id') === Current::read('Room.page_id_top')) { + if (Current::read('Space.permalink')) { + $url .= Current::read('Space.permalink') . '/'; + } + + if (Hash::get($page, 'Page.id') === Current::read('TopPage.id')) { $url .= ''; } else { $url .= h(Hash::get($page, 'Page.permalink')); diff --git a/View/Helper/BackToHelper.php b/View/Helper/BackToHelper.php index d63b84ba..77ca07f4 100644 --- a/View/Helper/BackToHelper.php +++ b/View/Helper/BackToHelper.php @@ -152,7 +152,7 @@ public function linkButton($title, $url, $options = array()) { * @return string */ public function pageLinkButton($title, $options = array()) { - $url = NetCommonsUrl::backToPageUrl(); + $url = NetCommonsUrl::backToPageUrl(null); return $this->linkButton($title, $url, $options); } diff --git a/View/Helper/ButtonHelper.php b/View/Helper/ButtonHelper.php index ef4aab9e..9c4578ba 100644 --- a/View/Helper/ButtonHelper.php +++ b/View/Helper/ButtonHelper.php @@ -235,7 +235,7 @@ public function cancel($title, $url, $options = array()) { public function cancelAndSave($cancelTitle, $saveTitle, $cancelUrl = null, $cancelOptions = [], $saveOptions = []) { if (! isset($cancelUrl)) { - $cancelUrl = NetCommonsUrl::backToPageUrl(); + $cancelUrl = NetCommonsUrl::backToPageUrl(null); } $output = ''; @@ -259,7 +259,7 @@ public function cancelAndSaveAndSaveTemp($cancelUrl = null, $cancelOptions = [], App::uses('WorkflowComponent', 'Workflow.Controller/Component'); if (! isset($cancelUrl)) { - $cancelUrl = NetCommonsUrl::backToPageUrl(); + $cancelUrl = NetCommonsUrl::backToPageUrl(null); } $output = ''; diff --git a/View/Helper/LinkButtonHelper.php b/View/Helper/LinkButtonHelper.php index f5cb569d..1a5a48df 100644 --- a/View/Helper/LinkButtonHelper.php +++ b/View/Helper/LinkButtonHelper.php @@ -206,7 +206,7 @@ public function toList($title = '', $url = null, $options = array()) { $output = ''; if (! isset($url)) { - $url = NetCommonsUrl::backToPageUrl(); + $url = NetCommonsUrl::backToPageUrl(null); } //Linkオプションの設定 diff --git a/View/Helper/WizardHelper.php b/View/Helper/WizardHelper.php index 7d140b02..0b1f0f35 100644 --- a/View/Helper/WizardHelper.php +++ b/View/Helper/WizardHelper.php @@ -96,7 +96,7 @@ public function beforeRender($viewFile) { $this->settings['navibar'] = array(); } if (! isset($this->settings['cancelUrl'])) { - $this->settings['cancelUrl'] = NetCommonsUrl::backToPageUrl(); + $this->settings['cancelUrl'] = NetCommonsUrl::backToPageUrl(null); } }