Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_h5p\framework Class Reference
Inheritance diagram for core_h5p\framework:
Moodle\H5PFrameworkInterface

Public Member Functions

 afterExportCreated ($content, $filename)
 Will trigger after the export file is created.
 
 alterLibrarySemantics (&$semantics, $name, $majorversion, $minorversion)
 Makes it possible to alter the semantics, adding custom fields, etc.
 
 clearFilteredParameters ($libraryids)
 Will clear filtered params for all the content that uses the specified.
 
 copyLibraryUsage ($contentid, $copyfromid, $contentmainid=null)
 Give an H5P the same library dependencies as a given H5P.
 
 deleteCachedAssets ($libraryid)
 Locate hash keys for given library and delete them.
 
 deleteContentData ($contentid)
 Deletes content data.
 
 deleteLibrary ($library)
 Delete a library from database and file system.
 
 deleteLibraryDependencies ($libraryid)
 Delete all dependencies belonging to given library.
 
 deleteLibraryUsage ($contentid)
 Delete what libraries a content item is using.
 
 fetchExternalData ($url, $data=null, $blocking=true, $stream=null, $fulldata=false, $headers=[], $files=[], $method='POST')
 Fetches a file from a remote server using HTTP GET Implements fetchExternalData.
 
 get_file ()
 Get the .h5p file.
 
 get_latest_library_version (string $machinename)
 Get the latest library version.
 
 getAdminUrl ()
 Returns the URL to the library admin page.
 
 getContentHubMetadataCache ($lang='en')
 Get content hub metadata cache from db.
 
 getContentHubMetadataChecked ($lang='en')
 Get time of last content hub metadata check.
 
 getLibraryConfig ($libraries=null)
 Load config for libraries.
 
 getLibraryContentCount ()
 Get the amount of content items associated to a library.
 
 getLibraryFileUrl ($libraryfoldername, $filename)
 Get URL to file in the specifimake_pluginfile_urlc library.
 
 getLibraryId ($machinename, $majorversion=null, $minorversion=null)
 Return the library's ID.
 
 getLibraryStats ($type)
 Generates statistics from the event log per library.
 
 getLibraryUsage ($id, $skipcontent=false)
 Get number of content/nodes using a library, and the number of dependencies to other libraries.
 
 getMessages ($type)
 Return messages.
 
 getNumAuthors ()
 Aggregate the current number of H5P authors.
 
 getNumContent ($libraryid, $skip=null)
 Get number of contents using library as main library.
 
 getNumNotFiltered ()
 Get number of contents that has to get their content dependencies rebuilt.
 
 getOption ($name, $default=false)
 Get stored setting.
 
 getPlatformInfo ()
 Returns info for the current platform.
 
 getUploadedH5pFolderPath ($setpath=null)
 Get the Path to the last uploaded h5p.
 
 getUploadedH5pFolderPath ()
 Get the Path to the last uploaded h5p.
 
 getUploadedH5pPath ($setpath=null)
 Get the path to the last uploaded h5p file.
 
 getUploadedH5pPath ()
 Get the path to the last uploaded h5p file.
 
 getWhitelist ($islibrary, $defaultcontentwhitelist, $defaultlibrarywhitelist)
 Get allowed file extension list.
 
 hasPermission ($permission, $id=null)
 Check whether a user has permissions to execute an action, such as embed H5P content.
 
 insertContent ($content, $contentmainid=null)
 Insert new content.
 
 isContentSlugAvailable ($slug)
 Determines if content slug is used.
 
 isInDevMode ()
 Is H5P in development mode? Implements isInDevMode.
 
 isPatchedLibrary ($library)
 Is the library a patched version of an existing library? Implements isPatchedLibrary.
 
 libraryHasUpgrade ($library)
 Checks if the given library has a higher version.
 
 loadAddons ()
 Load addon libraries.
 
 loadContent ($id)
 Load content.
 
 loadContentDependencies ($id, $type=null)
 Load dependencies for the given content of the given type.
 
 loadLibraries ()
 Get a list of the current installed libraries.
 
 loadLibrary ($machinename, $majorversion, $minorversion)
 Loads a library.
 
 loadLibrarySemantics ($name, $majorversion, $minorversion)
 Loads library semantics.
 
 lockDependencyStorage ()
 Start an atomic operation against the dependency storage.
 
 mayUpdateLibraries ()
 Is the current user allowed to update libraries? Implements mayUpdateLibraries.
 
 replaceContentHubMetadataCache ($metadata, $lang)
 Replace content hub metadata cache.
 
 replaceContentTypeCache ($contenttypecache)
 Replaces existing content type cache with the one passed in.
 
 resetContentUserData ($contentid)
 Resets marked user data for the given content.
 
 saveCachedAssets ($key, $libraries)
 Stores hash keys for cached assets, aggregated JavaScripts and stylesheets, and connects it to libraries so that we know which cache file to delete when a library is updated.
 
 saveLibraryData (&$librarydata, $new=true)
 Store data about a library.
 
 saveLibraryDependencies ($libraryid, $dependencies, $dependencytype)
 Save what libraries a library is depending on.
 
 saveLibraryUsage ($contentid, $librariesinuse)
 Saves what libraries the content uses.
 
 set_file (\stored_file $file)
 Set the .h5p file.
 
 setContentHubMetadataChecked ($time, $lang='en')
 Set time of last content hub metadata check.
 
 setErrorMessage ($message, $code=null)
 Set an error message.
 
 setInfoMessage ($message)
 Set an info message.
 
 setLibraryTutorialUrl ($libraryname, $url)
 Set the tutorial URL for a library.
 
 setOption ($name, $value)
 Stores the given setting.
 
 t ($message, $replacements=array())
 Translation function.
 
 unlockDependencyStorage ()
 Start an atomic operation against the dependency storage.
 
 updateContent ($content, $contentmainid=null)
 Update old content or insert new content.
 
 updateContentFields ($id, $fields)
 This will update selected fields on the given content.
 

