Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
inttype.php
1<?php
3
6
7Loc::loadMessages(__FILE__);
8
13class IntType extends Double
14{
15
19 public static function getType()
20 {
21 return FieldType::INT;
22 }
23
31 public static function toSingleValue(FieldType $fieldType, $value)
32 {
33 if (is_array($value))
34 {
35 reset($value);
36 $value = current($value);
37 }
38 return $value;
39 }
40
47 protected static function extractValue(FieldType $fieldType, array $field, array $request)
48 {
49 $value = Base::extractValue($fieldType, $field, $request);
50
51 if ($value !== null && is_string($value) && $value <> '')
52 {
53 if (\CBPActivity::isExpression($value))
54 return $value;
55
56 $value = str_replace(' ', '', $value);
57 if (preg_match('#^[0-9\-]+$#', $value))
58 {
59 $value = (int) $value;
60 }
61 else
62 {
63 $value = null;
64 static::addError(array(
65 'code' => 'ErrorValue',
66 'message' => Loc::getMessage('BPDT_INT_INVALID'),
67 'parameter' => static::generateControlName($field),
68 ));
69 }
70 }
71 elseif (is_numeric($value))
72 {
73 $value = (int)$value;
74 }
75 else
76 {
77 $value = null;
78 }
79
80 return $value;
81 }
82}
static extractValue(FieldType $fieldType, array $field, array $request)
Definition inttype.php:47
static toSingleValue(FieldType $fieldType, $value)
Definition inttype.php:31
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29