Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Contains API class for the H5P area. More...
Static Public Member Functions | |
static | can_edit_content (\stored_file $file) |
Check if the user can edit an H5P file. | |
static | create_content_from_pluginfile_url (string $url, stdClass $config, factory $factory, stdClass &$messages, bool $preventredirect=true, bool $skipcapcheck=false) |
Create, if it doesn't exist, the H5P DB instance id for a H5P pluginfile URL. | |
static | delete_content (\stdClass $content, factory $factory) |
Delete an H5P package. | |
static | delete_content_from_pluginfile_url (string $url, factory $factory) |
Delete an H5P package deployed from the defined $url. | |
static | delete_library (factory $factory, stdClass $library) |
Delete a library and also all the libraries depending on it and the H5P contents using it. | |
static | get_content_from_pathnamehash (string $pathnamehash) |
Returns the H5P content object corresponding to an H5P content file. | |
static | get_content_from_pluginfile_url (string $url, bool $preventredirect=true, bool $skipcapcheck=false) |
Get the H5P DB instance id for a H5P pluginfile URL. | |
static | get_contenttype_libraries (?string $fields='') |
Get all the H5P content type libraries versions. | |
static | get_dependent_libraries (int $libraryid) |
Get all the libraries using a defined library. | |
static | get_export_info_from_context_id (int $contextid, factory $factory, string $component, string $filearea) |
Return the H5P export information file when the file has been deployed. | |
static | get_library (int $libraryid) |
Get a library from an identifier. | |
static | get_library_details (array $params, bool $configurable, string $fields='') |
Returns a library as an object with properties that correspond to the fetched row's field names. | |
static | get_original_content_from_pluginfile_url (string $url, bool $preventredirect=true, bool $skipcapcheck=false) |
Get the original file and H5P DB instance for a given H5P pluginfile URL. | |
static | is_library_enabled (\stdClass $librarydata) |
Check whether a library is enabled or not. | |
static | is_valid_package (\stored_file $file, bool $onlyupdatelibs, bool $skipcontent=false, ?factory $factory=null, bool $deletefiletree=true) |
Check whether an H5P package is valid or not. | |
static | set_library_enabled (int $libraryid, bool $isenabled) |
Enable or disable a library. | |
Static Protected Member Functions | |
static | can_access_pluginfile_hash (string $url, bool $preventredirect=true) |
If user can access pathnamehash from an H5P internal URL. | |
static | get_pluginfile_hash (string $url) |
Get the pathnamehash from an H5P internal URL. | |
Contains API class for the H5P area.
|
staticprotected |
If user can access pathnamehash from an H5P internal URL.
string | $url | H5P pluginfile URL poiting to an H5P file. |
bool | $preventredirect | Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions |
bool | if user can access pluginfile hash. |
|
static |
Check if the user can edit an H5P file.
It will return true in the following situations:
stored_file | $file | The H5P file to check. |
boolean | Whether the user can edit or not the given file. |
|
static |
Create, if it doesn't exist, the H5P DB instance id for a H5P pluginfile URL.
If it exists:
string | $url | H5P pluginfile URL. |
stdClass | $config | Configuration for H5P buttons. |
factory | $factory | The core_h5p\factory object |
stdClass | $messages | The error, exception and info messages, raised while preparing and running an H5P content. |
bool | $preventredirect | Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions |
bool | $skipcapcheck | Whether capabilities should be checked or not to get the pluginfile URL because sometimes they might be controlled before calling this method. |
array | of [file, h5pid]:
|
|
static |
Delete an H5P package.
stdClass | $content | The H5P package to delete with, at least content['id]. |
factory | $factory | The core_h5p\factory object |
|
static |
Delete an H5P package deployed from the defined $url.
string | $url | pluginfile URL of the H5P package to delete. |
factory | $factory | The core_h5p\factory object |
|
static |
Delete a library and also all the libraries depending on it and the H5P contents using it.
For the H5P content, only the database entries in {h5p} are removed (the .h5p files are not removed in order to let users to deploy them again).
factory | $factory | The H5P factory. |
stdClass | $library | The library to delete. |
|
static |
Returns the H5P content object corresponding to an H5P content file.
string | $pathnamehash | The pathnamehash of the file associated to an H5P content. |
null|stdClass | H5P content object or null if not found. |
|
static |
Get the H5P DB instance id for a H5P pluginfile URL.
If it doesn't exist, it's not created.
string | $url | H5P pluginfile URL. |
bool | $preventredirect | Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions |
bool | $skipcapcheck | Whether capabilities should be checked or not to get the pluginfile URL because sometimes they might be controlled before calling this method. |
array | of [file, stdClass|false]:
|
|
static |
Get all the H5P content type libraries versions.
string | null | $fields | Library fields to return. |
array | An array with an object for each content type library installed. |
|
static |
Get all the libraries using a defined library.
int | $libraryid | The library to get its dependencies. |
array | List of libraryid with all the libraries required by a defined library. |
|
static |
Return the H5P export information file when the file has been deployed.
Otherwise, return null if H5P file: i) has not been deployed. ii) has changed the content.
The information returned will be:
int | $contextid | ContextId of the H5P activity. |
factory | $factory | The core_h5p\factory object. |
string | $component | component |
string | $filearea | file area |
array|null | Return file info otherwise null. |
|
static |
Get a library from an identifier.
int | $libraryid | The library identifier. |
stdClass | The library object having the library identifier defined. |
dml_exception | A DML specific exception is thrown if the libraryid doesn't exist. |
|
static |
Returns a library as an object with properties that correspond to the fetched row's field names.
array | $params | An associative array with the values of the machinename, majorversion and minorversion fields. |
bool | $configurable | A library that has semantics so it can be configured in the editor. |
string | $fields | Library attributes to retrieve. |
stdClass|null | An object with one attribute for each field name in $fields param. |
|
static |
Get the original file and H5P DB instance for a given H5P pluginfile URL.
If it doesn't exist, it's not created. If the file has been added as a reference, this method will return the original linked file.
string | $url | H5P pluginfile URL. |
bool | $preventredirect | Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions. |
bool | $skipcapcheck | Whether capabilities should be checked or not to get the pluginfile URL because sometimes they might be controlled before calling this method. |
array | of [stored_file|false, stdClass|false, stored_file|false]:
|
|
staticprotected |
Get the pathnamehash from an H5P internal URL.
string | $url | H5P pluginfile URL poiting to an H5P file. |
string|false | pathnamehash for the file in the internal URL. |
moodle_exception |
|
static |
Check whether a library is enabled or not.
When machinename is passed, it will return false if any of the versions for this machinename is disabled. If the library doesn't exist, it will return true.
stdClass | $librarydata | Supported fields for library: 'id' and 'machichename'. |
bool |
moodle_exception |
|
static |
Check whether an H5P package is valid or not.
stored_file | $file | The file with the H5P content. |
bool | $onlyupdatelibs | Whether new libraries can be installed or only the existing ones can be updated |
bool | $skipcontent | Should the content be skipped (so only the libraries will be saved)? |
factory | null | $factory | The core_h5p\factory object |
bool | $deletefiletree | Should the temporary files be deleted before returning? |
bool | True if the H5P file is valid (expected format, valid libraries...); false otherwise. |
|
static |
Enable or disable a library.
int | $libraryid | The id of the library to enable/disable. |
bool | $isenabled | True if the library should be enabled; false otherwise. |