From 414751aad2cf5b1a1a50bca0eae4da5aa15d4528 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Thu, 21 Apr 2016 11:38:14 +0200 Subject: [PATCH 1/3] Fixed uploading packages and export functionality with development mode. Changed update package to save package, update package was moved from interface in january, replaced with savePackage. Added optional parameter to exportLibrary where you can pass in development folder path for the library if it lives inside development folder. HVP-147 --- h5p-default-storage.class.php | 9 +++++++-- h5p.classes.php | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 27b250b..5b8ffeb 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -116,10 +116,13 @@ class H5PDefaultStorage implements \H5PFileStorage { * Library properties * @param string $target * Where the library folder will be saved + * @param string $developmentPath + * Folder that library resides in */ - public function exportLibrary($library, $target) { + public function exportLibrary($library, $target, $developmentPath=NULL) { $folder = \H5PCore::libraryToString($library, TRUE); - self::copyFileTree("{$this->path}/libraries/{$folder}", "{$target}/{$folder}"); + $srcPath = ($developmentPath === NULL ? "/libraries/{$folder}" : $developmentPath); + self::copyFileTree("{$this->path}{$srcPath}", "{$target}/{$folder}"); } /** @@ -253,6 +256,8 @@ class H5PDefaultStorage implements \H5PFileStorage { * To path * @return boolean * Indicates if the directory existed. + * + * @throws Exception Unable to copy the file */ private static function copyFileTree($source, $destination) { if (!self::dirReady($destination)) { diff --git a/h5p.classes.php b/h5p.classes.php index 8bb7c7b..f9655a3 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1550,8 +1550,25 @@ Class H5PExport { $library = $dependency['library']; try { + $exportFolder = NULL; + + // Determine path of export library + if (isset($this->h5pC) && isset($this->h5pC->h5pD)) { + + // Tries to find library in development folder + $isDevLibrary = $this->h5pC->h5pD->getLibrary( + $library['machineName'], + $library['majorVersion'], + $library['minorVersion'] + ); + + if ($isDevLibrary !== NULL) { + $exportFolder = "/" . $library['path']; + } + } + // Export required libraries - $this->h5pC->fs->exportLibrary($library, $tmpPath); + $this->h5pC->fs->exportLibrary($library, $tmpPath, $exportFolder); } catch (Exception $e) { $this->h5pF->setErrorMessage($this->h5pF->t($e->getMessage())); From 6869ecbb091d0e00b5ed85f046e466e4e0a0a04d Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Thu, 21 Apr 2016 13:22:01 +0200 Subject: [PATCH 2/3] Handling several digits in major and minor version --- js/h5p.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/h5p.js b/js/h5p.js index 003f179..5a1c9e1 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1503,7 +1503,7 @@ H5P.Coords = function (x, y, w, h) { * return false if the library parameter is invalid */ H5P.libraryFromString = function (library) { - var regExp = /(.+)\s(\d)+\.(\d)$/g; + var regExp = /(.+)\s(\d+)\.(\d+)$/g; var res = regExp.exec(library); if (res !== null) { return { From 926ff4af3a736a9b5949aaa40f7cc001e3d61686 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Thu, 21 Apr 2016 14:58:21 +0200 Subject: [PATCH 3/3] Avoid confirmation dialog skewering content. HFJ-1572 --- js/h5p-confirmation-dialog.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/h5p-confirmation-dialog.js b/js/h5p-confirmation-dialog.js index 3263b76..abeba8a 100644 --- a/js/h5p-confirmation-dialog.js +++ b/js/h5p-confirmation-dialog.js @@ -174,8 +174,10 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { popup.style.top = offsetTop + 'px'; popupBackground.classList.remove('hidden'); fitToContainer(); - popupBackground.classList.remove('hiding'); - popup.classList.remove('hidden'); + setTimeout(function () { + popup.classList.remove('hidden'); + popupBackground.classList.remove('hiding'); + }, 0); // Programmatically focus popup popup.setAttribute('tabindex', '-1');