Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

(no description)

File Size: 455 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

H5PEditorEndpoints:: (0 methods):

H5PEditorAjax:: (14 methods):
  __construct()
  action()
  fileUpload()
  libraryUpload()
  isValidEditorToken()
  libraryInstall()
  filter()
  isValidPackage()
  saveFileTemporarily()
  callHubEndpoint()
  isPostRequest()
  isHubOn()
  isContentTypeCacheUpdated()
  getContentTypeCache()


Class: H5PEditorAjax  - X-Ref

Class H5PEditorAjax

__construct(H5PCore $H5PCore, H5peditor $H5PEditor, H5peditorStorage $H5PEditorStorage)   X-Ref
H5PEditorAjax constructor requires core, editor and storage as building
blocks.

param: H5PCore $H5PCore
param: H5peditor $H5PEditor
param: H5peditorStorage $H5PEditorStorage

action($endpoint)   X-Ref

param: $endpoint

fileUpload($contentId = NULL)   X-Ref
Handles uploaded files from the editor, making sure they are validated
and ready to be permanently stored if saved.

Marks all uploaded files as
temporary so they can be cleaned up when we have finished using them.

param: int $contentId Id of content if already existing content

libraryUpload($uploadFilePath, $contentId)   X-Ref
Handles uploading libraries so they are ready to be modified or directly saved.

Validates and saves any dependencies, then exposes content to the editor.

param: {string} $uploadFilePath Path to the file that should be uploaded
param: {int} $contentId Content id of library

isValidEditorToken($token)   X-Ref
Validates security tokens used for the editor

param: string $token
return: bool

libraryInstall($machineName)   X-Ref
Handles installation of libraries from the Content Type Hub.

Accepts a machine name and attempts to fetch and install it from the Hub if
it is valid. Will also install any dependencies to the requested library.

param: string $machineName Name of library that should be installed

filter($libraryParameters)   X-Ref
End-point for filter parameter values according to semantics.

param: {string} $libraryParameters

isValidPackage($skipContent = FALSE)   X-Ref
Validates the package. Sets error messages if validation fails.

param: bool $skipContent Will not validate cotent if set to TRUE
return: bool

saveFileTemporarily($data, $move_file = FALSE)   X-Ref
Saves a file or moves it temporarily. This is often necessary in order to
validate and store uploaded or fetched H5Ps.

Sets error messages if saving fails.

param: string $data Uri of data that should be saved as a temporary file
param: boolean $move_file Can be set to TRUE to move the data instead of saving it
return: bool|object Returns false if saving failed or the path to the file

callHubEndpoint($endpoint)   X-Ref
Calls provided hub endpoint and downloads the response to a .h5p file.

param: string $endpoint Endpoint without protocol
return: bool

isPostRequest()   X-Ref
Checks if request is a POST. Sets error message on fail.

return: bool

isHubOn()   X-Ref
Checks if H5P Hub is enabled. Sets error message on fail.

return: bool

isContentTypeCacheUpdated()   X-Ref
Checks if Content Type Cache is up to date. Immediately tries to fetch
a new Content Type Cache if it is outdated.
Sets error message if fetching new Content Type Cache fails.

return: bool

getContentTypeCache($cacheOutdated = FALSE)   X-Ref
Gets content type cache for globally available libraries and the order
in which they have been used by the author

param: bool $cacheOutdated The cache is outdated and not able to update