Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  
   3  /**
   4   * A defined interface for the editor to communicate with the database of the
   5   * web system.
   6   */
   7  interface H5peditorStorage {
   8  
   9    /**
  10     * Load language file(JSON) from database.
  11     * This is used to translate the editor fields(title, description etc.)
  12     *
  13     * @param string $name The machine readable name of the library(content type)
  14     * @param int $major Major part of version number
  15     * @param int $minor Minor part of version number
  16     * @param string $lang Language code
  17     * @return string Translation in JSON format
  18     */
  19    public function getLanguage($machineName, $majorVersion, $minorVersion, $language);
  20  
  21    /**
  22     * Load a list of available language codes from the database.
  23     *
  24     * @param string $machineName The machine readable name of the library(content type)
  25     * @param int $majorVersion Major part of version number
  26     * @param int $minorVersion Minor part of version number
  27     * @return array List of possible language codes
  28     */
  29    public function getAvailableLanguages($machineName, $majorVersion, $minorVersion);
  30  
  31    /**
  32     * "Callback" for mark the given file as a permanent file.
  33     * Used when saving content that has new uploaded files.
  34     *
  35     * @param int $fileId
  36     */
  37    public function keepFile($fileId);
  38  
  39    /**
  40     * Decides which content types the editor should have.
  41     *
  42     * Two usecases:
  43     * 1. No input, will list all the available content types.
  44     * 2. Libraries supported are specified, load additional data and verify
  45     * that the content types are available. Used by e.g. the Presentation Tool
  46     * Editor that already knows which content types are supported in its
  47     * slides.
  48     *
  49     * @param array $libraries List of library names + version to load info for
  50     * @return array List of all libraries loaded
  51     */
  52    public function getLibraries($libraries = NULL);
  53  
  54    /**
  55     * Alter styles and scripts
  56     *
  57     * @param array $files
  58     *  List of files as objects with path and version as properties
  59     * @param array $libraries
  60     *  List of libraries indexed by machineName with objects as values. The objects
  61     *  have majorVersion and minorVersion as properties.
  62     */
  63    public function alterLibraryFiles(&$files, $libraries);
  64  
  65    /**
  66     * Saves a file or moves it temporarily. This is often necessary in order to
  67     * validate and store uploaded or fetched H5Ps.
  68     *
  69     * @param string $data Uri of data that should be saved as a temporary file
  70     * @param boolean $move_file Can be set to TRUE to move the data instead of saving it
  71     *
  72     * @return bool|object Returns false if saving failed or the path to the file
  73     *  if saving succeeded
  74     */
  75    public static function saveFileTemporarily($data, $move_file);
  76  
  77    /**
  78     * Marks a file for later cleanup, useful when files are not instantly cleaned
  79     * up. E.g. for files that are uploaded through the editor.
  80     *
  81     * @param H5peditorFile
  82     * @param $content_id
  83     */
  84    public static function markFileForCleanup($file, $content_id);
  85  
  86    /**
  87     * Clean up temporary files
  88     *
  89     * @param string $filePath Path to file or directory
  90     */
  91    public static function removeTemporarilySavedFiles($filePath);
  92  }