Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | class CRM_Activity_Import_Field { | |
34 | ||
6a488035 | 35 | /** |
3819f101 | 36 | * @var string |
37 | * Name of the field | |
6a488035 TO |
38 | */ |
39 | public $_name; | |
40 | ||
41 | /** | |
100fef9d | 42 | * Title of the field to be used in display |
62d3ee27 | 43 | * @var string |
6a488035 TO |
44 | */ |
45 | public $_title; | |
46 | ||
47 | /** | |
100fef9d | 48 | * Type of field |
6a488035 TO |
49 | * @var enum |
50 | */ | |
51 | public $_type; | |
52 | ||
53 | /** | |
100fef9d | 54 | * Is this field required |
6a488035 TO |
55 | * @var boolean |
56 | */ | |
57 | public $_required; | |
58 | ||
59 | /** | |
100fef9d | 60 | * Data to be carried for use by a derived class |
6a488035 TO |
61 | * @var object |
62 | */ | |
63 | public $_payload; | |
64 | ||
65 | /** | |
100fef9d | 66 | * Regexp to match the CSV header of this column/field |
6a488035 TO |
67 | * @var string |
68 | */ | |
69 | public $_headerPattern; | |
70 | ||
71 | /** | |
100fef9d | 72 | * Regexp to match the pattern of data from various column/fields |
6a488035 TO |
73 | * @var string |
74 | */ | |
75 | public $_dataPattern; | |
76 | ||
77 | /** | |
100fef9d | 78 | * Value of this field |
6a488035 TO |
79 | * @var object |
80 | */ | |
81 | public $_value; | |
ffd93213 EM |
82 | |
83 | /** | |
100fef9d | 84 | * @param string $name |
ffd93213 EM |
85 | * @param $title |
86 | * @param int $type | |
87 | * @param string $headerPattern | |
88 | * @param string $dataPattern | |
89 | */ | |
00be9182 | 90 | public function __construct($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') { |
6a488035 TO |
91 | $this->_name = $name; |
92 | $this->_title = $title; | |
93 | $this->_type = $type; | |
94 | $this->_headerPattern = $headerPattern; | |
95 | $this->_dataPattern = $dataPattern; | |
96 | ||
97 | $this->_value = NULL; | |
98 | } | |
99 | ||
00be9182 | 100 | public function resetValue() { |
6a488035 TO |
101 | $this->_value = NULL; |
102 | } | |
103 | ||
104 | /** | |
100fef9d | 105 | * The value is in string format. convert the value to the type of this field |
6a488035 | 106 | * and set the field value with the appropriate type |
645ee340 | 107 | * @param $value |
6a488035 | 108 | */ |
00be9182 | 109 | public function setValue($value) { |
6a488035 TO |
110 | $this->_value = $value; |
111 | } | |
112 | ||
ffd93213 EM |
113 | /** |
114 | * @return bool | |
115 | */ | |
00be9182 | 116 | public function validate() { |
6a488035 TO |
117 | |
118 | if (CRM_Utils_System::isNull($this->_value)) { | |
119 | return TRUE; | |
120 | } | |
121 | return TRUE; | |
122 | } | |
96025800 | 123 | |
6a488035 | 124 | } |