Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
H5PDefaultStorage Class Reference

The default file storage class for H5P. More...

Inheritance diagram for H5PDefaultStorage:

Public Member Functions

 __construct ($path, $alteditorpath=NULL)
 The great Constructor!
 
 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, $toId)
 Copy a file from another content or editor tmp dir.
 
 deleteCachedAssets ($keys)
 Remove the aggregated cache files.
 
 deleteContent ($content)
 Remove content folder.
 
 deleteExport ($filename)
 Removes given export file.
 
 exportContent ($id, $target)
 Fetch content folder and save in target directory.
 
 exportLibrary ($library, $target, $developmentPath=NULL)
 Fetch library folder and save in target directory.
 
 getCachedAssets ($key)
 Will check if there are cache assets available for content.
 
 getContent ($file_path)
 Read file content of given file and then return it.
 
 getContentFile ($file, $contentId)
 Checks to see if 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 ($libraryFolder, $developmentPath=null)
 Check if the file presave.js exists in the root of the library.
 
 hasWriteAccess ()
 Check if server setup has write permission to the required folders.
 
 moveContentDirectory ($source, $contentId=NULL)
 Copy a content from one directory to another.
 
 removeContentFile ($file, $contentId)
 Checks to see if content has the given file.
 
 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)
 Store the library folder.
 

Detailed Description

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.

License
MIT

Constructor & Destructor Documentation

◆ __construct()

H5PDefaultStorage::__construct ( $path,
$alteditorpath = NULL )

The great Constructor!

Parameters
string$pathThe base location of H5P files
string$alteditorpathOptional. Use a different editor path

Member Function Documentation

◆ cacheAssets()

H5PDefaultStorage::cacheAssets ( & $files,
$key )

Will concatenate all JavaScrips and Stylesheets into two files in order to improve page performance.

Parameters
array$filesA set of all the assets required for content to display
string$keyHashed key for cached asset

◆ cloneContent()

H5PDefaultStorage::cloneContent ( $id,
$newId )

Creates a stored copy of the content folder.

Parameters
string$idIdentifier of content to clone.
int$newIdThe cloned content's identifier

◆ cloneContentFile()

H5PDefaultStorage::cloneContentFile ( $file,
$fromId,
$toId )

Copy a file from another content or editor tmp dir.

Used when copy pasting content in H5P Editor.

Parameters
string$filepath + name
string | int$fromidContent ID or 'editor' string
int$toidTarget Content ID

◆ deleteCachedAssets()

H5PDefaultStorage::deleteCachedAssets ( $keys)

Remove the aggregated cache files.

Parameters
array$keysThe hash keys of removed files

◆ deleteContent()

H5PDefaultStorage::deleteContent ( $content)

Remove content folder.

Parameters
array$contentContent properties

◆ deleteExport()

H5PDefaultStorage::deleteExport ( $filename)

Removes given export file.

Parameters
string$filename

◆ exportContent()

H5PDefaultStorage::exportContent ( $id,
$target )

Fetch content folder and save in target directory.

Parameters
int$idContent identifier
string$targetWhere the content folder will be saved

◆ exportLibrary()

H5PDefaultStorage::exportLibrary ( $library,
$target,
$developmentPath = NULL )

Fetch library folder and save in target directory.

Parameters
array$libraryLibrary properties
string$targetWhere the library folder will be saved
string$developmentPathFolder that library resides in

◆ getCachedAssets()

H5PDefaultStorage::getCachedAssets ( $key)

Will check if there are cache assets available for content.

Parameters
string$keyHashed key for cached asset
Return values
array

◆ getContent()

H5PDefaultStorage::getContent ( $file_path)

Read file content of given file and then return it.

Parameters
string$file_path
Return values
string

◆ getContentFile()

H5PDefaultStorage::getContentFile ( $file,
$contentId )

Checks to see if content has the given file.

Used when saving content.

Parameters
string$filepath + name
int$contentId
Return values
stringFile ID or NULL if not found

◆ getTmpPath()

H5PDefaultStorage::getTmpPath ( )

Get path to a new unique tmp folder.

Return values
stringPath

◆ getUpgradeScript()

H5PDefaultStorage::getUpgradeScript ( $machineName,
$majorVersion,
$minorVersion )

Check if upgrades script exist for library.

Parameters
string$machineName
int$majorVersion
int$minorVersion
Return values
stringRelative path

◆ hasExport()

H5PDefaultStorage::hasExport ( $filename)

Check if the given export file exists.

Parameters
string$filename
Return values
boolean

◆ hasPresave()

H5PDefaultStorage::hasPresave ( $libraryFolder,
$developmentPath = null )

Check if the file presave.js exists in the root of the library.

Parameters
string$libraryFolder
string$developmentPath
Return values
bool

◆ hasWriteAccess()

H5PDefaultStorage::hasWriteAccess ( )

Check if server setup has write permission to the required folders.

Return values
boolTrue if site can write to the H5P files folder

◆ moveContentDirectory()

H5PDefaultStorage::moveContentDirectory ( $source,
$contentId = NULL )

Copy a content from one directory to another.

Defaults to cloning content from the current temporary upload folder to the editor path.

Parameters
string$sourcepath to source directory
string$contentIdId of contentarray

◆ removeContentFile()

H5PDefaultStorage::removeContentFile ( $file,
$contentId )

Checks to see if content has the given file.

Used when saving content.

Parameters
string$filepath + name
int$contentid
Return values
string|intFile ID or NULL if not found

◆ saveContent()

H5PDefaultStorage::saveContent ( $source,
$content )

Store the content folder.

Parameters
string$sourcePath on file system to content directory.
array$contentContent properties

◆ saveExport()

H5PDefaultStorage::saveExport ( $source,
$filename )

Save export in file system.

Parameters
string$sourcePath on file system to temporary export file.
string$filenameName of export file.
Exceptions
ExceptionUnable to save the file

◆ saveFile()

H5PDefaultStorage::saveFile ( $file,
$contentId )

Save files uploaded through the editor.

The files must be marked as temporary until the content form is saved.

Parameters
H5peditorFile$file
int$contentid

◆ saveFileFromZip()

H5PDefaultStorage::saveFileFromZip ( $path,
$file,
$stream )

Store the given stream into the given file.

Parameters
string$path
string$file
resource$stream
Return values
bool

◆ saveLibrary()

H5PDefaultStorage::saveLibrary ( $library)

Store the library folder.

Parameters
array$libraryLibrary properties

The documentation for this class was generated from the following file: