Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
calendareventviewformhelper.php
1
<?php
2
3
namespace
Bitrix\Calendar\ControllerHelper
;
4
5
use
Bitrix\Main\Engine\Response\Component
;
6
use
Bitrix\Main\Localization\Loc
;
7
use CCalendar;
8
use CCalendarEvent;
9
use COption;
10
11
class
CalendarEventViewFormHelper
12
{
13
//get parameters
14
public
static
function
getTimezoneHint
($userId, $event): string
15
{
16
$skipTime = $event[
'DT_SKIP_TIME'
] ===
"Y"
;
17
$timezoneHint =
''
;
18
if
(
19
!$skipTime
20
&& (
21
(
int
)$event[
'~USER_OFFSET_FROM'
] !== 0
22
|| (
int
)$event[
'~USER_OFFSET_TO'
] !== 0
23
|| $event[
'TZ_FROM'
] !== $event[
'TZ_TO'
]
24
|| $event[
'TZ_FROM'
] !== CCalendar::GetUserTimezoneName($userId)
25
)
26
)
27
{
28
if
($event[
'TZ_FROM'
] === $event[
'TZ_TO'
])
29
{
30
$timezoneHint = CCalendar::GetFromToHtml(
31
CCalendar::Timestamp($event[
'DATE_FROM'
]),
32
CCalendar::Timestamp($event[
'DATE_TO'
]),
33
false
,
34
$event[
'DT_LENGTH'
]
35
);
36
if
($event[
'TZ_FROM'
])
37
{
38
$timezoneHint .=
' ('
. $event[
'TZ_FROM'
] .
')'
;
39
}
40
}
41
else
42
{
43
$timezoneHint =
Loc::getMessage
(
'EC_VIEW_DATE_FROM_TO'
, array(
'#DATE_FROM#'
=> $event[
'DATE_FROM'
].
' ('
.$event[
'TZ_FROM'
].
')'
,
'#DATE_TO#'
=> $event[
'DATE_TO'
].
' ('
.$event[
'TZ_TO'
].
')'
));
44
}
45
}
46
return
$timezoneHint;
47
}
48
49
public
static
function
getFromToHtml
(array $event): string
50
{
51
$skipTime = $event[
'DT_SKIP_TIME'
] ===
"Y"
;
52
$fromTs = CCalendar::Timestamp($event[
'DATE_FROM'
]);
53
$toTs = CCalendar::Timestamp($event[
'DATE_TO'
]);
54
if
($skipTime)
55
{
56
$toTs += CCalendar::DAY_LENGTH;
57
}
58
else
59
{
60
$fromTs -= $event[
'~USER_OFFSET_FROM'
];
61
$toTs -= $event[
'~USER_OFFSET_TO'
];
62
}
63
return
CCalendar::GetFromToHtml($fromTs, $toTs, $skipTime, $event[
'DT_LENGTH'
]);
64
}
65
66
public
static
function
getMeetingCreator
(array $event): array
67
{
68
$meetingCreator = [];
69
if
(
70
$event[
'IS_MEETING'
]
71
&& $event[
'MEETING'
][
'MEETING_CREATOR'
]
72
&& $event[
'MEETING'
][
'MEETING_CREATOR'
] !== $event[
'MEETING_HOST'
]
73
)
74
{
75
$meetingCreator = CCalendar::GetUser($event[
'MEETING'
][
'MEETING_CREATOR'
],
true
);
76
$meetingCreator[
'DISPLAY_NAME'
] = CCalendar::GetUserName($meetingCreator);
77
$meetingCreator[
'URL'
] = CCalendar::GetUserUrl(
78
$meetingCreator[
"ID"
],
79
$meetingCreator[
"PATH_TO_USER"
] ??
null
80
);
81
}
82
return
$meetingCreator;
83
}
84
85
//get components
86
public
static
function
getCrmView
(array $event):
Component
87
{
88
return
new
Component
(
89
"bitrix:system.field.view"
,
90
$event[
'UF_CRM_CAL_EVENT'
][
"USER_TYPE"
][
"USER_TYPE_ID"
],
91
array(
"arUserField"
=> $event[
'UF_CRM_CAL_EVENT'
]),
92
array(
"HIDE_ICONS"
=>
"Y"
)
93
);
94
}
95
96
public
static
function
getFilesView
(array $event):
Component
97
{
98
return
new
Component
(
99
"bitrix:system.field.view"
,
100
$event[
'UF_WEBDAV_CAL_EVENT'
][
"USER_TYPE"
][
"USER_TYPE_ID"
],
101
array(
"arUserField"
=> $event[
'UF_WEBDAV_CAL_EVENT'
]),
102
array(
"HIDE_ICONS"
=>
"Y"
)
103
);
104
}
105
106
public
static
function
getCommentsView
(array $event):
Component
107
{
108
$userId = CCalendar::GetCurUserId();
109
if
(
110
$userId === (
int
)$event[
'CREATED_BY'
]
111
&& ((
int
)$event[
'PARENT_ID'
] === (
int
)$event[
'ID'
] || !$event[
'PARENT_ID'
])
112
)
113
{
114
$permission =
"Y"
;
115
}
116
else
117
{
118
$permission =
'M'
;
119
}
120
$set = CCalendar::GetSettings();
121
$eventCommentId = $event[
'PARENT_ID'
] ?: $event[
'ID'
];
122
123
return
new
Component
(
124
"bitrix:forum.comments"
,
"bitrix24"
, [
125
"FORUM_ID"
=> $set[
'forum_id'
],
126
"ENTITY_TYPE"
=>
"EV"
,
127
"ENTITY_ID"
=> $eventCommentId,
128
"ENTITY_XML_ID"
=> $event[
'ENTITY_XML_ID'
],
129
"PERMISSION"
=> $permission,
130
"URL_TEMPLATES_PROFILE_VIEW"
=> $set[
'path_to_user'
],
131
"SHOW_RATING"
=> COption::GetOptionString(
'main'
,
'rating_vote_show'
,
'N'
),
132
"SHOW_LINK_TO_MESSAGE"
=>
"N"
,
133
"BIND_VIEWER"
=>
"Y"
134
],
135
[
'HIDE_ICONS'
=>
'Y'
]
136
);
137
}
138
139
}
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper
Definition
calendareventviewformhelper.php:12
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper\getCommentsView
static getCommentsView(array $event)
Definition
calendareventviewformhelper.php:106
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper\getMeetingCreator
static getMeetingCreator(array $event)
Definition
calendareventviewformhelper.php:66
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper\getTimezoneHint
static getTimezoneHint($userId, $event)
Definition
calendareventviewformhelper.php:14
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper\getCrmView
static getCrmView(array $event)
Definition
calendareventviewformhelper.php:86
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper\getFilesView
static getFilesView(array $event)
Definition
calendareventviewformhelper.php:96
Bitrix\Calendar\ControllerHelper\CalendarEventViewFormHelper\getFromToHtml
static getFromToHtml(array $event)
Definition
calendareventviewformhelper.php:49
Bitrix\Main\Engine\Response\Component
Definition
component.php:5
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Calendar\ControllerHelper
Definition
calendareventviewformhelper.php:3
modules
calendar
lib
controllerhelper
calendareventviewformhelper.php
Создано системой
1.10.0