Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | List of all members
core_h5p\editor_framework Class Reference

Moodle's implementation of the H5P Editor storage interface. More...

Inheritance diagram for core_h5p\editor_framework:

Public Member Functions

 alterLibraryFiles (&$files, $libraries)
 Allow for other plugins to decide which styles and scripts are attached. More...
 
 getAvailableLanguages ($machinename, $major, $minor)
 Load a list of available language codes. More...
 
 getLanguage ($name, $major, $minor, $lang)
 Load language file(JSON). More...
 
 getLibraries ($libraries=null)
 Return libraries details. More...
 
 keepFile ($fileid)
 "Callback" for mark the given file as a permanent file. More...
 

Static Public Member Functions

static markFileForCleanup ($file, $contentid=null)
 Marks a file for later cleanup. More...
 
static removeTemporarilySavedFiles ($filepath)
 Clean up temporary files. More...
 
static saveFileTemporarily ($data, $movefile=false)
 Saves a file or moves it temporarily. More...
 

Detailed Description

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.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ alterLibraryFiles()

core_h5p\editor_framework::alterLibraryFiles ( $files,
  $libraries 
)

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.

Parameters
array$filesList of files as objects with path and version as properties.
array$librariesList of libraries indexed by machineName with objects as values. The objects have majorVersion and minorVersion as properties.

◆ getAvailableLanguages()

core_h5p\editor_framework::getAvailableLanguages (   $machinename,
  $major,
  $minor 
)

Load a list of available language codes.

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

Parameters
string$machinenameThe machine readable name of the library(content type)
int$majorMajor part of version number
int$minorMinor part of version number
Return values
arrayList of possible language codes

◆ getLanguage()

core_h5p\editor_framework::getLanguage (   $name,
  $major,
  $minor,
  $lang 
)

Load language file(JSON).

Used to translate the editor fields(title, description etc.)

Parameters
string$nameThe machine readable name of the library(content type)
int$majorMajor part of version number
int$minorMinor part of version number
string$langLanguage code
Return values
string|booleanTranslation in JSON format if available, false otherwise

◆ getLibraries()

core_h5p\editor_framework::getLibraries (   $libraries = null)

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.
Parameters
array$librariesList of library names + version to load info for.
Return values
arrayList of all libraries loaded.

◆ keepFile()

core_h5p\editor_framework::keepFile (   $fileid)

"Callback" for mark the given file as a permanent file.

Used when saving content that has new uploaded files.

Parameters
int$fileid

◆ markFileForCleanup()

static core_h5p\editor_framework::markFileForCleanup (   $file,
  $contentid = null 
)
static

Marks a file for later cleanup.

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

Parameters
int$fileId of file that should be cleaned up
int | null$contentidContent id of file

◆ removeTemporarilySavedFiles()

static core_h5p\editor_framework::removeTemporarilySavedFiles (   $filepath)
static

Clean up temporary files.

Parameters
string$filepathPath to file or directory

◆ saveFileTemporarily()

static core_h5p\editor_framework::saveFileTemporarily (   $data,
  $movefile = false 
)
static

Saves a file or moves it temporarily.

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

Parameters
string$dataUri of data that should be saved as a temporary file.
bool$movefileCan be set to TRUE to move the data instead of saving it.
Return values
bool|objectReturns false if saving failed or an object with path of the directory and file that is temporarily saved.

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