Static Public Member Functions

static get_language ()
 Get current H5P language code.
 

Member Function Documentation

◆ afterExportCreated()

core_h5p\framework::afterExportCreated ( $content,
$filename )

Will trigger after the export file is created.

Implements afterExportCreated.

Parameters
array$contentThe content
string$filenameThe file name

Implements Moodle\H5PFrameworkInterface.

◆ alterLibrarySemantics()

core_h5p\framework::alterLibrarySemantics ( & $semantics,
$name,
$majorversion,
$minorversion )

Makes it possible to alter the semantics, adding custom fields, etc.

Implements alterLibrarySemantics.

Parameters
array$semanticsAssociative array representing the semantics
string$nameThe library's machine name
int$majorversionThe library's major version
int$minorversionThe library's minor version

Implements Moodle\H5PFrameworkInterface.

◆ clearFilteredParameters()

core_h5p\framework::clearFilteredParameters ( $libraryids)

Will clear filtered params for all the content that uses the specified.

libraries. This means that the content dependencies will have to be rebuilt and the parameters re-filtered. Implements clearFilteredParameters().

Parameters
array$libraryidsArray of library ids

Implements Moodle\H5PFrameworkInterface.

◆ copyLibraryUsage()

core_h5p\framework::copyLibraryUsage ( $contentid,
$copyfromid,
$contentmainid = null )

Give an H5P the same library dependencies as a given H5P.

Implements copyLibraryUsage.

Parameters
int$contentidId identifying the content
int$copyfromidId identifying the content to be copied
int$contentmainidMain id for the content, typically used in frameworks

Implements Moodle\H5PFrameworkInterface.

◆ deleteCachedAssets()

core_h5p\framework::deleteCachedAssets ( $libraryid)

Locate hash keys for given library and delete them.

Used when cache file are deleted. Implements deleteCachedAssets.

