-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReservationUrlHelper.php
More file actions
198 lines (190 loc) · 4.92 KB
/
ReservationUrlHelper.php
File metadata and controls
198 lines (190 loc) · 4.92 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
<?php
/**
* Reservation Url Helper
*
* @author Allcreator Co., Ltd. <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AppHelper', 'View/Helper');
App::uses('WorkflowComponent', 'Workflow.Controller/Component');
App::uses('ReservationFrameSetting', 'Reservations.Model');
/**
* Reservation url Helper
*
* @author Allcreator Co., Ltd. <info@allcreator.net>
* @package NetCommons\Reservations\View\Helper
*/
class ReservationUrlHelper extends AppHelper {
/**
* Other helpers used by FormHelper
*
* @var array
*/
public $helpers = array(
'NetCommons.NetCommonsForm',
'NetCommons.NetCommonsHtml',
'NetCommons.BackTo',
'Reservations.ReservationCommon',
);
/**
* makePlanShowUrl
*
* 予定表示Url生成
*
* @param int $year 年
* @param int $month 月
* @param int $day 日
* @param array $plan 予定
* @param bool $isArray 配列での戻り値を求めているか
* @return string url
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function makePlanShowUrl($year, $month, $day, $plan, $isArray = false) {
if ($isArray) {
$url = $this->getReservationUrlAsArray(array(
'plugin' => 'reservations',
'controller' => 'reservation_plans',
'action' => 'view',
'key' => $plan['ReservationEvent']['key'],
'frame_id' => Current::read('Frame.id'),
));
} else {
$url = $this->getReservationUrl(array(
'plugin' => 'reservations',
'controller' => 'reservation_plans',
'action' => 'view',
'key' => $plan['ReservationEvent']['key'],
'frame_id' => Current::read('Frame.id'),
));
}
return $url;
}
/**
* makeEditUrl
*
* 編集画面URL生成
*
* @param int $year 年
* @param int $month 月
* @param int $day 日
* @param array &$vars 施設予約情報
* @return string Url
*/
public function makeEditUrl($year, $month, $day, &$vars) {
$options = array(
'plugin' => 'reservations',
'controller' => 'reservation_plans',
'action' => 'edit',
'frame_id' => Current::read('Frame.id'),
'?' => array(
'year' => $year,
'month' => $month,
'day' => $day,
)
);
$url = $this->getReservationUrlAsArray($options);
return $url;
}
/**
* makeEditUrlWithTime
*
* 編集画面URL生成
*
* @param int $year 年
* @param int $month 月
* @param int $day 日
* @param int $hour 時
* @param array &$vars 施設予約情報
* @return string Url
*/
public function makeEditUrlWithTime($year, $month, $day, $hour, &$vars) {
$options = array(
'plugin' => 'reservations',
'controller' => 'reservation_plans',
'action' => 'edit',
'frame_id' => Current::read('Frame.id'),
'?' => array(
'year' => $year,
'month' => $month,
'day' => $day,
'hour' => $hour,
)
);
$url = $this->getReservationUrlAsArray($options);
return $url;
}
/**
* getReservationDailyUrl
*
* 施設予約日次URL取得
*
* @param int $year 年
* @param int $month 月
* @param int $day 日
* @param array &$vars 施設予約情報
* @return string URL
*/
public function getReservationDailyUrl($year, $month, $day, &$vars) {
$url = $this->getReservationUrl(array(
'plugin' => 'reservations',
'controller' => 'reservations',
'action' => 'index',
'block_id' => '',
'frame_id' => Current::read('Frame.id'),
'?' => array(
'style' => $vars['style'],
'year' => $year,
'month' => $month,
'day' => $day,
)
));
return $url;
}
/**
* getBackFirstButton
*
* 最初の画面に戻るUrlリンクボタンの取得
*
* @param array $vars 施設予約情報
* @return string URL
*/
public function getBackFirstButton($vars) {
// urlパラメタにstyleがなくて、表示画面がデフォルトの画面と一緒ならこのボタンは不要
// 本当は共通関数[getQueryParam]を使いたかったが、
// AppControllerに作っちゃったためHelperから呼びづらく、似たコードを書いてしまった
// 許してほしい
$isNotMain = Hash::get($this->request->params, 'requested');
$frameId = Hash::get($this->request->query, 'frame_id');
if ($frameId === null || $frameId != Current::read('Frame.id') || $isNotMain) {
return '';
}
//return $this->BackTo->indexLinkButton(__d('reservations', 'Back to First view'));
return $this->BackTo->pageLinkButton(__d('reservations', 'Back'));
}
/**
* getReservationUrl
*
* URL取得汎用関数
*
* @param array $arr URL作成のためのパラメータ配列
* @return string URL文字列
*/
public function getReservationUrl($arr) {
return Router::url(NetCommonsUrl::actionUrlAsArray($arr));
}
/**
* getReservationUrlAsArray
*
* URL取得汎用関数
*
* @param array $arr URL作成のためのパラメータ配列
* @return array URL配列
*/
public function getReservationUrlAsArray($arr) {
$ret = NetCommonsUrl::actionUrlAsArray($arr);
$ret['block_id'] = '';
return $ret;
}
}