From 7cb2ebe17cf17831fd6cb386918dd091f765d2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Fri, 5 Sep 2014 14:12:46 +0200 Subject: [PATCH 01/12] Fixed bug in validation, which made library-upload on library admin page fail --- h5p.classes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 15ef52f..4a386a7 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -609,9 +609,10 @@ class H5PValidator { $missingLibraries = $this->getMissingLibraries($libraries); foreach ($missingLibraries as $missing) { if ($this->h5pF->getLibraryId($missing['machineName'], $missing['majorVersion'], $missing['minorVersion'])) { - unset($missingLibraries[$missing['machineName']]); + unset($missingLibraries[H5PCore::libraryToString($missing)]); } } + if (!empty($missingLibraries)) { foreach ($missingLibraries as $library) { $this->h5pF->setErrorMessage($this->h5pF->t('Missing required library @library', array('@library' => H5PCore::libraryToString($library)))); From f207c3be9b037ad770147a587341e1d122b1f466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Tue, 23 Sep 2014 10:44:22 +0200 Subject: [PATCH 02/12] Setting language on export to 'und' if not defined --- h5p.classes.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4a386a7..51ffcec 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1251,7 +1251,9 @@ Class H5PExport { // Build h5p.json $h5pJson = array ( 'title' => $content['title'], - 'language' => $content['language'], + // 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', 'mainLibrary' => $content['library']['name'], 'embedTypes' => $embedTypes, ); From 38c98202f48ac371d1c7ca5c81a810bd2221c44f Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 23 Sep 2014 11:35:21 +0200 Subject: [PATCH 03/12] Added info message when there's no installed libraries. --- js/h5p-library-list.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index a18eb93..0332216 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -23,9 +23,9 @@ var H5PLibraryList= H5PLibraryList || {}; * @param {object} libraries List of libraries and headers */ H5PLibraryList.createLibraryList = function (libraries) { - + var t = H5PIntegration.i18n.H5P; if(libraries.listData === undefined || libraries.listData.length === 0) { - return; + return $('
' + t.NA + '
'); } // Create table @@ -33,7 +33,6 @@ var H5PLibraryList= H5PLibraryList || {}; $table.addClass('libraries'); // Add libraries - var t = H5PIntegration.i18n.H5P; $.each (libraries.listData, function (index, library) { var $libraryRow = H5PUtils.createTableRow([ library.title, From 212f8c6f0fa62f4ee99fcfa755cfa588391c4c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Tue, 23 Sep 2014 12:00:21 +0200 Subject: [PATCH 04/12] Added H5P.htmlspecialchars() --- js/h5p.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/h5p.js b/js/h5p.js index 3b5db69..0500cc9 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -975,6 +975,13 @@ H5P.setFinished = function (contentId, points, maxPoints) { } }; +/** + * Mimics how php's htmlspecialchars works (the way we use it) + */ +H5P.htmlspecialchars = function(string) { + return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); +}; + // Add indexOf to browsers that lack them. (IEs) if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (needle) { From 24be95a78ef29bf8c7adee3fb3669e28aa3561fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Tue, 23 Sep 2014 12:59:08 +0200 Subject: [PATCH 05/12] Bumped core version because of the new function added --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4a386a7..ae8116f 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1344,7 +1344,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 3 + 'minorVersion' => 4 ); public static $styles = array( 'styles/h5p.css', From 7e669884cee4e295b84e99941111ab498b7c12e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20J=C3=B8rgensen?= Date: Tue, 23 Sep 2014 13:01:39 +0200 Subject: [PATCH 06/12] Correct capitalization of H5P.htmlspecialchars function --- js/h5p.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/h5p.js b/js/h5p.js index 0500cc9..73f833a 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -978,7 +978,7 @@ H5P.setFinished = function (contentId, points, maxPoints) { /** * Mimics how php's htmlspecialchars works (the way we use it) */ -H5P.htmlspecialchars = function(string) { +H5P.htmlSpecialChars = function(string) { return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); }; From 7fd333088b6bc44f8e158799aed512d6ea22f471 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 23 Sep 2014 15:10:23 +0200 Subject: [PATCH 07/12] Added missing translation. --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4a386a7..f05382e 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1147,7 +1147,7 @@ class H5PStorage { if ($upgradeOnly) { // TODO - support translation - $this->h5pF->setInfoMessage($upgradedLibsCount . ' libraries were upgraded!'); + $this->h5pF->setInfoMessage($this->h5pF->t('@num libraries were upgraded!', array('@num' => $upgradedLibsCount))); } return $library_saved; From 1236eb5fd11f344d15fd6aa0c80bc97ab314e1f1 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 24 Sep 2014 15:34:34 +0200 Subject: [PATCH 08/12] Revert "Merge branch 'adding-htmlspecialchars-to-h5p' into without-pal" This reverts commit 687fd8ddbc256c1e8c5f3714f561c06b3c31fee1, reversing changes made to ab1b691a27aadfc4b6a9798ca09bd2ff661f2f2f. --- js/h5p.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/h5p.js b/js/h5p.js index 73f833a..0500cc9 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -978,7 +978,7 @@ H5P.setFinished = function (contentId, points, maxPoints) { /** * Mimics how php's htmlspecialchars works (the way we use it) */ -H5P.htmlSpecialChars = function(string) { +H5P.htmlspecialchars = function(string) { return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); }; From 4b8804988eef20ade122a2b3b97ffc423c790198 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 24 Sep 2014 15:34:55 +0200 Subject: [PATCH 09/12] Revert "Merge branch 'adding-htmlspecialchars-to-h5p' into without-pal" This reverts commit ab1b691a27aadfc4b6a9798ca09bd2ff661f2f2f, reversing changes made to 2b12bf4441b92f6bb3f7985c7fcb36be9875d177. --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 83874f8..3cc31ac 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1346,7 +1346,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 4 + 'minorVersion' => 3 ); public static $styles = array( 'styles/h5p.css', From 3442954971184ae51e3a26026f6289d41d268720 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 24 Sep 2014 15:35:47 +0200 Subject: [PATCH 10/12] Revert "Merge branch 'adding-htmlspecialchars-to-h5p' into without-pal" This reverts commit 9f19f64baba068aee25ec2894017eb5f5e2fd733, reversing changes made to 38c98202f48ac371d1c7ca5c81a810bd2221c44f. --- js/h5p.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 0500cc9..3b5db69 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -975,13 +975,6 @@ H5P.setFinished = function (contentId, points, maxPoints) { } }; -/** - * Mimics how php's htmlspecialchars works (the way we use it) - */ -H5P.htmlspecialchars = function(string) { - return string.toString().replace(//g, '>').replace(/'/g, ''').replace(/"/g, '"'); -}; - // Add indexOf to browsers that lack them. (IEs) if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (needle) { From d359ce52ca0640596440c6121d47b5678d403108 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 24 Sep 2014 16:24:56 +0200 Subject: [PATCH 11/12] Help make libraries admin easier. --- js/h5p-library-list.js | 15 ++++++++++++--- js/h5p-utils.js | 10 ++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index 0332216..8327744 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -36,9 +36,18 @@ var H5PLibraryList= H5PLibraryList || {}; $.each (libraries.listData, function (index, library) { var $libraryRow = H5PUtils.createTableRow([ library.title, - library.numContent, - library.numContentDependencies, - library.numLibraryDependencies, + { + text: library.numContent, + class: 'h5p-admin-center' + }, + { + text: library.numContentDependencies, + class: 'h5p-admin-center' + }, + { + text: library.numLibraryDependencies, + class: 'h5p-admin-center' + }, '
\ \ \ diff --git a/js/h5p-utils.js b/js/h5p-utils.js index 3004c95..26ffa1d 100644 --- a/js/h5p-utils.js +++ b/js/h5p-utils.js @@ -16,7 +16,7 @@ var H5PUtils = H5PUtils || {}; $.each(headers, function (index, value) { if (!(value instanceof Object)) { value = { - text: value + html: value }; } @@ -38,7 +38,13 @@ var H5PUtils = H5PUtils || {}; var $tr = $(''); $.each(rows, function (index, value) { - $tr.append('' + value + ''); + if (!(value instanceof Object)) { + value = { + html: value + }; + } + + $('', value).appendTo($tr); }); return $tr; From 53ceb6156b3a8c6df421903352f4fd9223e22167 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Thu, 25 Sep 2014 14:38:05 +0200 Subject: [PATCH 12/12] Improved content check, supporting blank fields. --- js/h5p-library-list.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index 8327744..a1e517f 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -55,10 +55,11 @@ var H5PLibraryList= H5PLibraryList || {};
' ]); + var hasContent = !(library.numContent === '' || library.numContent === 0); if (library.upgradeUrl === null) { $('.h5p-admin-upgrade-library', $libraryRow).remove(); } - else if (library.upgradeUrl === false || library.numContent === 0) { + else if (library.upgradeUrl === false || !hasContent) { $('.h5p-admin-upgrade-library', $libraryRow).attr('disabled', true); } else { @@ -73,7 +74,7 @@ var H5PLibraryList= H5PLibraryList || {}; }); var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); - if (libraries.notCached !== undefined || library.numContent !== 0 || (library.numContentDependencies !== '' && library.numContentDependencies !== 0) || (library.numLibraryDependencies !== '' && library.numLibraryDependencies !== 0)) { + if (libraries.notCached !== undefined || hasContent || (library.numContentDependencies !== '' && library.numContentDependencies !== 0) || (library.numLibraryDependencies !== '' && library.numLibraryDependencies !== 0)) { // Disabled delete if content. $deleteButton.attr('disabled', true); }