From 3fcfffda64e4d986670f41a23472b23a15d0fc0c Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jul 2016 08:45:48 +0900 Subject: [PATCH 1/6] =?UTF-8?q?https://github.com/NetCommons3/NetCommons/t?= =?UTF-8?q?ree/NetCommonsUrl-issue=20=E3=81=AE=E3=83=9E=E3=83=BC=E3=82=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/NetCommonsUrl.php | 41 ++++++++++++++++++++++++++ View/Helper/NetCommonsHtmlHelper.php | 43 +++------------------------- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/Utility/NetCommonsUrl.php b/Utility/NetCommonsUrl.php index 72c85f0e..6f2be5ec 100644 --- a/Utility/NetCommonsUrl.php +++ b/Utility/NetCommonsUrl.php @@ -184,4 +184,45 @@ public static function url($params = array(), $full = false) { } } +/** + * BlockのURLを生成 + * + * @param array $url An array specifying any of the following: 'controller', 'action', + * and/or 'plugin', in addition to named arguments (keyed array elements), + * and standard URL arguments (indexed array elements). + * 'autoSetting': Current::SETTING_MODE_WORDを付ける処理を自動で行う。デフォルトfalse + * @return array block url + */ + public static function blockUrl($url = array()) { + if (!is_array($url)) { + return $url; + } + + $autoSetting = Hash::get($url, ['autoSetting']); + if ($autoSetting && Current::isSettingMode()) { + array_unshift($url, Current::SETTING_MODE_WORD); + } + unset($url['autoSetting']); + + $blockId = Current::read('Block.id'); + if (!isset($url['block_id']) && $blockId) { + $url['block_id'] = $blockId; + } + + if (Hash::get($url, ['?', 'frame_id'])) { + return $url; + } + if (isset($url['frame_id'])) { + $url['?']['frame_id'] = $url['frame_id']; + unset($url['frame_id']); + return $url; + } + + $frameId = Current::read('Frame.id'); + if ($frameId) { + $url['?']['frame_id'] = $frameId; + } + + return $url; + } } diff --git a/View/Helper/NetCommonsHtmlHelper.php b/View/Helper/NetCommonsHtmlHelper.php index 840ac7e9..98aa2bb0 100644 --- a/View/Helper/NetCommonsHtmlHelper.php +++ b/View/Helper/NetCommonsHtmlHelper.php @@ -128,35 +128,6 @@ public function json($results = [], $name = 'OK', $status = 200) { return json_encode($camelizeData); } -/** - * URL生成処理 - * - * @param mixed $url URL - * @return string URL - */ - private function __getUrl($url = null) { - //URLの設定 - if (is_array($url)) { - if (! isset($url['plugin'])) { - $url['plugin'] = $this->_View->request->params['plugin']; - } - if (! isset($url['controller'])) { - $url['controller'] = $this->_View->request->params['controller']; - } - if (! isset($url['action'])) { - $url['action'] = $this->_View->request->params['action']; - } - if (! isset($url['block_id']) && Current::read('Block.id')) { - $url['block_id'] = Current::read('Block.id'); - } - if (! isset($url['frame_id']) && Current::read('Frame.id')) { - $url['frame_id'] = Current::read('Frame.id'); - } - $url = NetCommonsUrl::actionUrl($url); - } - return $url; - } - /** * ImageのURLの取得 * @@ -167,7 +138,7 @@ private function __getUrl($url = null) { */ public function image($path, $options = array()) { //URLの設定 - $path = $this->__getUrl($path); + $path = NetCommonsUrl::blockUrl($path); $output = $this->Html->image($path, $options); return $output; } @@ -182,7 +153,7 @@ public function image($path, $options = array()) { */ public function url($url = null, $options = array()) { //URLの設定 - $url = $this->__getUrl($url); + $url = NetCommonsUrl::blockUrl($url); $output = $this->Html->url($url, $options); return $output; } @@ -197,7 +168,7 @@ public function url($url = null, $options = array()) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::button */ public function link($title = '', $url = null, $options = array()) { - $url = $this->__getUrl($url); + $url = NetCommonsUrl::blockUrl($url); $output = $this->Html->link($title, $url, $options); return $output; } @@ -261,13 +232,7 @@ public function editLink($title = '', $url = null, $options = array()) { if (! isset($url['action'])) { $url['action'] = 'edit'; } - if (! isset($url['block_id']) && Current::read('Block.id')) { - $url['block_id'] = Current::read('Block.id'); - } - if (! isset($url['frame_id']) && Current::read('Frame.id')) { - $url['frame_id'] = Current::read('Frame.id'); - } - $url = NetCommonsUrl::actionUrl($url); + $url = NetCommonsUrl::blockUrl($url); return $this->Html->link($title, $url, $options); } From e44e9be4251e6bd36ea6d62391b84cab757c1e1c Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jul 2016 17:40:07 +0900 Subject: [PATCH 2/6] =?UTF-8?q?blockUrl=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/NetCommonsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utility/NetCommonsUrl.php b/Utility/NetCommonsUrl.php index 6f2be5ec..8a6fc5bd 100644 --- a/Utility/NetCommonsUrl.php +++ b/Utility/NetCommonsUrl.php @@ -223,6 +223,6 @@ public static function blockUrl($url = array()) { $url['?']['frame_id'] = $frameId; } - return $url; + return self::actionUrlAsArray($url); } } From ff36129f7cfadc95da6711a19f70339c27c2814d Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 24 Jul 2016 09:52:58 +0900 Subject: [PATCH 3/6] =?UTF-8?q?blockUrl=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/Helper/NetCommonsHtmlHelper.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/View/Helper/NetCommonsHtmlHelper.php b/View/Helper/NetCommonsHtmlHelper.php index 98aa2bb0..5dbbc02d 100644 --- a/View/Helper/NetCommonsHtmlHelper.php +++ b/View/Helper/NetCommonsHtmlHelper.php @@ -128,6 +128,28 @@ public function json($results = [], $name = 'OK', $status = 200) { return json_encode($camelizeData); } +/** + * URL生成処理 + * + * @param mixed $url URL + * @return string URL + */ + private function __getUrl($url = null) { + //URLの設定 + if (is_array($url)) { + if (! isset($url['plugin'])) { + $url['plugin'] = $this->_View->request->params['plugin']; + } + if (! isset($url['controller'])) { + $url['controller'] = $this->_View->request->params['controller']; + } + if (! isset($url['action'])) { + $url['action'] = $this->_View->request->params['action']; + } + } + return NetCommonsUrl::blockUrl($url); + } + /** * ImageのURLの取得 * @@ -138,7 +160,7 @@ public function json($results = [], $name = 'OK', $status = 200) { */ public function image($path, $options = array()) { //URLの設定 - $path = NetCommonsUrl::blockUrl($path); + $path = $this->__getUrl($path); $output = $this->Html->image($path, $options); return $output; } @@ -153,7 +175,7 @@ public function image($path, $options = array()) { */ public function url($url = null, $options = array()) { //URLの設定 - $url = NetCommonsUrl::blockUrl($url); + $url = $this->__getUrl($url); $output = $this->Html->url($url, $options); return $output; } @@ -168,7 +190,7 @@ public function url($url = null, $options = array()) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::button */ public function link($title = '', $url = null, $options = array()) { - $url = NetCommonsUrl::blockUrl($url); + $url = $this->__getUrl($url); $output = $this->Html->link($title, $url, $options); return $output; } From b71c3b923e2f3d03afc0f2e3b1e366440d83f00f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 25 Jul 2016 10:30:46 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E8=A8=80=E8=AA=9E=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E5=8F=96=E5=BE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Utility/CurrentSystem.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Utility/CurrentSystem.php b/Utility/CurrentSystem.php index 5bc9f594..dc2a4617 100644 --- a/Utility/CurrentSystem.php +++ b/Utility/CurrentSystem.php @@ -65,6 +65,17 @@ public function setLanguage() { } } +/** + * 言語データを取得 + * + * @return void + */ + public function getLanguages() { + $this->setLanguage(); + + return Current::$m17n['Language']; + } + /** * Set Plugin * From 138a730de293b74b090cfa2418ef5b40ec24db4d Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 26 Jul 2016 16:49:47 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=86=E3=82=A3?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E3=83=A2=E3=83=BC=E3=83=89ON=E6=99=82?= =?UTF-8?q?=E3=81=AE=E3=83=AB=E3=83=BC=E3=83=86=E3=82=A3=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E5=87=A6=E7=90=86=E8=A6=8B=E7=9B=B4=E3=81=97=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/317?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/routes.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Config/routes.php b/Config/routes.php index 6bca362c..ec235399 100644 --- a/Config/routes.php +++ b/Config/routes.php @@ -71,6 +71,16 @@ $params, $options ); + Router::connect( + '/' . Current::SETTING_MODE_WORD . '/:plugin/:controller/:action/:block_id/:key/*', + $params, + $options + ); + Router::connect( + '/' . Current::SETTING_MODE_WORD . '/:plugin/:controller/:action/:block_id/*', + $params, + $options + ); Router::connect( '/:plugin/:controller/:action/:block_id', $params, From 71bc7a4df92a2c1251b3e807993aa600aed20e4c Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 29 Jul 2016 07:26:05 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Wysiwyg=E3=81=AEHTML=E3=82=B5=E3=83=8B?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=82=BA=E5=87=A6=E7=90=86=E3=82=92=E5=85=A5?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=81=93=E3=81=A8=E3=81=AB=E3=82=88=E3=82=8A?= =?UTF-8?q?=E3=80=81=E5=85=A8=E3=83=86=E3=82=B9=E3=83=88=E3=81=8C=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=AA=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/NetCommonsCakeTestCase.php | 1 + TestSuite/NetCommonsControllerBaseTestCase.php | 1 + 2 files changed, 2 insertions(+) diff --git a/TestSuite/NetCommonsCakeTestCase.php b/TestSuite/NetCommonsCakeTestCase.php index 6e16f5c0..f3e1b2bc 100644 --- a/TestSuite/NetCommonsCakeTestCase.php +++ b/TestSuite/NetCommonsCakeTestCase.php @@ -122,6 +122,7 @@ public function __construct($name = null, array $data = array(), $dataName = '') * @return void */ public function setUp() { + Current::$current['Permission']['html_not_limited']['value'] = true; parent::setUp(); Configure::write('NetCommons.installed', true); diff --git a/TestSuite/NetCommonsControllerBaseTestCase.php b/TestSuite/NetCommonsControllerBaseTestCase.php index 84e84675..f0aef803 100644 --- a/TestSuite/NetCommonsControllerBaseTestCase.php +++ b/TestSuite/NetCommonsControllerBaseTestCase.php @@ -136,6 +136,7 @@ public function __construct($name = null, array $data = array(), $dataName = '') public function setUp() { NetCommonsCakeTestCase::loadTestPlugin($this, 'NetCommons', 'TestPlugin'); + Current::$current['Permission']['html_not_limited']['value'] = true; parent::setUp(); Configure::write('NetCommons.installed', true);