Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
core\dataformat\base Class Reference

Base class for dataformat. More...

Inheritance diagram for core\dataformat\base:
core\dataformat\spout_base dataformat_html\writer dataformat_json\writer dataformat_pdf\writer dataformat_csv\writer dataformat_excel\writer dataformat_ods\writer

Public Member Functions

 close_output ()
 Write the end of the file. More...
 
 close_output_to_file ()
 Write the data to disk. More...
 
 close_sheet ($columns)
 Write the end of the sheet containing the data. More...
 
 get_extension ()
 Get the file extension. More...
 
 send_http_headers ()
 Output file headers to initialise the download of the file. More...
 
 set_filename ($filename)
 Set download filename base. More...
 
 set_filepath (string $filepath)
 Set file path when writing to file. More...
 
 set_sheettitle ($title)
 Set the title of the worksheet inside a spreadsheet. More...
 
 start_output ()
 Write the start of the file. More...
 
 start_output_to_file ()
 Set the dataformat to be output to current file. More...
 
 start_sheet ($columns)
 Write the start of the sheet we will be adding data to. More...
 
 supports_html ()
 Method to define whether the dataformat supports export of HTML. More...
 
 write_record ($record, $rownum)
 Write a single record. More...
 

Protected Member Functions

 export_html_image_source (\stored_file $file)
 Given a stored_file, return a suitable source attribute for an img element in the export (or null to use the original) More...
 
 format_record ($record)
 Apply formatting to the cells of a given record. More...
 
 replace_pluginfile_images (?string $content)
 We need to locate all img tags within a given cell that match pluginfile URL's. More...
 

Protected Attributes

$extension $extension = ".txt"
 
$filename $filename = ''
 
string $filepath = ''
 The location to store the output content.
 
$mimetype $mimetype = "text/plain"
 

Detailed Description

Base class for dataformat.

@subpackage dataformat

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ close_output()

core\dataformat\base::close_output ( )

◆ close_output_to_file()

core\dataformat\base::close_output_to_file ( )

Write the data to disk.

Calling code should have previously called {

See also
base::start_output_to_file()}
Return values
boolWhether the write succeeded

Reimplemented in dataformat_pdf\writer, and core\dataformat\spout_base.

◆ close_sheet()

core\dataformat\base::close_sheet (   $columns)

Write the end of the sheet containing the data.

Parameters
array$columns

Reimplemented in dataformat_html\writer, and dataformat_json\writer.

◆ export_html_image_source()

core\dataformat\base::export_html_image_source ( \stored_file  $file)
protected

Given a stored_file, return a suitable source attribute for an img element in the export (or null to use the original)

Parameters
stored_file$file
Return values
string|null

Reimplemented in dataformat_pdf\writer.

◆ format_record()

core\dataformat\base::format_record (   $record)
protected

Apply formatting to the cells of a given record.

Parameters
array | stdClass$record
Return values
array

◆ get_extension()

core\dataformat\base::get_extension ( )

Get the file extension.

Return values
stringfile extension

◆ replace_pluginfile_images()

core\dataformat\base::replace_pluginfile_images ( ?string  $content)
protected

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

Parameters
string | null$content
Return values
string

◆ send_http_headers()

core\dataformat\base::send_http_headers ( )

Output file headers to initialise the download of the file.

Reimplemented in dataformat_pdf\writer, and core\dataformat\spout_base.

◆ set_filename()

core\dataformat\base::set_filename (   $filename)

Set download filename base.

Parameters
string$filename

◆ set_filepath()

core\dataformat\base::set_filepath ( string  $filepath)

Set file path when writing to file.

Parameters
string$filepath
Exceptions
coding_exception

◆ set_sheettitle()

core\dataformat\base::set_sheettitle (   $title)

Set the title of the worksheet inside a spreadsheet.

For some formats this will be ignored.

Parameters
string$title

Reimplemented in dataformat_excel\writer, dataformat_ods\writer, and core\dataformat\spout_base.

◆ start_output()

core\dataformat\base::start_output ( )

Write the start of the file.

Reimplemented in dataformat_html\writer, dataformat_json\writer, and dataformat_pdf\writer.

◆ start_output_to_file()

core\dataformat\base::start_output_to_file ( )

Set the dataformat to be output to current file.

Calling code must call {

See also
base::close_output_to_file()} when finished

Reimplemented in dataformat_pdf\writer, and core\dataformat\spout_base.

◆ start_sheet()

core\dataformat\base::start_sheet (   $columns)

Write the start of the sheet we will be adding data to.

Parameters
array$columns

Reimplemented in dataformat_html\writer, dataformat_json\writer, dataformat_pdf\writer, and core\dataformat\spout_base.

◆ supports_html()

core\dataformat\base::supports_html ( )

Method to define whether the dataformat supports export of HTML.

Return values
bool

Reimplemented in dataformat_html\writer, and dataformat_pdf\writer.

◆ write_record()

core\dataformat\base::write_record (   $record,
  $rownum 
)
abstract

Write a single record.

Parameters
array$record
int$rownum

Reimplemented in dataformat_html\writer, dataformat_json\writer, dataformat_pdf\writer, and core\dataformat\spout_base.


The documentation for this class was generated from the following file: