From 217644379e69f319bdca044c44844053d613700c Mon Sep 17 00:00:00 2001 From: Rasmus Fuhse <fuhse@data-quest.de> Date: Tue, 15 Nov 2022 13:10:32 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20"OER-Campus:=20Gro=C3=9Fer=20schwarze?= =?UTF-8?q?r=20Kasten"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1384 Merge request studip/studip!906 --- app/views/oer/market/details.php | 6 ++++-- lib/models/OERMaterial.php | 15 +++++++++++++++ resources/assets/stylesheets/scss/oer.scss | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/views/oer/market/details.php b/app/views/oer/market/details.php index 7d54dc6cc9b..000e8a012da 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 7612f70f985..dfd37d20ee9 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 0482f8ad937..f91ed7d70fc 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; -- GitLab