Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

(no description)

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

Defines 2 classes

H5PEditorEndpoints:: (0 methods):

H5PEditorAjax:: (16 methods):
  __construct()
  action()
  fileUpload()
  libraryUpload()
  processContent()
  isValidEditorToken()
  libraryInstall()
  filter()
  getHubContent()
  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

processContent($contentId)   X-Ref
Process H5P content from local H5P package.

param: integer $contentId The Local Content ID / vid. TODO Remove when JI-366 is fixed

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

getHubContent($hubId, $localContentId)   X-Ref
Download and use content from the HUB

param: integer $hubId The Hub Content ID
param: integer $localContentId The Local Content ID

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