xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Core / DAO / Worldregion.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
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+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Core/Worldregion.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:710a568363468092ddc0fc7d1b14abd1)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Core_DAO_Worldregion extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_worldregion';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = false;
83 /**
84 * Country Id
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Region name to be associated with countries
91 *
92 * @var string
93 */
94 public $name;
95 /**
96 * class constructor
97 *
98 * @return civicrm_worldregion
99 */
100 function __construct() {
101 $this->__table = 'civicrm_worldregion';
102 parent::__construct();
103 }
104 /**
105 * Returns all the column names of this table
106 *
107 * @return array
108 */
109 static function &fields() {
110 if (!(self::$_fields)) {
111 self::$_fields = array(
112 'id' => array(
113 'name' => 'id',
114 'type' => CRM_Utils_Type::T_INT,
115 'title' => ts('World Region ID') ,
116 'description' => 'Country Id',
117 'required' => true,
118 ) ,
119 'world_region' => array(
120 'name' => 'name',
121 'type' => CRM_Utils_Type::T_STRING,
122 'title' => ts('World Region') ,
123 'description' => 'Region name to be associated with countries',
124 'maxlength' => 128,
125 'size' => CRM_Utils_Type::HUGE,
126 'export' => true,
127 'where' => 'civicrm_worldregion.name',
128 'headerPattern' => '',
129 'dataPattern' => '',
130 ) ,
131 );
132 }
133 return self::$_fields;
134 }
135 /**
136 * Returns an array containing, for each field, the arary key used for that
137 * field in self::$_fields.
138 *
139 * @return array
140 */
141 static function &fieldKeys() {
142 if (!(self::$_fieldKeys)) {
143 self::$_fieldKeys = array(
144 'id' => 'id',
145 'name' => 'world_region',
146 );
147 }
148 return self::$_fieldKeys;
149 }
150 /**
151 * Returns the names of this table
152 *
153 * @return string
154 */
155 static function getTableName() {
156 return self::$_tableName;
157 }
158 /**
159 * Returns if this table needs to be logged
160 *
161 * @return boolean
162 */
163 function getLog() {
164 return self::$_log;
165 }
166 /**
167 * Returns the list of fields that can be imported
168 *
169 * @param bool $prefix
170 *
171 * @return array
172 */
173 static function &import($prefix = false) {
174 if (!(self::$_import)) {
175 self::$_import = array();
176 $fields = self::fields();
177 foreach($fields as $name => $field) {
178 if (CRM_Utils_Array::value('import', $field)) {
179 if ($prefix) {
180 self::$_import['worldregion'] = & $fields[$name];
181 } else {
182 self::$_import[$name] = & $fields[$name];
183 }
184 }
185 }
186 }
187 return self::$_import;
188 }
189 /**
190 * Returns the list of fields that can be exported
191 *
192 * @param bool $prefix
193 *
194 * @return array
195 */
196 static function &export($prefix = false) {
197 if (!(self::$_export)) {
198 self::$_export = array();
199 $fields = self::fields();
200 foreach($fields as $name => $field) {
201 if (CRM_Utils_Array::value('export', $field)) {
202 if ($prefix) {
203 self::$_export['worldregion'] = & $fields[$name];
204 } else {
205 self::$_export[$name] = & $fields[$name];
206 }
207 }
208 }
209 }
210 return self::$_export;
211 }
212}