2016-01-11 18:31:04 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* File info?
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface needed to handle storage and export of H5P Content.
|
|
|
|
*/
|
2016-01-14 09:46:00 +01:00
|
|
|
interface H5PFileStorage {
|
2016-01-11 18:31:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the library folder.
|
|
|
|
*
|
|
|
|
* @param array $library
|
|
|
|
* Library properties
|
|
|
|
*/
|
|
|
|
public function saveLibrary($library);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the content folder.
|
|
|
|
*
|
|
|
|
* @param string $source
|
|
|
|
* Path on file system to content directory.
|
2016-09-14 10:44:10 +02:00
|
|
|
* @param array $content
|
|
|
|
* Content properties
|
2016-01-11 18:31:04 +01:00
|
|
|
*/
|
2016-09-14 10:44:10 +02:00
|
|
|
public function saveContent($source, $content);
|
2016-01-11 18:31:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove content folder.
|
|
|
|
*
|
2016-09-14 10:44:10 +02:00
|
|
|
* @param array $content
|
|
|
|
* Content properties
|
2016-01-11 18:31:04 +01:00
|
|
|
*/
|
2016-09-14 10:44:10 +02:00
|
|
|
public function deleteContent($content);
|
2016-01-11 18:31:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a stored copy of the content folder.
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* Identifier of content to clone.
|
|
|
|
* @param int $newId
|
|
|
|
* The cloned content's identifier
|
|
|
|
*/
|
|
|
|
public function cloneContent($id, $newId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get path to a new unique tmp folder.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* Path
|
|
|
|
*/
|
|
|
|
public function getTmpPath();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch content folder and save in target directory.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* Content identifier
|
|
|
|
* @param string $target
|
|
|
|
* Where the content folder will be saved
|
|
|
|
*/
|
|
|
|
public function exportContent($id, $target);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch library folder and save in target directory.
|
|
|
|
*
|
|
|
|
* @param array $library
|
|
|
|
* Library properties
|
|
|
|
* @param string $target
|
|
|
|
* Where the library folder will be saved
|
|
|
|
*/
|
|
|
|
public function exportLibrary($library, $target);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save export in file system
|
|
|
|
*
|
|
|
|
* @param string $source
|
|
|
|
* Path on file system to temporary export file.
|
|
|
|
* @param string $filename
|
|
|
|
* Name of export file.
|
|
|
|
*/
|
2016-09-08 14:48:08 +02:00
|
|
|
public function saveExport($source, $filename);
|
2016-01-11 18:31:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes given export file
|
|
|
|
*
|
|
|
|
* @param string $filename
|
|
|
|
*/
|
2016-09-08 14:48:08 +02:00
|
|
|
public function deleteExport($filename);
|
2016-01-13 14:23:34 +01:00
|
|
|
|
2016-09-23 10:52:40 +02:00
|
|
|
/**
|
|
|
|
* Check if the given export file exists
|
|
|
|
*
|
|
|
|
* @param string $filename
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function hasExport($filename);
|
|
|
|
|
2016-01-13 14:23:34 +01:00
|
|
|
/**
|
|
|
|
* Will concatenate all JavaScrips and Stylesheets into two files in order
|
|
|
|
* to improve page performance.
|
|
|
|
*
|
|
|
|
* @param array $files
|
|
|
|
* A set of all the assets required for content to display
|
|
|
|
* @param string $key
|
|
|
|
* Hashed key for cached asset
|
|
|
|
*/
|
|
|
|
public function cacheAssets(&$files, $key);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Will check if there are cache assets available for content.
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* Hashed key for cached asset
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getCachedAssets($key);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the aggregated cache files.
|
|
|
|
*
|
|
|
|
* @param array $keys
|
|
|
|
* The hash keys of removed files
|
|
|
|
*/
|
|
|
|
public function deleteCachedAssets($keys);
|
2016-04-22 11:35:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read file content of given file and then return it.
|
|
|
|
*
|
|
|
|
* @param string $file_path
|
|
|
|
* @return string contents
|
|
|
|
*/
|
|
|
|
public function getContent($file_path);
|
2016-04-25 14:31:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save files uploaded through the editor.
|
|
|
|
* The files must be marked as temporary until the content form is saved.
|
|
|
|
*
|
|
|
|
* @param \H5peditorFile $file
|
2017-03-14 14:21:36 +01:00
|
|
|
* @param int $contentId
|
2016-04-25 14:31:25 +02:00
|
|
|
*/
|
|
|
|
public function saveFile($file, $contentId);
|
2016-05-04 16:52:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy a file from another content or editor tmp dir.
|
|
|
|
* Used when copy pasting content in H5P.
|
|
|
|
*
|
|
|
|
* @param string $file path + name
|
2017-03-14 14:21:36 +01:00
|
|
|
* @param string|int $fromId Content ID or 'editor' string
|
|
|
|
* @param int $toId Target Content ID
|
2016-05-04 16:52:02 +02:00
|
|
|
*/
|
|
|
|
public function cloneContentFile($file, $fromId, $toId);
|
|
|
|
|
2017-03-14 14:21:36 +01:00
|
|
|
/**
|
|
|
|
* 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
|
2017-04-06 16:30:26 +02:00
|
|
|
* @param string $contentId Id of content
|
2017-03-14 14:21:36 +01:00
|
|
|
*
|
|
|
|
* @return object Object containing h5p json and content json data
|
|
|
|
*/
|
2017-04-06 16:30:26 +02:00
|
|
|
public function moveContentDirectory($source, $contentId = NULL);
|
|
|
|
|
2016-05-04 16:52:02 +02:00
|
|
|
/**
|
|
|
|
* Checks to see if content has the given file.
|
|
|
|
* Used when saving content.
|
|
|
|
*
|
|
|
|
* @param string $file path + name
|
2016-05-09 11:53:12 +02:00
|
|
|
* @param int $contentId
|
2016-05-04 16:52:02 +02:00
|
|
|
* @return string|int File ID or NULL if not found
|
|
|
|
*/
|
|
|
|
public function getContentFile($file, $contentId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove content files that are no longer used.
|
|
|
|
* Used when saving content.
|
|
|
|
*
|
|
|
|
* @param string $file path + name
|
2016-05-09 11:53:12 +02:00
|
|
|
* @param int $contentId
|
2016-05-04 16:52:02 +02:00
|
|
|
*/
|
|
|
|
public function removeContentFile($file, $contentId);
|
2017-02-23 14:20:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if server setup has write permission to
|
|
|
|
* the required folders
|
|
|
|
*
|
|
|
|
* @return bool True if server has the proper write access
|
|
|
|
*/
|
|
|
|
public function hasWriteAccess();
|
2018-01-19 14:42:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the library has a presave.js in the root folder
|
|
|
|
*
|
2018-06-07 12:43:12 +02:00
|
|
|
* @param string $libraryName
|
|
|
|
* @param string $developmentPath
|
|
|
|
* @return bool
|
2018-01-19 14:42:43 +01:00
|
|
|
*/
|
2018-02-01 12:18:31 +01:00
|
|
|
public function hasPresave($libraryName, $developmentPath = null);
|
2019-01-22 15:27:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if upgrades script exist for library.
|
|
|
|
*
|
|
|
|
* @param string $machineName
|
|
|
|
* @param int $majorVersion
|
|
|
|
* @param int $minorVersion
|
|
|
|
* @return string Relative path
|
|
|
|
*/
|
|
|
|
public function getUpgradeScript($machineName, $majorVersion, $minorVersion);
|
2019-03-15 12:52:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the given stream into the given file.
|
|
|
|
*
|
|
|
|
* @param string $path
|
|
|
|
* @param string $file
|
|
|
|
* @param resource $stream
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function saveFileFromZip($path, $file, $stream);
|
2016-01-11 18:31:04 +01:00
|
|
|
}
|