show pdf preview

This commit is contained in:
Uwe Steinmann 2016-11-07 09:25:55 +01:00
parent f960f69fc9
commit 84f9fd89f0
2 changed files with 76 additions and 7 deletions

View File

@ -36,6 +36,48 @@ require_once("SeedDMS/Preview.php");
*/
class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style {
function preview() { /* {{{ */
$document = $this->params['document'];
$timeout = $this->params['timeout'];
$showfullpreview = $this->params['showFullPreview'];
$converttopdf = $this->params['convertToPdf'];
$cachedir = $this->params['cachedir'];
$version = $this->params['version'];
if(!$showfullpreview)
return;
switch($version->getMimeType()) {
case 'audio/mpeg':
case 'audio/mp3':
case 'audio/ogg':
case 'audio/wav':
$this->contentHeading(getMLText("preview"));
?>
<audio controls style="width: 100%;">
<source src="../op/op.Download.php?documentid=<?php echo $document->getID(); ?>&version=<?php echo $version->getVersion(); ?>" type="audio/mpeg">
</audio>
<?php
break;
case 'application/pdf':
$this->contentHeading(getMLText("preview"));
?>
<iframe src="../pdfviewer/web/viewer.html?file=<?php echo urlencode('../../op/op.Download.php?documentid='.$document->getID().'&version='.$version->getVersion()); ?>" width="100%" height="700px"></iframe>
<?php
break;
default:
break;
}
if($converttopdf) {
$pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout);
if($pdfpreviewer->hasConverter($version->getMimeType())) {
$this->contentHeading(getMLText("preview"));
?>
<iframe src="../pdfviewer/web/viewer.html?file=<?php echo urlencode('../../op/op.PdfPreview.php?documentid='.$document->getID().'&version='.$version->getVersion()); ?>" width="100%" height="700px"></iframe>
<?php
}
}
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
@ -59,7 +101,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style {
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
?>
<div class="row-fluid">
<div class="span3">
<div class="span4">
<?php
$this->contentHeading(getMLText("document_infos"));
$this->contentContainerStart();
@ -138,9 +180,10 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style {
</table>
<?php
$this->contentContainerEnd();
$this->preview();
?>
</div>
<div class="span9">
<div class="span8">
<?php
// verify if file exists
@ -360,6 +403,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style {
}
?>
</div>
</div>
<?php
$this->contentEnd();
$this->htmlEndPage();

View File

@ -129,9 +129,17 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
function preview() { /* {{{ */
$document = $this->params['document'];
$timeout = $this->params['timeout'];
$showfullpreview = $this->params['showFullPreview'];
$converttopdf = $this->params['convertToPdf'];
$cachedir = $this->params['cachedir'];
if(!$showfullpreview)
return;
$latestContent = $document->getLatestContent();
switch($latestContent->getMimeType()) {
case 'audio/mpeg':
case 'audio/mp3':
case 'audio/ogg':
case 'audio/wav':
$this->contentHeading(getMLText("preview"));
@ -141,6 +149,23 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
</audio>
<?php
break;
case 'application/pdf':
$this->contentHeading(getMLText("preview"));
?>
<iframe src="../pdfviewer/web/viewer.html?file=<?php echo urlencode('../../op/op.Download.php?documentid='.$document->getID().'&version='.$latestContent->getVersion()); ?>" width="100%" height="700px"></iframe>
<?php
break;
default:
break;
}
if($converttopdf) {
$pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout);
if($pdfpreviewer->hasConverter($latestContent->getMimeType())) {
$this->contentHeading(getMLText("preview"));
?>
<iframe src="../pdfviewer/web/viewer.html?file=<?php echo urlencode('../../op/op.PdfPreview.php?documentid='.$document->getID().'&version='.$latestContent->getVersion()); ?>" width="100%" height="700px"></iframe>
<?php
}
}
} /* }}} */
@ -214,7 +239,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
?>
<div class="row-fluid">
<div class="span3">
<div class="span4">
<?php
$this->contentHeading(getMLText("document_infos"));
$this->contentContainerStart();
@ -330,10 +355,10 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
</table>
<?php
$this->contentContainerEnd();
// $this->preview();
$this->preview();
?>
</div>
<div class="span9">
<div class="span8">
<ul class="nav nav-tabs" id="docinfotab">
<li class="<?php if(!$currenttab || $currenttab == 'docinfo') echo 'active'; ?>"><a data-target="#docinfo" data-toggle="tab"><?php printMLText('current_version'); ?></a></li>
<?php if (count($versions)>1) { ?>
@ -356,7 +381,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
}
?>
<li class="<?php if($currenttab == 'attachments') echo 'active'; ?>"><a data-target="#attachments" data-toggle="tab"><?php printMLText('linked_files'); echo (count($files)) ? " (".count($files).")" : ""; ?></a></li>
<li class="<?php if($currenttab == 'links') echo 'active'; ?>"><a data-target="#links" data-toggle="tab"><?php printMLText('linked_documents'); echo (count($links)) ? " (".count($links).")" : ""; ?></a></li>
<li class="<?php if($currenttab == 'links') echo 'active'; ?>"><a data-target="#links" data-toggle="tab"><?php printMLText('linked_documents'); echo (count($links)) ? " (".count($links).")" : ""; ?></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane <?php if(!$currenttab || $currenttab == 'docinfo') echo 'active'; ?>" id="docinfo">
@ -1209,7 +1234,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
$this->contentContainerEnd();
}
?>
</div>
</div>
</div>
<?php
if($user->isAdmin()) {