From a0069235f1df38f1a288cb10435fe8b40fa84be9 Mon Sep 17 00:00:00 2001 From: thomasmars Date: Thu, 6 Apr 2017 16:30:26 +0200 Subject: [PATCH] Make it possible to move content directory to existing content HFP-899 --- h5p-default-storage.class.php | 10 +++++++--- h5p-file-storage.interface.php | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index f34bf09..2147f9b 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -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')); diff --git a/h5p-file-storage.interface.php b/h5p-file-storage.interface.php index fadee65..394210b 100644 --- a/h5p-file-storage.interface.php +++ b/h5p-file-storage.interface.php @@ -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.