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
35 changes: 20 additions & 15 deletions Utility/CurrentFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
*
Expand Down
25 changes: 21 additions & 4 deletions Utility/CurrentPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,38 @@ 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
*
* @return bool
*/
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')
Expand All @@ -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),
));
Expand Down Expand Up @@ -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;
}

Expand Down