Parameters
int$libraryidLibrary identifier
Return values
arrayList of hash keys removed

Implements Moodle\H5PFrameworkInterface.

◆ deleteContentData()

core_h5p\framework::deleteContentData ( $contentid)

Deletes content data.

Implements deleteContentData.

Parameters
int$contentidId identifying the content

Implements Moodle\H5PFrameworkInterface.

◆ deleteLibrary()

core_h5p\framework::deleteLibrary ( $library)

Delete a library from database and file system.

Implements deleteLibrary.

Parameters
stdClass$libraryLibrary object with id, name, major version and minor version

Implements Moodle\H5PFrameworkInterface.

◆ deleteLibraryDependencies()

core_h5p\framework::deleteLibraryDependencies ( $libraryid)

Delete all dependencies belonging to given library.

Implements deleteLibraryDependencies.

Parameters
int$libraryidLibrary identifier

Implements Moodle\H5PFrameworkInterface.

◆ deleteLibraryUsage()

core_h5p\framework::deleteLibraryUsage ( $contentid)

Delete what libraries a content item is using.

Implements deleteLibraryUsage.

Parameters
int$contentidContent Id of the content we'll be deleting library usage for

Implements Moodle\H5PFrameworkInterface.

◆ fetchExternalData()

core_h5p\framework::fetchExternalData ( $url,
$data = null,
$blocking = true,
$stream = null,
$fulldata = false,
$headers = [],
$files = [],
$method = 'POST' )

Fetches a file from a remote server using HTTP GET Implements fetchExternalData.

Parameters
string$urlWhere you want to get or send data.
array$dataData to post to the URL.
bool$blockingSet to 'FALSE' to instantly time out (fire and forget).
string$streamPath to where the file should be saved.
bool$fulldataReturn additional response data such as headers and potentially other data
array$headersHeaders to send
array$filesFiles to send
string$method
Return values
string|arrayThe content (response body), or an array with data. NULL if something went wrong

Implements Moodle\H5PFrameworkInterface.

◆ get_file()

core_h5p\framework::get_file ( )

Get the .h5p file.

Return values
stored_fileThe .h5p file.

◆ get_language()

static core_h5p\framework::get_language ( )
static

Get current H5P language code.

Return values
stringLanguage Code

◆ get_latest_library_version()

core_h5p\framework::get_latest_library_version ( string $machinename)

Get the latest library version.

Parameters
string$machinenameThe library's machine name
Return values
stdClass|nullAn object with the latest library version

◆ getAdminUrl()

core_h5p\framework::getAdminUrl ( )

Returns the URL to the library admin page.

Implements getAdminUrl.

Return values
stringURL to admin page

Implements Moodle\H5PFrameworkInterface.

◆ getContentHubMetadataCache()

core_h5p\framework::getContentHubMetadataCache ( $lang = 'en')

Get content hub metadata cache from db.

Parameters
string$langLanguage code in ISO 639-1
Return values
JsonSerializableJson string

Implements Moodle\H5PFrameworkInterface.

◆ getContentHubMetadataChecked()

core_h5p\framework::getContentHubMetadataChecked ( $lang = 'en')

Get time of last content hub metadata check.

Parameters
string$langLanguage code iin ISO 639-1 format
Return values
string|nullTime in RFC7231 format

Implements Moodle\H5PFrameworkInterface.

◆ getLibraryConfig()

core_h5p\framework::getLibraryConfig ( $libraries = null)

Load config for libraries.

Implements getLibraryConfig.

Parameters
array | null$librariesList of libraries
Return values
array|nullThe library config if it exists, null otherwise

Implements Moodle\H5PFrameworkInterface.

◆ getLibraryContentCount()

core_h5p\framework::getLibraryContentCount ( )

Get the amount of content items associated to a library.

Implements getLibraryContentCount.

return array The number of content items associated to a library

Implements Moodle\H5PFrameworkInterface.

