Skip to content

Commit

Permalink
CurrentPage::__getPageConditionsでpagesプラグイン固定になっているための改修
Browse files Browse the repository at this point in the history
  • Loading branch information
s-nakajima committed Aug 9, 2017
1 parent 4034246 commit 7462dbb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Test/Case/Utility/CurrentPage/SetPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function testPagesRoot() {
Current::$request->params['plugin'] = 'pages';
Current::$request->params['controller'] = 'pages';
Current::$request->params['pass'] = [];
Current::$request->params['pageView'] = true;

//テスト実施
$this->CurrentPage->setPage();
Expand All @@ -131,6 +132,7 @@ public function testPagesWithPermalink() {
Current::$request->params['plugin'] = 'pages';
Current::$request->params['controller'] = 'pages';
Current::$request->params['pass'] = ['test4'];
Current::$request->params['pageView'] = true;

//テスト実施
$this->CurrentPage->setPage();
Expand Down Expand Up @@ -174,6 +176,7 @@ public function testPagesEditWithPageId() {
Current::$request->params['plugin'] = 'pages';
Current::$request->params['controller'] = 'pages_edit';
Current::$request->params['pass'] = ['2', '4'];
Current::$request->params['pageEdit'] = true;

//テスト実施
$this->CurrentPage->setPage();
Expand All @@ -192,6 +195,7 @@ public function testPagesEditWOPageId() {
Current::$request->params['plugin'] = 'pages';
Current::$request->params['controller'] = 'pages_edit';
Current::$request->params['pass'] = ['2'];
Current::$request->params['pageEdit'] = true;

//テスト実施
$this->CurrentPage->setPage();
Expand Down
40 changes: 20 additions & 20 deletions Utility/CurrentPage.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 CurrentPage {

Expand Down Expand Up @@ -163,28 +164,27 @@ private function __getPageConditions() {
$pageId = Current::$request->data['Page']['id'];
$conditions = array('Page.id' => $pageId);

} elseif (Current::$request->params['plugin'] === Current::PLUGIN_PAGES) {
if (Current::$request->params['controller'] === 'pages') {
$value = implode('/', Current::$request->params['pass']);
if ($value === '') {
$value = Page::PUBLIC_ROOT_PAGE_ID;
$conditions = array('Page.root_id' => $value);
} else {
$conditions = array(
'Page.permalink' => $value,
'Room.space_id' => Hash::get(
Current::$request->params, 'spaceId', Space::PUBLIC_SPACE_ID
),
);
}
} elseif (!empty(Current::$request->params['pageView'])) {
$value = implode('/', Current::$request->params['pass']);
if ($value === '') {
$value = Page::PUBLIC_ROOT_PAGE_ID;
$conditions = array('Page.root_id' => $value);
} else {
$value = Hash::get(Current::$request->params, 'pass.1', '');
if (! $value) {
$this->setRoom(Hash::get(Current::$request->params, 'pass.0', ''));
$value = Hash::get(Current::$current, 'Room.page_id_top', '');
}
$conditions = array('Page.id' => $value);
$conditions = array(
'Page.permalink' => $value,
'Room.space_id' => Hash::get(
Current::$request->params, 'spaceId', Space::PUBLIC_SPACE_ID
),
);
}

} elseif (!empty(Current::$request->params['pageEdit'])) {
$value = Hash::get(Current::$request->params, 'pass.1', '');
if (! $value) {
$this->setRoom(Hash::get(Current::$request->params, 'pass.0', ''));
$value = Hash::get(Current::$current, 'Room.page_id_top', '');
}
$conditions = array('Page.id' => $value);

} elseif (Hash::get(Current::$request->query, 'page_id')) {
$pageId = Hash::get(Current::$request->query, 'page_id');
Expand Down

0 comments on commit 7462dbb

Please sign in to comment.