From 4525d6383f8c3f715df2506c20e7b43194a6a268 Mon Sep 17 00:00:00 2001 From: Thomas Horn Sivertsen <4159138+tsivert@users.noreply.github.com> Date: Thu, 21 Mar 2019 10:30:09 +0100 Subject: [PATCH 1/4] Incorrect json (#58) Default language is of type text and should therefore add quotes around the value like source, license and license_version do. --- h5p-metadata.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p-metadata.class.php b/h5p-metadata.class.php index 830e9dc..572cfd0 100644 --- a/h5p-metadata.class.php +++ b/h5p-metadata.class.php @@ -65,7 +65,7 @@ abstract class H5PMetadata { ',"yearFrom":' . (isset($content->year_from) ? $content->year_from : 'null') . ',"yearTo":' . (isset($content->year_to) ? $content->year_to : 'null') . ',"changes":' . (isset($content->changes) ? $content->changes : 'null') . - ',"defaultLanguage":' . (isset($content->default_language) ? $content->default_language : 'null') . + ',"defaultLanguage":' . (isset($content->default_language) ? '"' . $content->default_language . '"' : 'null') . ',"authorComments":' . (isset($content->author_comments) ? json_encode($content->author_comments) : 'null') . '}'; } From ac5dba1e19bec8349e882983a1665aa7909a6d6d Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Mon, 25 Mar 2019 14:03:43 +0100 Subject: [PATCH 2/4] Fix validation of old libraries before running content upgrade --- h5p.classes.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 04fe35e..96fed5f 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1006,28 +1006,29 @@ class H5PValidator { if (!empty($missingLibraries)) { // We still have missing libraries, check if our main library has an upgrade (BUT only if we has content) $mainDependency = NULL; - if (!$skipContent && !empty($mainH5PData)) { - foreach ($mainH5PData['preloadedDependencies'] as $dep) { - if ($dep['machineName'] === $mainH5PData['mainLibrary']) { + if (!$skipContent && !empty($mainH5pData)) { + foreach ($mainH5pData['preloadedDependencies'] as $dep) { + if ($dep['machineName'] === $mainH5pData['mainLibrary']) { $mainDependency = $dep; } } } if ($skipContent || !$mainDependency || !$this->h5pF->libraryHasUpgrade(array( - 'machineName' => $mainDependency['mainLibrary'], + 'machineName' => $mainDependency['machineName'], 'majorVersion' => $mainDependency['majorVersion'], 'minorVersion' => $mainDependency['minorVersion'] ))) { foreach ($missingLibraries as $libString => $library) { $this->h5pF->setErrorMessage($this->h5pF->t('Missing required library @library', array('@library' => $libString)), 'missing-required-library'); + $valid = FALSE; } if (!$this->h5pC->mayUpdateLibraries()) { $this->h5pF->setInfoMessage($this->h5pF->t("Note that the libraries may exist in the file you uploaded, but you're not allowed to upload new libraries. Contact the site administrator about this.")); + $valid = FALSE; } } } - $valid = empty($missingLibraries) && $valid; } if (!$valid) { H5PCore::deleteFileTree($tmpDir); From 7a85c115dbcf561d648701f2d9ddb4628827adf6 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 26 Mar 2019 14:51:38 +0100 Subject: [PATCH 3/4] HFP-2693 Fix dialog size on resize --- styles/h5p.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/styles/h5p.css b/styles/h5p.css index 3b3e1fe..1f81839 100644 --- a/styles/h5p.css +++ b/styles/h5p.css @@ -306,10 +306,11 @@ div.h5p-fullscreen { .h5p-embed-dialog .h5p-inner, .h5p-reuse-dialog .h5p-inner, .h5p-content-user-data-reset-dialog .h5p-inner { - width: 316px; + min-width: 316px; + max-width: 400px; left: 50%; top: 50%; - margin: 0 0 0 -158px; + transform: translateX(-50%); } .h5p-embed-dialog .h5p-embed-code-container, .h5p-embed-size { From 052ad0ea813225c7946606f6c57a7693ebd5aa13 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 26 Mar 2019 16:43:11 +0100 Subject: [PATCH 4/4] Fix use filtered instead of params in .h5p files --- h5p.classes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4d42029..03c14d3 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1783,7 +1783,7 @@ Class H5PExport { } // Update content.json with content from database - file_put_contents("{$tmpPath}/content/content.json", $content['params']); + file_put_contents("{$tmpPath}/content/content.json", $content['filtered']); // Make embedType into an array $embedTypes = explode(', ', $content['embedType']); @@ -2205,6 +2205,7 @@ class H5PCore { if ($this->exportEnabled) { // Recreate export file $exporter = new H5PExport($this->h5pF, $this); + $content['filtered'] = $params; $exporter->createExportFile($content); }