Add alternative mimetypes for PDF files; little code cleanup

This commit is contained in:
Thomas Bruederli 2013-01-24 14:10:20 +01:00
parent 451ced1d34
commit eb29aaeb96

View file

@ -30,6 +30,11 @@ class pdfviewer extends rcube_plugin
private $pdf_mimetypes = array( private $pdf_mimetypes = array(
'application/pdf', 'application/pdf',
'application/x-pdf',
'application/acrobat',
'applications/vnd.pdf',
'text/pdf',
'text/x-pdf',
); );
/** /**
@ -61,17 +66,12 @@ class pdfviewer extends rcube_plugin
*/ */
public function get_part($args) public function get_part($args)
{ {
if (!$args['download'] && $args['mimetype'] && in_array($args['mimetype'], $this->pdf_mimetypes)) { // redirect to viewer/viewer.html
$rcmail = rcube::get_instance(); if (!$args['download'] && $args['mimetype'] && empty($_GET['_load']) && in_array($args['mimetype'], $this->pdf_mimetypes)) {
$mimetype = 'application/pdf'; $file_url = $this->abs_url(rcube::get_instance()->url($_GET + array('_load' => 1)));
// 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)); header('Location: ' . $this->abs_url($this->urlbase . 'viewer/viewer.html') . '?file=' . urlencode($file_url));
$args['abort'] = true; $args['abort'] = true;
} }
}
return $args; return $args;
} }