From b55c1838a99386e7f5ea258492dc7df0c16e5375 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Wed, 23 Nov 2016 14:21:28 +0100 Subject: [PATCH 1/3] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9577d19..e8d34a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ vendor *~ - +.idea \ No newline at end of file From b4615e01b18385625d8461b1f5fa0195eebe2bf2 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Mon, 28 Nov 2016 14:54:33 +0100 Subject: [PATCH 2/3] Allow subContentId in group validation. Relates to: #HFP-285 --- h5p.classes.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/h5p.classes.php b/h5p.classes.php index 4d7223b..03d5136 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3063,6 +3063,11 @@ class H5PContentValidator { } else { foreach ($group as $key => &$value) { + // If subContentId is set, keep value + if($key == 'subContentId' && $value == TRUE){ + continue; + } + // Find semantics for name=$key $found = FALSE; foreach ($semantics->fields as $field) { From 4d010ef38ff2809e2c52aba07d61ce438261e85e Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Thu, 1 Dec 2016 11:34:28 +0100 Subject: [PATCH 3/3] Improved message presented to user --- h5p.classes.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 03d5136..dabca7d 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3132,7 +3132,30 @@ class H5PContentValidator { return; } if (!in_array($value->library, $semantics->options)) { - $this->h5pF->setErrorMessage($this->h5pF->t('Library used in content is not a valid library according to semantics')); + $message = NULL; + // Create an understandable error message: + $machineName = explode(' ', $value->library)[0]; + foreach ($semantics->options as $semanticsLibrary) { + $semanticsMachineName = explode(' ', $semanticsLibrary)[0]; + if ($machineName === $semanticsMachineName) { + // Using the wrong version of the library in the content + $message = $this->h5pF->t('The version of the H5P library %machineName used in this content is not valid. Content contains %contentLibrary, but it should be %semanticsLibrary.', array( + '%machineName' => $machineName, + '%contentLibrary' => $value->library, + '%semanticsLibrary' => $semanticsLibrary + )); + break; + } + } + + // Using a library in content that is not present at all in semantics + if ($message === NULL) { + $message = $this->h5pF->t('The H5P library %library used in the content is not valid', array( + '%library' => $value->library + )); + } + + $this->h5pF->setErrorMessage($message); $value = NULL; return; }