diff --git a/app/views/oer/market/details.php b/app/views/oer/market/details.php index 7b6b3ec7de292f4dbb1297755872b6d3c9cefbcc..a9f459f633bc106286bc50c9d9b474fe3458ec45 100644 --- a/app/views/oer/market/details.php +++ b/app/views/oer/market/details.php @@ -129,12 +129,12 @@ <? if (!Config::get()->OER_DISABLE_LICENSE) : ?> <div class="license" style="margin-top: 20px;"> <h2><?= _('Lizenz') ?></h2> - <? if ($material->license['link']) : ?> + <? if (!empty($material->license['link'])) : ?> <a href="<?= htmlReady($material->license['link']) ?>" target="_blank"> - <? endif ?> + <? endif ?> <?= LicenseAvatar::getAvatar($material['license_identifier'])->getImageTag(Avatar::MEDIUM) ?> <?= htmlReady($material['license_identifier']) ?> - <? if ($material->license['link']) : ?> + <? if (!empty($material->license['link'])) : ?> </a> <? endif ?> <div> diff --git a/lib/models/OERHostOERSI.php b/lib/models/OERHostOERSI.php index 24d32510ce69312946dccda24a14eb0bd27d6fc8..3bb5d9f70293a36a41364e9be1c496aa6fc5b799 100644 --- a/lib/models/OERHostOERSI.php +++ b/lib/models/OERHostOERSI.php @@ -115,21 +115,21 @@ class OERHostOERSI extends OERHost $data['draft'] = '0'; $data['filename'] = ''; $data['short_description'] = ''; - $data['description'] = $output['description'] ?: ''; + $data['description'] = $output['description'] ?? ''; $data['difficulty_start'] = 12; - $data['uri'] = $output['encoding'][0]['contentUrl'] ?: ''; + $data['uri'] = $output['encoding'][0]['contentUrl'] ?? ''; $data['source_url'] = $output['id']; - $data['content_type'] = $output['encoding'][0]['encodingFormat'] ?: ''; + $data['content_type'] = $output['encoding'][0]['encodingFormat'] ?? ''; $data['license_identifier'] = $this->getLicenseID($output['license']['id']) ?: ''; if (empty($data['category'])) { $data['category'] = $material->autoDetectCategory(); } - $data['front_image_content_type'] = $output['image'] ? 'image/jpg' : null; + $data['front_image_content_type'] = !empty($output['image']) ? 'image/jpg' : null; $data['data'] = $material['data']->getArrayCopy(); - $data['data']['download'] = $output['encoding'][0]['contentUrl'] ?: ''; - $data['data']['front_image_url'] = $output['image']; + $data['data']['download'] = $output['encoding'][0]['contentUrl'] ?? ''; + $data['data']['front_image_url'] = $output['image'] ?? ''; $data['data']['authors'] = $output['creator']; - $data['data']['organization'] = $output['sourceOrganization'][0]['name'] ?: $output['publisher'][0]['name']; + $data['data']['organization'] = $output['sourceOrganization'][0]['name'] ?? $output['publisher'][0]['name'] ?? ''; return [ 'data' => $data, 'topics' => $output['keywords'] ?? [] @@ -152,8 +152,8 @@ class OERHostOERSI extends OERHost */ protected function getLicenseID($license) { - preg_match("^https:\/\/creativecommons.org\/licenses\/([\w\d\-\.]+)\/([\w\d\-\.]+)^", $license, $matches); - if ($matches[0]) { + $matched = preg_match("^https:\/\/creativecommons.org\/licenses\/([\w\d\-\.]+)\/([\w\d\-\.]+)^", $license, $matches); + if ($matched) { $spdx_id = 'CC-' . strtoupper($matches[1]) . '-' . strtoupper($matches[2]); if (License::find($spdx_id)) { return $spdx_id;