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
10 changes: 10 additions & 0 deletions Config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions TestSuite/NetCommonsCakeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions TestSuite/NetCommonsControllerBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions Utility/CurrentSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ public function setLanguage() {
}
}

/**
* 言語データを取得
*
* @return void
*/
public function getLanguages() {
$this->setLanguage();

return Current::$m17n['Language'];
}

/**
* Set Plugin
*
Expand Down
41 changes: 41 additions & 0 deletions Utility/NetCommonsUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
17 changes: 2 additions & 15 deletions View/Helper/NetCommonsHtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down