◆ getLibraryFileUrl()

core_h5p\framework::getLibraryFileUrl ( $libraryfoldername,
$filename )

Get URL to file in the specifimake_pluginfile_urlc library.

Implements getLibraryFileUrl.

Parameters
string$libraryfoldernameThe name or path of the library's folder
string$filenameThe file name
Return values
stringURL to file

Implements Moodle\H5PFrameworkInterface.

◆ getLibraryId()

core_h5p\framework::getLibraryId ( $machinename,
$majorversion = null,
$minorversion = null )

Return the library's ID.

Implements getLibraryId.

Parameters
string$machinenameThe librarys machine name
string$majorversionMajor version number for library (optional)
string$minorversionMinor version number for library (optional)
Return values
int|boolIdentifier, or false if non-existent

Implements Moodle\H5PFrameworkInterface.

◆ getLibraryStats()

core_h5p\framework::getLibraryStats ( $type)

Generates statistics from the event log per library.

Implements getLibraryStats.

Parameters
string$typeType of event to generate stats for
Return values
arrayNumber values indexed by library name and version

Implements Moodle\H5PFrameworkInterface.

◆ getLibraryUsage()

core_h5p\framework::getLibraryUsage ( $id,
$skipcontent = false )

Get number of content/nodes using a library, and the number of dependencies to other libraries.

Implements getLibraryUsage.

Parameters
int$idLibrary identifier
boolean$skipcontentOptional. Set as true to get number of content instances for library
Return values
arrayThe array contains two elements, keyed by 'content' and 'libraries'. Each element contains a number

Implements Moodle\H5PFrameworkInterface.

◆ getMessages()

core_h5p\framework::getMessages ( $type)

Return messages.

Implements getMessages.

Parameters
string$typeThe message type, e.g. 'info' or 'error'
Return values
string[]Array of messages

Implements Moodle\H5PFrameworkInterface.

◆ getNumAuthors()

core_h5p\framework::getNumAuthors ( )

Aggregate the current number of H5P authors.

Implements getNumAuthors.

Return values
intThe current number of H5P authors

Implements Moodle\H5PFrameworkInterface.

◆ getNumContent()

core_h5p\framework::getNumContent ( $libraryid,
$skip = null )

Get number of contents using library as main library.

Implements getNumContent().

Parameters
int$libraryidThe library ID
array$skipThe array of h5p content ID's that should be ignored
Return values
intThe number of contents using library as main library

Implements Moodle\H5PFrameworkInterface.

◆ getNumNotFiltered()

core_h5p\framework::getNumNotFiltered ( )

Get number of contents that has to get their content dependencies rebuilt.

and parameters re-filtered. Implements getNumNotFiltered().

Return values
intThe number of contents that has to get their content dependencies rebuilt and parameters re-filtered

Implements Moodle\H5PFrameworkInterface.

◆ getOption()

core_h5p\framework::getOption ( $name,
$default = false )

Get stored setting.

Implements getOption.

To avoid updating the cache libraries when using the Hub selector, {

See also
Moodle\H5PEditorAjax\isContentTypeCacheUpdated}, the setting content_type_cache_updated_at always return the current time.
Parameters
string$nameIdentifier for the setting
string$defaultOptional default value if settings is not set
Return values
mixedReturn Whatever has been stored as the setting

Implements Moodle\H5PFrameworkInterface.

◆ getPlatformInfo()

core_h5p\framework::getPlatformInfo ( )

Returns info for the current platform.

Implements getPlatformInfo.

Return values
arrayAn associative array containing:
  • name: The name of the platform, for instance "Moodle"
  • version: The version of the platform, for instance "3.8"
  • h5pVersion: The version of the H5P component

Implements Moodle\H5PFrameworkInterface.

◆ getUploadedH5pFolderPath() [1/2]

core_h5p\framework::getUploadedH5pFolderPath ( $setpath = null)

Get the Path to the last uploaded h5p.

