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 +--------------------------------------------------------------------+
25 require_once 'wci-helper-functions.php';
27 class CRM_Wci_WidgetCode
{
29 static function generate_widget_code($widgetId, $preview = 0) {
31 $dynamic_content = FALSE;
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']);
36 $template->assign('preview', $preview);
38 if ($data["override"] == '0') {
39 $template->template_dir
[] = getWciWidgetTemplatePath();
40 $wcidata = $template->fetch('WCIWidget.tpl');
42 $wcidata = $template->fetch('string:' . html_entity_decode($data['custom_template']));
45 $code = json_encode($wcidata);
47 if ($data['progress_bar_id'] != 0) {
48 $dynamic_content = TRUE;
50 return array('dynamic' => $dynamic_content, 'code' => $code);
53 static function get_widget_code($embedId, $preview = 0) {
56 $widget = CRM_Wci_WidgetCode
::generate_widget_code($embedId, $preview);
57 return $widget['code'];
60 $widgetId = CRM_Wci_BAO_EmbedCode
::getWidgetId($embedId);
61 $code = CRM_Wci_BAO_WidgetCache
::getWidgetCache($widgetId);
64 $widget = CRM_Wci_WidgetCode
::generate_widget_code($widgetId);
65 CRM_Wci_BAO_WidgetCache
::setWidgetCache($widgetId, $widget);
66 $code = $widget['code'];