Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

File info?

File Size: 224 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Interface: H5PFileStorage  - X-Ref

Interface needed to handle storage and export of H5P Content.

saveLibrary($library)   X-Ref
Store the library folder.

param: array $library

saveContent($source, $content)   X-Ref
Store the content folder.

param: string $source
param: array $content

deleteContent($content)   X-Ref
Remove content folder.

param: array $content

cloneContent($id, $newId)   X-Ref
Creates a stored copy of the content folder.

param: string $id
param: int $newId

getTmpPath()   X-Ref
Get path to a new unique tmp folder.

return: string

exportContent($id, $target)   X-Ref
Fetch content folder and save in target directory.

param: int $id
param: string $target

exportLibrary($library, $target)   X-Ref
Fetch library folder and save in target directory.

param: array $library
param: string $target

saveExport($source, $filename)   X-Ref
Save export in file system

param: string $source
param: string $filename

deleteExport($filename)   X-Ref
Removes given export file

param: string $filename

hasExport($filename)   X-Ref
Check if the given export file exists

param: string $filename
return: boolean

cacheAssets(&$files, $key)   X-Ref
Will concatenate all JavaScrips and Stylesheets into two files in order
to improve page performance.

param: array $files
param: string $key

getCachedAssets($key)   X-Ref
Will check if there are cache assets available for content.

param: string $key
return: array

deleteCachedAssets($keys)   X-Ref
Remove the aggregated cache files.

param: array $keys

getContent($file_path)   X-Ref
Read file content of given file and then return it.

param: string $file_path
return: string contents

saveFile($file, $contentId)   X-Ref
Save files uploaded through the editor.
The files must be marked as temporary until the content form is saved.

param: H5peditorFile $file
param: int $contentId

cloneContentFile($file, $fromId, $toId)   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: int $toId Target Content ID

moveContentDirectory($source, $contentId = NULL)   X-Ref
Copy a 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
return: object Object containing h5p json and content json data

getContentFile($file, $contentId)   X-Ref
Checks to see if content has the given file.
Used when saving content.

param: string $file path + name
param: int $contentId
return: string|int 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 path + name
param: int $contentId

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