3 +--------------------------------------------------------------------+
4 | CiviCRM Widget Creation Interface (WCI) Version 1.0 |
5 +--------------------------------------------------------------------+
6 | Copyright Zyxware Technologies (c) 2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM WCI. |
10 | CiviCRM WCI is free software; you can copy, modify, and distribute |
11 | it under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007. |
14 | CiviCRM WCI is distributed in the hope that it will be useful, |
15 | but 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. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact Zyxware |
21 | Technologies at info[AT]zyxware[DOT]com. |
22 +--------------------------------------------------------------------+
28 * @copyright CiviCRM LLC (c) 2004-2013
30 class CRM_Wci_DAO_Widget
extends CRM_Core_DAO
33 * static instance to hold the table name
38 static $_tableName = 'civicrm_wci_widget';
40 * static instance to hold the field values
45 static $_fields = null;
47 * static instance to hold the keys used in $_fields for each field.
52 static $_fieldKeys = null;
54 * static instance to hold the FK relationships
59 static $_links = null;
61 * static instance to hold the values that can
67 static $_import = null;
69 * static instance to hold the values that can
75 static $_export = null;
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
109 * Widget contribute/donate button title
113 public $button_title;
115 * Contribution/donate page reference id
119 public $button_link_to;
121 * WCI Progress bar reference id
125 public $progress_bar_id;
133 * Newsletter signup group reference id
137 public $email_signup_group_id;
139 * Widget size (Thin/Normal/Wide)
143 public $size_variant;
151 * Widget title background color
155 public $color_title_bg;
157 * Widget progress bar color
161 public $color_progress_bar;
163 * Widget progress bar background color
167 public $color_progress_bar_bg;
170 * Widget background color
174 public $color_widget_bg;
176 * Widget description color
180 public $color_description;
182 * Widget border color
186 public $color_border;
188 * Widget button color
192 public $color_button;
194 * Widget button background color
198 public $color_button_bg;
200 * Additional custom style rules
206 * Flag to override default widget template
218 * Flag to Hide widget border
224 * Flag to Hide pb caption
230 * if true then shows pb in % else in collected amount
234 public $show_pb_perc;
240 public $custom_template;
243 * Newsletter Button text color
247 public $color_btn_newsletter;
250 * Newsletter Button color
254 public $color_btn_newsletter_bg;
261 public $newsletter_text;
264 * Newsletter msg text color
268 public $color_newsletter_text;
270 function __construct()
272 $this->__table
= 'civicrm_wci_widget';
273 parent
::__construct();
276 * return foreign keys and entity references
280 * @return array of CRM_Core_EntityReference
282 static function getReferenceColumns()
284 if (!self
::$_links) {
285 self
::$_links = array(
286 new CRM_Core_EntityReference(self
::getTableName() , 'button_link_to', 'civicrm_contribution_page', 'id') ,
287 new CRM_Core_EntityReference(self
::getTableName() , 'progress_bar_id', 'civicrm_wci_progress_bar', 'id') ,
288 new CRM_Core_EntityReference(self
::getTableName() , 'email_signup_group_id', 'civicrm_group', 'id') ,
291 return self
::$_links;
294 * returns all the column names of this table
299 static function &fields()
301 if (!(self
::$_fields)) {
302 self
::$_fields = array(
303 'widget_id' => array(
305 'type' => CRM_Utils_Type
::T_INT
,
306 'title' => ts('WCI Widget Id', array('domain' => 'com.zyxware.civiwci')) ,
311 'type' => CRM_Utils_Type
::T_STRING
,
312 'title' => ts('Widget title', array('domain' => 'com.zyxware.civiwci')) ,
316 'logo_image' => array(
317 'name' => 'logo_image',
318 'type' => CRM_Utils_Type
::T_STRING
,
319 'title' => ts('Image url of widget logo image', array('domain' => 'com.zyxware.civiwci')) ,
325 'type' => CRM_Utils_Type
::T_STRING
,
326 'title' => ts('Url of widget image', array('domain' => 'com.zyxware.civiwci')) ,
330 'button_title' => array(
331 'name' => 'button_title',
332 'type' => CRM_Utils_Type
::T_STRING
,
333 'title' => ts('Contribute/Donate button title', array('domain' => 'com.zyxware.civiwci')) ,
337 'button_link_to' => array(
338 'name' => 'button_link_to',
339 'type' => CRM_Utils_Type
::T_INT
,
340 'title' => ts('Contribution/Donation page reference', array('domain' => 'com.zyxware.civiwci')) ,
343 'progress_bar_id' => array(
345 'type' => CRM_Utils_Type
::T_INT
,
346 'title' => ts('WCI Progress Bar Reference Id', array('domain' => 'com.zyxware.civiwci')) ,
349 'description' => array(
350 'name' => 'description',
351 'type' => CRM_Utils_Type
::T_TEXT
,
352 'title' => ts('Widget description', array('domain' => 'com.zyxware.civiwci')) ,
355 'email_signup_group_id' => array(
356 'name' => 'email_signup_group_id',
357 'type' => CRM_Utils_Type
::T_INT
,
358 'title' => ts('Group reference for email newsletter signup', array('domain' => 'com.zyxware.civiwci')) ,
361 'size_variant' => array(
363 'type' => CRM_Utils_Type
::T_STRING
,
364 'title' => ts('Widget size variant', array('domain' => 'com.zyxware.civiwci')) ,
368 'color_title' => array(
369 'name' => 'color_title',
370 'type' => CRM_Utils_Type
::T_STRING
,
371 'title' => ts('Widget title color', array('domain' => 'com.zyxware.civiwci')) ,
375 'color_title_bg' => array(
376 'name' => 'color_title_bg',
377 'type' => CRM_Utils_Type
::T_STRING
,
378 'title' => ts('Widget title background color', array('domain' => 'com.zyxware.civiwci')) ,
382 'color_progress_bar' => array(
383 'name' => 'color_progress_bar',
384 'type' => CRM_Utils_Type
::T_STRING
,
385 'title' => ts('Progress bar color', array('domain' => 'com.zyxware.civiwci')) ,
389 'color_progress_bar_bg' => array(
390 'name' => 'color_progress_bar_bg',
391 'type' => CRM_Utils_Type
::T_STRING
,
392 'title' => ts('Progress bar background color', array('domain' => 'com.zyxware.civiwci')) ,
396 'color_widget_bg' => array(
397 'name' => 'color_widget_bg',
398 'type' => CRM_Utils_Type
::T_STRING
,
399 'title' => ts('Widget background color', array('domain' => 'com.zyxware.civiwci')) ,
403 'color_description' => array(
404 'name' => 'color_description',
405 'type' => CRM_Utils_Type
::T_STRING
,
406 'title' => ts('Widget description color', array('domain' => 'com.zyxware.civiwci')) ,
410 'color_border' => array(
411 'name' => 'color_border',
412 'type' => CRM_Utils_Type
::T_STRING
,
413 'title' => ts('Widget border color', array('domain' => 'com.zyxware.civiwci')) ,
417 'color_button' => array(
418 'name' => 'color_button',
419 'type' => CRM_Utils_Type
::T_STRING
,
420 'title' => ts('Widget button text color', array('domain' => 'com.zyxware.civiwci')) ,
424 'color_button_bg' => array(
425 'name' => 'color_button_bg',
426 'type' => CRM_Utils_Type
::T_STRING
,
427 'title' => ts('Widget button background color', array('domain' => 'com.zyxware.civiwci')) ,
431 'style_rules' => array(
432 'name' => 'style_rules',
433 'type' => CRM_Utils_Type
::T_TEXT
,
434 'title' => ts('Additional style rules', array('domain' => 'com.zyxware.civiwci')) ,
438 'name' => 'override',
439 'type' => CRM_Utils_Type
::T_BOOLEAN
,
440 'title' => ts('Override default template', array('domain' => 'com.zyxware.civiwci')) ,
443 'hide_title' => array(
444 'name' => 'hide_title',
445 'type' => CRM_Utils_Type
::T_BOOLEAN
,
446 'title' => ts('Hide title, if 1.', array('domain' => 'com.zyxware.civiwci')) ,
449 'hide_border' => array(
450 'name' => 'hide_border',
451 'type' => CRM_Utils_Type
::T_BOOLEAN
,
452 'title' => ts('Hide widget border, if 1.', array('domain' => 'com.zyxware.civiwci')) ,
455 'hide_pbcap' => array(
456 'name' => 'hide_pbcap',
457 'type' => CRM_Utils_Type
::T_BOOLEAN
,
458 'title' => ts('Hide pb caption, if 1.', array('domain' => 'com.zyxware.civiwci')) ,
461 'show_pb_perc' => array(
462 'name' => 'show_pb_perc',
463 'type' => CRM_Utils_Type
::T_BOOLEAN
,
464 'title' => ts('pb in %(1) or amount(0).', array('domain' => 'com.zyxware.civiwci')) ,
467 'custom_template' => array(
468 'name' => 'custom_template',
469 'type' => CRM_Utils_Type
::T_TEXT
,
470 'title' => ts('Widget custom template', array('domain' => 'com.zyxware.civiwci')) ,
474 'color_btn_newsletter' => array(
475 'name' => 'color_btn_newsletter',
476 'type' => CRM_Utils_Type
::T_STRING
,
477 'title' => ts('Newsletter Button text color', array('domain' => 'com.zyxware.civiwci')) ,
481 'color_btn_newsletter_bg' => array(
482 'name' => 'color_btn_newsletter_bg',
483 'type' => CRM_Utils_Type
::T_STRING
,
484 'title' => ts('Newsletter Button color', array('domain' => 'com.zyxware.civiwci')) ,
488 'newsletter_text' => array(
489 'name' => 'newsletter_text',
490 'type' => CRM_Utils_Type
::T_STRING
,
491 'title' => ts('Newsletter text', array('domain' => 'com.zyxware.civiwci')) ,
495 'color_newsletter_text' => array(
496 'name' => 'color_newsletter_text',
497 'type' => CRM_Utils_Type
::T_STRING
,
498 'title' => ts('Newsletter text color', array('domain' => 'com.zyxware.civiwci')) ,
504 return self
::$_fields;
507 * Returns an array containing, for each field, the arary key used for that
508 * field in self::$_fields.
513 static function &fieldKeys()
515 if (!(self
::$_fieldKeys)) {
516 self
::$_fieldKeys = array(
519 'logo_image' => 'logo_image',
521 'button_title' => 'button_title',
522 'button_link_to' => 'button_link_to',
523 'progress_bar_id' => 'progress_bar_id',
524 'description' => 'description',
525 'email_signup_group_id' => 'email_signup_group_id',
526 'size_variant' => 'size_variant',
527 'color_title' => 'color_title',
528 'color_title_bg' => 'color_title_bg',
529 'color_progress_bar' => 'color_progress_bar',
530 'color_progress_bar_bg' => 'color_progress_bar_bg',
531 'color_widget_bg' => 'color_widget_bg',
532 'color_description' => 'color_description',
533 'color_border' => 'color_border',
534 'color_button' => 'color_button',
535 'color_button_bg' => 'color_button_bg',
536 'style_rules' => 'style_rules',
537 'override' => 'override',
538 'hide_title' => 'hide_title',
539 'hide_border' => 'hide_border',
540 'hide_pbcap' => 'hide_pbcap',
541 'show_pb_perc' => 'show_pb_perc',
542 'custom_template' => 'custom_template',
545 return self
::$_fieldKeys;
548 * returns the names of this table
554 static function getTableName()
556 return self
::$_tableName;
559 * returns if this table needs to be logged
569 * returns the list of fields that can be imported
575 static function &import($prefix = false)
577 if (!(self
::$_import)) {
578 self
::$_import = array();
579 $fields = self
::fields();
580 foreach($fields as $name => $field) {
581 if (CRM_Utils_Array
::value('import', $field)) {
583 self
::$_import['wci_widget'] = & $fields[$name];
585 self
::$_import[$name] = & $fields[$name];
590 return self
::$_import;
593 * returns the list of fields that can be exported
599 static function &export($prefix = false)
601 if (!(self
::$_export)) {
602 self
::$_export = array();
603 $fields = self
::fields();
604 foreach($fields as $name => $field) {
605 if (CRM_Utils_Array
::value('export', $field)) {
607 self
::$_export['wci_widget'] = & $fields[$name];
609 self
::$_export[$name] = & $fields[$name];
614 return self
::$_export;