Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
Contains API class for the H5P area.
Copyright: | 2020 Sara Arjona <sara@moodle.com> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 721 lines (31 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
api:: (16 methods):
delete_library()
get_dependent_libraries()
get_library()
get_library_details()
get_contenttype_libraries()
get_content_from_pluginfile_url()
create_content_from_pluginfile_url()
delete_content()
delete_content_from_pluginfile_url()
can_access_pluginfile_hash()
get_pluginfile_hash()
get_content_from_pathnamehash()
get_export_info_from_context_id()
set_library_enabled()
is_library_enabled()
is_valid_package()
delete_library(factory $factory, \stdClass $library) X-Ref |
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). param: factory $factory The H5P factory. param: \stdClass $library The library to delete. |
get_dependent_libraries(int $libraryid) X-Ref |
Get all the libraries using a defined library. param: int $libraryid The library to get its dependencies. return: array List of libraryid with all the libraries required by a defined library. |
get_library(int $libraryid) X-Ref |
Get a library from an identifier. param: int $libraryid The library identifier. return: \stdClass The library object having the library identifier defined. |
get_library_details(array $params, bool $configurable, string $fields = '') X-Ref |
Returns a library as an object with properties that correspond to the fetched row's field names. param: array $params An associative array with the values of the machinename, majorversion and minorversion fields. param: bool $configurable A library that has semantics so it can be configured in the editor. param: string $fields Library attributes to retrieve. return: \stdClass|null An object with one attribute for each field name in $fields param. |
get_contenttype_libraries(?string $fields = '') X-Ref |
Get all the H5P content type libraries versions. param: string|null $fields Library fields to return. return: array An array with an object for each content type library installed. |
get_content_from_pluginfile_url(string $url, bool $preventredirect = true,bool $skipcapcheck = false) X-Ref |
Get the H5P DB instance id for a H5P pluginfile URL. If it doesn't exist, it's not created. param: string $url H5P pluginfile URL. param: bool $preventredirect Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions param: bool $skipcapcheck Whether capabilities should be checked or not to get the pluginfile URL because sometimes they return: array of [file, stdClass|false]: |
create_content_from_pluginfile_url(string $url, \stdClass $config, factory $factory,\stdClass &$messages, bool $preventredirect = true, bool $skipcapcheck = false) X-Ref |
Create, if it doesn't exist, the H5P DB instance id for a H5P pluginfile URL. If it exists: - If the content is not the same, remove the existing content and re-deploy the H5P content again. - If the content is the same, returns the H5P identifier. param: string $url H5P pluginfile URL. param: stdClass $config Configuration for H5P buttons. param: factory $factory The \core_h5p\factory object param: stdClass $messages The error, exception and info messages, raised while preparing and running an H5P content. param: bool $preventredirect Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions param: bool $skipcapcheck Whether capabilities should be checked or not to get the pluginfile URL because sometimes they return: array of [file, h5pid]: |
delete_content(\stdClass $content, factory $factory) X-Ref |
Delete an H5P package. param: stdClass $content The H5P package to delete with, at least content['id]. param: factory $factory The \core_h5p\factory object |
delete_content_from_pluginfile_url(string $url, factory $factory) X-Ref |
Delete an H5P package deployed from the defined $url. param: string $url pluginfile URL of the H5P package to delete. param: factory $factory The \core_h5p\factory object |
can_access_pluginfile_hash(string $url, bool $preventredirect = true) X-Ref |
If user can access pathnamehash from an H5P internal URL. param: string $url H5P pluginfile URL poiting to an H5P file. param: bool $preventredirect Set to true in scripts that can not redirect (CLI, RSS feeds, etc.), throws exceptions return: bool if user can access pluginfile hash. |
get_pluginfile_hash(string $url) X-Ref |
Get the pathnamehash from an H5P internal URL. param: string $url H5P pluginfile URL poiting to an H5P file. return: string|false pathnamehash for the file in the internal URL. |
get_content_from_pathnamehash(string $pathnamehash) X-Ref |
Returns the H5P content object corresponding to an H5P content file. param: string $pathnamehash The pathnamehash of the file associated to an H5P content. return: null|\stdClass H5P content object or null if not found. |
get_export_info_from_context_id(int $contextid,factory $factory,string $component,string $filearea) X-Ref |
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: - filename, filepath, mimetype, filesize, timemodified and fileurl. param: int $contextid ContextId of the H5P activity. param: factory $factory The \core_h5p\factory object. param: string $component component param: string $filearea file area return: array|null Return file info otherwise null. |
set_library_enabled(int $libraryid, bool $isenabled) X-Ref |
Enable or disable a library. param: int $libraryid The id of the library to enable/disable. param: bool $isenabled True if the library should be enabled; false otherwise. |
is_library_enabled(\stdClass $librarydata) X-Ref |
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. param: \stdClass $librarydata Supported fields for library: 'id' and 'machichename'. return: bool |
is_valid_package(\stored_file $file, bool $onlyupdatelibs, bool $skipcontent = false,?factory $factory = null, bool $deletefiletree = true) X-Ref |
Check whether an H5P package is valid or not. param: \stored_file $file The file with the H5P content. param: bool $onlyupdatelibs Whether new libraries can be installed or only the existing ones can be updated param: bool $skipcontent Should the content be skipped (so only the libraries will be saved)? param: factory|null $factory The \core_h5p\factory object param: bool $deletefiletree Should the temporary files be deleted before returning? return: bool True if the H5P file is valid (expected format, valid libraries...); false otherwise. |