MDL-15911: support in odslib to write the file out rather than just send it
This commit is contained in:
+15
-6
@@ -36,9 +36,11 @@
|
||||
class MoodleODSWorkbook {
|
||||
var $worksheets = array();
|
||||
var $filename;
|
||||
var $send;
|
||||
|
||||
function MoodleODSWorkbook($filename) {
|
||||
function MoodleODSWorkbook($filename, $send=true) {
|
||||
$this->filename = $filename;
|
||||
$this->send = $send;
|
||||
}
|
||||
|
||||
/* Create one Moodle Worksheet
|
||||
@@ -95,15 +97,22 @@ class MoodleODSWorkbook {
|
||||
$files[] = "$dir/META-INF";
|
||||
|
||||
$filename = "$dir/result.ods";
|
||||
if (!$this->send) {
|
||||
$filename = $this->filename;
|
||||
}
|
||||
zip_files($files, $filename);
|
||||
|
||||
$handle = fopen($filename, 'rb');
|
||||
$contents = fread($handle, filesize($filename));
|
||||
fclose($handle);
|
||||
if ($this->send) {
|
||||
$handle = fopen($filename, 'rb');
|
||||
$contents = fread($handle, filesize($filename));
|
||||
fclose($handle);
|
||||
|
||||
remove_dir($dir); // cleanup the temp directory
|
||||
remove_dir($dir); // cleanup the temp directory
|
||||
|
||||
send_file($contents, $this->filename, 0, 0, true, true, 'application/vnd.oasis.opendocument.spreadsheet');
|
||||
send_file($contents, $this->filename, 0, 0, true, true, 'application/vnd.oasis.opendocument.spreadsheet');
|
||||
return;
|
||||
}
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/* Not required to use
|
||||
|
||||
Reference in New Issue
Block a user