diff --git a/reportbuilder/classes/external/custom_report_exporter.php b/reportbuilder/classes/external/custom_report_exporter.php index 9fb6f60e8ad..b3e9f9fb6c0 100644 --- a/reportbuilder/classes/external/custom_report_exporter.php +++ b/reportbuilder/classes/external/custom_report_exporter.php @@ -100,6 +100,7 @@ class custom_report_exporter extends persistent_exporter { ], 'multiple' => true, ], + 'classes' => ['type' => PARAM_TEXT], 'editmode' => ['type' => PARAM_BOOL], 'sidebarmenucards' => [ 'type' => custom_report_column_cards_exporter::read_properties_definition(), @@ -155,10 +156,16 @@ class custom_report_exporter extends persistent_exporter { if ($filterspresent) { $filtersform = $this->generate_filters_form()->render(); } - // Get the report attributes. + + // Get the report classes and attributes. + $reportattributes = $report->get_attributes(); + if (isset($reportattributes['class'])) { + $classes = $reportattributes['class']; + unset($reportattributes['class']); + } $attributes = array_map(static function($key, $value): array { return ['name' => $key, 'value' => $value]; - }, array_keys($report->get_attributes()), $report->get_attributes()); + }, array_keys($reportattributes), $reportattributes); } // If we are editing we need all this information for the template. @@ -186,6 +193,7 @@ class custom_report_exporter extends persistent_exporter { 'filterspresent' => $filterspresent, 'filtersform' => $filtersform, 'attributes' => $attributes, + 'classes' => $classes ?? '', 'editmode' => $this->editmode, 'javascript' => '', ] + $editordata; diff --git a/reportbuilder/classes/external/system_report_exporter.php b/reportbuilder/classes/external/system_report_exporter.php index cabfa2a5457..4a2e2854bec 100644 --- a/reportbuilder/classes/external/system_report_exporter.php +++ b/reportbuilder/classes/external/system_report_exporter.php @@ -77,6 +77,7 @@ class system_report_exporter extends persistent_exporter { ], 'multiple' => true, ], + 'classes' => ['type' => PARAM_TEXT], ]; } @@ -116,10 +117,15 @@ class system_report_exporter extends persistent_exporter { $filtersform->set_data_for_dynamic_submission(); } - // Get the report attributes. + // Get the report classes and attributes. + $sourceattributes = $source->get_attributes(); + if (isset($sourceattributes['class'])) { + $classes = $sourceattributes['class']; + unset($sourceattributes['class']); + } $attributes = array_map(static function($key, $value): array { return ['name' => $key, 'value' => $value]; - }, array_keys($source->get_attributes()), $source->get_attributes()); + }, array_keys($sourceattributes), $sourceattributes); return [ 'table' => $output->render($table), @@ -128,6 +134,7 @@ class system_report_exporter extends persistent_exporter { 'filtersapplied' => $source->get_applied_filter_count(), 'filtersform' => $filterspresent ? $filtersform->render() : '', 'attributes' => $attributes, + 'classes' => $classes ?? '', ]; } } diff --git a/reportbuilder/templates/report.mustache b/reportbuilder/templates/report.mustache index ff28539a42f..65be77cb595 100644 --- a/reportbuilder/templates/report.mustache +++ b/reportbuilder/templates/report.mustache @@ -34,7 +34,7 @@ "filtersform": "form" } }} -