From db1db1787cc3b0b09d8671e58d8695c6a0fba1f2 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 17 Sep 2020 10:51:37 +0200 Subject: [PATCH 1/5] major update to make it look like the view document page, fixed preview --- out/out.DocumentVersionDetail.php | 2 + .../bootstrap/class.DocumentVersionDetail.php | 307 +++++++++++------- 2 files changed, 199 insertions(+), 110 deletions(-) diff --git a/out/out.DocumentVersionDetail.php b/out/out.DocumentVersionDetail.php index e2ef756b5..b0809c996 100644 --- a/out/out.DocumentVersionDetail.php +++ b/out/out.DocumentVersionDetail.php @@ -77,6 +77,8 @@ if($view) { $view->setParam('viewonlinefiletypes', $settings->_viewOnlineFileTypes); $view->setParam('enableversionmodification', $settings->_enableVersionModification); $view->setParam('previewWidthDetail', $settings->_previewWidthDetail); + $view->setParam('previewConverters', isset($settings->_converters['preview']) ? $settings->_converters['preview'] : array()); + $view->setParam('pdfConverters', isset($settings->_converters['pdf']) ? $settings->_converters['pdf'] : array()); $view->setParam('showFullPreview', $settings->_showFullPreview); $view->setParam('convertToPdf', $settings->_convertToPdf); $view->setParam('cachedir', $settings->_cacheDir); diff --git a/views/bootstrap/class.DocumentVersionDetail.php b/views/bootstrap/class.DocumentVersionDetail.php index 9313f30af..6d96e0299 100644 --- a/views/bootstrap/class.DocumentVersionDetail.php +++ b/views/bootstrap/class.DocumentVersionDetail.php @@ -36,50 +36,100 @@ require_once("SeedDMS/Preview.php"); */ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { + /** + * Output a single attribute in the document info section + * + * @param object $attribute attribute + */ + protected function printAttribute($attribute) { /* {{{ */ + $attrdef = $attribute->getAttributeDefinition(); +?> + + getName()); ?>: + getAttributeValue($attribute); ?> + +params['dms']; $document = $this->params['document']; $timeout = $this->params['timeout']; $xsendfile = $this->params['xsendfile']; $showfullpreview = $this->params['showFullPreview']; $converttopdf = $this->params['convertToPdf']; + $pdfconverters = $this->params['pdfConverters']; $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")); -?> - -contentHeading(getMLText("preview")); -?> - -contentHeading(getMLText("preview")); -?> - -callHook('preDocumentPreview', $version); + if(is_string($txt)) + echo $txt; + $txt = $this->callHook('documentPreview', $version); + if(is_string($txt)) + echo $txt; + else { + switch($version->getMimeType()) { + case 'audio/mpeg': + case 'audio/mp3': + case 'audio/ogg': + case 'audio/wav': + $this->contentHeading(getMLText("preview")); + ?> + + contentHeading(getMLText("preview")); + ?> + + contentHeading(getMLText("preview")); + ?> + + contentHeading(getMLText("preview")); + ?> + + callHook('additionalDocumentPreview', $version); + if(is_string($txt)) + echo $txt; + break; + } } + $txt = $this->callHook('postDocumentPreview', $version); + if(is_string($txt)) + echo $txt; + if($converttopdf) { $pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout, $xsendfile); + $pdfpreviewer->setConverters($pdfconverters); if($pdfpreviewer->hasConverter($version->getMimeType())) { - $this->contentHeading(getMLText("preview")); + $this->contentHeading(getMLText("preview_pdf")); ?> - + params['user']; $folder = $this->params['folder']; $document = $this->params['document']; + $accessop = $this->params['accessobject']; $version = $this->params['version']; $viewonlinefiletypes = $this->params['viewonlinefiletypes']; $enableversionmodification = $this->params['enableversionmodification']; @@ -174,13 +225,17 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { $attributes = $document->getAttributes(); if($attributes) { foreach($attributes as $attribute) { - $attrdef = $attribute->getAttributeDefinition(); -?> - - getName()); ?>: - getValueAsArray())); ?> - -callHook('showDocumentAttribute', $document, $attribute); + if(is_array($arr)) { + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].""; + echo ""; + } elseif(is_string($arr)) { + echo $arr; + } else { + $this->printAttribute($attribute); + } } } ?> @@ -200,11 +255,10 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { $this->contentContainerStart(); print ""; print "\n\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; + print "\n"; +// print "\n"; + print "\n"; + print "\n"; print "\n\n\n"; print "\n"; print "\n"; print "\n"; - print ""; - print ""; + print ""; + print ""; print "\n
".getMLText("file")."".getMLText("comment")."".getMLText("status")."".htmlspecialchars($version->getOriginalFileName())."".getMLText("comment")."".getMLText("status")."
    "; @@ -218,68 +272,94 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { print "
    \n"; - print "
  • ".$version->getOriginalFileName()."
  • \n"; print "
  • ".getMLText('version').": ".$version->getVersion()."
  • \n"; - if ($file_exists) print "
  • ". formatted_size(filesize($dms->contentDir . $version->getPath())) ." ".htmlspecialchars($version->getMimeType())."
  • "; + if ($file_exists) + print "
  • ". SeedDMS_Core_File::format_filesize($version->getFileSize()) .", ".htmlspecialchars($version->getMimeType())."
  • "; else print "
  • ".getMLText("document_deleted")."
  • "; $updatingUser = $version->getUser(); print "
  • ".getMLText("uploaded_by")." getEmail()."\">".htmlspecialchars($updatingUser->getFullName())."
  • "; print "
  • ".getLongReadableDate($version->getDate())."
  • "; + + print "
\n"; + $txt = $this->callHook('showVersionComment', $version); + if($txt) { + echo $txt; + } else { + if($version->getComment()) + print "

".htmlspecialchars($version->getComment())."

"; + } + print "
    \n"; + $attributes = $version->getAttributes(); + if($attributes) { + foreach($attributes as $attribute) { + $arr = $this->callHook('showDocumentContentAttribute', $version, $attribute); + if(is_array($arr)) { + print "
  • ".$arr[0].": ".$arr[1]."
  • \n"; + } else { + $attrdef = $attribute->getAttributeDefinition(); + print "
  • ".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars(implode(', ', $attribute->getValueAsArray()))."
  • \n"; + } + } + } print "
".htmlspecialchars($version->getComment())."".getOverallStatusText($status["status"]).""; + print getOverallStatusText($status["status"]); + if ( $status["status"]==S_DRAFT_REV || $status["status"]==S_DRAFT_APP || $status["status"]==S_IN_WORKFLOW || $status["status"]==S_EXPIRED ){ + print "
hasExpired()?" class=\"warning\" ":"").">".(!$document->getExpires() ? getMLText("does_not_expire") : getMLText("expires").": ".getReadableDate($document->getExpires())).""; + } + print "
"; //if (($document->getAccessMode($user) >= M_READWRITE)) { - print "
\n"; + $this->contentContainerEnd(); - print "\n"; + print "
"; + print "
"; - if (is_array($reviewStatus) && count($reviewStatus)>0) { + if (is_array($reviewStatus) && count($reviewStatus)>0) { /* {{{ */ - print "
\n"; - + print "".getMLText('reviewers').""; + print "
\n"; - $this->contentSubHeading(getMLText("reviewers")); - print "
\n"; print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; + print "\n"; + print "\n"; +// print ""; + print "\n"; print "\n"; foreach ($reviewStatus as $r) { @@ -291,7 +371,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { $reqName = getMLText("unknown_user")." '".$r["required"]."'"; } else { - $reqName = htmlspecialchars($required->getFullName()); + $reqName = " ".htmlspecialchars($required->getFullName()." (".$required->getLogin().")"); } break; case 1: // Reviewer is a group. @@ -300,32 +380,40 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { $reqName = getMLText("unknown_group")." '".$r["required"]."'"; } else { - $reqName = htmlspecialchars($required->getName()); + $reqName = " ".htmlspecialchars($required->getName()); } break; } - print "\n"; + print "\n"; print "\n"; - print ""; - print "\n"; + print (is_object($updateUser) ? htmlspecialchars($updateUser->getFullName()." (".$updateUser->getLogin().")") : "unknown user id '".$r["userID"]."'")."
"; + print htmlspecialchars($r["comment"]); + if($r['file']) { + echo "
"; + echo " ".getMLText('download').""; + } + print "\n"; print "\n"; print "\n"; } - } + print "
".getMLText("name")."".getMLText("last_update")."".getMLText("comment")."".getMLText("status")."".getMLText("name")."".getMLText("last_update")."".getMLText("comment")."".getMLText("status")."
".$reqName."
  • ".$r["date"]."
  • "; + print "
