Add titles and icons to entities
[civicrm-core.git] / CRM / Core / DAO / Country.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Country.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0e0ebf773f04ad229c4165fe05f63345)
10 */
11
12 /**
13 * Database access object for the Country entity.
14 */
15 class CRM_Core_DAO_Country extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_country';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = FALSE;
30
31 /**
32 * Country Id
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Country Name
40 *
41 * @var string
42 */
43 public $name;
44
45 /**
46 * ISO Code
47 *
48 * @var string
49 */
50 public $iso_code;
51
52 /**
53 * National prefix to be used when dialing TO this country.
54 *
55 * @var string
56 */
57 public $country_code;
58
59 /**
60 * Foreign key to civicrm_address_format.id.
61 *
62 * @var int
63 */
64 public $address_format_id;
65
66 /**
67 * International direct dialing prefix from within the country TO another country
68 *
69 * @var string
70 */
71 public $idd_prefix;
72
73 /**
74 * Access prefix to call within a country to a different area
75 *
76 * @var string
77 */
78 public $ndd_prefix;
79
80 /**
81 * Foreign key to civicrm_worldregion.id.
82 *
83 * @var int
84 */
85 public $region_id;
86
87 /**
88 * Should state/province be displayed as abbreviation for contacts from this country?
89 *
90 * @var bool
91 */
92 public $is_province_abbreviated;
93
94 /**
95 * Class constructor.
96 */
97 public function __construct() {
98 $this->__table = 'civicrm_country';
99 parent::__construct();
100 }
101
102 /**
103 * Returns localized title of this entity.
104 */
105 public static function getEntityTitle() {
106 return ts('Countries');
107 }
108
109 /**
110 * Returns foreign keys and entity references.
111 *
112 * @return array
113 * [CRM_Core_Reference_Interface]
114 */
115 public static function getReferenceColumns() {
116 if (!isset(Civi::$statics[__CLASS__]['links'])) {
117 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
118 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
119 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
120 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
121 }
122 return Civi::$statics[__CLASS__]['links'];
123 }
124
125 /**
126 * Returns all the column names of this table
127 *
128 * @return array
129 */
130 public static function &fields() {
131 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
132 Civi::$statics[__CLASS__]['fields'] = [
133 'id' => [
134 'name' => 'id',
135 'type' => CRM_Utils_Type::T_INT,
136 'title' => ts('Country ID'),
137 'description' => ts('Country Id'),
138 'required' => TRUE,
139 'where' => 'civicrm_country.id',
140 'table_name' => 'civicrm_country',
141 'entity' => 'Country',
142 'bao' => 'CRM_Core_BAO_Country',
143 'localizable' => 0,
144 ],
145 'name' => [
146 'name' => 'name',
147 'type' => CRM_Utils_Type::T_STRING,
148 'title' => ts('Country'),
149 'description' => ts('Country Name'),
150 'maxlength' => 64,
151 'size' => CRM_Utils_Type::BIG,
152 'import' => TRUE,
153 'where' => 'civicrm_country.name',
154 'headerPattern' => '/country/i',
155 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
156 'export' => TRUE,
157 'table_name' => 'civicrm_country',
158 'entity' => 'Country',
159 'bao' => 'CRM_Core_BAO_Country',
160 'localizable' => 0,
161 ],
162 'iso_code' => [
163 'name' => 'iso_code',
164 'type' => CRM_Utils_Type::T_STRING,
165 'title' => ts('Country ISO Code'),
166 'description' => ts('ISO Code'),
167 'maxlength' => 2,
168 'size' => CRM_Utils_Type::TWO,
169 'where' => 'civicrm_country.iso_code',
170 'table_name' => 'civicrm_country',
171 'entity' => 'Country',
172 'bao' => 'CRM_Core_BAO_Country',
173 'localizable' => 0,
174 ],
175 'country_code' => [
176 'name' => 'country_code',
177 'type' => CRM_Utils_Type::T_STRING,
178 'title' => ts('Country Phone Prefix'),
179 'description' => ts('National prefix to be used when dialing TO this country.'),
180 'maxlength' => 4,
181 'size' => CRM_Utils_Type::FOUR,
182 'where' => 'civicrm_country.country_code',
183 'table_name' => 'civicrm_country',
184 'entity' => 'Country',
185 'bao' => 'CRM_Core_BAO_Country',
186 'localizable' => 0,
187 ],
188 'address_format_id' => [
189 'name' => 'address_format_id',
190 'type' => CRM_Utils_Type::T_INT,
191 'title' => ts('Address Format'),
192 'description' => ts('Foreign key to civicrm_address_format.id.'),
193 'where' => 'civicrm_country.address_format_id',
194 'table_name' => 'civicrm_country',
195 'entity' => 'Country',
196 'bao' => 'CRM_Core_BAO_Country',
197 'localizable' => 0,
198 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
199 ],
200 'idd_prefix' => [
201 'name' => 'idd_prefix',
202 'type' => CRM_Utils_Type::T_STRING,
203 'title' => ts('Outgoing Phone Prefix'),
204 'description' => ts('International direct dialing prefix from within the country TO another country'),
205 'maxlength' => 4,
206 'size' => CRM_Utils_Type::FOUR,
207 'where' => 'civicrm_country.idd_prefix',
208 'table_name' => 'civicrm_country',
209 'entity' => 'Country',
210 'bao' => 'CRM_Core_BAO_Country',
211 'localizable' => 0,
212 ],
213 'ndd_prefix' => [
214 'name' => 'ndd_prefix',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Area Code'),
217 'description' => ts('Access prefix to call within a country to a different area'),
218 'maxlength' => 4,
219 'size' => CRM_Utils_Type::FOUR,
220 'where' => 'civicrm_country.ndd_prefix',
221 'table_name' => 'civicrm_country',
222 'entity' => 'Country',
223 'bao' => 'CRM_Core_BAO_Country',
224 'localizable' => 0,
225 ],
226 'region_id' => [
227 'name' => 'region_id',
228 'type' => CRM_Utils_Type::T_INT,
229 'title' => ts('World Region ID'),
230 'description' => ts('Foreign key to civicrm_worldregion.id.'),
231 'required' => TRUE,
232 'where' => 'civicrm_country.region_id',
233 'table_name' => 'civicrm_country',
234 'entity' => 'Country',
235 'bao' => 'CRM_Core_BAO_Country',
236 'localizable' => 0,
237 'localize_context' => 'country',
238 'FKClassName' => 'CRM_Core_DAO_Worldregion',
239 'pseudoconstant' => [
240 'table' => 'civicrm_worldregion',
241 'keyColumn' => 'id',
242 'labelColumn' => 'name',
243 ],
244 ],
245 'is_province_abbreviated' => [
246 'name' => 'is_province_abbreviated',
247 'type' => CRM_Utils_Type::T_BOOLEAN,
248 'title' => ts('Abbreviate Province?'),
249 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
250 'where' => 'civicrm_country.is_province_abbreviated',
251 'default' => '0',
252 'table_name' => 'civicrm_country',
253 'entity' => 'Country',
254 'bao' => 'CRM_Core_BAO_Country',
255 'localizable' => 0,
256 ],
257 ];
258 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
259 }
260 return Civi::$statics[__CLASS__]['fields'];
261 }
262
263 /**
264 * Return a mapping from field-name to the corresponding key (as used in fields()).
265 *
266 * @return array
267 * Array(string $name => string $uniqueName).
268 */
269 public static function &fieldKeys() {
270 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
271 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
272 }
273 return Civi::$statics[__CLASS__]['fieldKeys'];
274 }
275
276 /**
277 * Returns the names of this table
278 *
279 * @return string
280 */
281 public static function getTableName() {
282 return self::$_tableName;
283 }
284
285 /**
286 * Returns if this table needs to be logged
287 *
288 * @return bool
289 */
290 public function getLog() {
291 return self::$_log;
292 }
293
294 /**
295 * Returns the list of fields that can be imported
296 *
297 * @param bool $prefix
298 *
299 * @return array
300 */
301 public static function &import($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, []);
303 return $r;
304 }
305
306 /**
307 * Returns the list of fields that can be exported
308 *
309 * @param bool $prefix
310 *
311 * @return array
312 */
313 public static function &export($prefix = FALSE) {
314 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, []);
315 return $r;
316 }
317
318 /**
319 * Returns the list of indices
320 *
321 * @param bool $localize
322 *
323 * @return array
324 */
325 public static function indices($localize = TRUE) {
326 $indices = [
327 'UI_name_iso_code' => [
328 'name' => 'UI_name_iso_code',
329 'field' => [
330 0 => 'name',
331 1 => 'iso_code',
332 ],
333 'localizable' => FALSE,
334 'unique' => TRUE,
335 'sig' => 'civicrm_country::1::name::iso_code',
336 ],
337 ];
338 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
339 }
340
341 }