-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpoodlldiagnostics.php
59 lines (48 loc) · 1.73 KB
/
poodlldiagnostics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once("../../config.php");
require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('poodlldiagnostics');
//detect if its a CSV or not
$exportcsv = optional_param('csv', 0, PARAM_INT);
//get diagnostics info
$diagnostics = new \filter_poodll\diagnosticstools();
$dprops = $diagnostics->fetch_props();
//if we are exporting CSV, do that
if ($exportcsv) {
header("Content-Disposition: attachment; filename=poodll_support_info.csv");
header("Content-Type: text/comma-separated-values");
$quote = '"';
$delim = ",";
$newline = "\r\n";
//echo data rows
$datarow = '';
foreach ($dprops as $propname => $propvalue) {
$datarow .= $quote . $propname . $quote . $delim . $quote . $propvalue . $quote . $newline;
}
echo $datarow;
exit();
}
//if we are exporting html, do that
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('poodllsupportinfo', 'filter_poodll'), 3);
$csvexportbutton = new single_button(
new moodle_url('/filter/poodll/poodlldiagnostics.php', array('csv' => 1)),
get_string('exportdiagnostics', 'filter_poodll'));
echo '<div class="filter_poodll_diagnostics">';
echo $OUTPUT->render($csvexportbutton);
//make html table
$table = new html_table();
$table->head = array(get_string('name'), get_string('value', 'filter_poodll'));
$table->colclasses = array('leftalign', 'leftalign');
$table->id = 'filter_poodll_diag_props';
$table->attributes['class'] = 'admintable generaltable';
$table->data = array();
//add a row for each item
foreach ($dprops as $propname => $propvalue) {
$table->data[] = array($propname, $propvalue);
}
//display it
echo html_writer::table($table);
echo $OUTPUT->render($csvexportbutton);
echo '</div>';
echo $OUTPUT->footer();