1 |
efrain |
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.
|
|
|
13 |
//
|
|
|
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/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Display usage information about themes.
|
|
|
19 |
*
|
|
|
20 |
* @package report_themeusage
|
|
|
21 |
* @copyright 2023 David Woloszyn <david.woloszyn@moodle.com>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
use core_reportbuilder\system_report_factory;
|
|
|
26 |
use report_themeusage\form\theme_usage_form;
|
|
|
27 |
use report_themeusage\reportbuilder\local\systemreports\theme_usage_report;
|
|
|
28 |
|
|
|
29 |
require(__DIR__.'/../../config.php');
|
|
|
30 |
require_once($CFG->libdir.'/adminlib.php');
|
|
|
31 |
|
|
|
32 |
require_login();
|
|
|
33 |
admin_externalpage_setup('reportthemeusage');
|
|
|
34 |
|
|
|
35 |
// Get URL parameters.
|
|
|
36 |
$themechoice = optional_param('themechoice', '', PARAM_TEXT);
|
|
|
37 |
|
|
|
38 |
// Check the requested theme is a valid one.
|
|
|
39 |
if (!theme_usage_form::validate_theme_choice_param($themechoice)) {
|
|
|
40 |
throw new \moodle_exception(get_string('invalidparametertheme', 'report_themeusage'));
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
// Set up the page.
|
|
|
44 |
$pageurl = new moodle_url($CFG->wwwroot . '/report/themeusage/index.php');
|
|
|
45 |
$PAGE->set_url($pageurl);
|
|
|
46 |
$PAGE->set_context(context_system::instance());
|
|
|
47 |
$PAGE->set_pagelayout('report');
|
|
|
48 |
$PAGE->set_primary_active_tab('siteadminnode');
|
|
|
49 |
echo $OUTPUT->header();
|
|
|
50 |
|
|
|
51 |
// Show heading.
|
|
|
52 |
$heading = get_string('themeusage', 'report_themeusage');
|
|
|
53 |
echo $OUTPUT->heading($heading);
|
|
|
54 |
|
|
|
55 |
// Build form with prepared data.
|
|
|
56 |
$cutomdata['themechoice'] = $themechoice;
|
|
|
57 |
$form = new theme_usage_form($pageurl, $cutomdata);
|
|
|
58 |
$form->display();
|
|
|
59 |
|
|
|
60 |
if ($data = $form->get_data()) {
|
|
|
61 |
// Build report using submitted form data.
|
|
|
62 |
$themechoice = $data->themechoice;
|
|
|
63 |
$typechoice = $data->typechoice;
|
|
|
64 |
|
|
|
65 |
} else if (!empty($themechoice)) {
|
|
|
66 |
// Build report with incoming theme choice and set the type to 'all'.
|
|
|
67 |
$typechoice = 'all';
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
if (!empty($themechoice) && !empty($typechoice)) {
|
|
|
71 |
// Show a heading that explains what the report is showing.
|
|
|
72 |
$themename = get_string('pluginname', 'theme_' . $themechoice);
|
|
|
73 |
$reportheading = get_string('themeusagereport' . $typechoice, 'report_themeusage', $themename);
|
|
|
74 |
echo $OUTPUT->heading($reportheading, 3, 'mt-4');
|
|
|
75 |
|
|
|
76 |
// Build the report.
|
|
|
77 |
$reportparams = ['themechoice' => $themechoice, 'typechoice' => $typechoice];
|
|
|
78 |
$report = system_report_factory::create(theme_usage_report::class, context_system::instance(), '', '', 0, $reportparams);
|
|
|
79 |
echo $report->output();
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
// Show footer.
|
|
|
83 |
echo $OUTPUT->footer();
|