Commit | Line | Data |
---|---|---|
fd1ea018 TO |
1 | <?php |
2 | ||
3 | /** | |
4 | * @package CRM | |
5 | * @copyright CiviCRM LLC https://civicrm.org/licensing | |
6 | * | |
7 | * Generated from xml/schema/CRM/Core/Translation.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
28979d65 | 9 | * (GenCodeChecksum:f0f986e6ba50631d51e09da061eb494a) |
fd1ea018 TO |
10 | */ |
11 | ||
12 | /** | |
13 | * Database access object for the Translation entity. | |
14 | */ | |
15 | class CRM_Core_DAO_Translation extends CRM_Core_DAO { | |
16 | const EXT = 'civicrm'; | |
17 | const TABLE_ADDED = '5.39'; | |
18 | ||
19 | /** | |
20 | * Static instance to hold the table name. | |
21 | * | |
22 | * @var string | |
23 | */ | |
24 | public static $_tableName = 'civicrm_translation'; | |
25 | ||
26 | /** | |
27 | * Should CiviCRM log any modifications to this table in the civicrm_log table. | |
28 | * | |
29 | * @var bool | |
30 | */ | |
31 | public static $_log = TRUE; | |
32 | ||
33 | /** | |
34 | * Unique String ID | |
35 | * | |
28979d65 CW |
36 | * @var int|string|null |
37 | * (SQL type: int unsigned) | |
38 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
39 | */ |
40 | public $id; | |
41 | ||
42 | /** | |
43 | * Table where referenced item is stored | |
44 | * | |
45 | * @var string | |
28979d65 CW |
46 | * (SQL type: varchar(64)) |
47 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
48 | */ |
49 | public $entity_table; | |
50 | ||
51 | /** | |
52 | * Field where referenced item is stored | |
53 | * | |
54 | * @var string | |
28979d65 CW |
55 | * (SQL type: varchar(64)) |
56 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
57 | */ |
58 | public $entity_field; | |
59 | ||
60 | /** | |
61 | * ID of the relevant entity. | |
62 | * | |
28979d65 CW |
63 | * @var int|string |
64 | * (SQL type: int) | |
65 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
66 | */ |
67 | public $entity_id; | |
68 | ||
69 | /** | |
70 | * Relevant language | |
71 | * | |
72 | * @var string | |
28979d65 CW |
73 | * (SQL type: varchar(5)) |
74 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
75 | */ |
76 | public $language; | |
77 | ||
78 | /** | |
79 | * Specify whether the string is active, draft, etc | |
80 | * | |
28979d65 CW |
81 | * @var int|string |
82 | * (SQL type: tinyint) | |
83 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
84 | */ |
85 | public $status_id; | |
86 | ||
87 | /** | |
88 | * Translated string | |
89 | * | |
28979d65 CW |
90 | * @var string |
91 | * (SQL type: longtext) | |
92 | * Note that values will be retrieved from the database as a string. | |
fd1ea018 TO |
93 | */ |
94 | public $string; | |
95 | ||
96 | /** | |
97 | * Class constructor. | |
98 | */ | |
99 | public function __construct() { | |
100 | $this->__table = 'civicrm_translation'; | |
101 | parent::__construct(); | |
102 | } | |
103 | ||
104 | /** | |
105 | * Returns localized title of this entity. | |
106 | * | |
107 | * @param bool $plural | |
108 | * Whether to return the plural version of the title. | |
109 | */ | |
110 | public static function getEntityTitle($plural = FALSE) { | |
111 | return $plural ? ts('Translated Strings') : ts('Translated String'); | |
112 | } | |
113 | ||
114 | /** | |
115 | * Returns foreign keys and entity references. | |
116 | * | |
117 | * @return array | |
118 | * [CRM_Core_Reference_Interface] | |
119 | */ | |
120 | public static function getReferenceColumns() { | |
121 | if (!isset(Civi::$statics[__CLASS__]['links'])) { | |
122 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); | |
123 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); | |
124 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); | |
125 | } | |
126 | return Civi::$statics[__CLASS__]['links']; | |
127 | } | |
128 | ||
129 | /** | |
130 | * Returns all the column names of this table | |
131 | * | |
132 | * @return array | |
133 | */ | |
134 | public static function &fields() { | |
135 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { | |
136 | Civi::$statics[__CLASS__]['fields'] = [ | |
137 | 'id' => [ | |
138 | 'name' => 'id', | |
139 | 'type' => CRM_Utils_Type::T_INT, | |
9fa6bb0b | 140 | 'title' => ts('Translated String ID'), |
fd1ea018 TO |
141 | 'description' => ts('Unique String ID'), |
142 | 'required' => TRUE, | |
143 | 'where' => 'civicrm_translation.id', | |
144 | 'table_name' => 'civicrm_translation', | |
145 | 'entity' => 'Translation', | |
9fa6bb0b | 146 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
147 | 'localizable' => 0, |
148 | 'readonly' => TRUE, | |
149 | 'add' => '5.39', | |
150 | ], | |
151 | 'entity_table' => [ | |
152 | 'name' => 'entity_table', | |
153 | 'type' => CRM_Utils_Type::T_STRING, | |
9fa6bb0b | 154 | 'title' => ts('Translated Entity'), |
fd1ea018 TO |
155 | 'description' => ts('Table where referenced item is stored'), |
156 | 'required' => TRUE, | |
157 | 'maxlength' => 64, | |
158 | 'size' => CRM_Utils_Type::BIG, | |
159 | 'where' => 'civicrm_translation.entity_table', | |
160 | 'table_name' => 'civicrm_translation', | |
161 | 'entity' => 'Translation', | |
9fa6bb0b | 162 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
163 | 'localizable' => 0, |
164 | 'pseudoconstant' => [ | |
165 | 'callback' => 'CRM_Core_BAO_Translation::getEntityTables', | |
166 | ], | |
167 | 'add' => '5.39', | |
168 | ], | |
169 | 'entity_field' => [ | |
170 | 'name' => 'entity_field', | |
171 | 'type' => CRM_Utils_Type::T_STRING, | |
9fa6bb0b | 172 | 'title' => ts('Translated Field'), |
fd1ea018 TO |
173 | 'description' => ts('Field where referenced item is stored'), |
174 | 'required' => TRUE, | |
175 | 'maxlength' => 64, | |
176 | 'size' => CRM_Utils_Type::BIG, | |
177 | 'where' => 'civicrm_translation.entity_field', | |
178 | 'table_name' => 'civicrm_translation', | |
179 | 'entity' => 'Translation', | |
9fa6bb0b | 180 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
181 | 'localizable' => 0, |
182 | 'pseudoconstant' => [ | |
183 | 'callback' => 'CRM_Core_BAO_Translation::getEntityFields', | |
184 | ], | |
185 | 'add' => '5.39', | |
186 | ], | |
187 | 'entity_id' => [ | |
188 | 'name' => 'entity_id', | |
189 | 'type' => CRM_Utils_Type::T_INT, | |
9fa6bb0b | 190 | 'title' => ts('Translated Entity ID'), |
fd1ea018 TO |
191 | 'description' => ts('ID of the relevant entity.'), |
192 | 'required' => TRUE, | |
193 | 'where' => 'civicrm_translation.entity_id', | |
194 | 'table_name' => 'civicrm_translation', | |
195 | 'entity' => 'Translation', | |
9fa6bb0b | 196 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
197 | 'localizable' => 0, |
198 | 'add' => '5.39', | |
199 | ], | |
200 | 'language' => [ | |
201 | 'name' => 'language', | |
202 | 'type' => CRM_Utils_Type::T_STRING, | |
203 | 'title' => ts('Language'), | |
204 | 'description' => ts('Relevant language'), | |
205 | 'required' => TRUE, | |
206 | 'maxlength' => 5, | |
207 | 'size' => CRM_Utils_Type::SIX, | |
208 | 'where' => 'civicrm_translation.language', | |
209 | 'table_name' => 'civicrm_translation', | |
210 | 'entity' => 'Translation', | |
9fa6bb0b | 211 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
212 | 'localizable' => 0, |
213 | 'html' => [ | |
214 | 'type' => 'Select', | |
215 | ], | |
216 | 'pseudoconstant' => [ | |
217 | 'optionGroupName' => 'languages', | |
218 | 'keyColumn' => 'name', | |
219 | 'optionEditPath' => 'civicrm/admin/options/languages', | |
220 | ], | |
221 | 'add' => '5.39', | |
222 | ], | |
223 | 'status_id' => [ | |
224 | 'name' => 'status_id', | |
225 | 'type' => CRM_Utils_Type::T_INT, | |
9fa6bb0b | 226 | 'title' => ts('Status'), |
fd1ea018 TO |
227 | 'description' => ts('Specify whether the string is active, draft, etc'), |
228 | 'required' => TRUE, | |
229 | 'where' => 'civicrm_translation.status_id', | |
230 | 'default' => '1', | |
231 | 'table_name' => 'civicrm_translation', | |
232 | 'entity' => 'Translation', | |
9fa6bb0b | 233 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
234 | 'localizable' => 0, |
235 | 'pseudoconstant' => [ | |
236 | 'callback' => 'CRM_Core_BAO_Translation::getStatuses', | |
237 | ], | |
238 | 'add' => '5.39', | |
239 | ], | |
240 | 'string' => [ | |
241 | 'name' => 'string', | |
242 | 'type' => CRM_Utils_Type::T_LONGTEXT, | |
9fa6bb0b | 243 | 'title' => ts('Translated String'), |
fd1ea018 TO |
244 | 'description' => ts('Translated string'), |
245 | 'required' => TRUE, | |
246 | 'where' => 'civicrm_translation.string', | |
247 | 'table_name' => 'civicrm_translation', | |
248 | 'entity' => 'Translation', | |
9fa6bb0b | 249 | 'bao' => 'CRM_Core_BAO_Translation', |
fd1ea018 TO |
250 | 'localizable' => 0, |
251 | 'add' => '5.39', | |
252 | ], | |
253 | ]; | |
254 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); | |
255 | } | |
256 | return Civi::$statics[__CLASS__]['fields']; | |
257 | } | |
258 | ||
259 | /** | |
260 | * Return a mapping from field-name to the corresponding key (as used in fields()). | |
261 | * | |
262 | * @return array | |
263 | * Array(string $name => string $uniqueName). | |
264 | */ | |
265 | public static function &fieldKeys() { | |
266 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { | |
267 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
268 | } | |
269 | return Civi::$statics[__CLASS__]['fieldKeys']; | |
270 | } | |
271 | ||
272 | /** | |
273 | * Returns the names of this table | |
274 | * | |
275 | * @return string | |
276 | */ | |
277 | public static function getTableName() { | |
278 | return self::$_tableName; | |
279 | } | |
280 | ||
281 | /** | |
282 | * Returns if this table needs to be logged | |
283 | * | |
284 | * @return bool | |
285 | */ | |
286 | public function getLog() { | |
287 | return self::$_log; | |
288 | } | |
289 | ||
290 | /** | |
291 | * Returns the list of fields that can be imported | |
292 | * | |
293 | * @param bool $prefix | |
294 | * | |
295 | * @return array | |
296 | */ | |
297 | public static function &import($prefix = FALSE) { | |
298 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'translation', $prefix, []); | |
299 | return $r; | |
300 | } | |
301 | ||
302 | /** | |
303 | * Returns the list of fields that can be exported | |
304 | * | |
305 | * @param bool $prefix | |
306 | * | |
307 | * @return array | |
308 | */ | |
309 | public static function &export($prefix = FALSE) { | |
310 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'translation', $prefix, []); | |
311 | return $r; | |
312 | } | |
313 | ||
314 | /** | |
315 | * Returns the list of indices | |
316 | * | |
317 | * @param bool $localize | |
318 | * | |
319 | * @return array | |
320 | */ | |
321 | public static function indices($localize = TRUE) { | |
322 | $indices = [ | |
323 | 'index_entity_lang' => [ | |
324 | 'name' => 'index_entity_lang', | |
325 | 'field' => [ | |
326 | 0 => 'entity_id', | |
327 | 1 => 'entity_table', | |
328 | 2 => 'language', | |
329 | ], | |
330 | 'localizable' => FALSE, | |
331 | 'sig' => 'civicrm_translation::0::entity_id::entity_table::language', | |
332 | ], | |
333 | ]; | |
334 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; | |
335 | } | |
336 | ||
337 | } |