mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 00:02:18 +02:00
Merge branch 'MDL-72058' of https://github.com/paulholden/moodle
This commit is contained in:
@@ -2197,7 +2197,17 @@ class table_default_export_format_parent {
|
||||
function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL) {
|
||||
//use some whitespace to indicate where there was some line spacing.
|
||||
$text = str_replace(array('</p>', "\n", "\r"), ' ', $text);
|
||||
return strip_tags($text);
|
||||
return html_entity_decode(strip_tags($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a row of data, removing HTML tags and entities from each of the cells
|
||||
*
|
||||
* @param array $row
|
||||
* @return array
|
||||
*/
|
||||
public function format_data(array $row): array {
|
||||
return array_map([$this, 'format_text'], $row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2284,13 +2294,13 @@ class table_dataformat_export_format extends table_default_export_format_parent
|
||||
* @param array $headers
|
||||
*/
|
||||
public function output_headers($headers) {
|
||||
$this->columns = $headers;
|
||||
$this->columns = $this->format_data($headers);
|
||||
if (method_exists($this->dataformat, 'write_header')) {
|
||||
error_log('The function write_header() does not support multiple sheets. In order to support multiple sheets you ' .
|
||||
'must implement start_output() and start_sheet() and remove write_header() in your dataformat.');
|
||||
$this->dataformat->write_header($headers);
|
||||
$this->dataformat->write_header($this->columns);
|
||||
} else {
|
||||
$this->dataformat->start_sheet($headers);
|
||||
$this->dataformat->start_sheet($this->columns);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2300,6 +2310,10 @@ class table_dataformat_export_format extends table_default_export_format_parent
|
||||
* @param array $row One record of data
|
||||
*/
|
||||
public function add_data($row) {
|
||||
if (!$this->supports_html()) {
|
||||
$row = $this->format_data($row);
|
||||
}
|
||||
|
||||
$this->dataformat->write_record($row, $this->rownum++);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user