MDL-69542 enrol_lti: all lang string changes
[moodle.git] / reportbuilder / lib.php
blob4a0f575c1b42bcdd4d11b851b4fd69b307adbe1b
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
8 //
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/>.
17 /**
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;
31 /**
32 * Return the filters form fragment
34 * @param array $params
35 * @return string
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'],
41 ]);
43 $filtersform->set_data_for_dynamic_submission();
45 return $filtersform->render();
48 /**
49 * Return the audience form fragment
51 * @param array $params
52 * @return string
54 function core_reportbuilder_output_fragment_audience_form(array $params): string {
55 global $PAGE;
57 $audienceform = new audience(null, null, 'post', '', [], true, [
58 'reportid' => $params['reportid'],
59 'classname' => $params['classname'],
60 ]);
61 $audienceform->set_data_for_dynamic_submission();
63 $context = [
64 'instanceid' => 0,
65 'heading' => $params['title'],
66 'headingeditable' => $params['title'],
67 'form' => $audienceform->render(),
68 'canedit' => true,
69 'candelete' => true,
70 'showormessage' => $params['showormessage'],
73 $renderer = $PAGE->get_renderer('core_reportbuilder');
74 return $renderer->render_from_template('core_reportbuilder/local/audience/form', $context);
77 /**
78 * Plugin inplace editable implementation
80 * @param string $itemtype
81 * @param int $itemid
82 * @param string $newvalue
83 * @return inplace_editable|null
85 function core_reportbuilder_inplace_editable(string $itemtype, int $itemid, string $newvalue): ?inplace_editable {
86 switch ($itemtype) {
87 case 'reportname':
88 return \core_reportbuilder\output\report_name_editable::update($itemid, $newvalue);
90 case 'columnheading':
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);
96 case 'filterheading':
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);
102 case 'schedulename':
103 return \core_reportbuilder\output\schedule_name_editable::update($itemid, $newvalue);
106 return null;