diff options
| author | Rasmus Fuhse <fuhse@data-quest.de> | 2022-11-15 13:10:32 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2022-11-15 13:10:32 +0000 |
| commit | de69b6fdcb19deb5cbbfaec3e3a87f923ea6f762 (patch) | |
| tree | a1136e1e2b4630cb4cad3ebda6e01aeae7ddec59 /lib/models/OERMaterial.php | |
| parent | da3c47c4c12c706ce0c4b39d641c3fb0521f8e2f (diff) | |
Resolve "OER-Campus: Großer schwarzer Kasten"
Closes #1384
Merge request studip/studip!906
Diffstat (limited to 'lib/models/OERMaterial.php')
| -rw-r--r-- | lib/models/OERMaterial.php | 15 |
1 files changed, 15 insertions, 0 deletions
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); |
