Merge pull request #23810 from totten/5.51-msgadm-htmlraw
[civicrm-core.git] / CRM / Contribute / Page / Widget.php
CommitLineData
ea737cda
SL
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 */
17class CRM_Contribute_Page_Widget extends CRM_Core_Page {
18
19 /**
20 * the main function that is called when the page
21 * loads, it decides the which action has to be taken for the page.
22 *
23 * @throws \CRM_Core_Exception
24 * @throws \CiviCRM_API3_Exception
25 */
26 public function run() {
27 $config = CRM_Core_Config::singleton();
28 $template = CRM_Core_Smarty::singleton();
29
30 $cpageId = CRM_Utils_Request::retrieve('cpageId', 'Positive');
31 $widgetId = CRM_Utils_Request::retrieve('widgetId', 'Positive');
32 $format = CRM_Utils_Request::retrieve('format', 'Positive');
33 $includePending = CRM_Utils_Request::retrieve('includePending', 'Boolean');
34
35 $jsonvar = 'jsondata';
36 if (isset($format)) {
37 $jsonvar .= $cpageId;
38 }
39
40 $data = CRM_Contribute_BAO_Widget::getContributionPageData($cpageId, $widgetId, $includePending);
41
42 $output = '
43 var ' . $jsonvar . ' = ' . json_encode($data) . ';
44 ';
45
46 CRM_Core_Page_AJAX::setJsHeaders(60);
47 echo $output;
48 CRM_Utils_System::civiExit();
49 }
50
51}