| Moodle APIs 4.3
    Moodle 4.3.6 (Build: 20240812) | 
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. | |
| cloneContent ($id, $newid) | |
| Creates a stored copy of the content folder. | |
| cloneContentFile ($file, $fromid, $tocontent) | |
| Copy a file from another content or editor tmp dir. | |
| delete_library (array $library) | |
| Deletes a library from the file system. | |
| deleteCachedAssets ($keys) | |
| Remove the aggregated cache files. | |
| deleteContent ($content) | |
| Remove content folder. | |
| deleteExport ($filename) | |
| Removes given export file. | |
| deleteLibrary ($library) | |
| Delete library folder. | |
| exportContent ($id, $target) | |
| Fetch content folder and save in target directory. | |
| exportLibrary ($library, $target) | |
| Fetch library folder and save in target directory. | |
| get_export_file (string $filename) | |
| Get files ready for export. | |
| get_icon_url (int $itemid, string $machinename, int $majorversion, int $minorversion) | |
| Get the file URL or given library and then return it. | |
| getCachedAssets ($key) | |
| Will check if there are cache assets available for content. | |
| getContent ($filepath) | |
| Read file content of given file and then return it. | |
| getContentFile ($file, $content) | |
| Checks to see if an H5P content has the given file. | |
| getTmpPath () | |
| Get path to a new unique tmp folder. | |
| getUpgradeScript ($machinename, $majorversion, $minorversion) | |
| Check if upgrades script exist for library. | |
| hasExport ($filename) | |
| Check if the given export file exists. | |
| hasPresave ($libraryname, $developmentpath=null) | |
| Check if the library has a presave.js in the root folder. | |
| hasWriteAccess () | |
| Check if server setup has write permission to the required folders. | |
| moveContentDirectory ($source, $contentid=null) | |
| Copy content from one directory to another. | |
| removeContentFile ($file, $contentid) | |
| Remove content files that are no longer used. | |
| saveContent ($source, $content) | |
| Store the content folder. | |
| saveExport ($source, $filename) | |
| Save export in file system. | |
| saveFile ($file, $contentid) | |
| Save files uploaded through the editor. | |
| saveFileFromZip ($path, $file, $stream) | |
| Store the given stream into the given file. | |
| saveLibrary ($library) | |
| Stores a H5P library in the Moodle filesystem. | |
| Static Public Member Functions | |
| static | generate_custom_styles () | 
| Generate H5P custom styles if any. | |
| static | get_custom_styles () | 
| Get H5P custom styles if any. | |
| Protected Attributes | |
| context | $context | 
| $context Currently we use the system context everywhere. | |
| 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, | |||
| $tocontent ) | 
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 | 
| stdClass | $tocontent | Target Content | 
| void | 
| 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::deleteLibrary | ( | $library | ) | 
Delete library folder.
| array | $library | 
| 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 | 
| 
 | static | 
Get H5P custom styles if any.
| moodle_exception | If the CSS setting is empty but there is a file to serve or there is no file but the CSS setting is not empty. | 
| array|null | If there is CSS then an array with the keys 'cssurl' and 'cssversion' is returned otherwise null. 'cssurl' is a link to the generated 'custom_h5p.css' file and 'cssversion' the md5 hash of its contents. | 
| core_h5p\file_storage::get_export_file | ( | string | $filename | ) | 
Get files ready for export.
| string | $filename | File name to retrieve. | 
| bool|stored_file | Stored file instance if exists, false if not | 
| core_h5p\file_storage::get_icon_url | ( | int | $itemid, | 
| string | $machinename, | ||
| int | $majorversion, | ||
| int | $minorversion ) | 
Get the file URL or given library and then return it.
| int | $itemid | |
| string | $machinename | |
| int | $majorversion | |
| int | $minorversion | 
| string | url or false if the file doesn't exist | 
| 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, | |
| $content ) | 
Checks to see if an H5P content has the given file.
| string | $file | File path and name. | 
| int | $content | Content id. | 
| int|null | 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 | 
| core_h5p\file_storage::removeContentFile | ( | $file, | |
| $contentid ) | 
Remove content files that are no longer used.
Used when saving content.
| string | $file | File path and name. | 
| int | $contentid | Content id. | 
| void | 
| 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.
| H5peditorFile | $file | |
| int | $contentid | 
| int | The id of the saved file. | 
| 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.