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, 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); 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 * diff --git a/Utility/NetCommonsUrl.php b/Utility/NetCommonsUrl.php index 72c85f0e..8a6fc5bd 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 self::actionUrlAsArray($url); + } } diff --git a/View/Helper/NetCommonsHtmlHelper.php b/View/Helper/NetCommonsHtmlHelper.php index 840ac7e9..5dbbc02d 100644 --- a/View/Helper/NetCommonsHtmlHelper.php +++ b/View/Helper/NetCommonsHtmlHelper.php @@ -146,15 +146,8 @@ private function __getUrl($url = null) { 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; + return NetCommonsUrl::blockUrl($url); } /** @@ -261,13 +254,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); }