Make it possible to move content directory to existing content

HFP-899
pull/10/merge
thomasmars 2017-04-06 16:30:26 +02:00
parent 29fd758bf5
commit a0069235f1
2 changed files with 10 additions and 6 deletions

View File

@ -363,18 +363,22 @@ class H5PDefaultStorage implements \H5PFileStorage {
* content from the current temporary upload folder to the editor path.
*
* @param string $source path to source directory
* @param string $target path of target directory. Defaults to editor path
* @param string $contentId Id of content
*
* @return object Object containing h5p json and content json data
*/
public function moveContentDirectory($source, $target = NULL) {
public function moveContentDirectory($source, $contentId = NULL) {
if ($source === NULL) {
return NULL;
}
if ($target === NULL) {
if ($contentId === NULL || $contentId === 0) {
$target = $this->getEditorPath();
}
else {
// Use content folder
$target = "{$this->path}/content/{$contentId}";
}
$contentSource = $source . DIRECTORY_SEPARATOR . 'content';
$contentFiles = array_diff(scandir($contentSource), array('.','..', 'content.json'));

View File

@ -158,12 +158,12 @@ interface H5PFileStorage {
* content from the current temporary upload folder to the editor path.
*
* @param string $source path to source directory
* @param string $target path of target directory. Defaults to editor path
* @param string $contentId Id of content
*
* @return object Object containing h5p json and content json data
*/
public function moveContentDirectory($source, $target = NULL);
public function moveContentDirectory($source, $contentId = NULL);
/**
* Checks to see if content has the given file.
* Used when saving content.