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