Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Moodle\H5PFileStorage Interface Reference

Interface needed to handle storage and export of H5P Content. More...

Inheritance diagram for Moodle\H5PFileStorage:
core_h5p\file_storage

Public Member Functions

 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.
 
 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.
 
 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 ($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 a 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)
 Store the library folder.
 

Detailed Description

Interface needed to handle storage and export of H5P Content.

Member Function Documentation

◆ cacheAssets()

Moodle\H5PFileStorage::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

Implemented in core_h5p\file_storage.

◆ cloneContent()

Moodle\H5PFileStorage::cloneContent ( $id,
$newId )

Creates a stored copy of the content folder.

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

Implemented in core_h5p\file_storage.

◆ cloneContentFile()

Moodle\H5PFileStorage::cloneContentFile ( $file,
$fromId,
$toId )

Copy a file from another content or editor tmp dir.

Used when copy pasting content in H5P.

Parameters
string$filepath + name
string | int$fromIdContent ID or 'editor' string
int$toIdTarget Content ID

Implemented in core_h5p\file_storage.

◆ deleteCachedAssets()

Moodle\H5PFileStorage::deleteCachedAssets ( $keys)

Remove the aggregated cache files.

Parameters
array$keysThe hash keys of removed files

Implemented in core_h5p\file_storage.

◆ deleteContent()

Moodle\H5PFileStorage::deleteContent ( $content)

Remove content folder.

Parameters
array$contentContent properties

Implemented in core_h5p\file_storage.

◆ deleteExport()

Moodle\H5PFileStorage::deleteExport ( $filename)

Removes given export file.

Parameters
string$filename

Implemented in core_h5p\file_storage.

◆ deleteLibrary()

Moodle\H5PFileStorage::deleteLibrary ( $library)

Delete library folder.

Parameters
array$library

Implemented in core_h5p\file_storage.

◆ exportContent()

Moodle\H5PFileStorage::exportContent ( $id,
$target )

Fetch content folder and save in target directory.

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

Implemented in core_h5p\file_storage.

◆ exportLibrary()

Moodle\H5PFileStorage::exportLibrary ( $library,
$target )

Fetch library folder and save in target directory.

Parameters
array$libraryLibrary properties
string$targetWhere the library folder will be saved

Implemented in core_h5p\file_storage.

◆ getCachedAssets()

Moodle\H5PFileStorage::getCachedAssets ( $key)

Will check if there are cache assets available for content.

Parameters
string$keyHashed key for cached asset
Return values
array

Implemented in core_h5p\file_storage.

◆ getContent()

Moodle\H5PFileStorage::getContent ( $file_path)

Read file content of given file and then return it.

Parameters
string$file_path
Return values
stringcontents

Implemented in core_h5p\file_storage.

◆ getContentFile()

Moodle\H5PFileStorage::getContentFile ( $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

Implemented in core_h5p\file_storage.

◆ getTmpPath()

Moodle\H5PFileStorage::getTmpPath ( )

Get path to a new unique tmp folder.

Return values
stringPath

Implemented in core_h5p\file_storage.

◆ getUpgradeScript()

Moodle\H5PFileStorage::getUpgradeScript ( $machineName,
$majorVersion,
$minorVersion )

Check if upgrades script exist for library.

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

Implemented in core_h5p\file_storage.

◆ hasExport()

Moodle\H5PFileStorage::hasExport ( $filename)

Check if the given export file exists.

Parameters
string$filename
Return values
boolean

Implemented in core_h5p\file_storage.

◆ hasPresave()

Moodle\H5PFileStorage::hasPresave ( $libraryName,
$developmentPath = null )

Check if the library has a presave.js in the root folder.

Parameters
string$libraryName
string$developmentPath
Return values
bool

Implemented in core_h5p\file_storage.

◆ hasWriteAccess()

Moodle\H5PFileStorage::hasWriteAccess ( )

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

Return values
boolTrue if server has the proper write access

Implemented in core_h5p\file_storage.

◆ moveContentDirectory()

Moodle\H5PFileStorage::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 content
Return values
objectObject containing h5p json and content json data

Implemented in core_h5p\file_storage.

◆ removeContentFile()

Moodle\H5PFileStorage::removeContentFile ( $file,
$contentId )

Remove content files that are no longer used.

Used when saving content.

Parameters
string$filepath + name
int$contentId

Implemented in core_h5p\file_storage.

◆ saveContent()

Moodle\H5PFileStorage::saveContent ( $source,
$content )

Store the content folder.

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

Implemented in core_h5p\file_storage.

◆ saveExport()

Moodle\H5PFileStorage::saveExport ( $source,
$filename )

Save export in file system.

Parameters
string$sourcePath on file system to temporary export file.
string$filenameName of export file.

Implemented in core_h5p\file_storage.

◆ saveFile()

Moodle\H5PFileStorage::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

Implemented in core_h5p\file_storage.

◆ saveFileFromZip()

Moodle\H5PFileStorage::saveFileFromZip ( $path,
$file,
$stream )

Store the given stream into the given file.

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

Implemented in core_h5p\file_storage.

◆ saveLibrary()

Moodle\H5PFileStorage::saveLibrary ( $library)

Store the library folder.

Parameters
array$libraryLibrary properties

Implemented in core_h5p\file_storage.


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