Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_data\local\exporter\csv_entries_exporter Class Reference
Inheritance diagram for mod_data\local\exporter\csv_entries_exporter:
mod_data\local\exporter\entries_exporter

Public Member Functions

 add_file_from_string (string $filename, string $filecontent, string $zipsubdir='files/')
 Use this method to add a file which should be exported to the entries_exporter.
 
 add_row (array $row)
 Adds a row (array of strings) to the export data.
 
 add_to_current_row (string $cellcontent)
 Adds a data string (so the content for a "cell") to the current row.
 
 create_unique_filename (string $filename)
 Creates a unique filename based on the given filename.
 
 file_exists (string $filename, string $zipsubdir='files/')
 Checks if a file with the given name has already been added to the file export bundle.
 
 get_data_file_content ()
 Returns the csv data exported by the csv_export_writer for further handling.
 
 get_export_data_file_extension ()
 Returns the file extension of this entries exporter.
 
 get_records_count ()
 Returns the count of currently stored records (rows excluding header row).
 
 next_row ()
 Signal the entries_exporter to finish the current row and jump to the next row.
 
 send_file (bool $sendtouser=true)
 Sends the generated export file.
 
 set_delimiter_name (string $delimitername)
 Setter for the delimiter name which should be used in this csv_entries_exporter object.
 
 set_export_file_name (string $exportfilename)
 Sets the name of the export file.
 

Protected Attributes

array array $exportdata
 The data structure containing the data for exporting.
 
string string $exportfilename
 Name of the export file name without extension.
 

Member Function Documentation

◆ add_file_from_string()

mod_data\local\exporter\entries_exporter::add_file_from_string ( string $filename,
string $filecontent,
string $zipsubdir = 'files/' )
inherited

Use this method to add a file which should be exported to the entries_exporter.

Parameters
string$filenamethe name of the file which should be added
string$filecontentthe content of the file as a string
string$zipsubdirthe subdirectory in the zip archive. Defaults to 'files/'.
Return values
void
Exceptions
moodle_exceptionif there is an error adding the file to the zip archive

◆ add_row()

mod_data\local\exporter\entries_exporter::add_row ( array $row)
inherited

Adds a row (array of strings) to the export data.

Parameters
array$rowthe row to add, $row has to be a plain array of strings
Return values
void

◆ add_to_current_row()

mod_data\local\exporter\entries_exporter::add_to_current_row ( string $cellcontent)
inherited

Adds a data string (so the content for a "cell") to the current row.

Parameters
string$cellcontentthe content to add to the current row
Return values
void

◆ create_unique_filename()

mod_data\local\exporter\entries_exporter::create_unique_filename ( string $filename)
inherited

Creates a unique filename based on the given filename.

This method adds "_1", "_2", ... to the given file name until the newly generated filename is not equal to any of the already saved ones in the export file bundle.

Parameters
string$filenamethe filename based on which a unique filename should be generated
Return values
stringthe unique filename

◆ file_exists()

mod_data\local\exporter\entries_exporter::file_exists ( string $filename,
string $zipsubdir = 'files/' )
inherited

Checks if a file with the given name has already been added to the file export bundle.

Care: Filenames are compared to all files in the specified zip subdirectory which defaults to 'files/'.

Parameters
string$filenamethe filename containing the zip path of the file to check
string$zipsubdirThe subdirectory in which the filename should be looked for, defaults to 'files/'
Return values
booltrue if file with the given name already exists, false otherwise

◆ get_data_file_content()

mod_data\local\exporter\csv_entries_exporter::get_data_file_content ( )

Returns the csv data exported by the csv_export_writer for further handling.

See also
mod_data\local\exporter\entries_exporter\get_data_file_content()

Reimplemented from mod_data\local\exporter\entries_exporter.

◆ get_export_data_file_extension()

mod_data\local\exporter\csv_entries_exporter::get_export_data_file_extension ( )

Returns the file extension of this entries exporter.

See also
mod_data\local\exporter\entries_exporter\get_export_data_file_extension()

Reimplemented from mod_data\local\exporter\entries_exporter.

◆ get_records_count()

mod_data\local\exporter\entries_exporter::get_records_count ( )
inherited

Returns the count of currently stored records (rows excluding header row).

Return values
intthe count of records/rows

◆ next_row()

mod_data\local\exporter\entries_exporter::next_row ( )
inherited

Signal the entries_exporter to finish the current row and jump to the next row.

Return values
void

◆ send_file()

mod_data\local\exporter\entries_exporter::send_file ( bool $sendtouser = true)
inherited

Sends the generated export file.

Care: By default this function finishes the current PHP request and directly serves the file to the user as download.

Parameters
bool$sendtousertrue if the file should be sent directly to the user, if false the file content will be returned as string
Return values
string|nullfile content as string if $sendtouser is true
Exceptions
moodle_exceptionif there is an issue adding the data file
file_serving_exceptionif the file could not be served properly

◆ set_delimiter_name()

mod_data\local\exporter\csv_entries_exporter::set_delimiter_name ( string $delimitername)

Setter for the delimiter name which should be used in this csv_entries_exporter object.

Calling this setter is optional, the delimiter name defaults to 'comma'.

Parameters
string$delimiternameone of 'comma', 'tab', 'semicolon', 'colon' or 'cfg'
Return values
void
Exceptions
coding_exceptionif a wrong delimiter name has been specified

◆ set_export_file_name()

mod_data\local\exporter\entries_exporter::set_export_file_name ( string $exportfilename)
inherited

Sets the name of the export file.

Only use the basename without path and without extension here.

Parameters
string$exportfilenamename of the file without path and extension
Return values
void

Member Data Documentation

◆ $exportdata

array array mod_data\local\exporter\entries_exporter::$exportdata
protectedinherited

The data structure containing the data for exporting.

It's a 2-dimensional array of rows and columns.


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