31453 31498 code cleanup
[com.zyxware.civiwci.git] / CRM / Wci / BAO / Widget.php
CommitLineData
1720f579
M
1<?php
2/*
3 +--------------------------------------------------------------------+
bccdda02 4 | CiviCRM Widget Creation Interface (WCI) Version 1.0 |
1720f579 5 +--------------------------------------------------------------------+
bccdda02 6 | Copyright Zyxware Technologies (c) 2014 |
1720f579 7 +--------------------------------------------------------------------+
bccdda02 8 | This file is a part of CiviCRM WCI. |
1720f579 9 | |
bccdda02
J
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. |
1720f579 13 | |
bccdda02
J
14 | CiviCRM WCI is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
1720f579
M
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 |
bccdda02
J
20 | License along with this program; if not, contact Zyxware |
21 | Technologies at info[AT]zyxware[DOT]com. |
1720f579
M
22 +--------------------------------------------------------------------+
23*/
24
25/**
26 *
27 * @package CRM
28 * @copyright CiviCRM LLC (c) 2004-2013
29 *
30 */
31
e364fc74 32class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget {
1720f579 33
a946a2b6 34 public static function getWidgetData($widgetId) {
bccdda02 35
a946a2b6
J
36 $query = "SELECT * FROM civicrm_wci_widget where id=".$widgetId;
37 $params = array();
bccdda02 38
a946a2b6
J
39 $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
40
41 $data = array();
42 while ($dao->fetch()) {
cb59e7c2 43 $data["title"] = $dao->title;
a946a2b6
J
44 $data["logo_image"] = $dao->logo_image;
45 $data["image"] = $dao->image;
bccdda02
J
46
47 (empty($dao->button_title)) ? $contrin_title = "Donate" :
d6f51b17 48 $contrin_title = $dao->button_title;
bccdda02 49
d6f51b17 50 $data["button_title"] = $contrin_title;
bccdda02 51
d12b4a2c
M
52 $data["button_link_to"] = $dao->button_link_to;
53 $data["progress_bar_id"] = $dao->progress_bar_id;
46dee7f2 54 $data["description"] = $dao->description;
7602edcd 55 $data["email_signup_group_id"] = $dao->email_signup_group_id;
a946a2b6
J
56 $data["size_variant"] = $dao->size_variant;
57 $data["color_title"] = $dao->color_title;
58 $data["color_title_bg"] = $dao->color_title_bg;
59 $data["color_progress_bar"] = $dao->color_progress_bar;
f009fcb1 60 $data["color_progress_bar_bg"] = $dao->color_progress_bar_bg;
a946a2b6
J
61 $data["color_widget_bg"] = $dao->color_widget_bg;
62 $data["color_description"] = $dao->color_description;
63 $data["color_border"] = $dao->color_border;
64 $data["color_button"] = $dao->color_button;
65 $data["color_button_bg"] = $dao->color_button_bg;
58bba978 66 $data['style_rules'] = $dao->style_rules;
94f5fffd 67 $data["show_pb_perc"] = $dao->show_pb_perc;
d6f51b17 68 CRM_Wci_BAO_ProgressBar::getProgressbarData($dao->progress_bar_id, $data);
851c37a8
J
69 $data["custom_template"] = $dao->custom_template;
70 $data["widgetId"] = $widgetId;
71 $data["override"] = $dao->override;
6d608c2b
J
72 $data["hide_title"] = $dao->hide_title;
73 $data["hide_border"] = $dao->hide_border;
74 $data["hide_pbcap"] = $dao->hide_pbcap;
96bd4503 75 $data["color_bar"] = $dao->color_progress_bar;
68f8aff6 76 $defProf = civicrm_api3('setting', 'getValue', array('group' => 'Wci Preference', 'name' => 'default_wci_profile'));
4f895956 77 $data["emailSignupGroupFormURL"] = CRM_Utils_System::baseCMSURL() . '/civicrm/profile/create?reset=1&amp;gid=' . $defProf;
c1a7ee1f
J
78 $data["color_btn_newsletter"] = $dao->color_btn_newsletter;
79 $data["color_btn_newsletter_bg"] = $dao->color_btn_newsletter_bg;
80 $data["newsletter_text"] = $dao->newsletter_text;
81 $data["color_newsletter_text"] = $dao->color_newsletter_text;
a946a2b6 82 }
a946a2b6
J
83 return $data;
84 }
13e70378
J
85 /**
86 * Returns array of widgets
87 * Fields : id, name
88 * @return widget array
89 * @access public
bccdda02 90 */
13e70378
J
91 public static function getWidgetList() {
92 $query = "SELECT * FROM civicrm_wci_widget";
93 $params = array();
94 $widgList = array();
bccdda02 95
13e70378
J
96 $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
97
98 while ($dao->fetch()) {
99 $widgList[$dao->id] = array();
100 CRM_Core_DAO::storeValues($dao, $widgList[$dao->id]);
101 }
102
103 return $widgList;
104 }
1720f579 105}