Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectionbuilder.php
1<?php
2
4
5use Bitrix\Calendar\Core\Base\SingletonTrait;
8
10{
12
18 public function getCreateSectionContent(Section $section): string
19 {
20 $xmlns = " xmlns:A0=\"urn:ietf:params:xml:ns:caldav\"";
21 $xmlns .= " xmlns:A1=\"http://apple.com/ns/ical/\"";
22
23 $body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
24 $body .= "<A:mkcol xmlns:A=\"DAV:\"". $xmlns .">\r\n";
25 $body .= "\t<A:set>\r\n";
26 $body .= "\t\t<A:prop>\r\n";
27 $body .= "\t\t\t<A:resourcetype>\r\n";
28 $body .= "\t\t\t\t<A:collection/>\r\n";
29 $body .= "\t\t\t\t<A0:calendar/>\r\n";
30 $body .= "\t\t\t</A:resourcetype>\r\n";
31 $body = $this->getBodyProperties($section, $body);
32 $body .= "</A:mkcol>";
33
34 return $body;
35 }
36
42 public function getUpdateSectionContent(Section $section): string
43 {
44 $xmlns = " xmlns:A0=\"urn:ietf:params:xml:ns:caldav\"";
45 $xmlns .= " xmlns:A1=\"http://apple.com/ns/ical/\"";
46
47 $body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
48 $body .= "<A:propertyupdate xmlns:A=\"DAV:\"". $xmlns .">\r\n";
49 $body .= "\t<A:set>\r\n";
50 $body .= "\t\t<A:prop>\r\n";
51 $body = $this->getBodyProperties($section, $body);
52 $body .= "</A:propertyupdate>";
53
54 return $body;
55 }
56
63 private function getBodyProperties(Section $section, string $body): string
64 {
65 if ($section->getName())
66 {
67 IncludeModuleLangFile(
68 $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/modules/calendar/classes/general/calendar.php'
69 );
70 $body .= "\t\t\t<A:displayname>"
71 . ($section->getExternalType() === 'local' ? (Loc::getMessage('EC_CALENDAR_BITRIX24_NAME') . ' ') : '')
72 . $section->getName() . "</A:displayname>\r\n";
73 }
74 if ($section->getColor())
75 {
76 $body .= "\t\t\t<A1:calendar-color>" . $section->getColor() . "</A1:calendar-color>\r\n";
77 }
78 $body .= "\t\t</A:prop>\r\n";
79 $body .= "\t</A:set>\r\n";
80
81 return $body;
82 }
83}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29