aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Fuhse <fuhse@data-quest.de>2022-11-15 13:10:32 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2022-11-15 13:10:32 +0000
commitde69b6fdcb19deb5cbbfaec3e3a87f923ea6f762 (patch)
treea1136e1e2b4630cb4cad3ebda6e01aeae7ddec59
parentda3c47c4c12c706ce0c4b39d641c3fb0521f8e2f (diff)
Resolve "OER-Campus: Großer schwarzer Kasten"
Closes #1384 Merge request studip/studip!906
-rw-r--r--app/views/oer/market/details.php6
-rw-r--r--lib/models/OERMaterial.php15
-rw-r--r--resources/assets/stylesheets/scss/oer.scss3
3 files changed, 21 insertions, 3 deletions
diff --git a/app/views/oer/market/details.php b/app/views/oer/market/details.php
index cf73817..e764d90 100644
--- a/app/views/oer/market/details.php
+++ b/app/views/oer/market/details.php
@@ -25,8 +25,10 @@
src="<?= htmlReady($url) ?>"></audio>
</div>
<? elseif ($material->isPDF()) : ?>
- <iframe src="<?= htmlReady($url) ?>"
- class="lernmarktplatz_player"></iframe>
+ <? if ($material->isPDFInlineDisplayable()) : ?>
+ <iframe src="<?= htmlReady($url) ?>"
+ class="lernmarktplatz_player"></iframe>
+ <? endif ?>
<? elseif ($material['front_image_content_type']) : ?>
<div style="background-image: url('<?= htmlReady($material->getLogoURL()) ?>');" class="lernmarktplatz_player image"></div>
<? endif ?>
diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php
index 9fb45d9..b3430d4 100644
--- a/lib/models/OERMaterial.php
+++ b/lib/models/OERMaterial.php
@@ -322,6 +322,21 @@ class OERMaterial extends SimpleORMap
return $this['content_type'] === "application/pdf";
}
+ public function isPDFInlineDisplayable()
+ {
+ if (!$this->isPDF()) {
+ return false;
+ }
+ $url = $this->getDownloadUrl();
+ $headers = get_headers($url, true);
+ if ($headers['Content-Disposition']
+ && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment') {
+ //in this case the server forces to download the document and we cannot display it in an iframe:
+ return false;
+ }
+ return true;
+ }
+
protected function getFileEnding()
{
return pathinfo($this["filename"], PATHINFO_EXTENSION);
diff --git a/resources/assets/stylesheets/scss/oer.scss b/resources/assets/stylesheets/scss/oer.scss
index 0482f8a..f91ed7d 100644
--- a/resources/assets/stylesheets/scss/oer.scss
+++ b/resources/assets/stylesheets/scss/oer.scss
@@ -392,7 +392,8 @@ ul.reviews, ol.reviews {
width: 840px;
max-width: 100%;
box-sizing: border-box;
- min-height: 200px;
+ height: 200px;
+ max-height: 200px;
overflow: hidden;
.intro {
display: flex;