mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-40084 mod_data: Remove xls export, deprecate data_export_xls
This commit is contained in:
parent
8dbb6183ff
commit
ab09cf2b84
@ -61,3 +61,42 @@ function data_get_completion_state($course, $cm, $userid, $type) {
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 4.3.
|
||||
* @global object
|
||||
* @param array $export
|
||||
* @param string $dataname
|
||||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
function data_export_xls($export, $dataname, $count) {
|
||||
global $CFG;
|
||||
|
||||
debugging('Function data_export_xls() has been deprecated, because xls export has been dropped.',
|
||||
DEBUG_DEVELOPER);
|
||||
require_once("$CFG->libdir/excellib.class.php");
|
||||
$filename = clean_filename("{$dataname}-{$count}_record");
|
||||
if ($count > 1) {
|
||||
$filename .= 's';
|
||||
}
|
||||
$filename .= clean_filename('-' . gmdate("Ymd_Hi"));
|
||||
$filename .= '.xls';
|
||||
|
||||
$filearg = '-';
|
||||
$workbook = new MoodleExcelWorkbook($filearg);
|
||||
$workbook->send($filename);
|
||||
$worksheet = array();
|
||||
$worksheet[0] = $workbook->add_worksheet('');
|
||||
$rowno = 0;
|
||||
foreach ($export as $row) {
|
||||
$colno = 0;
|
||||
foreach($row as $col) {
|
||||
$worksheet[0]->write($rowno, $colno, $col);
|
||||
$colno++;
|
||||
}
|
||||
$rowno++;
|
||||
}
|
||||
$workbook->close();
|
||||
return $filename;
|
||||
}
|
||||
|
@ -102,12 +102,12 @@ if ($mform->is_cancelled()) {
|
||||
case 'csv':
|
||||
data_export_csv($exportdata, $formdata['delimiter_name'], $data->name, $count);
|
||||
break;
|
||||
case 'xls':
|
||||
data_export_xls($exportdata, $data->name, $count);
|
||||
break;
|
||||
case 'ods':
|
||||
data_export_ods($exportdata, $data->name, $count);
|
||||
break;
|
||||
default:
|
||||
throw new coding_exception('Invalid export format has been specified. '
|
||||
. 'Only "csv" and "ods" are currently supported.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3135,41 +3135,6 @@ function data_export_csv($export, $delimiter_name, $database, $count, $return=fa
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @global object
|
||||
* @param array $export
|
||||
* @param string $dataname
|
||||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
function data_export_xls($export, $dataname, $count) {
|
||||
global $CFG;
|
||||
require_once("$CFG->libdir/excellib.class.php");
|
||||
$filename = clean_filename("{$dataname}-{$count}_record");
|
||||
if ($count > 1) {
|
||||
$filename .= 's';
|
||||
}
|
||||
$filename .= clean_filename('-' . gmdate("Ymd_Hi"));
|
||||
$filename .= '.xls';
|
||||
|
||||
$filearg = '-';
|
||||
$workbook = new MoodleExcelWorkbook($filearg);
|
||||
$workbook->send($filename);
|
||||
$worksheet = array();
|
||||
$worksheet[0] = $workbook->add_worksheet('');
|
||||
$rowno = 0;
|
||||
foreach ($export as $row) {
|
||||
$colno = 0;
|
||||
foreach($row as $col) {
|
||||
$worksheet[0]->write($rowno, $colno, $col);
|
||||
$colno++;
|
||||
}
|
||||
$rowno++;
|
||||
}
|
||||
$workbook->close();
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global object
|
||||
* @param array $export
|
||||
|
@ -1,6 +1,9 @@
|
||||
This files describes API changes in /mod/data - plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
== 4.3 ==
|
||||
* Function data_export_xls() has been deprecated and moved to deprecatedlib, because xls support has already been dropped.
|
||||
|
||||
== 4.2 ==
|
||||
* The field base class now has a method validate(). Overwrite it in the field type to provide validation of field type's
|
||||
parameters in the field add/modify form.
|
||||
|
Loading…
x
Reference in New Issue
Block a user