Merge branch 'master' of github.com:h5p/h5p-php-library

semantics-font
Frode Petterson 2015-04-20 15:37:59 +02:00
commit 51a77c02ab
1 changed files with 18 additions and 4 deletions

View File

@ -1268,7 +1268,7 @@ class H5PStorage {
} }
$content['params'] = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json'); $content['params'] = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json');
if (isset($options['disable'])) { if (isset($options['disable'])) {
$content['disable'] = $options['disable']; $content['disable'] = $options['disable'];
} }
@ -2652,10 +2652,17 @@ class H5PContentValidator {
// Validate each element in list. // Validate each element in list.
foreach ($list as $key => &$value) { foreach ($list as $key => &$value) {
if (!is_int($key)) { if (!is_int($key)) {
unset($list[$key]); array_splice($list, $key, 1);
continue; continue;
} }
$this->$function($value, $field); $this->$function($value, $field);
if ($value === NULL) {
array_splice($list, $key, 1);
}
}
if (count($list) === 0) {
$list = NULL;
} }
} }
@ -2765,6 +2772,9 @@ class H5PContentValidator {
if ($found) { if ($found) {
if ($function) { if ($function) {
$this->$function($value, $field); $this->$function($value, $field);
if ($value === NULL) {
unset($group->$key);
}
} }
else { else {
// We have a field type in semantics for which we don't have a // We have a field type in semantics for which we don't have a
@ -2800,9 +2810,13 @@ class H5PContentValidator {
* Will recurse into validating the library's semantics too. * Will recurse into validating the library's semantics too.
*/ */
public function validateLibrary(&$value, $semantics) { public function validateLibrary(&$value, $semantics) {
if (!isset($value->library) || !in_array($value->library, $semantics->options)) { if (!isset($value->library)) {
$value = NULL;
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')); $this->h5pF->setErrorMessage($this->h5pF->t('Library used in content is not a valid library according to semantics'));
$value = new stdClass(); $value = NULL;
return; return;
} }