From eb29aaeb960a846c845d25960855e1c9baaabe27 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Thu, 24 Jan 2013 14:10:20 +0100 Subject: [PATCH] Add alternative mimetypes for PDF files; little code cleanup --- plugins/pdfviewer/pdfviewer.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/pdfviewer/pdfviewer.php b/plugins/pdfviewer/pdfviewer.php index 686da9a2..b6da2d2c 100644 --- a/plugins/pdfviewer/pdfviewer.php +++ b/plugins/pdfviewer/pdfviewer.php @@ -30,6 +30,11 @@ class pdfviewer extends rcube_plugin private $pdf_mimetypes = array( 'application/pdf', + 'application/x-pdf', + 'application/acrobat', + 'applications/vnd.pdf', + 'text/pdf', + 'text/x-pdf', ); /** @@ -50,7 +55,7 @@ class pdfviewer extends rcube_plugin } // only use pdf.js if the browser doesn't support inline PDF rendering - if (empty($_SESSION['browser_caps']['pdf']) || $ua->opera) + if (empty($_SESSION['browser_caps']['pdf']) || $ua->opera) $this->add_hook('message_part_get', array($this, 'get_part')); $this->add_hook('message_part_structure', array($this, 'part_structure')); @@ -61,16 +66,11 @@ class pdfviewer extends rcube_plugin */ public function get_part($args) { - if (!$args['download'] && $args['mimetype'] && in_array($args['mimetype'], $this->pdf_mimetypes)) { - $rcmail = rcube::get_instance(); - $mimetype = 'application/pdf'; - - // redirect to viewer.html - if (empty($_GET['_load'])) { - $file_url = $this->abs_url($rcmail->url($_GET + array('_load' => 1))); - header('Location: ' . $this->abs_url($this->urlbase . 'viewer/viewer.html') . '?file=' . urlencode($file_url)); - $args['abort'] = true; - } + // redirect to viewer/viewer.html + if (!$args['download'] && $args['mimetype'] && empty($_GET['_load']) && in_array($args['mimetype'], $this->pdf_mimetypes)) { + $file_url = $this->abs_url(rcube::get_instance()->url($_GET + array('_load' => 1))); + header('Location: ' . $this->abs_url($this->urlbase . 'viewer/viewer.html') . '?file=' . urlencode($file_url)); + $args['abort'] = true; } return $args;