-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCalendarPlanEditRepeatOptionHelper.php
More file actions
146 lines (138 loc) · 4.79 KB
/
CalendarPlanEditRepeatOptionHelper.php
File metadata and controls
146 lines (138 loc) · 4.79 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
<?php
/**
* Calendar Plan 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');
/**
* Calendar plan Helper
*
* @author Allcreator Co., Ltd. <info@allcreator.net>
* @package NetCommons\Calendars\View\Helper
*/
class CalendarPlanEditRepeatOptionHelper extends AppHelper {
/**
* Other helpers used by FormHelper
*
* @var array
*/
public $helpers = array(
'Html',
'Form',
'NetCommons.NetCommonsForm',
'NetCommons.NetCommonsHtml',
'NetCommons.Button',
'NetCommons.TitleIcon',
'Calendars.CalendarMonthly',
'Calendars.CalendarCommon',
'Calendars.CalendarUrl',
);
/**
* makeEditRepeatOption
*
* @param array $eventSiblings イベント情報
* @param int $firstSibEventKey イベントKey
* @param int $firstSibYear デフォルト登録年
* @param int $firstSibMonth デフォルト登録月
* @param int $firstSibDay デフォルト登録日
* @param bool $isRecurrence 繰り返し
* @return string
*
* 速度改善の修正に伴って発生したため抑制
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function makeEditRepeatOption(
$eventSiblings, $firstSibEventKey, $firstSibYear, $firstSibMonth, $firstSibDay, $isRecurrence) {
$orgNumOfEvSiblings =
isset($this->request->data['CalendarActionPlan']['origin_num_of_event_siblings'])
? $this->request->data['CalendarActionPlan']['origin_num_of_event_siblings']
: null;
if (count($eventSiblings) <= 1 && $orgNumOfEvSiblings <= 1) {
return '';
}
$editRrule = 0;
if (isset($this->request->query['editrrule'])) {
$editRrule = $this->request->query['editrrule'];
} elseif (isset($this->request->data['CalendarActionPlan']['edit_rrule'])) {
$editRrule = $this->request->data['CalendarActionPlan']['edit_rrule'];
}
$html = '<div class="form-group" data-calendar-name="RepeatSet">';
$html .= '<div class="col-xs-12 col-sm-10 col-sm-offset-1">';
$html .= '<div class="media"><div class="media-left h2">';
$html .= $this->TitleIcon->titleIcon('/net_commons/img/title_icon/10_070_warning.svg');
$html .= '</div><div class="media-body">';
//全選択用に、繰返し先頭eventのeditボタのリンクを生成しておく
$firstSibEditLink = '';
//$key = Hash::get($this->_View->viewVars, 'event.CalendarEvent.key');
if (!empty($firstSibEventKey)) {
$firstSibEditLink = $this->Button->editLink('', array(
'controller' => 'calendar_plans',
'action' => 'edit',
'key' => $firstSibEventKey,
'block_id' => '',
'frame_id' => Current::read('Frame.id'),
'?' => array(
'year' => $firstSibYear,
'month' => $firstSibMonth,
'day' => $firstSibDay,
'editrrule' => 2,
)
));
$firstSibEditLink = str_replace('"', '"', $firstSibEditLink);
$firstSibEditLink = str_replace('&', '&', $firstSibEditLink);
if (preg_match('/href="([^"]+)"/', $firstSibEditLink, $matches) === 1) {
$firstSibEditLink = $matches[1];
}
}
$html .= $this->_getMessage($isRecurrence);
$html .= '</div></div>';
$html .= '<div class="alert alert-warning">';
$options = array();
$options['0'] = __d('calendars', 'only this one');
if (!$isRecurrence) {
//「この予定のみ」指定で変更された予定ではないので、1,2も選択肢に加える。
$options['1'] = __d('calendars', 'all after this one');
$options['2'] = __d('calendars', 'all');
}
$html .= $this->NetCommonsForm->radio('CalendarActionPlan.edit_rrule', $options, array(
'div' => 'form-inline',
'value' => $editRrule,
'ng-model' => 'editRrule',
'ng-init' => "editRrule = '" . $editRrule . "'",
'ng-change' => "changeEditRrule('" . $firstSibEditLink . "')",
));
if (! $isRecurrence) {
$html .= '<p class="help-block text-right"><small>';
$html .= __d('calendars',
'When you select the [all] will be re-set to the contents is repeated first plan.');
$html .= '<br />';
$html .= __d('calendars',
'If you want to edit without changing the schedule key, select "all after this one" and edit.');
$html .= '</small></p>';
}
$html .= '</div></div></div>';
return $html;
}
/**
* _getMessage
*
* @param bool $isRecurrence 繰り返し状況
* @return string
*/
protected function _getMessage($isRecurrence) {
$html = __d('calendars',
'This plan has been repeatedly set. ' .
'Select the plan that you want to edit from the following items, ' .
'Repetation of the plan [only this one] is not displayed.');
if ($isRecurrence) {
$html .= __d('calendars', 'Because it was specified in the [only this one], ' .
'repetation of the plan can not be specified.');
}
return $html;
}
}