Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Base class for dataformat.

Copyright: 2016 Brendan Heywood (brendan@catalyst-au.net)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 261 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: base  - X-Ref

Base class for dataformat.

get_extension()   X-Ref
Get the file extension

return: string file extension

set_filename($filename)   X-Ref
Set download filename base

param: string $filename

set_filepath(string $filepath)   X-Ref
Set file path when writing to file

param: string $filepath

set_sheettitle($title)   X-Ref
Set the title of the worksheet inside a spreadsheet

For some formats this will be ignored.

param: string $title

send_http_headers()   X-Ref
Output file headers to initialise the download of the file.


start_output_to_file()   X-Ref
Set the dataformat to be output to current file. Calling code must call {@see base::close_output_to_file()} when finished


start_output()   X-Ref
Write the start of the file.


start_sheet($columns)   X-Ref
Write the start of the sheet we will be adding data to.

param: array $columns

supports_html()   X-Ref
Method to define whether the dataformat supports export of HTML

return: bool

format_record($record)   X-Ref
Apply formatting to the cells of a given record

param: array|\stdClass $record
return: array

export_html_image_source(\stored_file $file)   X-Ref
Given a stored_file, return a suitable source attribute for an img element in the export (or null to use the original)

param: \stored_file $file
return: string|null

replace_pluginfile_images(?string $content)   X-Ref
We need to locate all img tags within a given cell that match pluginfile URL's. Partly so the exported file will show
the image without requiring the user is logged in; and also to prevent some of the dataformats requesting the file
themselves, which is likely to fail due to them not having an active session

param: string|null $content
return: string

close_sheet($columns)   X-Ref
Write the end of the sheet containing the data.

param: array $columns

close_output()   X-Ref
Write the end of the file.


close_output_to_file()   X-Ref
Write the data to disk. Calling code should have previously called {@see base::start_output_to_file()}

return: bool Whether the write succeeded