See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]
Class \core_h5p\file_storage.
Copyright: | 2019 Victor Deniz <victor@moodle.com>, base on code by Joubel AS |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 873 lines (30 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
file_storage:: (35 methods):
__construct()
saveLibrary()
saveContent()
deleteContent()
cloneContent()
getTmpPath()
exportContent()
exportLibrary()
saveExport()
deleteExport()
hasExport()
cacheAssets()
getCachedAssets()
deleteCachedAssets()
getContent()
saveFile()
cloneContentFile()
moveContentDirectory()
get_icon_url()
getContentFile()
removeContentFile()
hasWriteAccess()
hasPresave()
getUpgradeScript()
saveFileFromZip()
delete_library()
delete_directory()
copy_directory()
export_file_tree()
concatenate_files()
get_export_file()
get_file_elements_from_filepath()
get_itemid_for_file()
get_file()
move_file()
Class: file_storage - X-Ref
Class to handle storage and export of H5P Content.__construct() X-Ref |
Initial setup for file_storage. |
saveLibrary($library) X-Ref |
Stores a H5P library in the Moodle filesystem. param: array $library Library properties. |
saveContent($source, $content) X-Ref |
Store the content folder. param: string $source Path on file system to content directory. param: array $content Content properties |
deleteContent($content) X-Ref |
Remove content folder. param: array $content Content properties |
cloneContent($id, $newid) X-Ref |
Creates a stored copy of the content folder. param: string $id Identifier of content to clone. param: int $newid The cloned content's identifier |
getTmpPath() X-Ref |
Get path to a new unique tmp folder. Please note this needs to not be a directory. return: string Path |
exportContent($id, $target) X-Ref |
Fetch content folder and save in target directory. param: int $id Content identifier param: string $target Where the content folder will be saved |
exportLibrary($library, $target) X-Ref |
Fetch library folder and save in target directory. param: array $library Library properties param: string $target Where the library folder will be saved |
saveExport($source, $filename) X-Ref |
Save export in file system param: string $source Path on file system to temporary export file. param: string $filename Name of export file. |
deleteExport($filename) X-Ref |
Removes given export file param: string $filename filename of the export to delete. |
hasExport($filename) X-Ref |
Check if the given export file exists param: string $filename The export file to check. return: boolean True if the export file exists. |
cacheAssets(&$files, $key) X-Ref |
Will concatenate all JavaScrips and Stylesheets into two files in order to improve page performance. param: array $files A set of all the assets required for content to display param: string $key Hashed key for cached asset |
getCachedAssets($key) X-Ref |
Will check if there are cache assets available for content. param: string $key Hashed key for cached asset return: array |
deleteCachedAssets($keys) X-Ref |
Remove the aggregated cache files. param: array $keys The hash keys of removed files |
getContent($filepath) X-Ref |
Read file content of given file and then return it. param: string $filepath return: string contents |
saveFile($file, $contentid) X-Ref |
Save files uploaded through the editor. param: H5peditorFile $file param: int $contentid return: int The id of the saved file. |
cloneContentFile($file, $fromid, $tocontent) X-Ref |
Copy a file from another content or editor tmp dir. Used when copy pasting content in H5P. param: string $file path + name param: string|int $fromid Content ID or 'editor' string param: \stdClass $tocontent Target Content return: void |
moveContentDirectory($source, $contentid = null) X-Ref |
Copy content from one directory to another. Defaults to cloning content from the current temporary upload folder to the editor path. param: string $source path to source directory param: string $contentid Id of content |
get_icon_url(int $itemid, string $machinename, int $majorversion, int $minorversion) X-Ref |
Get the file URL or given library and then return it. param: int $itemid param: string $machinename param: int $majorversion param: int $minorversion return: string url or false if the file doesn't exist |
getContentFile($file, $content) X-Ref |
Checks to see if an H5P content has the given file. param: string $file File path and name. param: int $content Content id. return: int|null File ID or NULL if not found |
removeContentFile($file, $contentid) X-Ref |
Remove content files that are no longer used. Used when saving content. param: string $file File path and name. param: int $contentid Content id. return: void |
hasWriteAccess() X-Ref |
Check if server setup has write permission to the required folders return: bool True if server has the proper write access |
hasPresave($libraryname, $developmentpath = null) X-Ref |
Check if the library has a presave.js in the root folder param: string $libraryname param: string $developmentpath return: bool |
getUpgradeScript($machinename, $majorversion, $minorversion) X-Ref |
Check if upgrades script exist for library. param: string $machinename param: int $majorversion param: int $minorversion return: string Relative path |
saveFileFromZip($path, $file, $stream) X-Ref |
Store the given stream into the given file. param: string $path param: string $file param: resource $stream return: bool|int |
delete_library(array $library) X-Ref |
Deletes a library from the file system. param: array $library Library details |
delete_directory(int $contextid, string $component, string $filearea, int $itemid) X-Ref |
Remove an H5P directory from the filesystem. param: int $contextid context ID param: string $component component param: string $filearea file area or all areas in context if not specified param: int $itemid item ID or all files if not specified |
copy_directory(string $source, array $options) X-Ref |
Copy an H5P directory from the temporary directory into the file system. param: string $source Temporary location for files. param: array $options File system information. |
export_file_tree(string $target, int $contextid, string $filearea, string $filepath, int $itemid = 0) X-Ref |
Copies files from storage to temporary folder. param: string $target Path to temporary folder param: int $contextid context where the files are found param: string $filearea file area param: string $filepath file path param: int $itemid Optional item ID |
concatenate_files(array $assets, string $type, \context $context) X-Ref |
Adds all files of a type into one file. param: array $assets A list of files. param: string $type The type of files in assets. Either 'scripts' or 'styles' param: \context $context Context return: string All of the file content in one string. |
get_export_file(string $filename) X-Ref |
No description |
get_file_elements_from_filepath(string $filepath) X-Ref |
Converts a relative system file path into Moodle File API elements. param: string $filepath The system filepath to get information from. return: array File information. |
get_itemid_for_file(string $filearea, string $filepath, string $filename) X-Ref |
Returns the item id given the other necessary variables. param: string $filearea The file area. param: string $filepath The file path. param: string $filename The file name. return: mixed the specified value false if not found. |
get_file(string $filearea, int $itemid, string $file) X-Ref |
Helper to make it easy to load content files. param: string $filearea File area where the file is saved. param: int $itemid Content instance or content id. param: string $file File path and name. return: stored_file|null |
move_file(string $sourcefile, int $contentid) X-Ref |
Move a single file param: string $sourcefile Path to source file param: int $contentid Content id or 0 if the file is in the editor file area return: void |