Implements getUploadedH5PFolderPath.

Parameters
string$setpathThe path to the folder of the last uploaded h5p
Return values
stringPath to the folder where the last uploaded h5p for this session is located

◆ getUploadedH5pFolderPath() [2/2]

Moodle\H5PFrameworkInterface::getUploadedH5pFolderPath ( )
inherited

Get the Path to the last uploaded h5p.

Return values
stringPath to the folder where the last uploaded h5p for this session is located.

◆ getUploadedH5pPath() [1/2]

core_h5p\framework::getUploadedH5pPath ( $setpath = null)

Get the path to the last uploaded h5p file.

Implements getUploadedH5PPath.

Parameters
string$setpathThe path to the last uploaded h5p
Return values
stringPath to the last uploaded h5p

◆ getUploadedH5pPath() [2/2]

Moodle\H5PFrameworkInterface::getUploadedH5pPath ( )
inherited

Get the path to the last uploaded h5p file.

Return values
stringPath to the last uploaded h5p

◆ getWhitelist()

core_h5p\framework::getWhitelist ( $islibrary,
$defaultcontentwhitelist,
$defaultlibrarywhitelist )

Get allowed file extension list.

Implements getWhitelist.

The default extension list is part of h5p, but admins should be allowed to modify it.

Parameters
boolean$islibraryTRUE if this is the whitelist for a library. FALSE if it is the whitelist for the content folder we are getting.
string$defaultcontentwhitelistA string of file extensions separated by whitespace.
string$defaultlibrarywhitelistA string of file extensions separated by whitespace.
Return values
stringA string containing the allowed file extensions separated by whitespace.

Implements Moodle\H5PFrameworkInterface.

◆ hasPermission()

core_h5p\framework::hasPermission ( $permission,
$id = null )

Check whether a user has permissions to execute an action, such as embed H5P content.

Implements hasPermission.

Parameters
H5PPermission$permissionPermission type
int$idId need by platform to determine permission
Return values
booleantrue if the user can execute the action defined in $permission; false otherwise

Implements Moodle\H5PFrameworkInterface.

◆ insertContent()

core_h5p\framework::insertContent ( $content,
$contentmainid = null )

Insert new content.

Implements insertContent.

Parameters
array$contentAn associative array containing:
  • id: The content id
  • params: The content in json format
  • library: An associative array containing:
    • libraryId: The id of the main library for this content
  • disable: H5P Button display options
  • pathnamehash: The pathnamehash linking the record with the entry in the mdl_files table
  • contenthash: The contenthash linking the record with the entry in the mdl_files table
int$contentmainidMain id for the content if this is a system that supports versions
Return values
intThe ID of the newly inserted content

Implements Moodle\H5PFrameworkInterface.

◆ isContentSlugAvailable()

core_h5p\framework::isContentSlugAvailable ( $slug)

Determines if content slug is used.

Implements isContentSlugAvailable.

Parameters
string$slugThe content slug
Return values
booleanWhether the content slug is used

Implements Moodle\H5PFrameworkInterface.

◆ isInDevMode()

core_h5p\framework::isInDevMode ( )

Is H5P in development mode? Implements isInDevMode.

Return values
booleanTRUE if H5P development mode is active FALSE otherwise

Implements Moodle\H5PFrameworkInterface.

◆ isPatchedLibrary()

core_h5p\framework::isPatchedLibrary ( $library)

Is the library a patched version of an existing library? Implements isPatchedLibrary.

Parameters
array$libraryAn associative array containing:
  • machineName: The library machine name
  • majorVersion: The librarys major version
  • minorVersion: The librarys minor version
  • patchVersion: The librarys patch version
Return values
booleanTRUE if the library is a patched version of an existing library FALSE otherwise

Implements Moodle\H5PFrameworkInterface.

◆ libraryHasUpgrade()

core_h5p\framework::libraryHasUpgrade ( $library)

Checks if the given library has a higher version.

