3b43aa025b7bc10f3b97e065833a254212087e7d
[civicrm-core.git] / CRM / Core / DAO / Website.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Website.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5fe7525ef0c24242d206c57a36d4899a)
10 */
11
12 /**
13 * Database access object for the Website entity.
14 */
15 class CRM_Core_DAO_Website extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.2';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_website';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-desktop';
32
33 /**
34 * Field to show when displaying a record.
35 *
36 * @var string
37 */
38 public static $_labelField = 'url';
39
40 /**
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
42 *
43 * @var bool
44 */
45 public static $_log = FALSE;
46
47 /**
48 * Unique Website ID
49 *
50 * @var int
51 */
52 public $id;
53
54 /**
55 * FK to Contact ID
56 *
57 * @var int
58 */
59 public $contact_id;
60
61 /**
62 * Website
63 *
64 * @var string
65 */
66 public $url;
67
68 /**
69 * Which Website type does this website belong to.
70 *
71 * @var int
72 */
73 public $website_type_id;
74
75 /**
76 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_website';
80 parent::__construct();
81 }
82
83 /**
84 * Returns localized title of this entity.
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
88 */
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Websites') : ts('Website');
91 }
92
93 /**
94 * Returns foreign keys and entity references.
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
99 public static function getReferenceColumns() {
100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
103 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
104 }
105 return Civi::$statics[__CLASS__]['links'];
106 }
107
108 /**
109 * Returns all the column names of this table
110 *
111 * @return array
112 */
113 public static function &fields() {
114 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
115 Civi::$statics[__CLASS__]['fields'] = [
116 'id' => [
117 'name' => 'id',
118 'type' => CRM_Utils_Type::T_INT,
119 'title' => ts('Website ID'),
120 'description' => ts('Unique Website ID'),
121 'required' => TRUE,
122 'where' => 'civicrm_website.id',
123 'table_name' => 'civicrm_website',
124 'entity' => 'Website',
125 'bao' => 'CRM_Core_BAO_Website',
126 'localizable' => 0,
127 'html' => [
128 'type' => 'Number',
129 ],
130 'add' => '3.2',
131 ],
132 'contact_id' => [
133 'name' => 'contact_id',
134 'type' => CRM_Utils_Type::T_INT,
135 'title' => ts('Contact ID'),
136 'description' => ts('FK to Contact ID'),
137 'where' => 'civicrm_website.contact_id',
138 'table_name' => 'civicrm_website',
139 'entity' => 'Website',
140 'bao' => 'CRM_Core_BAO_Website',
141 'localizable' => 0,
142 'FKClassName' => 'CRM_Contact_DAO_Contact',
143 'html' => [
144 'label' => ts("Contact"),
145 ],
146 'add' => '3.2',
147 ],
148 'url' => [
149 'name' => 'url',
150 'type' => CRM_Utils_Type::T_STRING,
151 'title' => ts('Website'),
152 'description' => ts('Website'),
153 'maxlength' => 128,
154 'size' => 30,
155 'import' => TRUE,
156 'where' => 'civicrm_website.url',
157 'headerPattern' => '/Website/i',
158 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
159 'export' => TRUE,
160 'table_name' => 'civicrm_website',
161 'entity' => 'Website',
162 'bao' => 'CRM_Core_BAO_Website',
163 'localizable' => 0,
164 'html' => [
165 'type' => 'Text',
166 ],
167 'add' => '3.2',
168 ],
169 'website_type_id' => [
170 'name' => 'website_type_id',
171 'type' => CRM_Utils_Type::T_INT,
172 'title' => ts('Website Type'),
173 'description' => ts('Which Website type does this website belong to.'),
174 'where' => 'civicrm_website.website_type_id',
175 'table_name' => 'civicrm_website',
176 'entity' => 'Website',
177 'bao' => 'CRM_Core_BAO_Website',
178 'localizable' => 0,
179 'html' => [
180 'type' => 'Select',
181 ],
182 'pseudoconstant' => [
183 'optionGroupName' => 'website_type',
184 'optionEditPath' => 'civicrm/admin/options/website_type',
185 ],
186 'add' => '3.2',
187 ],
188 ];
189 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
190 }
191 return Civi::$statics[__CLASS__]['fields'];
192 }
193
194 /**
195 * Return a mapping from field-name to the corresponding key (as used in fields()).
196 *
197 * @return array
198 * Array(string $name => string $uniqueName).
199 */
200 public static function &fieldKeys() {
201 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
202 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
203 }
204 return Civi::$statics[__CLASS__]['fieldKeys'];
205 }
206
207 /**
208 * Returns the names of this table
209 *
210 * @return string
211 */
212 public static function getTableName() {
213 return self::$_tableName;
214 }
215
216 /**
217 * Returns if this table needs to be logged
218 *
219 * @return bool
220 */
221 public function getLog() {
222 return self::$_log;
223 }
224
225 /**
226 * Returns the list of fields that can be imported
227 *
228 * @param bool $prefix
229 *
230 * @return array
231 */
232 public static function &import($prefix = FALSE) {
233 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'website', $prefix, []);
234 return $r;
235 }
236
237 /**
238 * Returns the list of fields that can be exported
239 *
240 * @param bool $prefix
241 *
242 * @return array
243 */
244 public static function &export($prefix = FALSE) {
245 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'website', $prefix, []);
246 return $r;
247 }
248
249 /**
250 * Returns the list of indices
251 *
252 * @param bool $localize
253 *
254 * @return array
255 */
256 public static function indices($localize = TRUE) {
257 $indices = [
258 'UI_website_type_id' => [
259 'name' => 'UI_website_type_id',
260 'field' => [
261 0 => 'website_type_id',
262 ],
263 'localizable' => FALSE,
264 'sig' => 'civicrm_website::0::website_type_id',
265 ],
266 ];
267 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
268 }
269
270 }