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: 588 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: H5PDefaultStorage  - X-Ref

The default file storage class for H5P. Will carry out the requested file
operations using PHP's standard file operation functions.

Some implementations of H5P that doesn't use the standard file system will
want to create their own implementation of the H5P\FileStorage interface.

__construct($path, $alteditorpath = NULL)   X-Ref
The great Constructor!

param: string $path
param: string $alteditorpath

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, $developmentPath=NULL)   X-Ref
Fetch library folder and save in target directory.

param: array $library
param: string $target
param: string $developmentPath

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
No description

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

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 Editor.

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 contentarray

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 File ID or NULL if not found

removeContentFile($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

hasWriteAccess()   X-Ref
Check if server setup has write permission to
the required folders

return: bool True if site can write to the H5P files folder

hasPresave($libraryFolder, $developmentPath = null)   X-Ref
Check if the file presave.js exists in the root of the library

param: string $libraryFolder
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

copyFileTree($source, $destination)   X-Ref
Recursive function for copying directories.

param: string $source
param: string $destination
return: boolean

getIgnoredFiles($file)   X-Ref
Retrieve array of file names from file.

param: string $file
return: array Array with files that should be ignored

dirReady($path)   X-Ref
Recursive function that makes sure the specified directory exists and
is writable.

param: string $path
return: bool

getEditorPath()   X-Ref
Easy helper function for retrieving the editor path

return: string Path to editor files