Implements libraryHasUpgrade.

Parameters
array$libraryAn associative array containing:
  • machineName: The library machineName
  • majorVersion: The library's majorVersion
  • minorVersion: The library's minorVersion
Return values
booleanWhether the library has a higher version

Implements Moodle\H5PFrameworkInterface.

◆ loadAddons()

core_h5p\framework::loadAddons ( )

Load addon libraries.

Implements loadAddons.

Return values
arrayThe array containing the addon libraries

Implements Moodle\H5PFrameworkInterface.

◆ loadContent()

core_h5p\framework::loadContent ( $id)

Load content.

Implements loadContent.

Parameters
int$idContent identifier
Return values
arrayAssociative array containing:
  • id: Identifier for the content
  • params: json content as string
  • embedType: list of supported embed types
  • disable: H5P Button display options
  • title: H5P content title
  • slug: Human readable content identifier that is unique
  • libraryId: Id for the main library
  • libraryName: The library machine name
  • libraryMajorVersion: The library's majorVersion
  • libraryMinorVersion: The library's minorVersion
  • libraryEmbedTypes: CSV of the main library's embed types
  • libraryFullscreen: 1 if fullscreen is supported. 0 otherwise
  • metadata: The content's metadata

Implements Moodle\H5PFrameworkInterface.

◆ loadContentDependencies()

core_h5p\framework::loadContentDependencies ( $id,
$type = null )

Load dependencies for the given content of the given type.

Implements loadContentDependencies.

Parameters
int$idContent identifier
int$typeThe dependency type
Return values
arrayList of associative arrays containing:
  • libraryId: The id of the library if it is an existing library
  • machineName: The library machineName
  • majorVersion: The library's majorVersion
  • minorVersion: The library's minorVersion
  • patchVersion: The library's patchVersion
  • preloadedJs(optional): comma separated string with js file paths
  • preloadedCss(optional): comma separated sting with css file paths
  • dropCss(optional): csv of machine names
  • dependencyType: The dependency type

Implements Moodle\H5PFrameworkInterface.

◆ loadLibraries()

core_h5p\framework::loadLibraries ( )

Get a list of the current installed libraries.

Implements loadLibraries.

Return values
arrayAssociative array containing one entry per machine name. For each machineName there is a list of libraries(with different versions).

Implements Moodle\H5PFrameworkInterface.

◆ loadLibrary()

core_h5p\framework::loadLibrary ( $machinename,
$majorversion,
$minorversion )

Loads a library.

Implements loadLibrary.

Parameters
string$machinenameThe library's machine name
int$majorversionThe library's major version
int$minorversionThe library's minor version
Return values
array|boolReturns FALSE if the library does not exist Otherwise an associative array containing:
  • libraryId: The id of the library if it is an existing library,
  • title: The library's name,
  • machineName: The library machineName
  • majorVersion: The library's majorVersion
  • minorVersion: The library's minorVersion
  • patchVersion: The library's patchVersion
  • runnable: 1 if the library is a content type, 0 otherwise
  • fullscreen: 1 if the library supports fullscreen, 0 otherwise
  • embedTypes: list of supported embed types
  • preloadedJs: comma separated string with js file paths
  • preloadedCss: comma separated sting with css file paths
  • dropLibraryCss: list of associative arrays containing:
    • machineName: machine name for the librarys that are to drop their css
  • semantics: Json describing the content structure for the library
  • preloadedDependencies(optional): list of associative arrays containing:
    • machineName: Machine name for a library this library is depending on
    • majorVersion: Major version for a library this library is depending on
    • minorVersion: Minor for a library this library is depending on
  • dynamicDependencies(optional): list of associative arrays containing:
    • machineName: Machine name for a library this library is depending on
    • majorVersion: Major version for a library this library is depending on
    • minorVersion: Minor for a library this library is depending on

Implements Moodle\H5PFrameworkInterface.

◆ loadLibrarySemantics()

