Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventdescription.php
1<?php
2
4
8
9IncludeModuleLangFile(__FILE__);
10
12{
21 public function prepareForExport(Event $event): ?string
22 {
23 $languageId = \CCalendar::getUserLanguageId($event->getOwner()?->getId());
24 $description = $this->addAttendeesInfo($event->getDescription(), $event, $languageId);
25
26 return $this->addSpecialInfo($description, $event, $languageId);
27 }
28
35 public function prepareAfterImport(string $description, string $languageId): string
36 {
37 $description = $this->removeAttendeesInfo($description, $languageId);
38
39 return $this->removeSpecialInfo($description, $languageId);
40 }
41
48 private function removeAttendeesInfo(string $description, string $languageId): string
49 {
50 return (new AttendeesDescription($languageId))
51 ->cutAttendeesFromDescription($description)
52 ;
53 }
54
65 private function addAttendeesInfo(?string $description, Event $event, string $languageId): string
66 {
67 if (!$description)
68 {
69 $description = '';
70 }
71
72 if (
73 $event->getAttendeesCollection()
74 && ($attendees = $event->getAttendeesCollection()->getAttendeesCodes())
75 && count($attendees) > 1
76 )
77 {
78 $description = (new AttendeesDescription($languageId))
79 ->addAttendeesToDescription($attendees, $description, $event->getParentId())
80 ;
81 }
82
83 return $description;
84 }
85
93 private function addSpecialInfo(string $description, Event $event, string $languageId): string
94 {
95 $padding = "\r\n\r\n";
96 if (!$event->getDescription())
97 {
98 $padding = '';
99 }
100
101 // temporary this functionality is turned off
102
103 // if ($this->isGuest($event) || $this->isReservation($event))
104 // {
105 // $description .= $padding . Loc::getMessage('CALENDAR_EXPORT_EVENT_LOCK', null, $languageId);
106 // }
107 // elseif ($this->isEventWithAttendees($event))
108 // {
109 // $description .= $padding . Loc::getMessage('CALENDAR_EXPORT_EVENT_MEETING', null, $languageId);
110 // }
111
112 return $description;
113 }
114
120 private function isGuest(Event $event): bool
121 {
122 return $event->getId() !== $event->getParentId();
123 }
124
130 private function isReservation(Event $event): bool
131 {
132 return $event->getSpecialLabel() === ResourceBooking::EVENT_LABEL;
133 }
134
140 private function isEventWithAttendees(Event $event): bool
141 {
142 return $event->getAttendeesCollection() !== null
143 && count($event->getAttendeesCollection()->getAttendeesCodes()) > 1;
144 }
145
151 private function removeSpecialInfo(string $description, string $languageId)
152 {
153 return str_replace(
154 [
155 Loc::getMessage('CALENDAR_EXPORT_EVENT_LOCK', null, $languageId),
156 Loc::getMessage('CALENDAR_EXPORT_EVENT_MEETING', null, $languageId)
157 ],
158 '',
159 $description
160 );
161 }
162}
prepareAfterImport(string $description, string $languageId)
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29