6c12cf28798fe4f212236e1c492e3b6a27f210a7
[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:9176466bab7c06d5ace2080bfcfe51d6)
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 'add' => '3.2',
128 ],
129 'contact_id' => [
130 'name' => 'contact_id',
131 'type' => CRM_Utils_Type::T_INT,
132 'title' => ts('Contact'),
133 'description' => ts('FK to Contact ID'),
134 'where' => 'civicrm_website.contact_id',
135 'table_name' => 'civicrm_website',
136 'entity' => 'Website',
137 'bao' => 'CRM_Core_BAO_Website',
138 'localizable' => 0,
139 'FKClassName' => 'CRM_Contact_DAO_Contact',
140 'add' => '3.2',
141 ],
142 'url' => [
143 'name' => 'url',
144 'type' => CRM_Utils_Type::T_STRING,
145 'title' => ts('Website'),
146 'description' => ts('Website'),
147 'maxlength' => 128,
148 'size' => 30,
149 'import' => TRUE,
150 'where' => 'civicrm_website.url',
151 'headerPattern' => '/Website/i',
152 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
153 'export' => TRUE,
154 'table_name' => 'civicrm_website',
155 'entity' => 'Website',
156 'bao' => 'CRM_Core_BAO_Website',
157 'localizable' => 0,
158 'html' => [
159 'type' => 'Text',
160 ],
161 'add' => '3.2',
162 ],
163 'website_type_id' => [
164 'name' => 'website_type_id',
165 'type' => CRM_Utils_Type::T_INT,
166 'title' => ts('Website Type'),
167 'description' => ts('Which Website type does this website belong to.'),
168 'where' => 'civicrm_website.website_type_id',
169 'table_name' => 'civicrm_website',
170 'entity' => 'Website',
171 'bao' => 'CRM_Core_BAO_Website',
172 'localizable' => 0,
173 'html' => [
174 'type' => 'Select',
175 ],
176 'pseudoconstant' => [
177 'optionGroupName' => 'website_type',
178 'optionEditPath' => 'civicrm/admin/options/website_type',
179 ],
180 'add' => '3.2',
181 ],
182 ];
183 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
184 }
185 return Civi::$statics[__CLASS__]['fields'];
186 }
187
188 /**
189 * Return a mapping from field-name to the corresponding key (as used in fields()).
190 *
191 * @return array
192 * Array(string $name => string $uniqueName).
193 */
194 public static function &fieldKeys() {
195 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
196 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
197 }
198 return Civi::$statics[__CLASS__]['fieldKeys'];
199 }
200
201 /**
202 * Returns the names of this table
203 *
204 * @return string
205 */
206 public static function getTableName() {
207 return self::$_tableName;
208 }
209
210 /**
211 * Returns if this table needs to be logged
212 *
213 * @return bool
214 */
215 public function getLog() {
216 return self::$_log;
217 }
218
219 /**
220 * Returns the list of fields that can be imported
221 *
222 * @param bool $prefix
223 *
224 * @return array
225 */
226 public static function &import($prefix = FALSE) {
227 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'website', $prefix, []);
228 return $r;
229 }
230
231 /**
232 * Returns the list of fields that can be exported
233 *
234 * @param bool $prefix
235 *
236 * @return array
237 */
238 public static function &export($prefix = FALSE) {
239 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'website', $prefix, []);
240 return $r;
241 }
242
243 /**
244 * Returns the list of indices
245 *
246 * @param bool $localize
247 *
248 * @return array
249 */
250 public static function indices($localize = TRUE) {
251 $indices = [
252 'UI_website_type_id' => [
253 'name' => 'UI_website_type_id',
254 'field' => [
255 0 => 'website_type_id',
256 ],
257 'localizable' => FALSE,
258 'sig' => 'civicrm_website::0::website_type_id',
259 ],
260 ];
261 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
262 }
263
264 }