From 1e5f1dc3c7b293d22b36aa18c20757310eb4340e Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 21 Jul 2015 20:53:39 +0900 Subject: [PATCH 01/36] Add control panel link --- View/Elements/common_header.ctp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/View/Elements/common_header.ctp b/View/Elements/common_header.ctp index c54f38c8..fe76ab14 100644 --- a/View/Elements/common_header.ctp +++ b/View/Elements/common_header.ctp @@ -66,6 +66,13 @@ if (! isset($isPageSetting)) { + + +
  • + Html->link(__d('control_panel', 'Control Panel'), '/control_panel/control_panel') ?> +
  • + + @@ -74,4 +81,4 @@ if (! isset($isPageSetting)) { element('Pages.edit_layout'); ?> - Date: Tue, 21 Jul 2015 21:45:20 +0900 Subject: [PATCH 02/36] Fix control panel link --- View/Elements/common_header.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/Elements/common_header.ctp b/View/Elements/common_header.ctp index fe76ab14..15a8c252 100644 --- a/View/Elements/common_header.ctp +++ b/View/Elements/common_header.ctp @@ -67,7 +67,7 @@ if (! isset($isPageSetting)) { - +
  • Html->link(__d('control_panel', 'Control Panel'), '/control_panel/control_panel') ?>
  • From 151cdb53db58ffccace361209d03237df735587f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 22 Jul 2015 09:12:23 +0900 Subject: [PATCH 03/36] Add control panel --- View/Elements/common_header.ctp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/View/Elements/common_header.ctp b/View/Elements/common_header.ctp index 15a8c252..502e643c 100644 --- a/View/Elements/common_header.ctp +++ b/View/Elements/common_header.ctp @@ -67,9 +67,13 @@ if (! isset($isPageSetting)) { - +
  • - Html->link(__d('control_panel', 'Control Panel'), '/control_panel/control_panel') ?> + + Html->link(__d('control_panel', 'Control Panel'), '/control_panel/control_panel'); ?> + + Html->link(__d('control_panel', 'Back to the Rooms'), $cancelUrl); ?> +
  • From f093579dfe88f6c562bec0372b7f35e9596f1c2c Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 22 Jul 2015 09:13:06 +0900 Subject: [PATCH 04/36] Fix migration for add records --- Config/Migration/NetCommonsMigration.php | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Config/Migration/NetCommonsMigration.php diff --git a/Config/Migration/NetCommonsMigration.php b/Config/Migration/NetCommonsMigration.php new file mode 100644 index 00000000..fb1cc57b --- /dev/null +++ b/Config/Migration/NetCommonsMigration.php @@ -0,0 +1,59 @@ + + * @author Shohei Nakajima + * @link http://www.netcommons.org NetCommons Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project + */ + +App::uses('CakeMigration', 'Migrations.Lib'); +App::uses('I18n', 'I18n'); + +/** + * NetCommonsMigration + * + * @author Shohei Nakajima + * @package NetCommons\NetCommons\Config\Migration + */ +class NetCommonsMigration extends CakeMigration { + +/** + * Update model records + * + * @param string $model model name to update + * @param string $records records to be stored + * @param string $scope ? + * @return bool Should process continue + */ + public function updateRecords($model, $records, $scope = null) { + $Model = $this->generateModel($model); + foreach ($records as $record) { + $Model->create(); + if (!$Model->save($record, false)) { + return false; + } + } + + return true; + } + +/** + * Load models + * + * @param array $models models to load + * @param string $source data source + * @return void + */ + public function loadModels(array $models = [], $source = 'master') { + foreach ($models as $model => $class) { + $this->$model = ClassRegistry::init($class, true); + if ($this->$model->useDbConfig !== 'test') { + $this->$model->setDataSource($source); + } + } + } + +} From e8750fdcdc7739df3d2a9ae75d5017260777b4cc Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 22 Jul 2015 14:17:58 +0900 Subject: [PATCH 05/36] Fix by add control panel --- .../Component/NetCommonsFrameComponent.php | 23 ++++++++--- Controller/NetCommonsAppController.php | 40 +++++++++++-------- .../NetCommonsFrameComponentTest.php | 20 +++++++++- .../NetCommonsAppControllerTest.php | 2 +- .../Controller/NetCommonsControllerTest.php | 2 +- View/Elements/common_header.ctp | 6 ++- 6 files changed, 66 insertions(+), 27 deletions(-) diff --git a/Controller/Component/NetCommonsFrameComponent.php b/Controller/Component/NetCommonsFrameComponent.php index 17e4c195..a51e9967 100644 --- a/Controller/Component/NetCommonsFrameComponent.php +++ b/Controller/Component/NetCommonsFrameComponent.php @@ -46,7 +46,7 @@ public function initialize(Controller $controller) { $models = array( 'Box' => 'Boxes.Box', 'Frame' => 'Frames.Frame', - 'Language' => 'M17n.Language', + //'Language' => 'M17n.Language', ); foreach ($models as $model => $class) { $this->$model = ClassRegistry::init($class); @@ -74,16 +74,29 @@ public function initialize(Controller $controller) { */ public function setView() { //set language_id - if (isset($this->controller->viewVars['languageId']) && $this->controller->viewVars['languageId'] === 0) { - $language = $this->Language->findByCode(Configure::read('Config.language')); - $this->controller->set('languageId', $language['Language']['id']); - } + //if (isset($this->controller->viewVars['languageId']) && $this->controller->viewVars['languageId'] === 0) { + // $language = $this->Language->findByCode(Configure::read('Config.language')); + // $this->controller->set('languageId', $language['Language']['id']); + //} //set frame by id $frame = $this->Frame->findById($this->frameId); $this->data = $frame; $this->__setViewFrame($frame); + + // Find page data from frame + $this->controller->current = $this->data; + + $box = $this->Box->find('first', [ + 'conditions' => [ + 'Box.id' => $this->data['Box']['id'], + ], + ]); + if (isset($box['Page'][0])) { + $this->controller->current['page'] = $box['Page'][0]; + $this->controller->set('cancelUrl', $this->controller->current['page']['permalink']); + } } /** diff --git a/Controller/NetCommonsAppController.php b/Controller/NetCommonsAppController.php index 715d11fa..0a66d6b6 100644 --- a/Controller/NetCommonsAppController.php +++ b/Controller/NetCommonsAppController.php @@ -76,10 +76,11 @@ class NetCommonsAppController extends Controller { * @var array */ public $uses = [ - 'Boxes.Box', + //'Boxes.Box', 'NetCommons.SiteSetting', - 'Pages.Page', - 'Frames.Frame', + //'Pages.Page', + //'Frames.Frame', + 'M17n.Language', ]; /** @@ -137,6 +138,11 @@ public function beforeFilter() { } elseif ($this->Session->check('Config.language')) { Configure::write('Config.language', $this->Session->read('Config.language')); } + //set language_id + $language = $this->Language->findByCode(Configure::read('Config.language')); + Configure::write('Config.languageId', $language['Language']['id']); + $this->set('languageId', $language['Language']['id']); + $this->Auth->allow('index', 'view'); Security::setHash('sha512'); @@ -147,22 +153,22 @@ public function beforeFilter() { $this->set('userId', (int)$this->Auth->user('id')); // Find page data from frame - if ($this->NetCommonsFrame && $this->NetCommonsFrame->data) { - $this->current = $this->NetCommonsFrame->data; - - $box = $this->Box->find('first', [ - 'conditions' => [ - 'Box.id' => $this->NetCommonsFrame->data['Box']['id'], - ], - ]); - if (isset($box['Page'][0])) { - $this->current['page'] = $box['Page'][0]; - $this->set('cancelUrl', $this->current['page']['permalink']); - } - + //if ($this->NetCommonsFrame && $this->NetCommonsFrame->data) { + // $this->current = $this->NetCommonsFrame->data; + // + // $box = $this->Box->find('first', [ + // 'conditions' => [ + // 'Box.id' => $this->NetCommonsFrame->data['Box']['id'], + // ], + // ]); + // if (isset($box['Page'][0])) { + // $this->current['page'] = $box['Page'][0]; + // $this->set('cancelUrl', $this->current['page']['permalink']); + // } + // $results = $this->camelizeKeyRecursive(['current' => $this->current]); $this->set($results); - } + //} } /** diff --git a/Test/Case/Controller/Component/NetCommonsFrameComponentTest.php b/Test/Case/Controller/Component/NetCommonsFrameComponentTest.php index 53040d99..c8a3cda1 100644 --- a/Test/Case/Controller/Component/NetCommonsFrameComponentTest.php +++ b/Test/Case/Controller/Component/NetCommonsFrameComponentTest.php @@ -23,6 +23,16 @@ */ class TestNetCommonsFrameController extends Controller { +/** + * camelizeKeyRecursive + * + * @param array $orig data to camelize + * @return array camelized data + */ + public static function camelizeKeyRecursive($orig) { + return $orig; + } + } /** @@ -41,9 +51,13 @@ class NetCommonsFrameComponentTest extends CakeTestCase { public $fixtures = array( 'plugin.blocks.block', 'plugin.boxes.box', + 'plugin.boxes.boxes_page', + 'plugin.containers.container', 'plugin.frames.frame', 'plugin.m17n.language', + 'plugin.pages.page', 'plugin.plugin_manager.plugin', + 'plugin.public_space.space', 'plugin.users.user', ); @@ -145,11 +159,13 @@ public function testSetView() { $expected = array( 'frameId' => 1, 'frameKey' => 'frame_1', - 'blockId' => 5, + 'blockId' => '5', 'blockKey' => 'block_5', 'roomId' => 1, - 'languageId' => 2 + 'languageId' => 2, + 'cancelUrl' => '', ); + $this->assertEquals($expected, $this->FrameController->viewVars); } diff --git a/Test/Case/Controller/NetCommonsAppControllerTest.php b/Test/Case/Controller/NetCommonsAppControllerTest.php index 1c67cc5d..2bfce805 100644 --- a/Test/Case/Controller/NetCommonsAppControllerTest.php +++ b/Test/Case/Controller/NetCommonsAppControllerTest.php @@ -36,8 +36,8 @@ class NetCommonsAppControllerTest extends YAControllerTestCase { 'plugin.m17n.language', 'plugin.net_commons.site_setting', 'plugin.pages.page', - 'plugin.pages.space', 'plugin.plugin_manager.plugin', + 'plugin.public_space.space', 'plugin.roles.default_role_permission', 'plugin.rooms.roles_rooms_user', 'plugin.rooms.roles_room', diff --git a/Test/Case/Controller/NetCommonsControllerTest.php b/Test/Case/Controller/NetCommonsControllerTest.php index cdafa505..fdf2a517 100644 --- a/Test/Case/Controller/NetCommonsControllerTest.php +++ b/Test/Case/Controller/NetCommonsControllerTest.php @@ -34,8 +34,8 @@ class NetCommonsControllerTest extends YAControllerTestCase { 'plugin.m17n.language', 'plugin.net_commons.site_setting', 'plugin.pages.page', - 'plugin.pages.space', 'plugin.plugin_manager.plugin', + 'plugin.public_space.space', 'plugin.roles.default_role_permission', 'plugin.rooms.room', 'plugin.rooms.room_role_permission', diff --git a/View/Elements/common_header.ctp b/View/Elements/common_header.ctp index 502e643c..e0f4433f 100644 --- a/View/Elements/common_header.ctp +++ b/View/Elements/common_header.ctp @@ -16,10 +16,14 @@ $pageEditable = isset($pageEditable) ? $pageEditable : null; if (! isset($isPageSetting)) { $isPageSetting = Page::isSetting(); } + +if (! isset($container)) { + $container = 'container'; +} ?>