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