".$r["date"]." - "; + /* $updateUser is the user who has done the review */ $updateUser = $dms->getUser($r["userID"]); - print "
  • ".(is_object($updateUser) ? $updateUser->getFullName() : "unknown user id '".$r["userID"]."'")."
  • ".$r["comment"]."".getReviewStatusText($r["status"])."
    \n"; + } /* }}} */ - if (is_array($approvalStatus) && count($approvalStatus)>0) { + print "\n"; + print "
    "; - print "\n"; - $this->contentSubHeading(getMLText("approvers")); - print "\n"; - + if (is_array($approvalStatus) && count($approvalStatus)>0) { /* {{{ */ + + print "".getMLText('approvers').""; + print "\n"; print "\n"; - print "\n"; - print "\n"; - print ""; - print "\n"; + print "\n"; + print "\n"; +// print ""; + print "\n"; print "\n"; foreach ($approvalStatus as $a) { @@ -337,7 +425,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { $reqName = getMLText("unknown_user")." '".$r["required"]."'"; } else { - $reqName = htmlspecialchars($required->getFullName()); + $reqName = " ".htmlspecialchars($required->getFullName()." (".$required->getLogin().")"); } break; case 1: // Approver is a group. @@ -346,38 +434,39 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { $reqName = getMLText("unknown_group")." '".$r["required"]."'"; } else { - $reqName = htmlspecialchars($required->getName()); + $reqName = " ".htmlspecialchars($required->getName()); } break; } - print "\n"; + print "\n"; print "\n"; - print ""; - print "\n"; + print (is_object($updateUser) ? htmlspecialchars($updateUser->getFullName()." (".$updateUser->getLogin().")") : "unknown user id '".$a["userID"]."'")."
    "; + print htmlspecialchars($a["comment"]); + if($a['file']) { + echo "
    "; + echo " ".getMLText('download').""; + } + echo "\n"; print "\n"; print "\n"; } - } + print "
    ".getMLText("name")."".getMLText("last_update")."".getMLText("comment")."".getMLText("status")."".getMLText("name")."".getMLText("last_update")."".getMLText("comment")."".getMLText("status")."
    ".$reqName."
    • ".$a["date"]."
    • "; + print "
    ".$a["date"]." - "; + /* $updateUser is the user who has done the approval */ $updateUser = $dms->getUser($a["userID"]); - print "
  • ".(is_object($updateUser) ? htmlspecialchars($updateUser->getFullName()) : "unknown user id '".$a["userID"]."'")."
  • ".$a["comment"]."".getApprovalStatusText($a["status"])."
    \n"; + } /* }}} */ - print "\n"; + print "
    \n"; + print "\n"; - $this->contentContainerEnd(); - - $tmpfiles = $document->getDocumentFiles($version->getVersion()); - /* Do the regular filtering by isPublic and access rights */ - $tmpfiles = SeedDMS_Core_DMS::filterDocumentFiles($user, $tmpfiles); - /* Also filter only those files belonging to this version and skip files - * belonging to the document (version = 0) + /* Get attachments exclusively for this version, without those + * attached to the document */ - $files = array(); - foreach($tmpfiles as $file) { - if($file->getVersion() == $version->getVersion()) - $files[] = $file; - } + $files = $document->getDocumentFiles($version->getVersion(), false); + /* Do the regular filtering by isPublic and access rights */ + $files = SeedDMS_Core_DMS::filterDocumentFiles($user, $files); - if (count($files) > 0) { + if (count($files) > 0) { /* {{{ */ $this->contentHeading(getMLText("linked_files")); $this->contentContainerStart(); @@ -392,8 +481,6 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { print "\n\n\n"; foreach($files as $file) { - if($file->getVersion() != $version->getVersion()) - continue; $file_exists=file_exists($dms->contentDir . $file->getPath()); @@ -452,7 +539,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Bootstrap_Style { print "\n\n"; $this->contentContainerEnd(); - } + } /* }}} */ if($user->isAdmin()) { $this->contentHeading(getMLText("status")); From b39f84e67c965bd179c26fe1495b79bd840f8845 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 17 Sep 2020 10:52:27 +0200 Subject: [PATCH 2/5] fix html tags for version actions --- views/bootstrap/class.ViewDocument.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index f048b1173..ace2be200 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -628,8 +628,6 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { } print "\n"; -// print "".htmlspecialchars($latestContent->getComment()).""; - print ""; print getOverallStatusText($status["status"]); if ( $status["status"]==S_DRAFT_REV || $status["status"]==S_DRAFT_APP || $status["status"]==S_IN_WORKFLOW || $status["status"]==S_EXPIRED ){ @@ -639,13 +637,14 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { print ""; - print ""; + print "