MDL-56046 core: convert download_as_dataformat to use new API
This commit is contained in:
+18
-2
@@ -56,7 +56,15 @@ function download_as_dataformat($filename, $dataformat, $columns, $iterator, $ca
|
||||
|
||||
$format->set_filename($filename);
|
||||
$format->send_http_headers();
|
||||
$format->write_header($columns);
|
||||
// This exists to support all dataformats - see MDL-56046.
|
||||
if (method_exists($format, 'write_header')) {
|
||||
error_log('The function write_header() does not support multiple tables. In order to support multiple tables you ' .
|
||||
'must implement start_output() and start_sheet() and remove write_header() in your dataformat.');
|
||||
$format->write_header($columns);
|
||||
} else {
|
||||
$format->start_output();
|
||||
$format->start_sheet($columns);
|
||||
}
|
||||
$c = 0;
|
||||
foreach ($iterator as $row) {
|
||||
if ($callback) {
|
||||
@@ -67,6 +75,14 @@ function download_as_dataformat($filename, $dataformat, $columns, $iterator, $ca
|
||||
}
|
||||
$format->write_record($row, $c++);
|
||||
}
|
||||
$format->write_footer($columns);
|
||||
// This exists to support all dataformats - see MDL-56046.
|
||||
if (method_exists($format, 'write_footer')) {
|
||||
error_log('The function write_footer() does not support multiple tables. In order to support multiple tables you ' .
|
||||
'must implement close_sheet() and close_output() and remove write_footer() in your dataformat.');
|
||||
$format->write_footer($columns);
|
||||
} else {
|
||||
$format->close_sheet($columns);
|
||||
$format->close_output();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user