Fix text in the embed code license
[com.zyxware.civiwci.git] / CRM / Wci / WidgetCode.php
CommitLineData
1008246f 1<?php
bccdda02
J
2/*
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. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
23*/
24
9e4494ed 25require_once 'wci-helper-functions.php';
1008246f
J
26
27class CRM_Wci_WidgetCode {
28
3ebd2f4b 29 static function generate_widget_code($widgetId, $preview = 0) {
a2b33bc5
VJ
30 $code = '';
31 $dynamic_content = FALSE;
1008246f
J
32 $data = CRM_Wci_BAO_Widget::getWidgetData($widgetId);
33 $template = CRM_Core_Smarty::singleton();
34 $template->assign('wciform', $data);
35 $template->assign('cpageId', $data['button_link_to']);
5a5c3cd9 36 $template->assign('preview', $preview);
1008246f
J
37
38 if ($data["override"] == '0') {
39 $template->template_dir[] = getWciWidgetTemplatePath();
2712a171 40 $wcidata = $template->fetch('WCIWidget.tpl');
1008246f
J
41 } else {
42 $wcidata = $template->fetch('string:' . html_entity_decode($data['custom_template']));
43 }
bccdda02 44
1008246f 45 $code = json_encode($wcidata);
bccdda02 46
a2b33bc5
VJ
47 if ($data['progress_bar_id'] != 0) {
48 $dynamic_content = TRUE;
49 }
50 return array('dynamic' => $dynamic_content, 'code' => $code);
1008246f 51 }
bccdda02 52
3ebd2f4b
VJ
53 static function get_widget_code($embedId, $preview = 0) {
54 $code = '';
55 if ($preview) {
a2b33bc5
VJ
56 $widget = CRM_Wci_WidgetCode::generate_widget_code($embedId, $preview);
57 return $widget['code'];
3ebd2f4b
VJ
58 }
59 else {
1008246f
J
60 $widgetId = CRM_Wci_BAO_EmbedCode::getWidgetId($embedId);
61 $code = CRM_Wci_BAO_WidgetCache::getWidgetCache($widgetId);
1008246f 62 }
3ebd2f4b 63 if (!$code) {
a2b33bc5
VJ
64 $widget = CRM_Wci_WidgetCode::generate_widget_code($widgetId);
65 CRM_Wci_BAO_WidgetCache::setWidgetCache($widgetId, $widget);
66 $code = $widget['code'];
3ebd2f4b
VJ
67 }
68
1008246f
J
69 return $code;
70 }
71}