|
Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Class to handle storage and export of H5P Content. More...
Public Member Functions | |
| __construct () | |
| Initial setup for file_storage. | |
| cacheAssets (&$files, $key) | |
| Will concatenate all JavaScrips and Stylesheets into two files in order to improve page performance. More... | |
| cloneContent ($id, $newid) | |
| Creates a stored copy of the content folder. More... | |
| cloneContentFile ($file, $fromid, $toid) | |
| Copy a file from another content or editor tmp dir. More... | |
| delete_library (array $library) | |
| Deletes a library from the file system. More... | |
| deleteCachedAssets ($keys) | |
| Remove the aggregated cache files. More... | |
| deleteContent ($content) | |
| Remove content folder. More... | |
| deleteExport ($filename) | |
| Removes given export file. More... | |
| exportContent ($id, $target) | |
| Fetch content folder and save in target directory. More... | |
| exportLibrary ($library, $target) | |
| Fetch library folder and save in target directory. More... | |
| getCachedAssets ($key) | |
| Will check if there are cache assets available for content. More... | |
| getContent ($filepath) | |
| Read file content of given file and then return it. More... | |
| getContentFile ($file, $contentid) | |
| Checks to see if content has the given file. More... | |
| getTmpPath () | |
| Get path to a new unique tmp folder. More... | |
| getUpgradeScript ($machinename, $majorversion, $minorversion) | |
| Check if upgrades script exist for library. More... | |
| hasExport ($filename) | |
| Check if the given export file exists. More... | |
| hasPresave ($libraryname, $developmentpath=null) | |
| Check if the library has a presave.js in the root folder. More... | |
| hasWriteAccess () | |
| Check if server setup has write permission to the required folders. More... | |
| moveContentDirectory ($source, $contentid=null) | |
| Copy content from one directory to another. More... | |
| removeContentFile ($file, $contentid) | |
| Remove content files that are no longer used. More... | |
| saveContent ($source, $content) | |
| Store the content folder. More... | |
| saveExport ($source, $filename) | |
| Save export in file system. More... | |
| saveFile ($file, $contentid) | |
| Save files uploaded through the editor. More... | |
| saveFileFromZip ($path, $file, $stream) | |
| Store the given stream into the given file. More... | |
| saveLibrary ($library) | |
| Stores a H5P library in the Moodle filesystem. More... | |
Public Attributes | |
| const | CACHED_ASSETS_FILEAREA = 'cachedassets' |
| The cached assest file area. | |
| const | COMPONENT = 'core_h5p' |
| The component for H5P. | |
| const | CONTENT_FILEAREA = 'content' |
| The content file area. | |
| const | EXPORT_FILEAREA = 'export' |
| The export file area. | |
| const | LIBRARY_FILEAREA = 'libraries' |
| The library file area. | |
Protected Attributes | |
| context | $context |
| $context Currently we use the system context everywhere. More... | |
| file_storage | $fs |
| $fs File storage. | |
Class to handle storage and export of H5P Content.
| core_h5p\file_storage::cacheAssets | ( | & | $files, |
| $key | |||
| ) |
Will concatenate all JavaScrips and Stylesheets into two files in order to improve page performance.
| array | $files | A set of all the assets required for content to display |
| string | $key | Hashed key for cached asset |
| core_h5p\file_storage::cloneContent | ( | $id, | |
| $newid | |||
| ) |
Creates a stored copy of the content folder.
| string | $id | Identifier of content to clone. |
| int | $newid | The cloned content's identifier |
| core_h5p\file_storage::cloneContentFile | ( | $file, | |
| $fromid, | |||
| $toid | |||
| ) |
Copy a file from another content or editor tmp dir.
Used when copy pasting content in H5P.
| string | $file | path + name |
| string | int | $fromid | Content ID or 'editor' string |
| int | $toid | Target Content ID |
| core_h5p\file_storage::delete_library | ( | array | $library | ) |
Deletes a library from the file system.
| array | $library | Library details |
| core_h5p\file_storage::deleteCachedAssets | ( | $keys | ) |
Remove the aggregated cache files.
| array | $keys | The hash keys of removed files |
| core_h5p\file_storage::deleteContent | ( | $content | ) |
Remove content folder.
| array | $content | Content properties |
| core_h5p\file_storage::deleteExport | ( | $filename | ) |
Removes given export file.
| string | $filename | filename of the export to delete. |
| core_h5p\file_storage::exportContent | ( | $id, | |
| $target | |||
| ) |
Fetch content folder and save in target directory.
| int | $id | Content identifier |
| string | $target | Where the content folder will be saved |
| core_h5p\file_storage::exportLibrary | ( | $library, | |
| $target | |||
| ) |
Fetch library folder and save in target directory.
| array | $library | Library properties |
| string | $target | Where the library folder will be saved |
| core_h5p\file_storage::getCachedAssets | ( | $key | ) |
Will check if there are cache assets available for content.
| string | $key | Hashed key for cached asset |
| array |
| core_h5p\file_storage::getContent | ( | $filepath | ) |
Read file content of given file and then return it.
| string | $filepath |
| string | contents |
| core_h5p\file_storage::getContentFile | ( | $file, | |
| $contentid | |||
| ) |
Checks to see if content has the given file.
Used when saving content.
| string | $file | path + name |
| int | $contentid |
| string|int | File ID or NULL if not found |
| core_h5p\file_storage::getTmpPath | ( | ) |
Get path to a new unique tmp folder.
Please note this needs to not be a directory.
| string | Path |
| core_h5p\file_storage::getUpgradeScript | ( | $machinename, | |
| $majorversion, | |||
| $minorversion | |||
| ) |
Check if upgrades script exist for library.
| string | $machinename | |
| int | $majorversion | |
| int | $minorversion |
| string | Relative path |
| core_h5p\file_storage::hasExport | ( | $filename | ) |
Check if the given export file exists.
| string | $filename | The export file to check. |
| boolean | True if the export file exists. |
| core_h5p\file_storage::hasPresave | ( | $libraryname, | |
$developmentpath = null |
|||
| ) |
Check if the library has a presave.js in the root folder.
| string | $libraryname | |
| string | $developmentpath |
| bool |
| core_h5p\file_storage::hasWriteAccess | ( | ) |
Check if server setup has write permission to the required folders.
| bool | True if server has the proper write access |
| core_h5p\file_storage::moveContentDirectory | ( | $source, | |
$contentid = null |
|||
| ) |
Copy content from one directory to another.
Defaults to cloning content from the current temporary upload folder to the editor path.
| string | $source | path to source directory |
| string | $contentid | Id of content |
| object | Object containing h5p json and content json data |
| core_h5p\file_storage::removeContentFile | ( | $file, | |
| $contentid | |||
| ) |
Remove content files that are no longer used.
Used when saving content.
| string | $file | path + name |
| int | $contentid |
| core_h5p\file_storage::saveContent | ( | $source, | |
| $content | |||
| ) |
Store the content folder.
| string | $source | Path on file system to content directory. |
| array | $content | Content properties |
| core_h5p\file_storage::saveExport | ( | $source, | |
| $filename | |||
| ) |
Save export in file system.
| string | $source | Path on file system to temporary export file. |
| string | $filename | Name of export file. |
| core_h5p\file_storage::saveFile | ( | $file, | |
| $contentid | |||
| ) |
Save files uploaded through the editor.
The files must be marked as temporary until the content form is saved.
| H5peditorFile | $file | |
| int | $contentid |
| core_h5p\file_storage::saveFileFromZip | ( | $path, | |
| $file, | |||
| $stream | |||
| ) |
Store the given stream into the given file.
| string | $path | |
| string | $file | |
| resource | $stream |
| bool|int |
| core_h5p\file_storage::saveLibrary | ( | $library | ) |
Stores a H5P library in the Moodle filesystem.
| array | $library | Library properties. |
|
protected |
$context Currently we use the system context everywhere.
Don't feel forced to keep it this way in the future.