Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Public Member Functions | |
__construct (writer $writer) | |
Constructor for the content writer. | |
export_area_files (array $subcontext, $component, $filearea, $itemid) | |
Export all files within the specified component, filearea, itemid combination. | |
export_custom_file (array $subcontext, $filename, $filecontent) | |
Export a piece of data in a custom format. | |
export_data (array $subcontext, stdClass $data) | |
Export the supplied data within the current context, at the supplied subcontext. | |
export_file (array $subcontext, stored_file $file) | |
Export the specified file in the target location. | |
export_metadata (array $subcontext, string $key, $value, string $description) | |
Export metadata about the supplied subcontext. | |
export_related_data (array $subcontext, $name, $data) | |
Export a piece of related data. | |
export_user_preference (string $component, string $key, string $value, string $description) | |
Export the specified user preference. | |
finalise_content () | |
Perform any required finalisation steps and return the location of the finalised export. | |
rewrite_pluginfile_urls (array $subcontext, $component, $filearea, $itemid, $text) | |
Prepare a text area by processing pluginfile URLs within it. | |
set_context (\context $context) | |
Set the context for the current item being processed. | |
Public Attributes | |
const | MAX_CONTEXT_NAME_LENGTH = 32 |
Maximum context name char size. | |
Protected Member Functions | |
check_plugin_is_installed (string $component) | |
Check to see if a specified plugin is installed. | |
condense_array (array $array) | |
Creates a multidimensional array out of array elements. | |
copy_data (array $path, array $destination) | |
Copy a file to the specified path. | |
get_context_path () | |
Determine the path for the current context. | |
get_file_content (string $filepath) | |
Get the contents of a file. | |
get_files_target_path ($component, $filearea, $itemid) | |
Get a path within a subcontext where exported files should be written to. | |
get_files_target_url ($component, $filearea, $itemid) | |
Get a relative url to the directory of the exported files within a subcontext. | |
get_full_path (array $subcontext, string $name) | |
Get the fully-qualified file path within the current context, and subcontext, using the specified filename. | |
get_path (array $subcontext, string $name) | |
Get the relative file path within the current context, and subcontext, using the specified filename. | |
make_tree_object (array $tree, array $treekey, array $currentkey=[]) | |
Add more detail to the tree to help with sorting and display in the renderer. | |
prepare_for_export () | |
This creates three different bits of data from all of the files that will be exported. | |
sort_my_list (array &$tree) | |
Sorts the tree list into an order that makes more sense. | |
write_data (string $path, string $data) | |
Write the data to the specified path. | |
write_html_data () | |
Writes the appropriate files for creating an HTML index page for human navigation of the user data export. | |
Protected Attributes | |
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. | |
core_privacy\local\request\moodle_content_writer::__construct | ( | writer | $writer | ) |
Constructor for the content writer.
Note: The writer factory must be passed.
writer | $writer | The factory. |
Implements core_privacy\local\request\content_writer.
|
protected |
Check to see if a specified plugin is installed.
string | $component | The component name e.g. tool_log |
bool | Whether this component is installed. |
|
protected |
Creates a multidimensional array out of array elements.
array | $array | Array which items are to be condensed into a multidimensional array. |
array | The multidimensional array. |
|
protected |
Copy a file to the specified path.
array | $path | Current location of the file. |
array | $destination | Destination path to copy the file to. |
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.
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.
core_privacy\local\request\moodle_content_writer::export_custom_file | ( | array | $subcontext, |
$filename, | |||
$filecontent ) |
Export a piece of data in a custom format.
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.
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.
array | $subcontext | The location within the current context that this data belongs. |
stdClass | $data | The data to be exported |
content_writer |
Implements core_privacy\local\request\content_writer.
core_privacy\local\request\moodle_content_writer::export_file | ( | array | $subcontext, |
stored_file | $file ) |
Export the specified file in the target location.
array | $subcontext | The location within the current context that this data belongs. |
stored_file | $file | The file to be exported. |
Implements core_privacy\local\request\content_writer.
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.
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. |
content_writer |
Implements core_privacy\local\request\content_writer.
core_privacy\local\request\moodle_content_writer::export_related_data | ( | array | $subcontext, |
$name, | |||
$data ) |
Export a piece of related data.
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. |
content_writer |
Implements core_privacy\local\request\content_writer.
core_privacy\local\request\moodle_content_writer::export_user_preference | ( | string | $component, |
string | $key, | ||
string | $value, | ||
string | $description ) |
Export the specified user preference.
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 |
content_writer |
Implements core_privacy\local\request\content_writer.
core_privacy\local\request\moodle_content_writer::finalise_content | ( | ) |
Perform any required finalisation steps and return the location of the finalised export.
string |
Implements core_privacy\local\request\content_writer.
|
protected |
Determine the path for the current context.
array | The context path. |
coding_exception |
|
protected |
Get the contents of a file.
string | $filepath | The file path. |
string | contents of the file. |
moodle_exception | If the file cannot be opened. |
|
protected |
Get a path within a subcontext where exported files should be written to.
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 | The path |
|
protected |
Get a relative url to the directory of the exported files within a subcontext.
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 | The url |
|
protected |
Get the fully-qualified file path within the current context, and subcontext, using the specified filename.
string[] | $subcontext | The location within the current context to export this data. |
string | $name | The intended filename, including any extensions. |
string | The fully-qualfiied file path. |
|
protected |
Get the relative file path within the current context, and subcontext, using the specified filename.
string[] | $subcontext | The location within the current context to export this data. |
string | $name | The intended filename, including any extensions. |
string | The fully-qualfiied file path. |
|
protected |
Add more detail to the tree to help with sorting and display in the renderer.
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. |
array | An array of objects that has additional data. |
|
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.
array | returns a tree, tree key, and a list of all files. |
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.
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 |
string | The processed string |
Implements core_privacy\local\request\content_writer.
core_privacy\local\request\moodle_content_writer::set_context | ( | \context | $context | ) |
Set the context for the current item being processed.
context | $context | The context to use |
Implements core_privacy\local\request\content_writer.
|
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.
array | $tree | The tree structure to order. |
|
protected |
Write the data to the specified path.
string | $path | The path to export the data at. |
string | $data | The data to be exported. |
moodle_exception | If the file cannot be written for some reason. |