1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
calc.php
См. документацию.
1<?php
2
5
6class CBPCalc
7{
9 private $activity;
10 private $arErrorsList = [];
11
12 private static $weekHolidays;
13 private static $yearHolidays;
14 private static $startWorkDay;
15 private static $endWorkDay;
16 private static $yearWorkdays;
17
18 // Operation priority
19 private $arPriority = [
20 '(' => 0, ')' => 1, ';' => 2, '=' => 3, '<' => 3, '>' => 3,
21 '<=' => 3, '>=' => 3, '<>' => 3, '&' => 4, '+' => 5, '-' => 5,
22 '*' => 6, '/' => 6, '^' => 7, '%' => 8, '-m' => 9, '+m' => 9,
23 ' ' => 10, ':' => 11, 'f' => 12,
24 ];
25
26 // Allowable functions
27 private $arAvailableFunctions = [
28 'abs' => ['args' => true, 'func' => 'FunctionAbs'],
29 'and' => ['args' => true, 'func' => 'FunctionAnd'],
30 'date' => ['args' => true, 'func' => 'FunctionDate'],
31 'dateadd' => ['args' => true, 'func' => 'FunctionDateAdd'],
32 'datediff' => ['args' => true, 'func' => 'FunctionDateDiff'],
33 'false' => ['args' => false, 'func' => 'FunctionFalse'],
34 'if' => ['args' => true, 'func' => 'FunctionIf'],
35 'intval' => ['args' => true, 'func' => 'FunctionIntval'],
36 'floatval' => ['args' => true, 'func' => 'FunctionFloatval'],
37 'numberformat' => ['args' => true, 'func' => 'FunctionNumberFormat'],
38 'min' => ['args' => true, 'func' => 'FunctionMin'],
39 'max' => ['args' => true, 'func' => 'FunctionMax'],
40 'rand' => ['args' => true, 'func' => 'FunctionRand'],
41 'round' => ['args' => true, 'func' => 'FunctionRound'],
42 'ceil' => ['args' => true, 'func' => 'FunctionCeil'],
43 'floor' => ['args' => true, 'func' => 'FunctionFloor'],
44 'not' => ['args' => true, 'func' => 'FunctionNot'],
45 'or' => ['args' => true, 'func' => 'FunctionOr'],
46 'substr' => ['args' => true, 'func' => 'FunctionSubstr'],
47 'strpos' => ['args' => true, 'func' => 'FunctionStrpos'],
48 'strlen' => ['args' => true, 'func' => 'FunctionStrlen'],
49 'implode' => ['args' => true, 'func' => 'FunctionImplode'],
50 'explode' => ['args' => true, 'func' => 'FunctionExplode'],
51 'randstring' => ['args' => true, 'func' => 'FunctionRandString'],
52 'true' => ['args' => false, 'func' => 'FunctionTrue'],
53 'convert' => ['args' => true, 'func' => 'FunctionConvert'],
54 'merge' => ['args' => true, 'func' => 'FunctionMerge'],
55 'addworkdays' => ['args' => true, 'func' => 'FunctionAddWorkDays'],
56 'workdateadd' => ['args' => true, 'func' => 'FunctionWorkDateAdd'],
57 'isworkday' => ['args' => true, 'func' => 'FunctionIsWorkDay'],
58 'isworktime' => ['args' => true, 'func' => 'FunctionIsWorkTime'],
59 'urlencode' => ['args' => true, 'func' => 'FunctionUrlencode'],
60 'touserdate' => ['args' => true, 'func' => 'FunctionToUserDate'],
61 'getuserdateoffset' => ['args' => true, 'func' => 'FunctionGetUserDateOffset'],
62 'strtolower' => ['args' => true, 'func' => 'FunctionStrtolower'],
63 'strtoupper' => ['args' => true, 'func' => 'FunctionStrtoupper'],
64 'ucwords' => ['args' => true, 'func' => 'FunctionUcwords'],
65 'ucfirst' => ['args' => true, 'func' => 'FunctionUcfirst'],
66 'strtotime' => ['args' => true, 'func' => 'FunctionStrtotime'],
67 'locdate' => ['args' => true, 'func' => 'FunctionLocDate'],
68 'shuffle' => ['args' => true, 'func' => 'FunctionShuffle'],
69 'firstvalue'=> ['args' => true, 'func' => 'FunctionFirstValue'],
70 'swirl' => ['args' => true, 'func' => 'FunctionSwirl'],
71 'getdocumenturl' => ['args' => true, 'func' => 'FunctionGetDocumentUrl'],
72 'trim' => ['args' => true, 'func' => 'functionTrim'],
73 ];
74
75 // Allowable errors
76 private $arAvailableErrors = [
77 0 => 'Incorrect variable name - "#STR#"',
78 1 => 'Empty',
79 2 => 'Syntax error "#STR#"',
80 3 => 'Unknown function "#STR#"',
81 4 => 'Unmatched closing bracket ")"',
82 5 => 'Unmatched opening bracket "("',
83 6 => 'Division by zero',
84 7 => 'Incorrect order of operands',
85 8 => 'Incorrect arguments of function "#STR#"',
86 ];
87
88 const Operation = 0;
89 const Variable = 1;
90 const Constant = 2;
91
92 public function __construct(CBPActivity $activity)
93 {
94 $this->activity = $activity;
95 }
96
97 private function getVariableValue($variable)
98 {
99 $variable = trim($variable);
100 if (!preg_match(CBPActivity::ValuePattern, $variable))
101 return null;
102
103 return $this->activity->ParseValue($variable);
104 }
105
106 private function setError($errnum, $errstr = '')
107 {
108 $this->arErrorsList[] = [$errnum, str_replace('#STR#', $errstr, $this->arAvailableErrors[$errnum])];
109 }
110
111 public function getErrors()
112 {
113 return $this->arErrorsList;
114 }
115
116 /*
117 Return array of polish notation
118 array(
119 key => array(value, self::Operation | self::Variable | self::Constant)
120 )
121 */
122 private function getPolishNotation($text)
123 {
124 $text = trim($text);
125 if (mb_substr($text, 0, 1) === '=')
126 $text = mb_substr($text, 1);
127 if (mb_strpos($text, '{{=') === 0 && mb_substr($text, -2) == '}}')
128 {
129 $text = mb_substr($text, 3);
130 $text = mb_substr($text, 0, -2);
131 }
132
133 if ($text == '')
134 {
135 $this->SetError(1);
136 return false;
137 }
138
139 $arPolishNotation = $arStack = [];
140 $prev = '';
141 $preg = '/
142 \s*\‍(\s* |
143 \s*\‍)\s* |
144 \s*,\s* | # Combine ranges of variables
145 \s*;\s* | # Combine ranges of variables
146 \s*=\s* |
147 \s*<=\s* |
148 \s*>=\s* |
149 \s*<>\s* |
150 \s*<\s* |
151 \s*>\s* |
152 \s*&\s* | # String concatenation
153 \s*\+\s* | # Addition or unary plus
154 \s*-\s* |
155 \s*\*\s* |
156 \s*\/\s* |
157 \s*\^\s* | # Exponentiation
158 \s*%\s* | # Percent
159 \s*[\d\.]+\s* | # Numbers
160 \s*\'[^\']*\'\s* | # String constants in apostrophes
161 \s*"[^"]*"\s* | # String constants in quotes
162 (\s*\w+\s*\‍(\s*) | # Function names
163 \s*'.CBPActivity::ValueInternalPattern.'\s* | # Variables
164 (?<error>.+) # Any erroneous substring
165 /xi';
166 while (preg_match($preg, $text, $match))
167 {
168 if (isset($match['error']))
169 {
170 $this->SetError(2, $match['error']);
171 return false;
172 }
173
174 $str = trim($match[0]);
175 if ($str === ",")
176 $str = ";";
177
178 if (isset($match[1]) && $match[1])
179 {
180 $str = mb_strtolower($str);
181 list($name, $left) = explode('(', $str);
182 $name = trim($name);
183 if (isset($this->arAvailableFunctions[$name]))
184 {
185 if (!$arStack)
186 {
187 array_unshift($arStack, [$name, $this->arPriority['f']]);
188 }
189 else
190 {
191 while ($this->arPriority['f'] <= $arStack[0][1])
192 {
193 $op = array_shift($arStack);
194 $arPolishNotation[] = [$op[0], self::Operation];
195 if (!$arStack)
196 break;
197 }
198 array_unshift($arStack, [$name, $this->arPriority['f']]);
199 }
200 }
201 else
202 {
203 $this->SetError(3, $name);
204 return false;
205 }
206 $str = '(';
207 }
208
209 if ($str == '-' || $str == '+')
210 {
211 if ($prev == '' || in_array($prev, ['(', ';', '=', '<=', '>=', '<>', '<', '>', '&', '+', '-', '*', '/', '^']))
212 $str .= 'm';
213 }
214 $prev = $str;
215
216 switch ($str)
217 {
218 case '(':
219 array_unshift($arStack, ['(', $this->arPriority['(']]);
220 break;
221 case ')':
222 while ($op = array_shift($arStack))
223 {
224 if ($op[0] == '(')
225 break;
226 $arPolishNotation[] = [$op[0], self::Operation];
227 }
228 if ($op == null)
229 {
230 $this->SetError(4);
231 return false;
232 }
233 break;
234 case ';' : case '=' : case '<=': case '>=':
235 case '<>': case '<' : case '>' : case '&' :
236 case '+' : case '-' : case '+m': case '-m':
237 case '*' : case '/' : case '^' : case '%' :
238 if (!$arStack)
239 {
240 array_unshift($arStack, [$str, $this->arPriority[$str]]);
241 break;
242 }
243 while ($this->arPriority[$str] <= $arStack[0][1])
244 {
245 $op = array_shift($arStack);
246 $arPolishNotation[] = [$op[0], self::Operation];
247 if (!$arStack)
248 break;
249 }
250 array_unshift($arStack, [$str, $this->arPriority[$str]]);
251 break;
252 default:
253 if (mb_substr($str, 0, 1) == '0' || (int) $str)
254 {
255 $arPolishNotation[] = [(float)$str, self::Constant];
256 break;
257 }
258 if (mb_substr($str, 0, 1) == '"' || mb_substr($str, 0, 1) == "'")
259 {
260 $arPolishNotation[] = [mb_substr($str, 1, -1), self::Constant];
261 break;
262 }
263 $arPolishNotation[] = [$str, self::Variable];
264 }
265 $text = mb_substr($text, mb_strlen($match[0]));
266 }
267 while ($op = array_shift($arStack))
268 {
269 if ($op[0] == '(')
270 {
271 $this->SetError(5);
272 return false;
273 }
274 $arPolishNotation[] = [$op[0], self::Operation];
275 }
276 return $arPolishNotation;
277 }
278
279 public function calculate($text)
280 {
281 if (!$arPolishNotation = $this->GetPolishNotation($text))
282 return null;
283
284 $stack = [];
285 foreach ($arPolishNotation as $item)
286 {
287 switch ($item[1])
288 {
289 case self::Constant:
290 array_unshift($stack, $item[0]);
291 break;
292 case self::Variable:
293 array_unshift($stack, $this->GetVariableValue($item[0]));
294 break;
295 case self::Operation:
296 switch ($item[0])
297 {
298 case ';':
299 $arg2 = array_shift($stack);
300 $arg1 = array_shift($stack);
301 if (!is_array($arg1) || !isset($arg1[0]))
302 $arg1 = [$arg1];
303 $arg1[] = $arg2;
304 array_unshift($stack, $arg1);
305 break;
306 case '=':
307 $arg2 = array_shift($stack);
308 $arg1 = array_shift($stack);
309 array_unshift($stack, $arg1 == $arg2);
310 break;
311 case '<=':
312 $arg2 = array_shift($stack);
313 $arg1 = array_shift($stack);
314 array_unshift($stack, $arg1 <= $arg2);
315 break;
316 case '>=':
317 $arg2 = array_shift($stack);
318 $arg1 = array_shift($stack);
319 array_unshift($stack, $arg1 >= $arg2);
320 break;
321 case '<>':
322 $arg2 = array_shift($stack);
323 $arg1 = array_shift($stack);
324 array_unshift($stack, $arg1 != $arg2);
325 break;
326 case '<':
327 $arg2 = array_shift($stack);
328 $arg1 = array_shift($stack);
329 array_unshift($stack, $arg1 < $arg2);
330 break;
331 case '>':
332 $arg2 = array_shift($stack);
333 $arg1 = array_shift($stack);
334 array_unshift($stack, $arg1 > $arg2);
335 break;
336 case '&':
337 $arg2 = (string) array_shift($stack);
338 $arg1 = (string) array_shift($stack);
339 array_unshift($stack, $arg1 . $arg2);
340 break;
341 case '+':
342 $arg2 = (float) array_shift($stack);
343 $arg1 = (float) array_shift($stack);
344 array_unshift($stack, $arg1 + $arg2);
345 break;
346 case '-':
347 $arg2 = (float) array_shift($stack);
348 $arg1 = (float) array_shift($stack);
349 array_unshift($stack, $arg1 - $arg2);
350 break;
351 case '+m':
352 $arg = (float) array_shift($stack);
353 array_unshift($stack, $arg);
354 break;
355 case '-m':
356 $arg = (float) array_shift($stack);
357 array_unshift($stack, (-$arg));
358 break;
359 case '*':
360 $arg2 = (float) array_shift($stack);
361 $arg1 = (float) array_shift($stack);
362 array_unshift($stack, $arg1 * $arg2);
363 break;
364 case '/':
365 $arg2 = (float) array_shift($stack);
366 $arg1 = (float) array_shift($stack);
367 if (0 == $arg2)
368 {
369 $this->SetError(6);
370 return null;
371 }
372 array_unshift($stack, $arg1 / $arg2);
373 break;
374 case '^':
375 $arg2 = (float) array_shift($stack);
376 $arg1 = (float) array_shift($stack);
377 array_unshift($stack, pow($arg1, $arg2));
378 break;
379 case '%':
380 $arg = (float) array_shift($stack);
381 array_unshift($stack, $arg / 100);
382 break;
383 default:
384 $func = $this->arAvailableFunctions[$item[0]]['func'];
385 if ($this->arAvailableFunctions[$item[0]]['args'])
386 {
387 $arg = array_shift($stack);
388 $val = $this->$func($arg);
389 }
390 else
391 {
392 $val = $this->$func();
393 }
394 $error = is_float($val) && (is_nan($val) || is_infinite($val));
395 if ($error)
396 {
397 $this->SetError(8, $item[0]);
398 return null;
399 }
400 array_unshift($stack, $val);
401 }
402 }
403 }
404 if (count($stack) > 1)
405 {
406 $this->SetError(7);
407 return null;
408 }
409 return array_shift($stack);
410 }
411
412 private function arrgsToArray($args)
413 {
414 if (!is_array($args))
415 return [$args];
416
417 $result = [];
418 foreach ($args as $arg)
419 {
420 if (!is_array($arg))
421 {
422 $result[] = $arg;
423 }
424 else
425 {
426 foreach ($this->ArrgsToArray($arg) as $val)
427 $result[] = $val;
428 }
429 }
430
431 return $result;
432 }
433
434 /* Math */
435
436 private function functionAbs($num)
437 {
438 return abs((float) $num);
439 }
440
441 private function functionRound($args)
442 {
443 $ar = $this->ArrgsToArray($args);
444 $val = (float)array_shift($ar);
445 $precision = (int)array_shift($ar);
446
447 return round($val, $precision);
448 }
449
450 private function functionCeil($num)
451 {
452 return ceil((double)$num);
453 }
454
455 private function functionFloor($num)
456 {
457 return floor((double)$num);
458 }
459
460 private function functionMin($args)
461 {
462 if (!is_array($args))
463 return (float) $args;
464
465 foreach ($args as &$arg)
466 $arg = (float) $arg;
467
468 $args = $this->ArrgsToArray($args);
469
470 return $args ? min($args) : false;
471 }
472
473 private function functionMax($args)
474 {
475 if (!is_array($args))
476 return (float) $args;
477
478 foreach ($args as &$arg)
479 $arg = (float) $arg;
480
481 $args = $this->ArrgsToArray($args);
482
483 return $args ? max($args) : false;
484 }
485
486 private function functionRand($args)
487 {
488 $ar = $this->ArrgsToArray($args);
489 $min = (int)array_shift($ar);
490 $max = (int)array_shift($ar);
491 if (!$max)
492 {
493 $max = mt_getrandmax();
494 }
495
496 return mt_rand($min, $max);
497 }
498
499 private function functionIntval($num)
500 {
501 return intval($num);
502 }
503
504 private function functionFloatval($num)
505 {
506 return floatval($num);
507 }
508
509 /* Logic */
510
511 private function functionTrue()
512 {
513 return true;
514 }
515
516 private function functionFalse()
517 {
518 return false;
519 }
520
521 private function functionIf($args)
522 {
523 if (!is_array($args))
524 return null;
525
526 $expression = (boolean) array_shift($args);
527 $ifTrue = array_shift($args);
528 $ifFalse = array_shift($args);
529 return $expression ? $ifTrue : $ifFalse;
530 }
531
532 private function functionNot($arg)
533 {
534 return !((boolean) $arg);
535 }
536
537 private function functionAnd($args)
538 {
539 if (!is_array($args))
540 return (boolean) $args;
541
542 $args = $this->ArrgsToArray($args);
543
544 foreach ($args as $arg)
545 {
546 if (!$arg)
547 return false;
548 }
549 return true;
550 }
551
552 private function functionOr($args)
553 {
554 if (!is_array($args))
555 return (boolean) $args;
556
557 $args = $this->ArrgsToArray($args);
558 foreach ($args as $arg)
559 {
560 if ($arg)
561 return true;
562 }
563
564 return false;
565 }
566
567 /* Date */
568
569 private function functionDateAdd($args)
570 {
571 if (!is_array($args))
572 {
573 $args = [$args];
574 }
575
576 $ar = $this->ArrgsToArray($args);
577 $date = array_shift($ar);
578 $offset = $this->getDateTimeOffset($date);
579 $interval = array_shift($ar);
580
581 if (($date = $this->makeTimestamp($date)) === false)
582 {
583 return null;
584 }
585
586 if (empty($interval))
587 {
588 return $date; // new Bizproc\BaseType\Value\DateTime($date, $offset);
589 }
590
591 // 1Y2M3D4H5I6S, -4 days 5 hours, 1month, 5h
592
593 $interval = trim($interval);
594 $bMinus = false;
595 if (mb_substr($interval, 0, 1) === "-")
596 {
597 $interval = mb_substr($interval, 1);
598 $bMinus = true;
599 }
600
601 static $arMap = ["y" => "YYYY", "year" => "YYYY", "years" => "YYYY",
602 "m" => "MM", "month" => "MM", "months" => "MM",
603 "d" => "DD", "day" => "DD", "days" => "DD",
604 "h" => "HH", "hour" => "HH", "hours" => "HH",
605 "i" => "MI", "min" => "MI", "minute" => "MI", "minutes" => "MI",
606 "s" => "SS", "sec" => "SS", "second" => "SS", "seconds" => "SS",
607 ];
608
609 $arInterval = [];
610 while (preg_match('/\s*([\d]+)\s*([a-z]+)\s*/i', $interval, $match))
611 {
612 $match2 = mb_strtolower($match[2]);
613 if (array_key_exists($match2, $arMap))
614 {
615 $arInterval[$arMap[$match2]] = ($bMinus ? -intval($match[1]) : intval($match[1]));
616 }
617
618 $p = mb_strpos($interval, $match[0]);
619 $interval = mb_substr($interval, $p + mb_strlen($match[0]));
620 }
621
622 $date += $offset; // to server
623
624 $newDate = AddToTimeStamp($arInterval, $date);
625
626 $newDate -= $offset; // to user timezone
627
628 return new Bizproc\BaseType\Value\DateTime($newDate, $offset);
629 }
630
631 private function functionWorkDateAdd($args)
632 {
633 if (!is_array($args))
634 $args = [$args];
635
636 $ar = $this->ArrgsToArray($args);
637 $date = array_shift($ar);
638 $offset = $this->getDateTimeOffset($date);
639 $paramInterval = array_shift($ar);
640 $user = array_shift($ar);
641
642 if ($user)
643 {
644 $date = $this->FunctionToUserDate([$user, $date]);
645 $offset = $this->getDateTimeOffset($date);
646 }
647
648 if (($date = $this->makeTimestamp($date, true)) === false)
649 return null;
650
651 if (empty($paramInterval) || !CModule::IncludeModule('calendar'))
652 return $date;
653
654 $paramInterval = trim($paramInterval);
655 $multiplier = 1;
656 if (mb_substr($paramInterval, 0, 1) === "-")
657 {
658 $paramInterval = mb_substr($paramInterval, 1);
659 $multiplier = -1;
660 }
661
662 $workDayInterval = $this->getWorkDayInterval();
663 $intervalMap = ["d" => $workDayInterval, "day" => $workDayInterval, "days" => $workDayInterval,
664 "h" => 3600, "hour" => 3600, "hours" => 3600,
665 "i" => 60, "min" => 60, "minute" => 60, "minutes" => 60,
666 ];
667
668 $interval = 0;
669 while (preg_match('/\s*([\d]+)\s*([a-z]+)\s*/i', $paramInterval, $match))
670 {
671 $match2 = mb_strtolower($match[2]);
672 if (array_key_exists($match2, $intervalMap))
673 $interval += intval($match[1]) * $intervalMap[$match2];
674
675 $p = mb_strpos($paramInterval, $match[0]);
676 $paramInterval = mb_substr($paramInterval, $p + mb_strlen($match[0]));
677 }
678
679 if (date('H:i:s', $date) === '00:00:00')
680 {
681 //add start work day seconds
682 $date += $this->getCalendarWorkTime()[0];
683 }
684
685 $date = $this->getNearestWorkTime($date, $multiplier);
686 if ($interval)
687 {
688 $days = (int) floor($interval / $workDayInterval);
689 $hours = $interval % $workDayInterval;
690
691 $remainTimestamp = $this->getWorkDayRemainTimestamp($date, $multiplier);
692
693 if ($days)
694 $date = $this->addWorkDay($date, $days * $multiplier);
695
696 if ($hours > $remainTimestamp)
697 {
698 $date += $multiplier < 0 ? -$remainTimestamp -60 : $remainTimestamp + 60;
699 $date = $this->getNearestWorkTime($date, $multiplier) + (($hours - $remainTimestamp) * $multiplier);
700 }
701 else
702 $date += $multiplier * $hours;
703 }
704
705 $date -= $offset;
706
707 return new Bizproc\BaseType\Value\DateTime($date, $offset);
708 }
709
710 private function functionAddWorkDays($args)
711 {
712 if (!is_array($args))
713 $args = [$args];
714
715 $ar = $this->ArrgsToArray($args);
716 $date = array_shift($ar);
717 $offset = $this->getDateTimeOffset($date);
718 $days = (int) array_shift($ar);
719
720 if (($date = $this->makeTimestamp($date)) === false)
721 return null;
722
723 if ($days === 0 || !CModule::IncludeModule('calendar'))
724 return $date;
725
726 $date = $this->addWorkDay($date, $days);
727
728 return new Bizproc\BaseType\Value\DateTime($date, $offset);
729 }
730
731 private function functionIsWorkDay($args)
732 {
733 if (!CModule::IncludeModule('calendar'))
734 return null;
735
736 if (!is_array($args))
737 $args = [$args];
738
739 $ar = $this->ArrgsToArray($args);
740 $date = array_shift($ar);
741 $user = array_shift($ar);
742
743 if ($user)
744 {
745 $date = $this->FunctionToUserDate([$user, $date]);
746 }
747
748 if (($date = $this->makeTimestamp($date, true)) === false)
749 return null;
750
751 return !$this->isHoliday($date);
752 }
753
754 private function functionIsWorkTime($args)
755 {
756 if (!CModule::IncludeModule('calendar'))
757 return null;
758
759 if (!is_array($args))
760 $args = [$args];
761
762 $ar = $this->ArrgsToArray($args);
763 $date = array_shift($ar);
764 $user = array_shift($ar);
765
766 if ($user)
767 {
768 $date = $this->FunctionToUserDate([$user, $date]);
769 }
770
771 if (($date = $this->makeTimestamp($date, true)) === false)
772 return null;
773
774 return !$this->isHoliday($date) && $this->isWorkTime($date);
775 }
776
777 private function functionDateDiff($args)
778 {
779 if (!is_array($args))
780 $args = [$args];
781
782 $ar = $this->ArrgsToArray($args);
783 $date1 = array_shift($ar);
784 $date2 = array_shift($ar);
785 $format = array_shift($ar);
786
787 if ($date1 == null || $date2 == null)
788 return null;
789
790 $date1Formatted = $this->getDateTimeObject($date1);
791 $date2Formatted = $this->getDateTimeObject($date2);
792 if ($date1Formatted === false || $date2Formatted === false)
793 {
794 return null;
795 }
796
797 $interval = $date1Formatted->diff($date2Formatted);
798
799 return $interval === false ? null : $interval->format($format);
800 }
801
802 private function functionDate($args)
803 {
804 $ar = $this->ArrgsToArray($args);
805 $format = array_shift($ar);
806 $date = array_shift($ar);
807
808 if (!$format || !is_string($format))
809 {
810 return null;
811 }
812
813 $ts = $date ? $this->makeTimestamp($date, true) : time();
814
815 if (!$ts)
816 {
817 return null;
818 }
819
820 return date($format, $ts);
821 }
822
823 private function functionToUserDate($args)
824 {
825 if (!is_array($args))
826 {
827 $args = [$args];
828 }
829
830 $ar = $this->ArrgsToArray($args);
831 $user = array_shift($ar);
832 $date = array_shift($ar);
833
834 if (!$user)
835 {
836 return null;
837 }
838
839 if (!$date)
840 {
841 $date = time();
842 }
843 elseif (($date = $this->makeTimestamp($date)) === false)
844 {
845 return null;
846 }
847
848 $userId = CBPHelper::ExtractUsers($user, $this->activity->GetDocumentId(), true);
849 $offset = $userId ? CTimeZone::GetOffset($userId, true) : 0;
850
851 return new Bizproc\BaseType\Value\DateTime($date, $offset);
852 }
853
854 private function functionGetUserDateOffset($args)
855 {
856 if (!is_array($args))
857 {
858 $args = [$args];
859 }
860
861 $ar = $this->ArrgsToArray($args);
862 $user = array_shift($ar);
863
864 if (!$user)
865 {
866 return null;
867 }
868
869 $userId = CBPHelper::ExtractUsers($user, $this->activity->GetDocumentId(), true);
870
871 if (!$userId)
872 {
873 return null;
874 }
875
876 return CTimeZone::GetOffset($userId, true);
877 }
878
879 private function functionStrtotime($args)
880 {
881 $ar = $this->ArrgsToArray($args);
882 $datetime = (string)array_shift($ar);
883 $baseDate = array_shift($ar);
884
885 $baseTimestamp = $baseDate ? $this->makeTimestamp($baseDate, true) : time();
886
887 if (!$baseTimestamp)
888 {
889 return null;
890 }
891
892 $timestamp = strtotime($datetime, (int)$baseTimestamp);
893
894 if ($timestamp === false)
895 {
896 return null;
897 }
898
899 return new Bizproc\BaseType\Value\DateTime($timestamp);
900 }
901
902 private function functionLocDate($args)
903 {
904 $ar = $this->ArrgsToArray($args);
905 $format = array_shift($ar);
906 $date = array_shift($ar);
907
908 if (!$format || !is_string($format))
909 {
910 return null;
911 }
912
913 $reformFormat = $this->frameSymbolsInDateFormat($format);
914 $timestamp = $date ? $this->makeTimestamp($date, true) : time();
915
916 if (!$timestamp)
917 {
918 return null;
919 }
920
921 $formattedDate = date($reformFormat, $timestamp);
922
923 if ($formattedDate === false)
924 {
925 return null;
926 }
927
928 return $this->replaceDateToLocDate($formattedDate, $reformFormat);
929 }
930
931 /* Date - Helpers */
932
933 private function makeTimestamp($date, $appendOffset = false)
934 {
935 if (!$date)
936 {
937 return false;
938 }
939
940 //serialized date string
941 if (is_string($date) && Bizproc\BaseType\Value\Date::isSerialized($date))
942 {
943 $date = new Bizproc\BaseType\Value\Date($date);
944 }
945
946 if ($date instanceof Bizproc\BaseType\Value\Date)
947 {
948 return $date->getTimestamp() + ($appendOffset? $date->getOffset() : 0);
949 }
950
951 if (intval($date)."!" === $date."!")
952 return $date;
953
954 if (($result = MakeTimeStamp($date, FORMAT_DATETIME)) === false)
955 {
956 if (($result = MakeTimeStamp($date, FORMAT_DATE)) === false)
957 {
958 if (($result = MakeTimeStamp($date, "YYYY-MM-DD HH:MI:SS")) === false)
959 {
960 $result = MakeTimeStamp($date, "YYYY-MM-DD");
961 }
962 }
963 }
964 return $result;
965 }
966
967 private function getWorkDayTimestamp($date)
968 {
969 return date('H', $date) * 3600 + date('i', $date) * 60;
970 }
971
972 private function getWorkDayRemainTimestamp($date, $multiplier = 1)
973 {
974 $dayTs = $this->getWorkDayTimestamp($date);
975 list ($startSeconds, $endSeconds) = $this->getCalendarWorkTime();
976 return $multiplier < 0 ? $dayTs - $startSeconds :$endSeconds - $dayTs;
977 }
978
979 private function getWorkDayInterval()
980 {
981 list ($startSeconds, $endSeconds) = $this->getCalendarWorkTime();
982 return $endSeconds - $startSeconds;
983 }
984
985 private function isHoliday($date)
986 {
987 [$yearWorkdays] = $this->getCalendarWorkdays();
988 [$weekHolidays, $yearHolidays] = $this->getCalendarHolidays();
989
990 $dayOfYear = date('j.n', $date);
991 if (in_array($dayOfYear, $yearWorkdays, true))
992 {
993 return false;
994 }
995
996 $dayOfWeek = date('w', $date);
997 if (in_array($dayOfWeek, $weekHolidays))
998 {
999 return true;
1000 }
1001
1002 $dayOfYear = date('j.n', $date);
1003 if (in_array($dayOfYear, $yearHolidays, true))
1004 {
1005 return true;
1006 }
1007
1008 return false;
1009 }
1010
1011 private function isWorkTime($date)
1012 {
1013 $dayTs = $this->getWorkDayTimestamp($date);
1014 list ($startSeconds, $endSeconds) = $this->getCalendarWorkTime();
1015 return ($dayTs >= $startSeconds && $dayTs <= $endSeconds);
1016 }
1017
1018 private function getNearestWorkTime($date, $multiplier = 1)
1019 {
1020 $reverse = $multiplier < 0;
1021 list ($startSeconds, $endSeconds) = $this->getCalendarWorkTime();
1022 $dayTimeStamp = $this->getWorkDayTimestamp($date);
1023
1024 if ($this->isHoliday($date))
1025 {
1026 $date -= $dayTimeStamp;
1027 $date += $reverse? -86400 + $endSeconds : $startSeconds;
1028 $dayTimeStamp = $reverse? $endSeconds : $startSeconds;
1029 }
1030
1031 if (!$this->isWorkTime($date))
1032 {
1033 $date -= $dayTimeStamp;
1034
1035 if ($dayTimeStamp < $startSeconds)
1036 {
1037 $date += $reverse? -86400 + $endSeconds : $startSeconds;
1038 }
1039 else
1040 {
1041 $date += $reverse? $endSeconds : 86400 + $startSeconds;
1042 }
1043 }
1044
1045 if ($this->isHoliday($date))
1046 $date = $this->addWorkDay($date, $reverse? -1 : 1);
1047
1048 return $date;
1049 }
1050
1051 private function addWorkDay($date, $days)
1052 {
1053 $delta = 86400;
1054 if ($days < 0)
1055 $delta *= -1;
1056
1057 $days = abs($days);
1058 $iterations = 0;
1059
1060 while ($days > 0 && $iterations < 1000)
1061 {
1062 ++$iterations;
1063 $date += $delta;
1064
1065 if ($this->isHoliday($date))
1066 continue;
1067 --$days;
1068 }
1069
1070 return $date;
1071 }
1072
1073 private function getCalendarHolidays()
1074 {
1075 if (static::$yearHolidays === null)
1076 {
1077 $calendarSettings = CCalendar::GetSettings();
1078 $weekHolidays = [0, 6];
1079 $yearHolidays = [];
1080
1081 if (isset($calendarSettings['week_holidays']))
1082 {
1083 $weekDays = ['SU' => 0, 'MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6];
1084 $weekHolidays = [];
1085 foreach ($calendarSettings['week_holidays'] as $day)
1086 $weekHolidays[] = $weekDays[$day];
1087 }
1088
1089 if (isset($calendarSettings['year_holidays']))
1090 {
1091 foreach (explode(',', $calendarSettings['year_holidays']) as $yearHoliday)
1092 {
1093 $date = explode('.', trim($yearHoliday));
1094 if (count($date) == 2 && $date[0] && $date[1])
1095 $yearHolidays[] = (int)$date[0] . '.' . (int)$date[1];
1096 }
1097 }
1098 static::$weekHolidays = $weekHolidays;
1099 static::$yearHolidays = $yearHolidays;
1100 }
1101
1102 return [static::$weekHolidays, static::$yearHolidays];
1103 }
1104
1105 private function getCalendarWorkTime()
1106 {
1107 if (static::$startWorkDay === null)
1108 {
1109 $startSeconds = 0;
1110 $endSeconds = 24 * 3600 - 1;
1111
1112 $calendarSettings = CCalendar::GetSettings();
1113 if (!empty($calendarSettings['work_time_start']))
1114 {
1115 $time = explode('.', $calendarSettings['work_time_start']);
1116 $startSeconds = $time[0] * 3600;
1117 if (!empty($time[1]))
1118 $startSeconds += $time[1] * 60;
1119 }
1120
1121 if (!empty($calendarSettings['work_time_end']))
1122 {
1123 $time = explode('.', $calendarSettings['work_time_end']);
1124 $endSeconds = $time[0] * 3600;
1125 if (!empty($time[1]))
1126 $endSeconds += $time[1] * 60;
1127 }
1128 static::$startWorkDay = $startSeconds;
1129 static::$endWorkDay = $endSeconds;
1130 }
1131 return [static::$startWorkDay, static::$endWorkDay];
1132 }
1133
1134 private function getCalendarWorkdays()
1135 {
1136 if (static::$yearWorkdays === null)
1137 {
1138 $yearWorkdays = [];
1139
1140 $calendarSettings = CCalendar::GetSettings();
1141 $calendarYearWorkdays = $calendarSettings['year_workdays'] ?? '';
1142
1143 foreach (explode(',', $calendarYearWorkdays) as $yearWorkday)
1144 {
1145 $date = explode('.', trim($yearWorkday));
1146 if (count($date) === 2 && $date[0] && $date[1])
1147 {
1148 $yearWorkdays[] = (int)$date[0] . '.' . (int)$date[1];
1149 }
1150 }
1151
1152 static::$yearWorkdays = $yearWorkdays;
1153 }
1154
1155 return [static::$yearWorkdays];
1156 }
1157
1158 private function getDateTimeObject($date)
1159 {
1160 if ($date instanceof Bizproc\BaseType\Value\Date)
1161 {
1162 return (new \DateTime())->setTimestamp($date->getTimestamp());
1163 }
1164
1165 $df = Main\Type\DateTime::getFormat();
1166 $df2 = Main\Type\Date::getFormat();
1167 $date1Formatted = \DateTime::createFromFormat($df, $date);
1168 if ($date1Formatted === false)
1169 {
1170 $date1Formatted = \DateTime::createFromFormat($df2, $date);
1171 if ($date1Formatted)
1172 {
1173 $date1Formatted->setTime(0, 0);
1174 }
1175 }
1176 return $date1Formatted;
1177 }
1178
1179 private function getDateTimeOffset($date)
1180 {
1181 if ($date instanceof Bizproc\BaseType\Value\Date)
1182 {
1183 return $date->getOffset();
1184 }
1185 return 0;
1186 }
1187
1188 private function frameSymbolsInDateFormat($format)
1189 {
1190 $complexSymbols = ['j F', 'd F', 'jS F'];
1191 $symbols = ['D', 'l', 'F', 'M', 'r'];
1192
1193 $frameRule = [];
1194 foreach ($symbols as $symbol)
1195 {
1196 $frameRule[$symbol] = '#' . $symbol . '#';
1197 $frameRule['\\' . $symbol] = '\\' . $symbol;
1198 }
1199 foreach ($complexSymbols as $symbol)
1200 {
1201 $frameRule[$symbol] = substr($symbol, 0, -1) . '#' . $symbol[-1] . '_1#';
1202 $frameRule['\\' . $symbol] = '\\' . substr($symbol, 0, -1) . '#' . $symbol[-1] . '#';
1203 }
1204
1205 return strtr($format, $frameRule);
1206 }
1207
1208 private function frameNamesInFormattedDateRFC2822($formattedDate)
1209 {
1210 $matches = [];
1211 $pattern = "/#(\w{3}), \d{2} (\w{3}) \d{4} \d{2}:\d{2}:\d{2} [+-]\d{4}#/";
1212 if (preg_match_all($pattern, $formattedDate, $matches))
1213 {
1214 foreach ($matches[0] as $key => $match)
1215 {
1216 $day = $matches[1][$key];
1217 $month = $matches[2][$key];
1218
1219 $reformMatch = str_replace(
1220 [$day, $month],
1221 ['#' . $day . '#', '#' . $month . '#'],
1222 $match
1223 );
1224 $reformMatch = substr($reformMatch, 1, -1);
1225
1226 $formattedDate = str_replace($match, $reformMatch, $formattedDate);
1227 }
1228 }
1229
1230 return $formattedDate;
1231 }
1232
1233 private function replaceDateToLocDate($formattedDate, $format)
1234 {
1235 $lenShortName = 3;
1236 $dayNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
1237 $monthNames = [
1238 'January',
1239 'February',
1240 'March',
1241 'April',
1242 'May',
1243 'June',
1244 'July',
1245 'August',
1246 'September',
1247 'October',
1248 'November',
1249 'December',
1250 ];
1251
1252 if (strpos($format, '#r#') !== false)
1253 {
1254 $formattedDate = $this->frameNamesInFormattedDateRFC2822($formattedDate);
1255 }
1256
1257 $replacementRule = [];
1258 foreach (array_merge($dayNames, $monthNames) as $name)
1259 {
1260 $replacementRule['#' . $name . '#'] = GetMessage(
1261 'BPCGCALC_LOCDATE_' . strtoupper($name)
1262 );
1263 $shortName = substr($name, 0, $lenShortName);
1264 $replacementRule['#' . $shortName . '#'] = GetMessage(
1265 'BPCGCALC_LOCDATE_' . strtoupper($shortName) . '_SHORT'
1266 );
1267 }
1268 foreach ($monthNames as $monthName)
1269 {
1270 $replacementRule['#' . $monthName . '_1' . '#'] = GetMessage(
1271 'BPCGCALC_LOCDATE_' . strtoupper($monthName) . '_1'
1272 );
1273 }
1274
1275 return strtr($formattedDate, $replacementRule);
1276 }
1277
1278 /* String & Formatting */
1279
1280 private function functionNumberFormat($args)
1281 {
1282 $ar = $this->ArrgsToArray($args);
1283 $number = (float) array_shift($ar);
1284 $decimals = (int) (array_shift($ar) ?: 0);
1285 $decPoint = array_shift($ar);
1286 if ($decPoint === null)
1287 {
1288 $decPoint = '.';
1289 }
1290 $decPoint = (string) $decPoint;
1291
1292 $thousandsSeparator = array_shift($ar);
1293 if ($thousandsSeparator === null)
1294 {
1295 $thousandsSeparator = ',';
1296 }
1297 $thousandsSeparator = (string) $thousandsSeparator;
1298
1299 return number_format($number, $decimals, $decPoint, $thousandsSeparator);
1300 }
1301
1302 private function functionRandString($args)
1303 {
1304 $ar = $this->ArrgsToArray($args);
1305 $len = (int)array_shift($ar);
1306
1307 return \randString($len);
1308 }
1309
1310 private function functionSubstr($args)
1311 {
1312 if (!is_array($args))
1313 $args = [$args];
1314
1315 $ar = $this->ArrgsToArray($args);
1316 $str = array_shift($ar);
1317 $pos = (int)array_shift($ar);
1318 $len = (int)array_shift($ar);
1319
1320 if (($str == null) || ($str === ""))
1321 return null;
1322
1323 if ($len)
1324 {
1325 return mb_substr($str, $pos, $len);
1326 }
1327
1328 return mb_substr($str, $pos);
1329 }
1330
1331 private function functionStrpos($args)
1332 {
1333 $ar = $this->ArrgsToArray($args);
1334 $haystack = (string)array_shift($ar);
1335
1336 if (empty($haystack))
1337 {
1338 return false;
1339 }
1340
1341 $maxOffset = mb_strlen($haystack);
1342 $minOffset = -1 * $maxOffset;
1343
1344 $needle = (string)array_shift($ar);
1345 $offset = max($minOffset, min($maxOffset, (int)array_shift($ar)));
1346
1347 return mb_strpos($haystack, $needle, $offset);
1348 }
1349
1350 private function functionStrlen($args)
1351 {
1352 $ar = $this->ArrgsToArray($args);
1353 $str = array_shift($ar);
1354
1355 if (!is_scalar($str))
1356 {
1357 return null;
1358 }
1359
1360 $str = (string) $str;
1361 return mb_strlen($str);
1362 }
1363
1364 private function functionImplode($args)
1365 {
1366 $ar = (array) $args;
1367 $glue = (string)array_shift($ar);
1368 $pieces = \CBPHelper::MakeArrayFlat(array_shift($ar));
1369
1370 if (!$pieces)
1371 {
1372 return '';
1373 }
1374
1375 return implode($glue, $pieces);
1376 }
1377
1378 private function functionExplode($args)
1379 {
1380 $ar = (array) $args;
1381 $delimiter = array_shift($ar);
1382 $str = array_shift($ar);
1383
1384 if (is_array($str))
1385 {
1386 $str = reset($str);
1387 }
1388
1389 if (is_array($delimiter))
1390 {
1391 $delimiter = reset($delimiter);
1392 }
1393
1394 if (empty($delimiter) || !is_scalar($str) || !is_scalar($delimiter))
1395 {
1396 return null;
1397 }
1398
1399 $str = (string) $str;
1400 return explode($delimiter, $str);
1401 }
1402
1403 private function functionUrlencode($args)
1404 {
1405 $ar = $this->ArrgsToArray($args);
1406 $str = array_shift($ar);
1407
1408 if (!is_scalar($str))
1409 {
1410 if (is_array($str))
1411 {
1412 $str = implode(", ", CBPHelper::MakeArrayFlat($str));
1413 }
1414 else
1415 {
1416 return null;
1417 }
1418 }
1419
1420 $str = (string) $str;
1421 return urlencode($str);
1422 }
1423
1424 private function functionConvert($args)
1425 {
1426 if (!is_array($args))
1427 $args = [$args];
1428
1429 $ar = $this->ArrgsToArray($args);
1430 $val = array_shift($ar);
1431 $type = array_shift($ar);
1432 $attr = array_shift($ar);
1433
1434 $type = mb_strtolower($type);
1435 if ($type === 'printableuserb24')
1436 {
1437 $result = [];
1438
1439 $users = CBPHelper::StripUserPrefix($val);
1440 if (!is_array($users))
1441 $users = [$users];
1442
1443 foreach ($users as $userId)
1444 {
1445 $db = CUser::GetByID($userId);
1446 if ($ar = $db->GetNext())
1447 {
1448 $ix = randString(5);
1449 $attr = (!empty($attr) ? 'href="'.$attr.'"' : 'href="#" onClick="return false;"');
1450 $result[] = '<a class="feed-post-user-name" id="bp_'.$userId.'_'.$ix.'" '.$attr.' bx-post-author-id="'.$userId.'" bx-post-author-gender="'.$ar['PERSONAL_GENDER'].'" bx-tooltip-user-id="'.$userId.'">'.CUser::FormatName(CSite::GetNameFormat(false), $ar, false).'</a>';
1451 }
1452 }
1453
1454 $result = implode(", ", $result);
1455 }
1456 elseif ($type == 'printableuser')
1457 {
1458 $result = [];
1459
1460 $users = CBPHelper::StripUserPrefix($val);
1461 if (!is_array($users))
1462 $users = [$users];
1463
1464 foreach ($users as $userId)
1465 {
1466 $db = CUser::GetByID($userId);
1467 if ($ar = $db->GetNext())
1468 $result[] = CUser::FormatName(CSite::GetNameFormat(false), $ar, false);
1469 }
1470
1471 $result = implode(", ", $result);
1472
1473 }
1474 else
1475 {
1476 $result = $val;
1477 }
1478
1479 return $result;
1480 }
1481
1482 private function functionStrtolower($args)
1483 {
1484 $ar = $this->ArrgsToArray($args);
1485 $str = array_shift($ar);
1486
1487 if (!is_scalar($str))
1488 {
1489 return null;
1490 }
1491
1492 return mb_strtolower((string) $str);
1493 }
1494
1495 private function functionStrtoupper($args)
1496 {
1497 $ar = $this->ArrgsToArray($args);
1498 $str = array_shift($ar);
1499
1500 if (!is_scalar($str))
1501 {
1502 return null;
1503 }
1504
1505 return mb_strtoupper((string) $str);
1506 }
1507
1508 private function functionUcwords($args)
1509 {
1510 $ar = $this->ArrgsToArray($args);
1511 $str = array_shift($ar);
1512
1513 if (!is_scalar($str))
1514 {
1515 return null;
1516 }
1517
1518 return mb_convert_case((string) $str, MB_CASE_TITLE);
1519 }
1520
1521 private function functionUcfirst($args)
1522 {
1523 $ar = $this->ArrgsToArray($args);
1524 $str = array_shift($ar);
1525
1526 if (!is_scalar($str))
1527 {
1528 return null;
1529 }
1530
1531 return $this->mb_ucfirst((string) $str);
1532 }
1533
1534 private function mb_ucfirst($str)
1535 {
1536 $len = mb_strlen($str);
1537 $firstChar = mb_substr($str, 0, 1);
1538 $otherChars = mb_substr($str, 1, $len - 1);
1539 return mb_strtoupper($firstChar) . $otherChars;
1540 }
1541
1542 private function functionTrim($args)
1543 {
1544 $array = $this->ArrgsToArray($args);
1545 if (empty($array))
1546 {
1547 return null;
1548 }
1549
1550 $result = [];
1551 foreach ($array as $str)
1552 {
1553 if (is_scalar($str) || (is_object($str) && method_exists($str, '__toString')))
1554 {
1555 $result[] = trim((string)$str);
1556
1557 continue;
1558 }
1559
1560 return null;
1561 }
1562
1563 return count($result) > 1 ? $result : $result[0];
1564 }
1565
1566 /* Complex values */
1567
1568 private function functionMerge($args)
1569 {
1570 if (!is_array($args))
1571 $args = [];
1572
1573 foreach ($args as &$a)
1574 {
1575 $a = is_object($a) ? [$a] : (array)$a;
1576 }
1577 return call_user_func_array('array_merge', $args);
1578 }
1579
1580 private function functionShuffle($args)
1581 {
1582 if (!is_array($args) || $args === [])
1583 {
1584 return null;
1585 }
1586
1587 $array = $this->ArrgsToArray($args);
1588 shuffle($array);
1589
1590 return $array;
1591 }
1592
1593 private function functionFirstValue($args)
1594 {
1595 $ar = $this->ArrgsToArray($args);
1596
1597 return $ar[0] ?? null;
1598 }
1599
1600 private function functionSwirl($args)
1601 {
1602 $ar = $this->ArrgsToArray($args);
1603 if (count($ar) <= 1)
1604 {
1605 return $ar[0] ?? null;
1606 }
1607
1608 return array_merge(array_slice($ar, 1), [$ar[0]]);
1609 }
1610
1611 private function functionGetDocumentUrl($args)
1612 {
1613 $ar = $this->ArrgsToArray($args);
1614 $format = array_shift($ar);
1615 $external = array_shift($ar);
1616
1617 $url = $this->activity->workflow->getService('DocumentService')->GetDocumentAdminPage(
1618 $this->activity->getDocumentId()
1619 );
1620 $name = null;
1621
1622 if ($external)
1623 {
1624 $url = Main\Engine\UrlManager::getInstance()->getHostUrl() . $url;
1625 }
1626
1627 if ($format === 'bb' || $format === 'html')
1628 {
1629 $name = $this->activity->workflow->getService('DocumentService')->getDocumentName(
1630 $this->activity->getDocumentId()
1631 );
1632 }
1633
1634 if ($format === 'bb')
1635 {
1636 return sprintf(
1637 '[url=%s]%s[/url]',
1638 $url,
1639 $name
1640 );
1641 }
1642
1643 if ($format === 'html')
1644 {
1645 return sprintf(
1646 '<a href="%s" target="_blank">%s</a>',
1647 $url,
1649 );
1650 }
1651
1652 return $url;
1653 }
1654}
$type
Определения options.php:106
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static GetByID($ID)
Определения user.php:3820
static FormatName($NAME_TEMPLATE, $arUser, $bUseLogin=false, $bHTMLSpec=true, $enabledEmptyNameStub=true)
Определения user.php:5614
Определения activity.php:8
const ValuePattern
Определения activity.php:26
Определения calc.php:7
const Constant
Определения calc.php:90
getErrors()
Определения calc.php:111
__construct(CBPActivity $activity)
Определения calc.php:92
const Variable
Определения calc.php:89
calculate($text)
Определения calc.php:279
const Operation
Определения calc.php:88
static GetSettings($params=[])
Определения calendar.php:4717
static GetOffset($USER_ID=null, $forced=false)
Определения time.php:193
$str
Определения commerceml2.php:63
$hours
Определения cron_html_pages.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$p
Определения group_list_element_edit.php:23
const FORMAT_DATETIME
Определения include.php:64
const FORMAT_DATE
Определения include.php:63
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetMessage($name, $aReplace=null)
Определения tools.php:3397
AddToTimeStamp($arrAdd, $stmp=false)
Определения tools.php:687
randString($pass_len=10, $pass_chars=false)
Определения tools.php:2154
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538
$name
Определения menu_edit.php:35
$user
Определения mysql_to_pgsql.php:33
$time
Определения payment.php:61
$delta
Определения prolog_main_admin.php:363
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
if(empty($signedUserToken)) $key
Определения quickway.php:257
$text
Определения template_pdf.php:79
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$precision
Определения template.php:403
else $a
Определения template.php:137
$val
Определения options.php:1793
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20
$matches
Определения index.php:22
$error
Определения subscription_card_product.php:20
$max
Определения template_copy.php:262
$url
Определения iframe.php:7