|
| __construct () |
| Creates an entries_exporter object.
|
|
| 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_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_export_file_name (string $exportfilename) |
| Sets the name of the export file.
|
|
|
| get_data_file_content () |
| The entries_exporter will prepare a data file from the rows and columns being added.
|
|
| get_export_data_file_extension () |
| Overwrite the method to return the file extension your data file will have, for example return 'csv'; for a csv file entries_exporter.
|
|
|
array array | $exportdata |
| The data structure containing the data for exporting.
|
|
string string | $exportfilename |
| Name of the export file name without extension.
|
|
◆ __construct()
mod_data\local\exporter\entries_exporter::__construct |
( |
| ) |
|
Creates an entries_exporter object.
This object can be used to export data to different formats including files. If files are added, everything will be bundled up in a zip archive.
◆ add_file_from_string()
mod_data\local\exporter\entries_exporter::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.
- Parameters
-
string | $filename | the name of the file which should be added |
string | $filecontent | the content of the file as a string |
string | $zipsubdir | the subdirectory in the zip archive. Defaults to 'files/'. |
- Return values
-
- Exceptions
-
◆ add_row()
mod_data\local\exporter\entries_exporter::add_row |
( |
array | $row | ) |
|
Adds a row (array of strings) to the export data.
- Parameters
-
array | $row | the row to add, $row has to be a plain array of strings |
- Return values
-
◆ add_to_current_row()
mod_data\local\exporter\entries_exporter::add_to_current_row |
( |
string | $cellcontent | ) |
|
Adds a data string (so the content for a "cell") to the current row.
- Parameters
-
string | $cellcontent | the content to add to the current row |
- Return values
-
◆ create_unique_filename()
mod_data\local\exporter\entries_exporter::create_unique_filename |
( |
string | $filename | ) |
|
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 | $filename | the filename based on which a unique filename should be generated |
- Return values
-
string | the unique filename |
◆ file_exists()
mod_data\local\exporter\entries_exporter::file_exists |
( |
string | $filename, |
|
|
string | $zipsubdir = 'files/' ) |
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 | $filename | the filename containing the zip path of the file to check |
string | $zipsubdir | The subdirectory in which the filename should be looked for, defaults to 'files/' |
- Return values
-
bool | true if file with the given name already exists, false otherwise |
◆ get_data_file_content()
mod_data\local\exporter\entries_exporter::get_data_file_content |
( |
| ) |
|
|
abstractprotected |
◆ get_export_data_file_extension()
mod_data\local\exporter\entries_exporter::get_export_data_file_extension |
( |
| ) |
|
|
abstractprotected |
◆ get_records_count()
mod_data\local\exporter\entries_exporter::get_records_count |
( |
| ) |
|
Returns the count of currently stored records (rows excluding header row).
- Return values
-
int | the count of records/rows |
◆ next_row()
mod_data\local\exporter\entries_exporter::next_row |
( |
| ) |
|
Signal the entries_exporter to finish the current row and jump to the next row.
- Return values
-
◆ send_file()
mod_data\local\exporter\entries_exporter::send_file |
( |
bool | $sendtouser = true | ) |
|
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 | $sendtouser | true if the file should be sent directly to the user, if false the file content will be returned as string |
- Return values
-
string|null | file content as string if $sendtouser is true |
- Exceptions
-
◆ set_export_file_name()
mod_data\local\exporter\entries_exporter::set_export_file_name |
( |
string | $exportfilename | ) |
|
Sets the name of the export file.
Only use the basename without path and without extension here.
- Parameters
-
string | $exportfilename | name of the file without path and extension |
- Return values
-
◆ $exportdata
array array mod_data\local\exporter\entries_exporter::$exportdata |
|
protected |
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:
- mod/data/classes/local/exporter/entries_exporter.php