Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

Class \core_h5p\editor_framework

Copyright: 2020 Victor Deniz <victor@moodle.com>, base on code by Joubel AS
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 357 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: editor_framework  - X-Ref

Moodle's implementation of the H5P Editor storage interface.

Makes it possible for the editor's core library to communicate with the
database used by Moodle.

get_language_record(string $name, int $major, int $minor, string $lang)   X-Ref
Retrieve library language file from file storage. Note that parent languages will also be checked until a matching
record is found (e.g. "de_kids" -> "de_du" -> "de")

return: stdClass|bool Translation record if available, false otherwise
param: string $name
param: int $major
param: int $minor
param: string $lang

getLanguage($name, $major, $minor, $lang)   X-Ref
Load language file(JSON).
Used to translate the editor fields(title, description etc.)

return: string|boolean Translation in JSON format if available, false otherwise
param: string $name The machine readable name of the library(content type)
param: int $major Major part of version number
param: int $minor Minor part of version number
param: string $lang Language code

getAvailableLanguages($machinename, $major, $minor)   X-Ref
Load a list of available language codes.

Until translations is implemented, only returns the "en" language.

return: array List of possible language codes
param: string $machinename The machine readable name of the library(content type)
param: int $major Major part of version number
param: int $minor Minor part of version number

keepFile($fileid)   X-Ref
"Callback" for mark the given file as a permanent file.

Used when saving content that has new uploaded files.

param: int $fileid

getLibraries($libraries = null)   X-Ref
Return libraries details.

Two use cases:
1. No input, will list all the available content types.
2. Libraries supported are specified, load additional data and verify
that the content types are available. Used by e.g. the Presentation Tool
Editor that already knows which content types are supported in its
slides.

return: array List of all libraries loaded.
param: array $libraries List of library names + version to load info for.

alterLibraryFiles(&$files, $libraries)   X-Ref
Allow for other plugins to decide which styles and scripts are attached.

This is useful for adding and/or modifying the functionality and look of
the content types.

param: array $files List of files as objects with path and version as properties.
param: array $libraries List of libraries indexed by machineName with objects as values. The objects have majorVersion and

saveFileTemporarily($data, $movefile = false)   X-Ref
Saves a file or moves it temporarily.

This is often necessary in order to validate and store uploaded or fetched H5Ps.

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

markFileForCleanup($file, $contentid = null)   X-Ref
Marks a file for later cleanup.

Useful when files are not instantly cleaned up. E.g. for files that are uploaded through the editor.

param: int $file Id of file that should be cleaned up
param: int|null $contentid Content id of file

removeTemporarilySavedFiles($filepath)   X-Ref
Clean up temporary files

param: string $filepath Path to file or directory