Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

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")

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

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

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
return: string|boolean Translation in JSON format if available, false otherwise

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

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

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
return: array List of possible language codes

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.

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

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.

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.
return: bool|object Returns false if saving failed or an object with path

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