Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
/**
4
 * File info?
5
 */
6
 
7
/**
8
 * Interface needed to handle storage and export of H5P Content.
9
 */
10
interface H5PFileStorage {
11
 
12
  /**
13
   * Store the library folder.
14
   *
15
   * @param array $library
16
   *  Library properties
17
   */
18
  public function saveLibrary($library);
19
 
20
  /**
21
   * Delete library folder
22
   *
23
   * @param array $library
24
   */
25
  public function deleteLibrary($library);
26
 
27
  /**
28
   * Store the content folder.
29
   *
30
   * @param string $source
31
   *  Path on file system to content directory.
32
   * @param array $content
33
   *  Content properties
34
   */
35
  public function saveContent($source, $content);
36
 
37
  /**
38
   * Remove content folder.
39
   *
40
   * @param array $content
41
   *  Content properties
42
   */
43
  public function deleteContent($content);
44
 
45
  /**
46
   * Creates a stored copy of the content folder.
47
   *
48
   * @param string $id
49
   *  Identifier of content to clone.
50
   * @param int $newId
51
   *  The cloned content's identifier
52
   */
53
  public function cloneContent($id, $newId);
54
 
55
  /**
56
   * Get path to a new unique tmp folder.
57
   *
58
   * @return string
59
   *  Path
60
   */
61
  public function getTmpPath();
62
 
63
  /**
64
   * Fetch content folder and save in target directory.
65
   *
66
   * @param int $id
67
   *  Content identifier
68
   * @param string $target
69
   *  Where the content folder will be saved
70
   */
71
  public function exportContent($id, $target);
72
 
73
  /**
74
   * Fetch library folder and save in target directory.
75
   *
76
   * @param array $library
77
   *  Library properties
78
   * @param string $target
79
   *  Where the library folder will be saved
80
   */
81
  public function exportLibrary($library, $target);
82
 
83
  /**
84
   * Save export in file system
85
   *
86
   * @param string $source
87
   *  Path on file system to temporary export file.
88
   * @param string $filename
89
   *  Name of export file.
90
   */
91
  public function saveExport($source, $filename);
92
 
93
  /**
94
   * Removes given export file
95
   *
96
   * @param string $filename
97
   */
98
  public function deleteExport($filename);
99
 
100
  /**
101
   * Check if the given export file exists
102
   *
103
   * @param string $filename
104
   * @return boolean
105
   */
106
  public function hasExport($filename);
107
 
108
  /**
109
   * Will concatenate all JavaScrips and Stylesheets into two files in order
110
   * to improve page performance.
111
   *
112
   * @param array $files
113
   *  A set of all the assets required for content to display
114
   * @param string $key
115
   *  Hashed key for cached asset
116
   */
117
  public function cacheAssets(&$files, $key);
118
 
119
  /**
120
   * Will check if there are cache assets available for content.
121
   *
122
   * @param string $key
123
   *  Hashed key for cached asset
124
   * @return array
125
   */
126
  public function getCachedAssets($key);
127
 
128
  /**
129
   * Remove the aggregated cache files.
130
   *
131
   * @param array $keys
132
   *   The hash keys of removed files
133
   */
134
  public function deleteCachedAssets($keys);
135
 
136
  /**
137
   * Read file content of given file and then return it.
138
   *
139
   * @param string $file_path
140
   * @return string contents
141
   */
142
  public function getContent($file_path);
143
 
144
  /**
145
   * Save files uploaded through the editor.
146
   * The files must be marked as temporary until the content form is saved.
147
   *
148
   * @param \H5peditorFile $file
149
   * @param int $contentId
150
   */
151
  public function saveFile($file, $contentId);
152
 
153
  /**
154
   * Copy a file from another content or editor tmp dir.
155
   * Used when copy pasting content in H5P.
156
   *
157
   * @param string $file path + name
158
   * @param string|int $fromId Content ID or 'editor' string
159
   * @param int $toId Target Content ID
160
   */
161
  public function cloneContentFile($file, $fromId, $toId);
162
 
163
  /**
164
   * Copy a content from one directory to another. Defaults to cloning
165
   * content from the current temporary upload folder to the editor path.
166
   *
167
   * @param string $source path to source directory
168
   * @param string $contentId Id of content
169
   *
170
   * @return object Object containing h5p json and content json data
171
   */
172
  public function moveContentDirectory($source, $contentId = NULL);
173
 
174
  /**
175
   * Checks to see if content has the given file.
176
   * Used when saving content.
177
   *
178
   * @param string $file path + name
179
   * @param int $contentId
180
   * @return string|int File ID or NULL if not found
181
   */
182
  public function getContentFile($file, $contentId);
183
 
184
  /**
185
   * Remove content files that are no longer used.
186
   * Used when saving content.
187
   *
188
   * @param string $file path + name
189
   * @param int $contentId
190
   */
191
  public function removeContentFile($file, $contentId);
192
 
193
  /**
194
   * Check if server setup has write permission to
195
   * the required folders
196
   *
197
   * @return bool True if server has the proper write access
198
   */
199
  public function hasWriteAccess();
200
 
201
  /**
202
   * Check if the library has a presave.js in the root folder
203
   *
204
   * @param string $libraryName
205
   * @param string $developmentPath
206
   * @return bool
207
   */
208
  public function hasPresave($libraryName, $developmentPath = null);
209
 
210
  /**
211
   * Check if upgrades script exist for library.
212
   *
213
   * @param string $machineName
214
   * @param int $majorVersion
215
   * @param int $minorVersion
216
   * @return string Relative path
217
   */
218
  public function getUpgradeScript($machineName, $majorVersion, $minorVersion);
219
 
220
  /**
221
   * Store the given stream into the given file.
222
   *
223
   * @param string $path
224
   * @param string $file
225
   * @param resource $stream
226
   * @return bool
227
   */
228
  public function saveFileFromZip($path, $file, $stream);
229
}