HFP-1905 Fix unset values for array fields

Some array fields were filled with undefined and lead to warnings.
pull/52/head
Oliver Tacke 2018-03-26 11:24:26 +02:00
parent 6ef2f96e8b
commit c589285351
1 changed files with 7 additions and 10 deletions

View File

@ -1600,18 +1600,15 @@ Class H5PExport {
'title' => $content['title'], 'title' => $content['title'],
'language' => (isset($content['language']) && strlen(trim($content['language'])) !== 0) ? $content['language'] : 'und', 'language' => (isset($content['language']) && strlen(trim($content['language'])) !== 0) ? $content['language'] : 'und',
'mainLibrary' => $content['library']['name'], 'mainLibrary' => $content['library']['name'],
'embedTypes' => $embedTypes, 'embedTypes' => $embedTypes
'authors' => json_decode(json_encode($content['metadata']['authors'], TRUE)),
'source' => $content['metadata']['source'],
'yearFrom' => $content['metadata']['yearFrom'],
'yearTo' => $content['metadata']['yearTo'],
'license' => $content['metadata']['license'],
'licenseVersion' => $content['metadata']['licenseVersion'],
'licenseExtras' => $content['metadata']['licenseExtras'],
'changes' => json_decode(json_encode($content['metadata']['changes'], TRUE)),
'authorComments' => $content['metadata']['authorComments']
); );
foreach(array('authors', 'source', 'license', 'licenseVersion', 'licenseExtras' ,'yearFrom', 'yearTo', 'changes', 'authorComments') as $field) {
if (isset($content['metadata'][$field])) {
$h5pJson[$field] = json_decode(json_encode($content['metadata'][$field], TRUE));
}
}
// Remove all values that are not set // Remove all values that are not set
foreach ($h5pJson as $key => $value) { foreach ($h5pJson as $key => $value) {
if (!isset($value)) { if (!isset($value)) {