Merge pull request #15759 from tunbola/active-option-values-for-custom-group
[civicrm-core.git] / extern / widget.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 */
18 require_once '../civicrm.config.php';
19 require_once 'CRM/Core/Config.php';
20
21 $config = CRM_Core_Config::singleton();
22 $template = CRM_Core_Smarty::singleton();
23
24 require_once 'CRM/Utils/Request.php';
25 $cpageId = CRM_Utils_Request::retrieve('cpageId', 'Positive');
26 $widgetId = CRM_Utils_Request::retrieve('widgetId', 'Positive');
27 $format = CRM_Utils_Request::retrieve('format', 'Positive');
28 $includePending = CRM_Utils_Request::retrieve('includePending', 'Boolean');
29
30 require_once 'CRM/Contribute/BAO/Widget.php';
31
32 $jsonvar = 'jsondata';
33 if (isset($format)) {
34 $jsonvar .= $cpageId;
35 }
36
37 $data = CRM_Contribute_BAO_Widget::getContributionPageData($cpageId, $widgetId, $includePending);
38
39 $output = '
40 var ' . $jsonvar . ' = ' . json_encode($data) . ';
41 ';
42
43 // FIXME: Not using CRM_Core_Page_AJAX::setJsHeaders because CMS is not bootstrapped
44 header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 60));
45 header('Content-Type: application/javascript');
46 header("Cache-Control: max-age=60, public");
47
48 echo $output;
49 CRM_Utils_System::civiExit();