Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Public Member Functions | |
__construct (H5PFrameworkInterface $framework, $path, string $url, string $language='en', bool $export=false) | |
Constructor for core_h5p/core. | |
checkSetupErrorMessage () | |
Check if the current server setup is valid and set error messages. | |
checkSetupForRequirements () | |
Check that all H5P requirements for the server setup is met. | |
combineArrayValues ($inputs) | |
Easy way to combine similar data sets. | |
deleteLibrary ($libraryId) | |
Deletes a library. | |
detectSiteType () | |
Detects if the site was accessed from localhost, through a local network or from the internet. | |
fetch_content_type (array $library) | |
Given an H5P content type machine name, fetch and install the required library from the official H5P repository. | |
fetch_latest_content_types () | |
Fetch and install the latest H5P content types libraries from the official H5P repository. | |
fetchLibrariesMetadata ($fetchingDisabled=FALSE, $onlyRegister=false) | |
Communicate with H5P.org and get content type cache. | |
filterParameters (&$content) | |
Filter content run parameters, rebuild content dependency cache and export file. | |
findLibraryDependencies (&$dependencies, $library, $nextWeight=1, $editor=FALSE) | |
Recursive. | |
get_api_endpoint (?string $library=null, string $endpoint='content') | |
Get H5P endpoints. | |
get_dependency_roots (int $id) | |
Get the paths to the content dependencies. | |
get_latest_content_types () | |
Get the latest version of the H5P content types available in the official repository. | |
get_site_uuid () | |
Get the site UUID. | |
getAssetsUrls ($assets) | |
Combines path with cache buster / version. | |
getDependenciesFiles ($dependencies, $prefix='') | |
Return file paths for all dependencies files. | |
getDisplayOptionsForEdit ($disable=NULL) | |
Determine display options visibility and value on edit. | |
getDisplayOptionsForView ($disable, $id) | |
Determine display option visibility when viewing H5P. | |
getHubContentStatus ($hubContentId, $syncStatus) | |
Get status of content from content hub. | |
getLibrariesInstalled () | |
Get a list of installed libraries, different minor versions will return separate entries. | |
getLibraryId ($library, $libString=null) | |
Small helper for getting the library's ID. | |
getLocalization () | |
Provide localization for the Core JS. | |
getStorableDisplayOptions (&$sources, $current) | |
Create representation of display options as int. | |
getUpdatedContentHubMetadataCache ($lang='en') | |
Get updated content hub metadata cache. | |
getUpgrades ($library, $versions) | |
Determine which versions content with the given library can be upgraded to. | |
hubAccountInfo () | |
Fetch account info for our site from the content hub. | |
hubGetAuthorizationHeader () | |
Creates the authorization header needed to access the private parts of the H5P Hub. | |
hubPublishContent ($data, $files, $content_hub_id=NULL) | |
Publish content on the H5P Hub. | |
hubRegisterAccount ($formData, $logo) | |
Register account. | |
hubRetrieveContent ($id) | |
Publish content on the H5P Hub. | |
hubSyncContent ($hubId, $exportPath) | |
Sync content with content hub. | |
hubUnpublishContent ($hubId) | |
Unpublish content from content hub. | |
is_required_core_api ($coreapi) | |
Checks that the required H5P core API version or higher is installed. | |
isSameVersion ($library, $dependency) | |
Check if a library is of the version we're looking for. | |
loadContent ($id) | |
Load content. | |
loadContentDependencies ($id, $type=NULL) | |
Find the files required for this content to work. | |
loadLibrary ($name, $majorVersion, $minorVersion) | |
Load library. | |
loadLibrarySemantics ($name, $majorVersion, $minorVersion) | |
Load library semantics. | |
mayUpdateLibraries ($set=null) | |
Check if the current user has permission to update and install new libraries. | |
saveContent ($content, $contentMainId=NULL) | |
Save content and clear cache. | |
updateContentHubMetadataCache ($lang='en') | |
Update content hub metadata cache. | |
updateContentTypeCache ($postData=NULL) | |
Update content type cache. | |
Static Public Member Functions | |
static | ajaxError ($message=NULL, $error_code=NULL, $status_code=NULL, $details=NULL) |
Makes it easier to print response when AJAX request fails. | |
static | ajaxSuccess ($data=NULL, $only_data=FALSE) |
Makes it easier to print response when AJAX request succeeds. | |
static | createToken ($action) |
Get a new H5P security token for the given action. | |
static | deleteFileTree ($dir) |
Recursive function for removing directories. | |
static | determineEmbedType ($contentEmbedType, $libraryEmbedTypes) |
Determine the correct embed type to use. | |
static | get_scripts () |
Get the list of JS scripts to include on the page. | |
static | libraryFromString ($libraryString) |
Parses library data from a string on the form {machineName} {majorVersion}. | |
static | libraryToFolderName ($library) |
Get the name of a library's folder name. | |
static | libraryToString ($library) |
Writes library data as string on the form {machineName} {majorVersion}. | |
static | libraryVersion ($library) |
Get the absolute version for the library as a human readable string. | |
static | record_to_string (stdClass $record, bool $foldername=false) |
Get the library string from a DB library record. | |
static | returnBytes ($val) |
Return bytes from php_ini string value. | |
static | slugify ($input) |
Convert strings of text into simple kebab case slugs. | |
static | snakeToCamel ($arr, $obj=false) |
Converts all the properties of the given object or array from snake_case to camelCase. | |
static | validToken ($action, $token) |
Verify if the given token is valid for the given action. | |
Static Public Attributes | |
static | $adminScripts |
static | $coreApi |
static | $defaultContentWhitelist = 'json png jpg jpeg gif bmp tif tiff svg eot ttf woff woff2 otf webm mp4 ogg mp3 m4a wav txt pdf rtf doc docx xls xlsx ppt pptx odt ods odp xml csv diff patch swf md textile vtt webvtt gltf glb' |
static | $defaultLibraryWhitelistExtras = 'js css' |
static | $disable |
static | $scripts |
static | $styles |
Protected Member Functions | |
find_library (array $dependency) | |
Get a particular dependency library. | |
getDependencyPath (array $dependency) | |
Get the path to the dependency. | |
Protected Attributes | |
string | $fullPluginPath |
full path of plugin. | |
array | $libraries |
The array containing all the present libraries. | |
core_h5p\core::__construct | ( | H5PFrameworkInterface | $framework, |
$path, | |||
string | $url, | ||
string | $language = 'en', | ||
bool | $export = false ) |
Constructor for core_h5p/core.
H5PFrameworkInterface | $framework | The frameworks implementation of the H5PFrameworkInterface |
string | H5PFileStorage | $path | The H5P file storage directory or class |
string | $url | The URL to the file storage directory |
string | $language | The language code. Defaults to english |
boolean | $export | Whether export is enabled |
|
staticinherited |
Makes it easier to print response when AJAX request fails.
Will exit after printing error.
string | $message | A human readable error message |
string | $error_code | An machine readable error code that a client should be able to interpret |
null | int | $status_code | Http response code |
array | [$details=null] Better description of the error and possible which action to take |
|
staticinherited |
Makes it easier to print response when AJAX request succeeds.
mixed | $data |
|
inherited |
Check if the current server setup is valid and set error messages.
object | Setup object with errors and disable hub properties |
|
inherited |
Easy way to combine similar data sets.
array | $inputs | Multiple arrays with data |
array |
|
staticinherited |
Get a new H5P security token for the given action.
string | $action |
string | token |
|
staticinherited |
Recursive function for removing directories.
string | $dir | Path to the directory we'll be deleting |
boolean | Indicates if the directory existed. |
|
inherited |
Deletes a library.
stdClass | $libraryId |
|
staticinherited |
Determine the correct embed type to use.
$contentEmbedType | |
$libraryEmbedTypes |
string | 'div' or 'iframe'. |
core_h5p\core::fetch_content_type | ( | array | $library | ) |
Given an H5P content type machine name, fetch and install the required library from the official H5P repository.
array | $library | Library machineName, majorversion and minorversion. |
int|null | Returns the id of the content type library installed, null otherwise. |
core_h5p\core::fetch_latest_content_types | ( | ) |
Fetch and install the latest H5P content types libraries from the official H5P repository.
If the latest version of a content type library is present in the system, nothing is done for that content type.
stdClass |
|
inherited |
Communicate with H5P.org and get content type cache.
Each platform implementation is responsible for invoking this, eg using cron
bool | $fetchingDisabled | |
bool | $onlyRegister | Only register site with H5P.org |
bool|object | Returns endpoint data if found, otherwise FALSE |
|
inherited |
Filter content run parameters, rebuild content dependency cache and export file.
Object | array | $content |
Object | NULL on failure. |
|
protected |
Get a particular dependency library.
array | $dependency | An array containing information of the dependency library |
stdClass|null | The library object if the library dependency exists, null otherwise |
|
inherited |
Recursive.
Goes through the dependency tree for the given library and adds all the dependencies to the given array in a flat format.
$dependencies | ||
array | $library | To find all dependencies for. |
int | $nextWeight | An integer determining the order of the libraries when they are loaded |
bool | $editor | Used internally to force all preloaded sub dependencies of an editor dependency to be editor dependencies. |
int |
core_h5p\core::get_api_endpoint | ( | ?string | $library = null, |
string | $endpoint = 'content' ) |
Get H5P endpoints.
If $endpoint = 'content' and $library is null, moodle_url is the endpoint of the latest version of the H5P content types; however, if $library is the machine name of a content type, moodle_url is the endpoint to download the content type. The SITES endpoint ($endpoint = 'site') may be use to get a site UUID or send site data.
string | null | $library | The machineName of the library whose endpoint is requested. |
string | $endpoint | The endpoint required. Valid values: "site", "content". |
moodle_url | The endpoint moodle_url object. |
core_h5p\core::get_dependency_roots | ( | int | $id | ) |
Get the paths to the content dependencies.
int | $id | The H5P content ID |
array | An array containing the path of each content dependency |
core_h5p\core::get_latest_content_types | ( | ) |
Get the latest version of the H5P content types available in the official repository.
stdClass | An object with 2 properties:
|
|
static |
Get the list of JS scripts to include on the page.
array | The array containg urls of the core JavaScript files |
core_h5p\core::get_site_uuid | ( | ) |
Get the site UUID.
If site UUID is not defined, try to register the site.
return $string The site UUID, null if it is not set.
|
inherited |
Combines path with cache buster / version.
array | $assets |
array |
|
inherited |
Return file paths for all dependencies files.
array | $dependencies | |
string | $prefix | Optional. Make paths relative to another dir. |
array | files. |
|
protected |
Get the path to the dependency.
array | $dependency | An array containing the information of the requested dependency library |
string | The path to the dependency library |
Reimplemented from Moodle\H5PCore.
|
inherited |
Determine display options visibility and value on edit.
int | $disable |
array |
|
inherited |
Determine display option visibility when viewing H5P.
int | $display_options | |
int | $id | Might be content id or user id. Depends on what the platform needs to be able to determine permissions. |
array |
|
inherited |
Get status of content from content hub.
string | $hubContentId | |
int | $syncStatus |
false|int | Returns a new H5PContentStatus if successful, else false |
|
inherited |
Get a list of installed libraries, different minor versions will return separate entries.
array | A distinct array of installed libraries |
core_h5p\core::getLibraryId | ( | $library, | |
$libString = null ) |
Small helper for getting the library's ID.
This method is rewritten to use MUC (instead of an static variable which causes some problems with PHPUnit).
array | $library | |
string | $libString |
int | Identifier, or FALSE if non-existent |
Reimplemented from Moodle\H5PCore.
|
inherited |
Provide localization for the Core JS.
array |
|
inherited |
Create representation of display options as int.
array | $sources | |
int | $current |
int |
|
inherited |
Get updated content hub metadata cache.
string | $lang | Language as ISO 639-1 code |
JsonSerializable|string |
|
inherited |
Determine which versions content with the given library can be upgraded to.
object | $library | |
array | $versions |
array |
|
inherited |
Fetch account info for our site from the content hub.
array|bool|string | False if account is not setup, otherwise data |
|
inherited |
Creates the authorization header needed to access the private parts of the H5P Hub.
string |
|
inherited |
Publish content on the H5P Hub.
array | $data | Data from content publishing process |
array | $files | Files to upload with the content publish |
bigint | $content_hub_id | For updating existing content |
stdClass |
|
inherited |
Register account.
array | $formData | Form data. Should include: name, email, description, contact_person, phone, address, city, zip, country, remove_logo |
object | $logo | Input image |
array |
|
inherited |
Publish content on the H5P Hub.
bigint | $id |
stdClass |
|
inherited |
Sync content with content hub.
integer | $hubId | Content hub id |
string | $exportPath | Export path where .h5p for content can be found |
bool |
|
inherited |
Unpublish content from content hub.
integer | $hubId | Content hub id |
bool | True if successful |
core_h5p\core::is_required_core_api | ( | $coreapi | ) |
Checks that the required H5P core API version or higher is installed.
stdClass | $coreapi | Object with properties major and minor for the core API version required. |
bool | True if the required H5P core API version is installed. False if not. |
|
inherited |
Check if a library is of the version we're looking for.
Same version means that the majorVersion and minorVersion is the same
array | $library | Data from library.json |
array | $dependency | Definition of what library we're looking for |
boolean | TRUE if the library is the same version as the dependency FALSE otherwise |
|
staticinherited |
Parses library data from a string on the form {machineName} {majorVersion}.
{minorVersion}
string | $libraryString | On the form {machineName} {majorVersion}.{minorVersion} |
array|FALSE | With keys machineName, majorVersion and minorVersion. Returns FALSE only if string is not parsable in the normal library string formats "Lib.Name-x.y" or "Lib.Name x.y" |
|
staticinherited |
Get the name of a library's folder name.
string |
|
staticinherited |
Writes library data as string on the form {machineName} {majorVersion}.
{minorVersion}
array | $library | With keys (machineName and/or name), majorVersion and minorVersion |
string | On the form {machineName} {majorVersion}.{minorVersion} |
|
staticinherited |
Get the absolute version for the library as a human readable string.
object | $library |
string |
|
inherited |
Load content.
int | $id | for content. |
object |
|
inherited |
Find the files required for this content to work.
int | $id | for content. |
null | $type |
array |
|
inherited |
Load library.
$name | |
$majorVersion | |
$minorVersion |
array | or null. |
|
inherited |
Load library semantics.
$name | |
$majorVersion | |
$minorVersion |
string |
|
inherited |
Check if the current user has permission to update and install new libraries.
bool | [$set] Optional, sets the permission |
bool |
|
static |
|
staticinherited |
Return bytes from php_ini string value.
string | $val |
int|string |
|
inherited |
Save content and clear cache.
array | $content | |
null | int | $contentMainId |
int | Content ID |
|
staticinherited |
Convert strings of text into simple kebab case slugs.
Very useful for readable urls etc.
string | $input |
string |
|
staticinherited |
Converts all the properties of the given object or array from snake_case to camelCase.
Useful after fetching data from the database.
Note that some databases does not support camelCase.
mixed | $arr | input |
boolean | $obj | return object |
mixed | object or array |
|
inherited |
Update content type cache.
object | $postData | Data sent to the hub |
bool|object | Returns endpoint data if found, otherwise FALSE |
|
staticinherited |
Verify if the given token is valid for the given action.
string | $action | |
string | $token |
boolean | valid token |
|
staticinherited |
|
staticinherited |
|
staticinherited |
|
staticinherited |
|
staticinherited |