aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2023-05-22 11:16:52 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2023-05-22 11:16:52 +0000
commit3d9350a77cdf5eb88604acb565829981e174321a (patch)
tree2dc12519911d1f0148fc4384487bdcf723f4194b
parent600ca064170648f43425c0e56a697a5912a694a7 (diff)
fixes #2653
Closes #2653 Merge request studip/studip!1798
-rw-r--r--app/views/oer/market/details.php6
-rw-r--r--lib/models/OERHostOERSI.php18
2 files changed, 12 insertions, 12 deletions
diff --git a/app/views/oer/market/details.php b/app/views/oer/market/details.php
index 7b6b3ec..a9f459f 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 24d3251..3bb5d9f 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;