2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Callback methods for reportbuilder component
20 * @package core_reportbuilder
21 * @copyright 2021 Paul Holden <paulh@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 declare(strict_types
=1);
27 use core\output\inplace_editable
;
28 use core_reportbuilder\form\audience
;
29 use core_reportbuilder\form\filter
;
32 * Return the filters form fragment
34 * @param array $params
37 function core_reportbuilder_output_fragment_filters_form(array $params): string {
38 $filtersform = new filter(null, null, 'post', '', [], true, [
39 'reportid' => $params['reportid'],
40 'parameters' => $params['parameters'],
43 $filtersform->set_data_for_dynamic_submission();
45 return $filtersform->render();
49 * Return the audience form fragment
51 * @param array $params
54 function core_reportbuilder_output_fragment_audience_form(array $params): string {
57 $audienceform = new audience(null, null, 'post', '', [], true, [
58 'reportid' => $params['reportid'],
59 'classname' => $params['classname'],
61 $audienceform->set_data_for_dynamic_submission();
65 'heading' => $params['title'],
66 'headingeditable' => $params['title'],
67 'form' => $audienceform->render(),
70 'showormessage' => $params['showormessage'],
73 $renderer = $PAGE->get_renderer('core_reportbuilder');
74 return $renderer->render_from_template('core_reportbuilder/local/audience/form', $context);
78 * Plugin inplace editable implementation
80 * @param string $itemtype
82 * @param string $newvalue
83 * @return inplace_editable|null
85 function core_reportbuilder_inplace_editable(string $itemtype, int $itemid, string $newvalue): ?inplace_editable
{
88 return \core_reportbuilder\output\report_name_editable
::update($itemid, $newvalue);
91 return \core_reportbuilder\output\column_heading_editable
::update($itemid, $newvalue);
93 case 'columnaggregation':
94 return \core_reportbuilder\output\column_aggregation_editable
::update($itemid, $newvalue);
97 return \core_reportbuilder\output\filter_heading_editable
::update($itemid, $newvalue);
99 case 'audienceheading':
100 return \core_reportbuilder\output\audience_heading_editable
::update($itemid, $newvalue);
103 return \core_reportbuilder\output\schedule_name_editable
::update($itemid, $newvalue);