Skip to content
Snippets Groups Projects
Commit 3d9350a7 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #2653

Closes #2653

Merge request studip/studip!1798
parent 600ca064
No related branches found
No related tags found
No related merge requests found
...@@ -129,12 +129,12 @@ ...@@ -129,12 +129,12 @@
<? if (!Config::get()->OER_DISABLE_LICENSE) : ?> <? if (!Config::get()->OER_DISABLE_LICENSE) : ?>
<div class="license" style="margin-top: 20px;"> <div class="license" style="margin-top: 20px;">
<h2><?= _('Lizenz') ?></h2> <h2><?= _('Lizenz') ?></h2>
<? if ($material->license['link']) : ?> <? if (!empty($material->license['link'])) : ?>
<a href="<?= htmlReady($material->license['link']) ?>" target="_blank"> <a href="<?= htmlReady($material->license['link']) ?>" target="_blank">
<? endif ?> <? endif ?>
<?= LicenseAvatar::getAvatar($material['license_identifier'])->getImageTag(Avatar::MEDIUM) ?> <?= LicenseAvatar::getAvatar($material['license_identifier'])->getImageTag(Avatar::MEDIUM) ?>
<?= htmlReady($material['license_identifier']) ?> <?= htmlReady($material['license_identifier']) ?>
<? if ($material->license['link']) : ?> <? if (!empty($material->license['link'])) : ?>
</a> </a>
<? endif ?> <? endif ?>
<div> <div>
......
...@@ -115,21 +115,21 @@ class OERHostOERSI extends OERHost ...@@ -115,21 +115,21 @@ class OERHostOERSI extends OERHost
$data['draft'] = '0'; $data['draft'] = '0';
$data['filename'] = ''; $data['filename'] = '';
$data['short_description'] = ''; $data['short_description'] = '';
$data['description'] = $output['description'] ?: ''; $data['description'] = $output['description'] ?? '';
$data['difficulty_start'] = 12; $data['difficulty_start'] = 12;
$data['uri'] = $output['encoding'][0]['contentUrl'] ?: ''; $data['uri'] = $output['encoding'][0]['contentUrl'] ?? '';
$data['source_url'] = $output['id']; $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']) ?: ''; $data['license_identifier'] = $this->getLicenseID($output['license']['id']) ?: '';
if (empty($data['category'])) { if (empty($data['category'])) {
$data['category'] = $material->autoDetectCategory(); $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'] = $material['data']->getArrayCopy();
$data['data']['download'] = $output['encoding'][0]['contentUrl'] ?: ''; $data['data']['download'] = $output['encoding'][0]['contentUrl'] ?? '';
$data['data']['front_image_url'] = $output['image']; $data['data']['front_image_url'] = $output['image'] ?? '';
$data['data']['authors'] = $output['creator']; $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 [ return [
'data' => $data, 'data' => $data,
'topics' => $output['keywords'] ?? [] 'topics' => $output['keywords'] ?? []
...@@ -152,8 +152,8 @@ class OERHostOERSI extends OERHost ...@@ -152,8 +152,8 @@ class OERHostOERSI extends OERHost
*/ */
protected function getLicenseID($license) protected function getLicenseID($license)
{ {
preg_match("^https:\/\/creativecommons.org\/licenses\/([\w\d\-\.]+)\/([\w\d\-\.]+)^", $license, $matches); $matched = preg_match("^https:\/\/creativecommons.org\/licenses\/([\w\d\-\.]+)\/([\w\d\-\.]+)^", $license, $matches);
if ($matches[0]) { if ($matched) {
$spdx_id = 'CC-' . strtoupper($matches[1]) . '-' . strtoupper($matches[2]); $spdx_id = 'CC-' . strtoupper($matches[1]) . '-' . strtoupper($matches[2]);
if (License::find($spdx_id)) { if (License::find($spdx_id)) {
return $spdx_id; return $spdx_id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment