## Class mr_file_export

Description

MR File Export

Manages exporting of data to files and the different export formats.

- author: Mark Nielsen
- example: See how to use this class

Located in /file/export.php (line 37)

Variable Summary
array $exporters
boolean $exporting
string $filename
mr_file_export_abstract $instance
moodle_url $url
Method Summary
mr_file_export __construct ([mixed $exporters = '**'], [boolean $requirefile = false], [ $url = NULL], [string $filename = 'export'])
mr_file_export cleanup ()
mixed close ()
array get_select_options ()
moodle_url get_url ()
array get_url_select_options ()
mr_file_export init (string $exporter, [string $filename = NULL])
mr_file_export_abstract instance ()
boolean is_exporting ()
void send ()
mr_file_export set_filename (string $filename)
Variables
array $exporters = array() (line 51)

Loaded exporters, only these can be used

- access: protected

boolean $exporting = false (line 44)

Flag for if exporting is currently underway or not

- access: protected

string $filename (line 58)

Export file name

- access: protected

mr_file_export_abstract $instance = NULL (line 65)

Exporter instance

- access: protected

moodle_url $url (line 72)

Moodle URL - used for rendering

- access: protected

Methods
Constructor __construct (line 107)

Exporter setup

There are many ways to define which exporters are available. The $exporters param can be a string or an array of strings that get sent to the mr_helper_load class.

Examples:

1. <?php
2. // Load all exporters
3. $export = new mr_file_export('**');
5. // Load only text exporters
6. $export = new mr_file_export('text/*');
8. // Load all spreadsheet and text/csv exporters
9. $export = new mr_file_export(array('text/csv', 'spreadsheet/*'));
11. // Load an instance of a class that extends mr_file_export_abstract
12. $export = new mr_file_export(new blocks_dummy_file_export_csv());
14. // Load an instance and all text exporters
15. $export = new mr_file_export(array('text/*', new blocks_dummy_file_export_csv()));
17. ?>

- throws: coding_exception
- access: public

mr_file_export __construct ([mixed $exporters = '**'], [boolean $requirefile = false], [ $url = NULL], [string $filename = 'export'])

- mixed $exporters: This can take on many forms, see above for examples.
- boolean $requirefile: If true, then no export plugin will be included that cannot generate a file
- moodle_url $url: Moodle URL for current page, used for rendering only
- string $filename: The exported file's name

cleanup (line 249)

Calls the exporters cleanup.

If the exporter generates a file, then the file is deleted.

- access: public

mr_file_export cleanup ()
close (line 226)

Stop exporting and if the exporter returns a file, then the file is returned, otherwise, always returns false.

To remove the export file from the file system, you must call mr_file_export::cleanup()

- access: public

mixed close ()
get_select_options (line 324)

Get select options for the currently available exporters

- access: public

array get_select_options ()
get_url (line 312)

Get the URL

- throws: coding_exception
- access: public

moodle_url get_url ()
get_url_select_options (line 337)

Get URL select options for the currently available exporters

- access: public

array get_url_select_options ()
init (line 193)

Start exporting process

Can be manually called.

- throws: coding_exception
- access: public

mr_file_export init (string $exporter, [string $filename = NULL])

- string $exporter: The exporter to use
- string $filename: Optionally change the file name

instance (line 167)

Once an export has started, you can get access to the current exporter through this method.

- throws: coding_exception
- access: public

mr_file_export_abstract instance ()
is_exporting (line 179)

Are we currently exporting?

- access: public

boolean is_exporting ()
send (line 264)

Closes, cleans and sends the exported file to the browser for download.

If a file is sent, this method will kill the PHP script!

- access: public

void send ()
set_filename (line 296)

Change the export file name

- throws: coding_exception
- access: public

mr_file_export set_filename (string $filename)

- string $filename: The new file name

Documentation generated on Thu, 28 Jun 2012 16:33:48 -0700 by phpDocumentor 1.4.3