Beta2 bug fix.31242 progress bar background color
[com.zyxware.civiwci.git] / CRM / Wci / DAO / Widget.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 *
29 * @package CRM
30 * @copyright CiviCRM LLC (c) 2004-2013
31 */
32 class CRM_Wci_DAO_Widget extends CRM_Core_DAO
33 {
34 /**
35 * static instance to hold the table name
36 *
37 * @var string
38 * @static
39 */
40 static $_tableName = 'civicrm_wci_widget';
41 /**
42 * static instance to hold the field values
43 *
44 * @var array
45 * @static
46 */
47 static $_fields = null;
48 /**
49 * static instance to hold the keys used in $_fields for each field.
50 *
51 * @var array
52 * @static
53 */
54 static $_fieldKeys = null;
55 /**
56 * static instance to hold the FK relationships
57 *
58 * @var string
59 * @static
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 * @static
68 */
69 static $_import = null;
70 /**
71 * static instance to hold the values that can
72 * be exported
73 *
74 * @var array
75 * @static
76 */
77 static $_export = null;
78 /**
79 * static value to see if we should log any modifications to
80 * this table in the civicrm_log table
81 *
82 * @var boolean
83 * @static
84 */
85 static $_log = true;
86 /**
87 * Widget Id
88 *
89 * @var int unsigned
90 */
91 public $id;
92 /**
93 * Widget title
94 *
95 * @var string
96 */
97 public $title;
98 /**
99 * Widget title logo
100 *
101 * @var string
102 */
103 public $logo_image;
104 /**
105 * Widget image
106 *
107 * @var string
108 */
109 public $image;
110 /**
111 * Widget contribute/donate button title
112 *
113 * @var string
114 */
115 public $button_title;
116 /**
117 * Contribution/donate page reference id
118 *
119 * @var int unsigned
120 */
121 public $button_link_to;
122 /**
123 * WCI Progress bar reference id
124 *
125 * @var int unsigned
126 */
127 public $progress_bar_id;
128 /**
129 * Widget description
130 *
131 * @var string
132 */
133 public $description;
134 /**
135 * Newsletter signup group reference id
136 *
137 * @var int unsigned
138 */
139 public $email_signup_group_id;
140 /**
141 * Widget size (Thin/Normal/Wide)
142 *
143 * @var string
144 */
145 public $size_variant;
146 /**
147 * Widget title color
148 *
149 * @var string
150 */
151 public $color_title;
152 /**
153 * Widget title background color
154 *
155 * @var string
156 */
157 public $color_title_bg;
158 /**
159 * Widget progress bar color
160 *
161 * @var string
162 */
163 public $color_progress_bar;
164 /**
165 * Widget progress bar background color
166 *
167 * @var string
168 */
169 public $color_progress_bar_bg;
170
171 /**
172 * Widget background color
173 *
174 * @var string
175 */
176 public $color_widget_bg;
177 /**
178 * Widget description color
179 *
180 * @var string
181 */
182 public $color_description;
183 /**
184 * Widget border color
185 *
186 * @var string
187 */
188 public $color_border;
189 /**
190 * Widget button color
191 *
192 * @var string
193 */
194 public $color_button;
195 /**
196 * Widget button background color
197 *
198 * @var string
199 */
200 public $color_button_bg;
201 /**
202 * Additional custom style rules
203 *
204 * @var int unsigned
205 */
206 public $style_rules;
207 /**
208 * Flag to override default widget template
209 *
210 * @var boolean
211 */
212 public $override;
213 /**
214 * Flag to Hide title
215 *
216 * @var boolean
217 */
218 public $hide_title;
219 /**
220 * Flag to Hide widget border
221 *
222 * @var boolean
223 */
224 public $hide_border;
225 /**
226 * Flag to Hide pb caption
227 *
228 * @var boolean
229 */
230 public $hide_pbcap;
231 /**
232 * Custom template
233 *
234 * @var string
235 */
236 public $custom_template;
237
238 /**
239 * Newsletter Button text color
240 *
241 * @var string
242 */
243 public $color_btn_newsletter;
244
245 /**
246 * Newsletter Button color
247 *
248 * @var string
249 */
250 public $color_btn_newsletter_bg;
251
252 /**
253 * Newsletter text
254 *
255 * @var string
256 */
257 public $newsletter_text;
258
259 /**
260 * Newsletter msg text color
261 *
262 * @var string
263 */
264 public $color_newsletter_text;
265
266 function __construct()
267 {
268 $this->__table = 'civicrm_wci_widget';
269 parent::__construct();
270 }
271 /**
272 * return foreign keys and entity references
273 *
274 * @static
275 * @access public
276 * @return array of CRM_Core_EntityReference
277 */
278 static function getReferenceColumns()
279 {
280 if (!self::$_links) {
281 self::$_links = array(
282 new CRM_Core_EntityReference(self::getTableName() , 'button_link_to', 'civicrm_contribution_page', 'id') ,
283 new CRM_Core_EntityReference(self::getTableName() , 'progress_bar_id', 'civicrm_wci_progress_bar', 'id') ,
284 new CRM_Core_EntityReference(self::getTableName() , 'email_signup_group_id', 'civicrm_group', 'id') ,
285 );
286 }
287 return self::$_links;
288 }
289 /**
290 * returns all the column names of this table
291 *
292 * @access public
293 * @return array
294 */
295 static function &fields()
296 {
297 if (!(self::$_fields)) {
298 self::$_fields = array(
299 'widget_id' => array(
300 'name' => 'id',
301 'type' => CRM_Utils_Type::T_INT,
302 'title' => ts('WCI Widget Id', array('domain' => 'org.civicrm.wci')) ,
303 'required' => true,
304 ) ,
305 'title' => array(
306 'name' => 'title',
307 'type' => CRM_Utils_Type::T_STRING,
308 'title' => ts('Widget title', array('domain' => 'org.civicrm.wci')) ,
309 'required' => true,
310 'maxlength' => 64,
311 ) ,
312 'logo_image' => array(
313 'name' => 'logo_image',
314 'type' => CRM_Utils_Type::T_STRING,
315 'title' => ts('Image url of widget logo image', array('domain' => 'org.civicrm.wci')) ,
316 'required' => false,
317 'maxlength' => 255,
318 ) ,
319 'image' => array(
320 'name' => 'image',
321 'type' => CRM_Utils_Type::T_STRING,
322 'title' => ts('Url of widget image', array('domain' => 'org.civicrm.wci')) ,
323 'required' => false,
324 'maxlength' => 255,
325 ) ,
326 'button_title' => array(
327 'name' => 'button_title',
328 'type' => CRM_Utils_Type::T_STRING,
329 'title' => ts('Contribute/Donate button title', array('domain' => 'org.civicrm.wci')) ,
330 'required' => false,
331 'maxlength' => 64,
332 ) ,
333 'button_link_to' => array(
334 'name' => 'button_link_to',
335 'type' => CRM_Utils_Type::T_INT,
336 'title' => ts('Contribution/Donation page reference', array('domain' => 'org.civicrm.wci')) ,
337 'required' => false,
338 ) ,
339 'progress_bar_id' => array(
340 'name' => 'id',
341 'type' => CRM_Utils_Type::T_INT,
342 'title' => ts('WCI Progress Bar Reference Id', array('domain' => 'org.civicrm.wci')) ,
343 'required' => false,
344 ) ,
345 'description' => array(
346 'name' => 'description',
347 'type' => CRM_Utils_Type::T_TEXT,
348 'title' => ts('Widget description', array('domain' => 'org.civicrm.wci')) ,
349 'required' => false,
350 ) ,
351 'email_signup_group_id' => array(
352 'name' => 'email_signup_group_id',
353 'type' => CRM_Utils_Type::T_INT,
354 'title' => ts('Group reference for email newsletter signup', array('domain' => 'org.civicrm.wci')) ,
355 'required' => false,
356 ) ,
357 'size_variant' => array(
358 'name' => 'id',
359 'type' => CRM_Utils_Type::T_STRING,
360 'title' => ts('Widget size variant', array('domain' => 'org.civicrm.wci')) ,
361 'required' => true,
362 'maxlength' => 10,
363 ) ,
364 'color_title' => array(
365 'name' => 'color_title',
366 'type' => CRM_Utils_Type::T_STRING,
367 'title' => ts('Widget title color', array('domain' => 'org.civicrm.wci')) ,
368 'required' => true,
369 'maxlength' => 10,
370 ) ,
371 'color_title_bg' => array(
372 'name' => 'color_title_bg',
373 'type' => CRM_Utils_Type::T_STRING,
374 'title' => ts('Widget title background color', array('domain' => 'org.civicrm.wci')) ,
375 'required' => true,
376 'maxlength' => 10,
377 ) ,
378 'color_progress_bar' => array(
379 'name' => 'color_progress_bar',
380 'type' => CRM_Utils_Type::T_STRING,
381 'title' => ts('Progress bar color', array('domain' => 'org.civicrm.wci')) ,
382 'required' => true,
383 'maxlength' => 10,
384 ) ,
385 'color_progress_bar_bg' => array(
386 'name' => 'color_progress_bar_bg',
387 'type' => CRM_Utils_Type::T_STRING,
388 'title' => ts('Progress bar background color', array('domain' => 'org.civicrm.wci')) ,
389 'required' => true,
390 'maxlength' => 10,
391 ) ,
392 'color_widget_bg' => array(
393 'name' => 'color_widget_bg',
394 'type' => CRM_Utils_Type::T_STRING,
395 'title' => ts('Widget background color', array('domain' => 'org.civicrm.wci')) ,
396 'required' => true,
397 'maxlength' => 10,
398 ) ,
399 'color_description' => array(
400 'name' => 'color_description',
401 'type' => CRM_Utils_Type::T_STRING,
402 'title' => ts('Widget description color', array('domain' => 'org.civicrm.wci')) ,
403 'required' => true,
404 'maxlength' => 10,
405 ) ,
406 'color_border' => array(
407 'name' => 'color_border',
408 'type' => CRM_Utils_Type::T_STRING,
409 'title' => ts('Widget border color', array('domain' => 'org.civicrm.wci')) ,
410 'required' => true,
411 'maxlength' => 10,
412 ) ,
413 'color_button' => array(
414 'name' => 'color_button',
415 'type' => CRM_Utils_Type::T_STRING,
416 'title' => ts('Widget button text color', array('domain' => 'org.civicrm.wci')) ,
417 'required' => true,
418 'maxlength' => 10,
419 ) ,
420 'color_button_bg' => array(
421 'name' => 'color_button_bg',
422 'type' => CRM_Utils_Type::T_STRING,
423 'title' => ts('Widget button background color', array('domain' => 'org.civicrm.wci')) ,
424 'required' => true,
425 'maxlength' => 10,
426 ) ,
427 'style_rules' => array(
428 'name' => 'style_rules',
429 'type' => CRM_Utils_Type::T_TEXT,
430 'title' => ts('Additional style rules', array('domain' => 'org.civicrm.wci')) ,
431 'required' => false,
432 ) ,
433 'override' => array(
434 'name' => 'override',
435 'type' => CRM_Utils_Type::T_BOOLEAN,
436 'title' => ts('Override default template', array('domain' => 'org.civicrm.wci')) ,
437 'required' => false,
438 ) ,
439 'hide_title' => array(
440 'name' => 'hide_title',
441 'type' => CRM_Utils_Type::T_BOOLEAN,
442 'title' => ts('Hide title, if 1.', array('domain' => 'org.civicrm.wci')) ,
443 'required' => false,
444 ) ,
445 'hide_border' => array(
446 'name' => 'hide_border',
447 'type' => CRM_Utils_Type::T_BOOLEAN,
448 'title' => ts('Hide widget border, if 1.', array('domain' => 'org.civicrm.wci')) ,
449 'required' => false,
450 ) ,
451 'hide_pbcap' => array(
452 'name' => 'hide_pbcap',
453 'type' => CRM_Utils_Type::T_BOOLEAN,
454 'title' => ts('Hide pb caption, if 1.', array('domain' => 'org.civicrm.wci')) ,
455 'required' => false,
456 ) ,
457 'custom_template' => array(
458 'name' => 'custom_template',
459 'type' => CRM_Utils_Type::T_TEXT,
460 'title' => ts('Widget custom template', array('domain' => 'org.civicrm.wci')) ,
461 'required' => false,
462 ) ,
463
464 'color_btn_newsletter' => array(
465 'name' => 'color_btn_newsletter',
466 'type' => CRM_Utils_Type::T_STRING,
467 'title' => ts('Newsletter Button text color', array('domain' => 'org.civicrm.wci')) ,
468 'required' => true,
469 'maxlength' => 10,
470 ) ,
471 'color_btn_newsletter_bg' => array(
472 'name' => 'color_btn_newsletter_bg',
473 'type' => CRM_Utils_Type::T_STRING,
474 'title' => ts('Newsletter Button color', array('domain' => 'org.civicrm.wci')) ,
475 'required' => true,
476 'maxlength' => 10,
477 ) ,
478 'newsletter_text' => array(
479 'name' => 'newsletter_text',
480 'type' => CRM_Utils_Type::T_STRING,
481 'title' => ts('Newsletter text', array('domain' => 'org.civicrm.wci')) ,
482 'required' => true,
483 'maxlength' => 64,
484 ) ,
485 'color_newsletter_text' => array(
486 'name' => 'color_newsletter_text',
487 'type' => CRM_Utils_Type::T_STRING,
488 'title' => ts('Newsletter text color', array('domain' => 'org.civicrm.wci')) ,
489 'required' => true,
490 'maxlength' => 10,
491 ) ,
492 );
493 }
494 return self::$_fields;
495 }
496 /**
497 * Returns an array containing, for each field, the arary key used for that
498 * field in self::$_fields.
499 *
500 * @access public
501 * @return array
502 */
503 static function &fieldKeys()
504 {
505 if (!(self::$_fieldKeys)) {
506 self::$_fieldKeys = array(
507 'id' => 'widget_id',
508 'title' => 'title',
509 'logo_image' => 'logo_image',
510 'image' => 'image',
511 'button_title' => 'button_title',
512 'button_link_to' => 'button_link_to',
513 'progress_bar_id' => 'progress_bar_id',
514 'description' => 'description',
515 'email_signup_group_id' => 'email_signup_group_id',
516 'size_variant' => 'size_variant',
517 'color_title' => 'color_title',
518 'color_title_bg' => 'color_title_bg',
519 'color_progress_bar' => 'color_progress_bar',
520 'color_progress_bar_bg' => 'color_progress_bar_bg',
521 'color_widget_bg' => 'color_widget_bg',
522 'color_description' => 'color_description',
523 'color_border' => 'color_border',
524 'color_button' => 'color_button',
525 'color_button_bg' => 'color_button_bg',
526 'style_rules' => 'style_rules',
527 'override' => 'override',
528 'hide_title' => 'hide_title',
529 'hide_border' => 'hide_border',
530 'hide_pbcap' => 'hide_pbcap',
531 'custom_template' => 'custom_template',
532 );
533 }
534 return self::$_fieldKeys;
535 }
536 /**
537 * returns the names of this table
538 *
539 * @access public
540 * @static
541 * @return string
542 */
543 static function getTableName()
544 {
545 return self::$_tableName;
546 }
547 /**
548 * returns if this table needs to be logged
549 *
550 * @access public
551 * @return boolean
552 */
553 function getLog()
554 {
555 return self::$_log;
556 }
557 /**
558 * returns the list of fields that can be imported
559 *
560 * @access public
561 * return array
562 * @static
563 */
564 static function &import($prefix = false)
565 {
566 if (!(self::$_import)) {
567 self::$_import = array();
568 $fields = self::fields();
569 foreach($fields as $name => $field) {
570 if (CRM_Utils_Array::value('import', $field)) {
571 if ($prefix) {
572 self::$_import['wci_widget'] = & $fields[$name];
573 } else {
574 self::$_import[$name] = & $fields[$name];
575 }
576 }
577 }
578 }
579 return self::$_import;
580 }
581 /**
582 * returns the list of fields that can be exported
583 *
584 * @access public
585 * return array
586 * @static
587 */
588 static function &export($prefix = false)
589 {
590 if (!(self::$_export)) {
591 self::$_export = array();
592 $fields = self::fields();
593 foreach($fields as $name => $field) {
594 if (CRM_Utils_Array::value('export', $field)) {
595 if ($prefix) {
596 self::$_export['wci_widget'] = & $fields[$name];
597 } else {
598 self::$_export[$name] = & $fields[$name];
599 }
600 }
601 }
602 }
603 return self::$_export;
604 }
605 }