Ian province abbreviation patch - issue 724
[civicrm-core.git] / CRM / Activity / Import / Field.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7e9e8871 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035
TO
32 */
33class 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
6a488035
TO
43 */
44 public $_title;
45
46 /**
100fef9d 47 * Type of field
6a488035
TO
48 * @var enum
49 */
50 public $_type;
51
52 /**
100fef9d 53 * Is this field required
6a488035
TO
54 * @var boolean
55 */
56 public $_required;
57
58 /**
100fef9d 59 * Data to be carried for use by a derived class
6a488035
TO
60 * @var object
61 */
62 public $_payload;
63
64 /**
100fef9d 65 * Regexp to match the CSV header of this column/field
6a488035
TO
66 * @var string
67 */
68 public $_headerPattern;
69
70 /**
100fef9d 71 * Regexp to match the pattern of data from various column/fields
6a488035
TO
72 * @var string
73 */
74 public $_dataPattern;
75
76 /**
100fef9d 77 * Value of this field
6a488035
TO
78 * @var object
79 */
80 public $_value;
ffd93213
EM
81
82 /**
100fef9d 83 * @param string $name
ffd93213
EM
84 * @param $title
85 * @param int $type
86 * @param string $headerPattern
87 * @param string $dataPattern
88 */
00be9182 89 public function __construct($name, $title, $type = CRM_Utils_Type::T_INT, $headerPattern = '//', $dataPattern = '//') {
6a488035
TO
90 $this->_name = $name;
91 $this->_title = $title;
92 $this->_type = $type;
93 $this->_headerPattern = $headerPattern;
94 $this->_dataPattern = $dataPattern;
95
96 $this->_value = NULL;
97 }
98
00be9182 99 public function resetValue() {
6a488035
TO
100 $this->_value = NULL;
101 }
102
103 /**
100fef9d 104 * The value is in string format. convert the value to the type of this field
6a488035 105 * and set the field value with the appropriate type
645ee340 106 * @param $value
6a488035 107 */
00be9182 108 public function setValue($value) {
6a488035
TO
109 $this->_value = $value;
110 }
111
ffd93213
EM
112 /**
113 * @return bool
114 */
00be9182 115 public function validate() {
6a488035
TO
116
117 if (CRM_Utils_System::isNull($this->_value)) {
118 return TRUE;
119 }
120 return TRUE;
121 }
96025800 122
6a488035 123}