Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | class CRM_Activity_Import_Field { | |
18 | ||
6a488035 | 19 | /** |
3819f101 | 20 | * @var string |
21 | * Name of the field | |
6a488035 TO |
22 | */ |
23 | public $_name; | |
24 | ||
25 | /** | |
100fef9d | 26 | * Title of the field to be used in display |
62d3ee27 | 27 | * @var string |
6a488035 TO |
28 | */ |
29 | public $_title; | |
30 | ||
31 | /** | |
100fef9d | 32 | * Type of field |
6a488035 TO |
33 | * @var enum |
34 | */ | |
35 | public $_type; | |
36 | ||
37 | /** | |
100fef9d | 38 | * Is this field required |
d51c6add | 39 | * @var bool |
6a488035 TO |
40 | */ |
41 | public $_required; | |
42 | ||
43 | /** | |
100fef9d | 44 | * Data to be carried for use by a derived class |
6a488035 TO |
45 | * @var object |
46 | */ | |
47 | public $_payload; | |
48 | ||
49 | /** | |
100fef9d | 50 | * Regexp to match the CSV header of this column/field |
6a488035 TO |
51 | * @var string |
52 | */ | |
53 | public $_headerPattern; | |
54 | ||
55 | /** | |
100fef9d | 56 | * Regexp to match the pattern of data from various column/fields |
6a488035 TO |
57 | * @var string |
58 | */ | |
59 | public $_dataPattern; | |
60 | ||
61 | /** | |
100fef9d | 62 | * Value of this field |
6a488035 TO |
63 | * @var object |
64 | */ | |
65 | public $_value; | |
ffd93213 EM |
66 | |
67 | /** | |
100fef9d | 68 | * @param string $name |
ffd93213 EM |
69 | * @param $title |
70 | * @param int $type | |
71 | * @param string $headerPattern | |
72 | * @param string $dataPattern | |
73 | */ | |
00be9182 | 74 | public function __construct($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') { |
6a488035 TO |
75 | $this->_name = $name; |
76 | $this->_title = $title; | |
77 | $this->_type = $type; | |
78 | $this->_headerPattern = $headerPattern; | |
79 | $this->_dataPattern = $dataPattern; | |
80 | ||
81 | $this->_value = NULL; | |
82 | } | |
83 | ||
00be9182 | 84 | public function resetValue() { |
6a488035 TO |
85 | $this->_value = NULL; |
86 | } | |
87 | ||
88 | /** | |
100fef9d | 89 | * The value is in string format. convert the value to the type of this field |
6a488035 | 90 | * and set the field value with the appropriate type |
645ee340 | 91 | * @param $value |
6a488035 | 92 | */ |
00be9182 | 93 | public function setValue($value) { |
6a488035 TO |
94 | $this->_value = $value; |
95 | } | |
96 | ||
ffd93213 EM |
97 | /** |
98 | * @return bool | |
99 | */ | |
00be9182 | 100 | public function validate() { |
6a488035 TO |
101 | |
102 | if (CRM_Utils_System::isNull($this->_value)) { | |
103 | return TRUE; | |
104 | } | |
105 | return TRUE; | |
106 | } | |
96025800 | 107 | |
6a488035 | 108 | } |