Merge pull request #15785 from eileenmcnaughton/contribution_url_params
[civicrm-core.git] / CRM / Activity / Import / Field.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_Activity_Import_Field {
18
19 /**
20 * @var string
21 * Name of the field
22 */
23 public $_name;
24
25 /**
26 * Title of the field to be used in display
27 * @var string
28 */
29 public $_title;
30
31 /**
32 * Type of field
33 * @var enum
34 */
35 public $_type;
36
37 /**
38 * Is this field required
39 * @var bool
40 */
41 public $_required;
42
43 /**
44 * Data to be carried for use by a derived class
45 * @var object
46 */
47 public $_payload;
48
49 /**
50 * Regexp to match the CSV header of this column/field
51 * @var string
52 */
53 public $_headerPattern;
54
55 /**
56 * Regexp to match the pattern of data from various column/fields
57 * @var string
58 */
59 public $_dataPattern;
60
61 /**
62 * Value of this field
63 * @var object
64 */
65 public $_value;
66
67 /**
68 * @param string $name
69 * @param $title
70 * @param int $type
71 * @param string $headerPattern
72 * @param string $dataPattern
73 */
74 public function __construct($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
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
84 public function resetValue() {
85 $this->_value = NULL;
86 }
87
88 /**
89 * The value is in string format. convert the value to the type of this field
90 * and set the field value with the appropriate type
91 * @param $value
92 */
93 public function setValue($value) {
94 $this->_value = $value;
95 }
96
97 /**
98 * @return bool
99 */
100 public function validate() {
101
102 if (CRM_Utils_System::isNull($this->_value)) {
103 return TRUE;
104 }
105 return TRUE;
106 }
107
108 }