1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
alert.php
См. документацию.
1<?php
2
3
4namespace Bitrix\Calendar\ICal\Builder;
5
6use Bitrix\Calendar\ICal\Basic\Content;
7use Bitrix\Calendar\ICal\Basic\DatetimePropertyType;
8use Bitrix\Calendar\ICal\Basic\LengthPropertyType;
9use Bitrix\Calendar\ICal\Basic\Parameter;
10use Bitrix\Main\Type\Date;
11
12class Alert
13{
14 private const TRIGGER_START = 'trigger_start';
15 private const TRIGGER_END = 'trigger_end';
16 private const TRIGGER_DATE = 'trigger_date';
17 private $triggerDate;
18 private $triggerInterval;
19 private $triggerMode = self::TRIGGER_DATE;
20 private $message;
21
22 public static function date(Date $date, string $description = null): Alert
23 {
24 return static::getInstance($description)->triggerDate($date);
25 }
26
27 public static function minutesBeforeStart(int $minutes, string $description = null): Alert
28 {
29 $interval = new \DateInterval("PT{$minutes}M");
30 $interval->invert = 1;
31
32 return static::getInstance($description)->triggerAtStart($interval);
33 }
34
35 public static function minutesAfterStart(int $min, string $description = null): Alert
36 {
37 return static::getInstance($description)->triggerAtStart(new \DateInterval("PT{$min}M"));
38 }
39
40 public static function minutesBeforeEnd(int $min, string $description = null): Alert
41 {
42 $interval = new \DateInterval("PT{$min}M");
43 $interval->invert = 1;
44
45 return static::getInstance($description)->triggerAtEnd($interval);
46 }
47
48 public static function minutesAfterEnd(int $min, string $description = null): Alert
49 {
50 return static::getInstance($description)->triggerAtEnd(new \DateInterval("PT{$min}M"));
51 }
52
53 private static function getInstance(array $reminds = [], $description = ''): Alert
54 {
55 return new self($reminds, $description);
56 }
57
58 public function __construct(array $reminds = [], $description = '')
59 {
60 $this->message = $reminds;
61 $this->message = $description;
62 }
63
64 public function getType(): string
65 {
66 return 'VALARM';
67 }
68
69 public function getRequiredProperties(): array
70 {
71 return [
72 'ACTION',
73 'TRIGGER',
74 'DESCRIPTION',
75 ];
76 }
77
78 public function message(string $message): Alert
79 {
80 $this->message = $message;
81
82 return $this;
83 }
84
85 public function triggerDate(Date $triggerAt): Alert
86 {
87 $this->triggerMode = self::TRIGGER_DATE;
88 $this->triggerDate = $triggerAt;
89
90 return $this;
91 }
92
93 public function triggerAtStart(\DateInterval $interval): Alert
94 {
95 $this->triggerMode = self::TRIGGER_START;
96 $this->triggerInterval = $interval;
97
98 return $this;
99 }
100
101 public function triggerAtEnd(\DateInterval $interval): Alert
102 {
103 $this->triggerMode = self::TRIGGER_END;
104 $this->triggerInterval = $interval;
105
106 return $this;
107 }
108
109 protected function setContent(): Content
110 {
111 return Content::getInstance($this->getType())
112 ->textProperty('ACTION', 'DISPLAY')
113 ->textProperty('DESCRIPTION', $this->message)
114 ->property($this->resolveTriggerProperty());
115 }
116
117 private function resolveTriggerProperty()
118 {
119 if ($this->triggerMode === self::TRIGGER_DATE) {
120 return DateTimePropertyType::getInstance(
121 'TRIGGER',
122 $this->triggerDate,
123 true
124 )->addParameter(new Parameter('VALUE', 'DATE-TIME'));
125 }
126
127 $property = LengthPropertyType::getInstance('TRIGGER', $this->triggerInterval);
128
129 if ($this->triggerMode === self::TRIGGER_END) {
130 return $property->addParameter(new Parameter('RELATED', 'END'));
131 }
132
133 return $property;
134 }
135}
textProperty($names, ?string $value, bool $disableEscaping=false)
Определения content.php:48
triggerAtEnd(\DateInterval $interval)
Определения alert.php:101
triggerDate(Date $triggerAt)
Определения alert.php:85
static minutesBeforeStart(int $minutes, string $description=null)
Определения alert.php:27
static minutesAfterStart(int $min, string $description=null)
Определения alert.php:35
static minutesBeforeEnd(int $min, string $description=null)
Определения alert.php:40
static date(Date $date, string $description=null)
Определения alert.php:22
__construct(array $reminds=[], $description='')
Определения alert.php:58
message(string $message)
Определения alert.php:78
static minutesAfterEnd(int $min, string $description=null)
Определения alert.php:48
triggerAtStart(\DateInterval $interval)
Определения alert.php:93
getRequiredProperties()
Определения alert.php:69
Определения date.php:9
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24