Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Utility/CurrentPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

App::uses('CurrentFrame', 'NetCommons.Utility');
App::uses('Space', 'Rooms.Space');

/**
* CurrentPage Utility
Expand Down Expand Up @@ -42,6 +43,7 @@ public function initialize() {
}

$this->setPage();
$this->setTopPage();
$this->setPageByRoomPageTopId();
$this->setRolesRoomsUser();
$this->setDefaultRolePermissions();
Expand Down Expand Up @@ -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'];
}

/**
* ページ取得
*
Expand Down
10 changes: 7 additions & 3 deletions Utility/NetCommonsUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\NetCommons\Utility
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class NetCommonsUrl {

Expand All @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion View/Helper/BackToHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions View/Helper/ButtonHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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 = '';

Expand Down
2 changes: 1 addition & 1 deletion View/Helper/LinkButtonHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function toList($title = '', $url = null, $options = array()) {
$output = '';

if (! isset($url)) {
$url = NetCommonsUrl::backToPageUrl();
$url = NetCommonsUrl::backToPageUrl(null);
}

//Linkオプションの設定
Expand Down
2 changes: 1 addition & 1 deletion View/Helper/WizardHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down