core_h5p\framework::loadLibrarySemantics ( $name,
$majorversion,
$minorversion )

Loads library semantics.

Implements loadLibrarySemantics.

Parameters
string$nameMachine name for the library
int$majorversionThe library's major version
int$minorversionThe library's minor version
Return values
stringThe library's semantics as json

Implements Moodle\H5PFrameworkInterface.

◆ lockDependencyStorage()

core_h5p\framework::lockDependencyStorage ( )

Start an atomic operation against the dependency storage.

Implements lockDependencyStorage.

Implements Moodle\H5PFrameworkInterface.

◆ mayUpdateLibraries()

core_h5p\framework::mayUpdateLibraries ( )

Is the current user allowed to update libraries? Implements mayUpdateLibraries.

Return values
booleanTRUE if the user is allowed to update libraries, FALSE if the user is not allowed to update libraries.

Implements Moodle\H5PFrameworkInterface.

◆ replaceContentHubMetadataCache()

core_h5p\framework::replaceContentHubMetadataCache ( $metadata,
$lang )

Replace content hub metadata cache.

Parameters
JsonSerializable$metadataMetadata as received from content hub
string$langLanguage in ISO 639-1
Return values
mixed

Implements Moodle\H5PFrameworkInterface.

◆ replaceContentTypeCache()

core_h5p\framework::replaceContentTypeCache ( $contenttypecache)

Replaces existing content type cache with the one passed in.

Implements replaceContentTypeCache.

Parameters
object$contenttypecacheJson with an array called 'libraries' containing the new content type cache that should replace the old one

Implements Moodle\H5PFrameworkInterface.

◆ resetContentUserData()

core_h5p\framework::resetContentUserData ( $contentid)

Resets marked user data for the given content.

Implements resetContentUserData.

Parameters
int$contentidThe h5p content id

Implements Moodle\H5PFrameworkInterface.

◆ saveCachedAssets()

core_h5p\framework::saveCachedAssets ( $key,
$libraries )

Stores hash keys for cached assets, aggregated JavaScripts and stylesheets, and connects it to libraries so that we know which cache file to delete when a library is updated.

Implements saveCachedAssets.

Parameters
string$keyHash key for the given libraries
array$librariesList of dependencies(libraries) used to create the key

Implements Moodle\H5PFrameworkInterface.

◆ saveLibraryData()

core_h5p\framework::saveLibraryData ( & $librarydata,
$new = true )

Store data about a library.

Implements saveLibraryData.

Also fills in the libraryId in the libraryData object if the object is new.

Parameters
array$librarydataAssociative array containing:
  • libraryId: The id of the library if it is an existing library
  • title: The library's name
  • machineName: The library machineName
  • majorVersion: The library's majorVersion
  • minorVersion: The library's minorVersion
  • patchVersion: The library's patchVersion
  • runnable: 1 if the library is a content type, 0 otherwise
  • fullscreen(optional): 1 if the library supports fullscreen, 0 otherwise
  • embedtypes: list of supported embed types
  • preloadedJs(optional): list of associative arrays containing:
    • path: path to a js file relative to the library root folder
  • preloadedCss(optional): list of associative arrays containing:
    • path: path to css file relative to the library root folder
  • dropLibraryCss(optional): list of associative arrays containing:
    • machineName: machine name for the librarys that are to drop their css
  • semantics(optional): Json describing the content structure for the library
  • metadataSettings(optional): object containing:
    • disable: 1 if metadata is disabled completely
    • disableExtraTitleField: 1 if the title field is hidden in the form
bool$newWhether it is a new or existing library.

Implements Moodle\H5PFrameworkInterface.

◆ saveLibraryDependencies()

core_h5p\framework::saveLibraryDependencies ( $libraryid,
$dependencies,
$dependencytype )

Save what libraries a library is depending on.

Implements saveLibraryDependencies.

