-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFramesHelper.php
More file actions
206 lines (172 loc) · 5.06 KB
/
FramesHelper.php
File metadata and controls
206 lines (172 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?php
/**
* LayoutHelper
*
* @copyright Copyright 2014, NetCommons Project
* @author Kohei Teraguchi <kteraguchi@commonsnet.org>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
App::uses('AppHelper', 'View/Helper');
App::uses('Current', 'NetCommons.Utility');
/**
* LayoutHelper
*
*/
class FramesHelper extends AppHelper {
/**
* Other helpers used by FormHelper
*
* @var array
*/
public $helpers = array(
'NetCommons.NetCommonsForm',
'NetCommons.NetCommonsHtml',
);
/**
* Plugins data
*
* @var array
*/
public $plugins;
/**
* Default Constructor
*
* @param View $View The View this helper is being attached to.
* @param array $settings Configuration settings for the helper.
*/
public function __construct(View $View, $settings = array()) {
parent::__construct($View, $settings);
$this->plugins = Hash::get($settings, 'plugins', array());
}
/**
* フレームの編集画面のリンク
*
* @param array $frame Frameデータ
* @return string
*/
public function frameActionUrl($frame) {
if ($frame['default_action']) {
$action = $frame['default_action'];
} elseif (Hash::get($this->plugins, $frame['plugin_key'] . '.default_action')) {
$action = Hash::get($this->plugins, $frame['plugin_key'] . '.default_action');
} else {
$action = $frame['plugin_key'] . '/index';
}
if (substr($action, 0, 1) === '/') {
$url = substr($action, 1) . '?frame_id=' . $frame['id'];
} else {
$url = $frame['plugin_key'] . '/' . $action . '?frame_id=' . $frame['id'];
}
if (Current::read('Page.id') && ! Current::read('Box.page_id')) {
$url .= '&page_id=' . Current::read('Page.id');
}
//if (Current::isSettingMode()) {
// $url = Current::SETTING_MODE_WORD . '/' . $url;
//}
return $url;
}
/**
* フレームの編集画面のリンク
*
* @param array $frame Frameデータ
* @param string $settingAction デフォルトセッティングアクション
* @param string|null $title タイトル
* @param array|null $options リンクオプション
* @return string
*/
public function frameSettingLink($frame, $settingAction = null, $title = null, $options = []) {
$html = '';
if (is_null($settingAction)) {
if (!empty($frame['default_setting_action'])) {
$action = $frame['default_setting_action'];
} else {
$action = Hash::get($this->plugins, $frame['plugin_key'] . '.default_setting_action');
}
} else {
$action = $settingAction;
}
if ($action) {
if (! $title) {
$title = '<span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> ';
$title .= '<span class="sr-only">' . __d('frames', 'Show flame setting') . '</span>';
}
$options = array_merge(
array(
'class' => 'btn btn-default btn-sm frame-btn pull-left',
'escapeTitle' => false
),
$options
);
if (substr($action, 0, 1) === '/') {
$url = $action . '?frame_id=' . $frame['id'];
} else {
$url = '/' . $frame['plugin_key'] . '/' . $action . '?frame_id=' . $frame['id'];
}
if (Current::read('Page.id') && ! Current::read('Box.page_id')) {
$url .= '&page_id=' . Current::read('Page.id');
}
$html .= $this->NetCommonsHtml->link($title, $url, $options);
}
return $html;
}
/**
* フレームの編集終了のリンク
*
* @return string
*/
public function frameSettingQuitLink() {
$html = '';
$title = '<span class="glyphicon glyphicon-cog" aria-hidden="true"></span> ';
$title .= __d('net_commons', 'Quit');
$options = array(
'class' => 'btn btn-default btn-sm',
'escapeTitle' => false
);
$html .= $this->NetCommonsHtml->link($title, NetCommonsUrl::backToPageUrl(true), $options);
return $html;
}
/**
* フレームの順序変更ボタン
*
* @param string $type タイプ(up or down)
* @return string
*/
public function frameOrderButton($type) {
$html = '';
if ($type === 'up') {
$title = '<span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span> ';
$title .= '<span class="sr-only">' . __d('frames', 'Up frame position') . '</span>';
$options = array(
'name' => 'up',
'class' => 'btn btn-default btn-sm frame-btn pull-left'
);
} else {
$title = '<span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>';
$title .= '<span class="sr-only">' . __d('frames', 'Down frame position') . '</span>';
$options = array(
'name' => 'down',
'class' => 'btn btn-default btn-sm frame-btn pull-left'
);
}
$html .= $this->NetCommonsForm->button($title, $options);
return $html;
}
/**
* フレームの削除ボタン
*
* @return string
*/
public function frameDeleteButton() {
$html = '';
$title = '<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> ';
$title .= '<span class="sr-only">' . __d('frames', 'Delete frame') . '</span>';
$options = array(
'name' => 'delete',
'class' => 'btn btn-default btn-sm',
'onclick' => 'return confirm(\'' . __d('frames', 'Do you want to delete the frame?') . '\')'
);
$html .= $this->NetCommonsForm->button($title, $options);
return $html;
}
}