-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCalendarDailyHelper.php
More file actions
175 lines (159 loc) · 5.2 KB
/
CalendarDailyHelper.php
File metadata and controls
175 lines (159 loc) · 5.2 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
<?php
/**
* Calendar Daily 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('CalendarMonthlyHelper', 'Calendars.View/Helper');
/**
* Calendar daily Helper
*
* @property \NetCommonsFormHelper $NetCommonsForm
* @property \NetCommonsHtmlHelper $NetCommonsHtml
* @property \TitleIconHelper $TitleIcon
* @property \FormHelper $Form
* @property \CalendarCommonHelper $CalendarCommon
* @property \CalendarUrlHelper $CalendarUrl
*
* @author Allcreator Co., Ltd. <info@allcreator.net>
* @package NetCommons\Calendars\View\Helper
*/
class CalendarDailyHelper extends CalendarMonthlyHelper {
/**
* Other helpers used by FormHelper
*
* @var array
*/
public $helpers = array(
'NetCommons.NetCommonsForm',
'NetCommons.NetCommonsHtml',
'NetCommons.TitleIcon',
'Form',
'Calendars.CalendarCommon',
'Calendars.CalendarUrl',
);
/**
* getSpaceName
*
* スペース名取得
*
* @param array $vars カレンダー情報
* @param int $roomId ルームID
* @param int $languageId language_id
* @return string
*/
public function getSpaceName($vars, $roomId, $languageId) {
if ($roomId == Space::getRoomIdRoot(Space::COMMUNITY_SPACE_ID)) {
return __d('calendars', 'All the members');
}
$roomsLanguages = $vars['roomsLanguages'];
$roomName = '';
foreach ($roomsLanguages as $room) {
//print_r($room);
if ($room['RoomsLanguages']['room_id'] == $roomId &&
$room['RoomsLanguages']['language_id'] == $languageId) {
$roomName = $room['RoomsLanguages']['name'];
}
}
return $roomName;
}
/**
* getPlanSummariesHtml
*
* 予定概要群html取得
*
* @param array $vars カレンダー情報
* @param int $year 年
* @param int $month 月
* @param int $day 日
* @param string $fromTime この日の1日のスタート時刻
* @param string $toTime この日の1日のエンド時刻
* @param array $plans この日の予定群
* @return string HTML
*/
public function getPlanSummariesHtml($vars, $year, $month, $day, $fromTime, $toTime, $plans) {
$html = '';
if ($plans) {
foreach ($plans as $plan) {
//仕様
//予定が1件以上あるとき)
$html .= "<tr><td><div class='row'><div class='col-xs-12'>"; //1プランの開始
//$html .= "<p class='calendar-plan-clickable text-left calendar-daily-nontimeline-plan'>";
$html .= $this->getPlanTitleDailyListHtml(
$vars, $year, $month, $day, $fromTime, $toTime, $plan);
// 1プランの終了
$html .= "</p>";
$html .= "</div></div></div></td></tr>";
}
}
return $html;
}
/**
* getPlanTitleDailyListHtml
*
* 予定(タイトル)html取得
*
* @param array $vars カレンダー情報
* @param int $year 年
* @param int $month 月
* @param int $day 日
* @param string $fromTime この日の1日のスタート時刻
* @param string $toTime この日の1日のエンド時刻
* @param array $plan 予定
* @return string HTML
*/
public function getPlanTitleDailyListHtml($vars, $year, $month, $day, $fromTime, $toTime, $plan) {
$calendarPlanMark = $this->CalendarCommon->getPlanMarkClassName($vars, $plan);
$html = "<div class='calendar-plan-mark {$calendarPlanMark}'>";
// ワークフロー(一時保存/承認待ち、など)のマーク
$html .= '<div>';
$html .= $this->CalendarCommon->makeWorkFlowLabel($plan['CalendarEvent']['status']);
$html .= '</div>';
$url = $this->CalendarUrl->makePlanShowUrl($year, $month, $day, $plan, true);
if ($fromTime !== $plan['CalendarEvent']['fromTime'] || $toTime !==
$plan['CalendarEvent']['toTime']) {
$html .= '<p class="calendar-daily-nontimeline-plan calendar-plan-time small">';
$html .= h($plan['CalendarEvent']['fromTime']) . ' - ' .
h($plan['CalendarEvent']['toTime']) . '</p>';
}
$spaceName = $this->getSpaceName(
$vars, $plan['CalendarEvent']['room_id'], $plan['CalendarEvent']['language_id']);
$spaceName = $this->CalendarCommon->decideRoomName($spaceName, $calendarPlanMark);
$html .= '<p class="calendar-plan-spacename small">' . h($spaceName) . '</p>';
$html .= '<h3 class="calendar-plan-tittle">';
$html .= $this->NetCommonsHtml->link(
$this->TitleIcon->titleIcon($plan['CalendarEvent']['title_icon']) .
h($plan['CalendarEvent']['title']),
$url,
array('escape' => false)
);
$html .= '</h3>';
$html .= '</p>';
if ($plan['CalendarEvent']['location'] != '') {
$html .= '<p class="calendar-plan-place small">' . __d('calendars', 'Location details:');
$html .= h($plan['CalendarEvent']['location']) . '</p>';
}
if ($plan['CalendarEvent']['contact']) {
$html .= '<p class="calendar-plan-address small">' . __d('calendars', 'Contact');
$html .= h($plan['CalendarEvent']['contact']) . '</p>';
}
return $html;
}
/**
* makeDailyListBodyHtml
*
* (日表示)本体html生成
*
* @param array $vars コントローラーからの情報
* @return string HTML
*/
public function makeDailyListBodyHtml($vars) {
$html = '';
$nctm = new NetCommonsTime();
$html .= $this->_makePlanSummariesHtml($vars, $nctm, $vars['year'], $vars['month'], $vars['day']);
return $html;
}
}