Parameters
int$libraryidLibrary Id for the library we're saving dependencies for
array$dependenciesList of dependencies as associative arrays containing:
  • machineName: The library machineName
  • majorVersion: The library's majorVersion
  • minorVersion: The library's minorVersion
string$dependencytypeThe type of dependency

Implements Moodle\H5PFrameworkInterface.

◆ saveLibraryUsage()

core_h5p\framework::saveLibraryUsage ( $contentid,
$librariesinuse )

Saves what libraries the content uses.

Implements saveLibraryUsage.

Parameters
int$contentidId identifying the content
array$librariesinuseList of libraries the content uses

Implements Moodle\H5PFrameworkInterface.

◆ set_file()

core_h5p\framework::set_file ( \stored_file $file)

Set the .h5p file.

Parameters
stored_file$fileThe .h5p file.

◆ setContentHubMetadataChecked()

core_h5p\framework::setContentHubMetadataChecked ( $time,
$lang = 'en' )

Set time of last content hub metadata check.

Parameters
int | null$timeTime in RFC7231 format
string$langLanguage code iin ISO 639-1 format
Return values
boolTrue if successful

Implements Moodle\H5PFrameworkInterface.

◆ setErrorMessage()

core_h5p\framework::setErrorMessage ( $message,
$code = null )

Set an error message.

Implements setErrorMessage.

Parameters
string$messageThe error message
string$codeAn optional code

Implements Moodle\H5PFrameworkInterface.

◆ setInfoMessage()

core_h5p\framework::setInfoMessage ( $message)

Set an info message.

Implements setInfoMessage.

Parameters
string$messageThe info message

Implements Moodle\H5PFrameworkInterface.

◆ setLibraryTutorialUrl()

core_h5p\framework::setLibraryTutorialUrl ( $libraryname,
$url )

Set the tutorial URL for a library.

All versions of the library is set. Implements setLibraryTutorialUrl.

Parameters
string$libraryname
string$url

Implements Moodle\H5PFrameworkInterface.

◆ setOption()

core_h5p\framework::setOption ( $name,
$value )

Stores the given setting.

For example when did we last check h5p.org for updates to our libraries. Implements setOption.

Parameters
string$nameIdentifier for the setting
mixed$valueData Whatever we want to store as the setting

Implements Moodle\H5PFrameworkInterface.

◆ t()

core_h5p\framework::t ( $message,
$replacements = array() )

Translation function.

The purpose of this function is to map the strings used in the core h5p methods and replace them with the translated ones. If a translation for a particular string is not available, the default message (key) will be returned. Implements t.

Parameters
string$messageThe english string to be translated
array$replacementsAn associative array of replacements to make after translation
Return values
stringTranslated string or the english string if a translation is not available

Implements Moodle\H5PFrameworkInterface.

◆ unlockDependencyStorage()

core_h5p\framework::unlockDependencyStorage ( )

Start an atomic operation against the dependency storage.

Implements unlockDependencyStorage.

Implements Moodle\H5PFrameworkInterface.

◆ updateContent()

core_h5p\framework::updateContent ( $content,
$contentmainid = null )

Update old content or insert new content.

Implements updateContent.

Parameters
array$contentAn associative array containing:
  • id: The content id
  • params: The content in json format
  • library: An associative array containing:
    • libraryId: The id of the main library for this content
  • disable: H5P Button display options
  • pathnamehash: The pathnamehash linking the record with the entry in the mdl_files table
  • contenthash: The contenthash linking the record with the entry in the mdl_files table
int$contentmainidMain id for the content if this is a system that supports versions
Return values
intThe ID of the newly inserted or updated content

Implements Moodle\H5PFrameworkInterface.

◆ updateContentFields()

core_h5p\framework::updateContentFields ( $id,
$fields )

This will update selected fields on the given content.

Implements updateContentFields().

Parameters
int$idContent identifier
array$fieldsContent fields, e.g. filtered

Implements Moodle\H5PFrameworkInterface.


The documentation for this class was generated from the following file: