From 41ed0c18e4fa2ccec5c89958a1237554e759005b Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 2 Nov 2014 17:52:39 +0100 Subject: [PATCH 1/8] Add htmlSpecialChars --- h5p.classes.php | 2 +- js/h5p.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 7d964ba..b4fc7a7 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1526,7 +1526,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 3 + 'minorVersion' => 4 ); public static $styles = array( 'styles/h5p.css', diff --git a/js/h5p.js b/js/h5p.js index d53f8e2..fe257f2 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1099,3 +1099,10 @@ if (H5P.jQuery) { } }); } + + /** + * Mimics how php's htmlspecialchars works (the way we use it) + */ +H5P.htmlSpecialChars = function(string) { + return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); +}; \ No newline at end of file From 7c3ddea71a7431ec455597260759583019740e50 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 2 Nov 2014 19:13:14 +0100 Subject: [PATCH 2/8] Become node_clone compatible again --- h5p.classes.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index b4fc7a7..e77258c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1648,19 +1648,23 @@ class H5PCore { // Update content dependencies. $content['dependencies'] = $validator->getDependencies(); - $this->h5pF->deleteLibraryUsage($content['id']); - $this->h5pF->saveLibraryUsage($content['id'], $content['dependencies']); - if ($this->exportEnabled) { - // Recreate export file - $exporter = new H5PExport($this->h5pF, $this); - $exporter->createExportFile($content); + // Sometimes the parameters are filtered before content has been created + if ($content['id']) { + $this->h5pF->deleteLibraryUsage($content['id']); + $this->h5pF->saveLibraryUsage($content['id'], $content['dependencies']); - // TODO: Should we rather create the file once first accessed, like imagecache? + if ($this->exportEnabled) { + // Recreate export file + $exporter = new H5PExport($this->h5pF, $this); + $exporter->createExportFile($content); + + // TODO: Should we rather create the file once first accessed, like imagecache? + } + + // Cache. + $this->h5pF->setFilteredParameters($content['id'], $params); } - - // Cache. - $this->h5pF->setFilteredParameters($content['id'], $params); return $params; } From 415e2171341e79d8eae9801054aeea0509336347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Mon, 3 Nov 2014 07:02:45 +0100 Subject: [PATCH 3/8] Fixed URL to h5p.org --- h5p.classes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index e77258c..e31964b 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2188,7 +2188,7 @@ class H5PCore { $platformInfo['uuid'] = $this->h5pF->getOption('h5p_site_uuid', ''); // Adding random string to GET to be sure nothing is cached $random = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 5); - $json = $this->h5pF->fetchExternalData('http://h5p.lvh.me/h5p.org/libraries-metadata.json?api=1&platform=' . urlencode(json_encode($platformInfo)) . '&x=' . urlencode($random)); + $json = $this->h5pF->fetchExternalData('http://h5p.org/libraries-metadata.json?api=1&platform=' . urlencode(json_encode($platformInfo)) . '&x=' . urlencode($random)); if ($json !== NULL) { $json = json_decode($json); if (isset($json->libraries)) { @@ -2320,7 +2320,7 @@ class H5PContentValidator { */ public function validateContentFiles($contentPath, $isLibrary = FALSE) { if ($this->h5pC->disableFileCheck === TRUE) { - return TRUE; + return TRUE; } // Scan content directory for files, recurse into sub directories. From 57db1d99266ca51d08e0d3e916369a9a8ed11397 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Mon, 3 Nov 2014 10:15:23 +0100 Subject: [PATCH 4/8] Revert "Add htmlSpecialChars" This reverts commit 41ed0c18e4fa2ccec5c89958a1237554e759005b. --- h5p.classes.php | 2 +- js/h5p.js | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index e31964b..827903a 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1526,7 +1526,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 4 + 'minorVersion' => 3 ); public static $styles = array( 'styles/h5p.css', diff --git a/js/h5p.js b/js/h5p.js index fe257f2..d53f8e2 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1099,10 +1099,3 @@ if (H5P.jQuery) { } }); } - - /** - * Mimics how php's htmlspecialchars works (the way we use it) - */ -H5P.htmlSpecialChars = function(string) { - return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); -}; \ No newline at end of file From 2d7824aa932a6b217bc16a4f7b53c6ab654a1790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Thu, 6 Nov 2014 11:13:24 +0100 Subject: [PATCH 5/8] Fix for language containing empty string in H5P export (h5p.json) --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 827903a..905b72c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1433,7 +1433,7 @@ Class H5PExport { 'title' => $content['title'], // TODO - stop using 'und', this is not the preferred way. // Either remove language from the json if not existing, or use "language": null - 'language' => isset($content['language']) ? $content['language'] : 'und', + 'language' => (isset($content['language']) && strlen(trim($content['language'])) !== 0) ? $content['language'] : 'und', 'mainLibrary' => $content['library']['name'], 'embedTypes' => $embedTypes, ); From 60d166c6da256bb2d5a66be2f4927efd229b6fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Wed, 19 Nov 2014 12:43:59 +0100 Subject: [PATCH 6/8] Made creation of h5p export file overwrite existing file --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 905b72c..9a456a5 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1465,7 +1465,7 @@ Class H5PExport { // Create new zip instance. $zip = new ZipArchive(); - $zip->open($zipPath, ZIPARCHIVE::CREATE); + $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);); // Get all files and folders in $tempPath $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR)); From 9ed2e48fb5c97ce398ba7176ca678f2d3e50209c Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 25 Nov 2014 10:55:32 +0100 Subject: [PATCH 7/8] Fixed parse error. --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 9a456a5..36151b1 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1465,7 +1465,7 @@ Class H5PExport { // Create new zip instance. $zip = new ZipArchive(); - $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);); + $zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); // Get all files and folders in $tempPath $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR)); From fb07f54e3517bff606934b0b056188afce24524d Mon Sep 17 00:00:00 2001 From: falcon Date: Thu, 27 Nov 2014 23:14:15 +0100 Subject: [PATCH 8/8] Make it possible to do the dependency transactions in an atomic way --- h5p-development.class.php | 2 ++ h5p.classes.php | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/h5p-development.class.php b/h5p-development.class.php index 75e9daf..7f33689 100644 --- a/h5p-development.class.php +++ b/h5p-development.class.php @@ -93,6 +93,7 @@ class H5PDevelopment { // TODO: Should we remove libraries without files? Not really needed, but must be cleaned up some time, right? // Go trough libraries and insert dependencies. Missing deps. will just be ignored and not available. (I guess?!) + $this->h5pF->lockDependencyStorage(); foreach ($this->libraries as $library) { $this->h5pF->deleteLibraryDependencies($library['libraryId']); // This isn't optimal, but without it we would get duplicate warnings. @@ -104,6 +105,7 @@ class H5PDevelopment { } } } + $this->h5pF->unlockDependencyStorage(); // TODO: Deps must be inserted into h5p_nodes_libraries as well... ? But only if they are used?! } diff --git a/h5p.classes.php b/h5p.classes.php index 36151b1..5940e06 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -408,6 +408,17 @@ interface H5PFrameworkInterface { */ public function deleteLibraryDependencies($libraryId); + /** + * Start an atomic operation against the dependency storage + */ + public function lockDependencyStorage(); + + /** + * Stops an atomic operation against the dependency storage + */ + public function unlockDependencyStorage(); + + /** * Delete a library from database and file system *