The moodle_content_writer is the default Moodle implementation of a content writer.
More...
|
| __construct (writer $writer) |
| Constructor for the content writer. More...
|
|
| export_area_files (array $subcontext, $component, $filearea, $itemid) |
| Export all files within the specified component, filearea, itemid combination. More...
|
|
| export_custom_file (array $subcontext, $filename, $filecontent) |
| Export a piece of data in a custom format. More...
|
|
| export_data (array $subcontext, stdClass $data) |
| Export the supplied data within the current context, at the supplied subcontext. More...
|
|
| export_file (array $subcontext, stored_file $file) |
| Export the specified file in the target location. More...
|
|
| export_metadata (array $subcontext, string $key, $value, string $description) |
| Export metadata about the supplied subcontext. More...
|
|
| export_related_data (array $subcontext, $name, $data) |
| Export a piece of related data. More...
|
|
| export_user_preference (string $component, string $key, string $value, string $description) |
| Export the specified user preference. More...
|
|
| finalise_content () |
| Perform any required finalisation steps and return the location of the finalised export. More...
|
|
| rewrite_pluginfile_urls (array $subcontext, $component, $filearea, $itemid, $text) |
| Prepare a text area by processing pluginfile URLs within it. More...
|
|
| set_context (\context $context) |
| Set the context for the current item being processed. More...
|
|
|
| check_plugin_is_installed (string $component) |
| Check to see if a specified plugin is installed. More...
|
|
| condense_array (array $array) |
| Creates a multidimensional array out of array elements. More...
|
|
| copy_data (array $path, array $destination) |
| Copy a file to the specified path. More...
|
|
| get_context_path () |
| Determine the path for the current context. More...
|
|
| get_file_content (string $filepath) |
| Get the contents of a file. More...
|
|
| get_files_target_path ($component, $filearea, $itemid) |
| Get a path within a subcontext where exported files should be written to. More...
|
|
| get_files_target_url ($component, $filearea, $itemid) |
| Get a relative url to the directory of the exported files within a subcontext. More...
|
|
| get_full_path (array $subcontext, string $name) |
| Get the fully-qualified file path within the current context, and subcontext, using the specified filename. More...
|
|
| get_path (array $subcontext, string $name) |
| Get the relative file path within the current context, and subcontext, using the specified filename. More...
|
|
| make_tree_object (array $tree, array $treekey, array $currentkey=[]) |
| Add more detail to the tree to help with sorting and display in the renderer. More...
|
|
| prepare_for_export () |
| This creates three different bits of data from all of the files that will be exported. More...
|
|
| sort_my_list (array &$tree) |
| Sorts the tree list into an order that makes more sense. More...
|
|
| write_data (string $path, string $data) |
| Write the data to the specified path. More...
|
|
| write_html_data () |
| Writes the appropriate files for creating an HTML index page for human navigation of the user data export.
|
|
|
array | $checkedplugins = [] |
| The list of plugins that have been checked to see if they are installed.
|
|
context | $context = null |
| The current context of the writer.
|
|
stored_file[] | $files = [] |
| The list of files to be exported.
|
|
string | $path = null |
| The base path on disk for this instance.
|
|
The moodle_content_writer is the default Moodle implementation of a content writer.
It exports data to a rich tree structure using Moodle's context system, and produces a single zip file with all content.
Objects of data are stored as JSON.
- Copyright
- 2018 Andrew Nicols andre.nosp@m.w@ni.nosp@m.cols..nosp@m.co.u.nosp@m.k
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
core_privacy\local\request\moodle_content_writer::__construct |
( |
writer |
$writer | ) |
|
◆ check_plugin_is_installed()
core_privacy\local\request\moodle_content_writer::check_plugin_is_installed |
( |
string |
$component | ) |
|
|
protected |
Check to see if a specified plugin is installed.
- Parameters
-
string | $component | The component name e.g. tool_log |
- Return values
-
bool | Whether this component is installed. |
◆ condense_array()
core_privacy\local\request\moodle_content_writer::condense_array |
( |
array |
$array | ) |
|
|
protected |
Creates a multidimensional array out of array elements.
- Parameters
-
array | $array | Array which items are to be condensed into a multidimensional array. |
- Return values
-
array | The multidimensional array. |
◆ copy_data()
core_privacy\local\request\moodle_content_writer::copy_data |
( |
array |
$path, |
|
|
array |
$destination |
|
) |
| |
|
protected |
Copy a file to the specified path.
- Parameters
-
array | $path | Current location of the file. |
array | $destination | Destination path to copy the file to. |
◆ export_area_files()
core_privacy\local\request\moodle_content_writer::export_area_files |
( |
array |
$subcontext, |
|
|
|
$component, |
|
|
|
$filearea, |
|
|
|
$itemid |
|
) |
| |
Export all files within the specified component, filearea, itemid combination.
- Parameters
-
array | $subcontext | The location within the current context that this data belongs. |
string | $component | The name of the component that the files belong to. |
string | $filearea | The filearea within that component. |
string | $itemid | Which item those files belong to. |
Implements core_privacy\local\request\content_writer.
◆ export_custom_file()
core_privacy\local\request\moodle_content_writer::export_custom_file |
( |
array |
$subcontext, |
|
|
|
$filename, |
|
|
|
$filecontent |
|
) |
| |
Export a piece of data in a custom format.
- Parameters
-
array | $subcontext | The location within the current context that this data belongs. |
string | $filename | The name of the file to be exported. |
string | $filecontent | The content to be exported. |
Implements core_privacy\local\request\content_writer.
◆ export_data()
core_privacy\local\request\moodle_content_writer::export_data |
( |
array |
$subcontext, |
|
|
stdClass |
$data |
|
) |
| |
Export the supplied data within the current context, at the supplied subcontext.
- Parameters
-
array | $subcontext | The location within the current context that this data belongs. |
stdClass | $data | The data to be exported |
- Return values
-
Implements core_privacy\local\request\content_writer.
◆ export_file()
core_privacy\local\request\moodle_content_writer::export_file |
( |
array |
$subcontext, |
|
|
stored_file |
$file |
|
) |
| |
◆ export_metadata()
core_privacy\local\request\moodle_content_writer::export_metadata |
( |
array |
$subcontext, |
|
|
string |
$key, |
|
|
|
$value, |
|
|
string |
$description |
|
) |
| |
Export metadata about the supplied subcontext.
Metadata consists of a key/value pair and a description of the value.
- Parameters
-
array | $subcontext | The location within the current context that this data belongs. |
string | $key | The metadata name. |
string | $value | The metadata value. |
string | $description | The description of the value. |
- Return values
-
Implements core_privacy\local\request\content_writer.
◆ export_related_data()
core_privacy\local\request\moodle_content_writer::export_related_data |
( |
array |
$subcontext, |
|
|
|
$name, |
|
|
|
$data |
|
) |
| |
Export a piece of related data.
- Parameters
-
array | $subcontext | The location within the current context that this data belongs. |
string | $name | The name of the file to be exported. |
stdClass | $data | The related data to export. |
- Return values
-
Implements core_privacy\local\request\content_writer.
◆ export_user_preference()
core_privacy\local\request\moodle_content_writer::export_user_preference |
( |
string |
$component, |
|
|
string |
$key, |
|
|
string |
$value, |
|
|
string |
$description |
|
) |
| |
Export the specified user preference.
- Parameters
-
string | $component | The name of the component. |
string | $key | The name of th key to be exported. |
string | $value | The value of the preference |
string | $description | A description of the value |
- Return values
-
Implements core_privacy\local\request\content_writer.
◆ finalise_content()
core_privacy\local\request\moodle_content_writer::finalise_content |
( |
| ) |
|
◆ get_context_path()
core_privacy\local\request\moodle_content_writer::get_context_path |
( |
| ) |
|
|
protected |
Determine the path for the current context.
- Return values
-
- Exceptions
-
◆ get_file_content()
core_privacy\local\request\moodle_content_writer::get_file_content |
( |
string |
$filepath | ) |
|
|
protected |
Get the contents of a file.
- Parameters
-
string | $filepath | The file path. |
- Return values
-
string | contents of the file. |
- Exceptions
-
◆ get_files_target_path()
core_privacy\local\request\moodle_content_writer::get_files_target_path |
( |
|
$component, |
|
|
|
$filearea, |
|
|
|
$itemid |
|
) |
| |
|
protected |
Get a path within a subcontext where exported files should be written to.
- Parameters
-
string | $component | The name of the component that the files belong to. |
string | $filearea | The filearea within that component. |
string | $itemid | Which item those files belong to. |
- Return values
-
◆ get_files_target_url()
core_privacy\local\request\moodle_content_writer::get_files_target_url |
( |
|
$component, |
|
|
|
$filearea, |
|
|
|
$itemid |
|
) |
| |
|
protected |
Get a relative url to the directory of the exported files within a subcontext.
- Parameters
-
string | $component | The name of the component that the files belong to. |
string | $filearea | The filearea within that component. |
string | $itemid | Which item those files belong to. |
- Return values
-
◆ get_full_path()
core_privacy\local\request\moodle_content_writer::get_full_path |
( |
array |
$subcontext, |
|
|
string |
$name |
|
) |
| |
|
protected |
Get the fully-qualified file path within the current context, and subcontext, using the specified filename.
- Parameters
-
string[] | $subcontext | The location within the current context to export this data. |
string | $name | The intended filename, including any extensions. |
- Return values
-
string | The fully-qualfiied file path. |
◆ get_path()
core_privacy\local\request\moodle_content_writer::get_path |
( |
array |
$subcontext, |
|
|
string |
$name |
|
) |
| |
|
protected |
Get the relative file path within the current context, and subcontext, using the specified filename.
- Parameters
-
string[] | $subcontext | The location within the current context to export this data. |
string | $name | The intended filename, including any extensions. |
- Return values
-
string | The fully-qualfiied file path. |
◆ make_tree_object()
core_privacy\local\request\moodle_content_writer::make_tree_object |
( |
array |
$tree, |
|
|
array |
$treekey, |
|
|
array |
$currentkey = [] |
|
) |
| |
|
protected |
Add more detail to the tree to help with sorting and display in the renderer.
- Parameters
-
array | $tree | The file structure currently as a multidimensional array. |
array | $treekey | An array of the current file paths. |
array | $currentkey | The current short path of the tree. |
- Return values
-
array | An array of objects that has additional data. |
◆ prepare_for_export()
core_privacy\local\request\moodle_content_writer::prepare_for_export |
( |
| ) |
|
|
protected |
This creates three different bits of data from all of the files that will be exported.
$tree - A multidimensional array of the navigation tree structure. $treekey - An array with the short path of the file and element data for html (data_file_{number} or 'No var') $allfiles - All *.json files that need to be added as an index to be referenced by the js files to display the user data.
- Return values
-
array | returns a tree, tree key, and a list of all files. |
◆ rewrite_pluginfile_urls()
core_privacy\local\request\moodle_content_writer::rewrite_pluginfile_urls |
( |
array |
$subcontext, |
|
|
|
$component, |
|
|
|
$filearea, |
|
|
|
$itemid, |
|
|
|
$text |
|
) |
| |
Prepare a text area by processing pluginfile URLs within it.
- Parameters
-
array | $subcontext | The location within the current context that this data belongs. |
string | $component | The name of the component that the files belong to. |
string | $filearea | The filearea within that component. |
string | $itemid | Which item those files belong to. |
string | $text | The text to be processed |
- Return values
-
string | The processed string |
Implements core_privacy\local\request\content_writer.
◆ set_context()
core_privacy\local\request\moodle_content_writer::set_context |
( |
\context |
$context | ) |
|
◆ sort_my_list()
core_privacy\local\request\moodle_content_writer::sort_my_list |
( |
array & |
$tree | ) |
|
|
protected |
Sorts the tree list into an order that makes more sense.
Order is: 1 - Items with a context first, the lower the number the higher up the tree. 2 - Items that are directories. 3 - Items that are log directories. 4 - Links to a page.
- Parameters
-
array | $tree | The tree structure to order. |
◆ write_data()
core_privacy\local\request\moodle_content_writer::write_data |
( |
string |
$path, |
|
|
string |
$data |
|
) |
| |
|
protected |
Write the data to the specified path.
- Parameters
-
string | $path | The path to export the data at. |
string | $data | The data to be exported. |
- Exceptions
-
The documentation for this class was generated from the following file: