6598530183e78d9cd16e61490f6a186030a1c8d8
[com.zyxware.civiwci.git] / CRM / Wci / BAO / 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 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 *
33 */
34
35 class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget {
36
37 public static function getWidgetData($widgetId) {
38
39 $query = "SELECT * FROM civicrm_wci_widget where id=".$widgetId;
40 $params = array();
41
42 $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
43
44 $data = array();
45 while ($dao->fetch()) {
46 $data["title"] = $dao->title;
47 $data["logo_image"] = $dao->logo_image;
48 $data["image"] = $dao->image;
49
50 (empty($dao->button_title)) ? $contrin_title = "Donate" :
51 $contrin_title = $dao->button_title;
52
53 $data["button_title"] = $contrin_title;
54
55 $data["button_link_to"] = $dao->button_link_to;
56 $data["progress_bar_id"] = $dao->progress_bar_id;
57 $data["description"] = $dao->description;
58 $data["email_signup_group_id"] = $dao->email_signup_group_id;
59 $data["size_variant"] = $dao->size_variant;
60 $data["color_title"] = $dao->color_title;
61 $data["color_title_bg"] = $dao->color_title_bg;
62 $data["color_progress_bar"] = $dao->color_progress_bar;
63 $data["color_progress_bar_bg"] = $dao->color_progress_bar_bg;
64 $data["color_widget_bg"] = $dao->color_widget_bg;
65 $data["color_description"] = $dao->color_description;
66 $data["color_border"] = $dao->color_border;
67 $data["color_button"] = $dao->color_button;
68 $data["color_button_bg"] = $dao->color_button_bg;
69 $data['style_rules'] = $dao->style_rules;
70 $data["show_pb_perc"] = $dao->show_pb_perc;
71 CRM_Wci_BAO_ProgressBar::getProgressbarData($dao->progress_bar_id, $data);
72 $data["custom_template"] = $dao->custom_template;
73 $data["widgetId"] = $widgetId;
74 $data["override"] = $dao->override;
75 $data["hide_title"] = $dao->hide_title;
76 $data["hide_border"] = $dao->hide_border;
77 $data["hide_pbcap"] = $dao->hide_pbcap;
78 $data["color_bar"] = $dao->color_progress_bar;
79 $defProf = civicrm_api3('setting', 'getValue', array('group' => 'Wci Preference', 'name' => 'default_wci_profile'));
80 $data["emailSignupGroupFormURL"] = CRM_Utils_System::baseCMSURL() . '/civicrm/profile/create?reset=1&amp;gid=' . $defProf;
81 $data["color_btn_newsletter"] = $dao->color_btn_newsletter;
82 $data["color_btn_newsletter_bg"] = $dao->color_btn_newsletter_bg;
83 $data["newsletter_text"] = $dao->newsletter_text;
84 $data["color_newsletter_text"] = $dao->color_newsletter_text;
85 }
86 return $data;
87 }
88 /**
89 * Returns array of widgets
90 * Fields : id, name
91 * @return widget array
92 * @access public
93 */
94 public static function getWidgetList() {
95 $query = "SELECT * FROM civicrm_wci_widget";
96 $params = array();
97 $widgList = array();
98
99 $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
100
101 while ($dao->fetch()) {
102 $widgList[$dao->id] = array();
103 CRM_Core_DAO::storeValues($dao, $widgList[$dao->id]);
104 }
105
106 return $widgList;
107 }
108 }