mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
b27895e4ea
|
@ -168,6 +168,17 @@ class SeedDMS_Controller_Download extends SeedDMS_Controller_Common {
|
|||
$dms = $this->params['dms'];
|
||||
$type = $this->params['type'];
|
||||
|
||||
$version = $this->params['version'];
|
||||
$document = $this->params['document'];
|
||||
$content = $document->getContentByVersion($version);
|
||||
if (!is_object($content)) {
|
||||
$this->errormsg = 'invalid_version';
|
||||
return false;
|
||||
}
|
||||
/* set params['content'] for compatiblity with older extensions which
|
||||
* expect the content in the controller
|
||||
*/
|
||||
$this->params['content'] = $content;
|
||||
switch($type) {
|
||||
case "version":
|
||||
$this->version();
|
||||
|
|
75
controllers/class.Preview.php
Normal file
75
controllers/class.Preview.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of Preview controller
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class which does the busines logic for previewing a document
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
|
||||
|
||||
public function run() {
|
||||
$dms = $this->params['dms'];
|
||||
$type = $this->params['type'];
|
||||
$settings = $this->params['settings'];
|
||||
|
||||
switch($type) {
|
||||
case "version":
|
||||
$version = $this->params['version'];
|
||||
$document = $this->params['document'];
|
||||
$width = $this->params['width'];
|
||||
if($version < 1) {
|
||||
$content = $this->callHook('documentLatestContent', $document);
|
||||
if($content === null)
|
||||
$content = $document->getLatestContent();
|
||||
} else {
|
||||
$content = $this->callHook('documentContent', $document, $version);
|
||||
if($content === null)
|
||||
$content = $document->getContentByVersion($version);
|
||||
}
|
||||
if (!is_object($content)) {
|
||||
$this->errormsg = 'invalid_version';
|
||||
return false;
|
||||
}
|
||||
/* set params['content'] for compatiblity with older extensions which
|
||||
* expect the content in the controller
|
||||
*/
|
||||
$this->params['content'] = $content;
|
||||
if(null === $this->callHook('version')) {
|
||||
if($width)
|
||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir, $width);
|
||||
else
|
||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
||||
$previewer->setConverters($settings->_converters['preview']);
|
||||
$previewer->setXsendfile($settings->_enableXsendfile);
|
||||
if(!$previewer->hasPreview($content)) {
|
||||
if(!$previewer->createPreview($content)) {
|
||||
}
|
||||
}
|
||||
if(!$previewer->hasPreview($content)) {
|
||||
header('Content-Type: image/svg+xml');
|
||||
readfile('../views/'.$theme.'/images/empty.svg');
|
||||
exit;
|
||||
}
|
||||
header('Content-Type: image/png');
|
||||
$previewer->getPreview($content);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -26,11 +26,28 @@ class SeedDMS_Controller_ViewOnline extends SeedDMS_Controller_Common {
|
|||
$dms = $this->params['dms'];
|
||||
$settings = $this->params['settings'];
|
||||
$type = $this->params['type'];
|
||||
$content = $this->params['content'];
|
||||
$document = $content->getDocument();
|
||||
|
||||
switch($type) {
|
||||
case "version":
|
||||
$version = $this->params['version'];
|
||||
$document = $this->params['document'];
|
||||
if($version < 1) {
|
||||
$content = $this->callHook('documentLatestContent', $document);
|
||||
if($content === null)
|
||||
$content = $document->getLatestContent();
|
||||
} else {
|
||||
$content = $this->callHook('documentContent', $document, $version);
|
||||
if($content === null)
|
||||
$content = $document->getContentByVersion($version);
|
||||
}
|
||||
if (!is_object($content)) {
|
||||
$this->errormsg = 'invalid_version';
|
||||
return false;
|
||||
}
|
||||
/* set params['content'] for compatiblity with older extensions which
|
||||
* expect the content in the controller
|
||||
*/
|
||||
$this->params['content'] = $content;
|
||||
if(null === $this->callHook('version')) {
|
||||
header("Content-Type: " . $content->getMimeType());
|
||||
$efilename = rawurlencode($content->getOriginalFileName());
|
||||
|
@ -46,5 +63,7 @@ class SeedDMS_Controller_ViewOnline extends SeedDMS_Controller_Common {
|
|||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,15 +62,13 @@ if (isset($_GET["version"])) { /* {{{ */
|
|||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
$version = $_GET["version"];
|
||||
$content = $document->getContentByVersion($version);
|
||||
|
||||
if (!is_object($content)) {
|
||||
$controller->setParam('document', $document);
|
||||
$controller->setParam('version', $version);
|
||||
$controller->setParam('type', 'version');
|
||||
if(!$controller->run()) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
$controller->setParam('content', $content);
|
||||
$controller->version();
|
||||
|
||||
} /* }}} */
|
||||
elseif (isset($_GET["file"])) { /* {{{ */
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ include("../inc/inc.Init.php");
|
|||
include("../inc/inc.Extension.php");
|
||||
include("../inc/inc.DBInit.php");
|
||||
include("../inc/inc.ClassUI.php");
|
||||
include("../inc/inc.ClassController.php");
|
||||
include("../inc/inc.Authentication.php");
|
||||
|
||||
/**
|
||||
|
@ -34,6 +35,9 @@ include("../inc/inc.Authentication.php");
|
|||
*/
|
||||
require_once("SeedDMS/Preview.php");
|
||||
|
||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||
$controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||
|
||||
$documentid = $_GET["documentid"];
|
||||
if (!isset($documentid) || !is_numeric($documentid) || intval($documentid)<1) {
|
||||
exit;
|
||||
|
@ -52,10 +56,15 @@ if(isset($_GET['version'])) {
|
|||
$version = $_GET["version"];
|
||||
if (!is_numeric($version))
|
||||
exit;
|
||||
if(intval($version)<1)
|
||||
$object = $document->getLatestContent();
|
||||
else
|
||||
$object = $document->getContentByVersion($version);
|
||||
|
||||
$controller->setParam('width', !empty($_GET["width"]) ? $_GET["width"] : null);
|
||||
$controller->setParam('document', $document);
|
||||
$controller->setParam('version', $version);
|
||||
$controller->setParam('type', 'version');
|
||||
if(!$controller->run()) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
exit;
|
||||
} elseif(isset($_GET['file'])) {
|
||||
$file = $_GET['file'];
|
||||
if (!is_numeric($file) || intval($file)<1)
|
||||
|
|
|
@ -57,18 +57,12 @@ if(isset($_GET["version"])) {
|
|||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
if(intval($version)<1)
|
||||
$content = $document->getLatestContent();
|
||||
else
|
||||
$content = $document->getContentByVersion($version);
|
||||
|
||||
if (!is_object($content)) {
|
||||
$controller->setParam('document', $document);
|
||||
$controller->setParam('version', intval($version));
|
||||
$controller->setParam('type', 'version');
|
||||
if(!$controller->run()) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
$controller->setParam('content', $content);
|
||||
$controller->setParam('type', 'version');
|
||||
$controller->run();
|
||||
} elseif(isset($_GET["file"])) {
|
||||
$fileid = $_GET["file"];
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ if (!is_object($content)) {
|
|||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
// operation is admitted only for last deocument version
|
||||
// operation is admitted only for last document version
|
||||
$latestContent = $document->getLatestContent();
|
||||
if ($latestContent->getVersion()!=$version) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version"));
|
||||
|
|
|
@ -56,7 +56,7 @@ if (!is_object($content)) {
|
|||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version"));
|
||||
}
|
||||
|
||||
// operation is admitted only for last deocument version
|
||||
// operation is admitted only for last document version
|
||||
$latestContent = $document->getLatestContent();
|
||||
if ($latestContent->getVersion()!=$version) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version"));
|
||||
|
|
|
@ -2359,10 +2359,15 @@ $(document).ready( function() {
|
|||
if(!$skipcont)
|
||||
$content .= "<tr id=\"table-row-document-".$docID."\" class=\"table-row-document\" rel=\"document_".$docID."\" formtoken=\"".createFormKey('movedocument')."\" draggable=\"true\">";
|
||||
|
||||
if($version)
|
||||
$latestContent = $document->getContentByVersion($version);
|
||||
else
|
||||
$latestContent = $document->getLatestContent();
|
||||
if($version) {
|
||||
$latestContent = $this->callHook('documentContent', $document, $version);
|
||||
if($latestContent === null)
|
||||
$latestContent = $document->getContentByVersion($version);
|
||||
} else {
|
||||
$latestContent = $this->callHook('documentLatestContent', $document);
|
||||
if($latestContent === null)
|
||||
$latestContent = $document->getLatestContent();
|
||||
}
|
||||
|
||||
if($latestContent) {
|
||||
$previewer->createPreview($latestContent);
|
||||
|
|
|
@ -135,7 +135,10 @@ class SeedDMS_View_Clipboard extends SeedDMS_Bootstrap_Style {
|
|||
if($document = $dms->getDocument($docid)) {
|
||||
$comment = $document->getComment();
|
||||
if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "...";
|
||||
if($latestContent = $document->getLatestContent()) {
|
||||
$latestContent = $this->callHook('documentLatestContent', $document);
|
||||
if($latestContent === null)
|
||||
$latestContent = $document->getLatestContent();
|
||||
if($latestContent) {
|
||||
$previewer->createPreview($latestContent);
|
||||
$version = $latestContent->getVersion();
|
||||
$status = $latestContent->getStatus();
|
||||
|
|
|
@ -189,7 +189,10 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
|
||||
header('Content-Type: application/javascript');
|
||||
if($user->isAdmin()) {
|
||||
$this->printTimelineJs('out.ViewDocument.php?action=timelinedata&documentid='.$document->getID(), 300, '', date('Y-m-d'));
|
||||
$latestContent = $this->callHook('documentLatestContent', $document);
|
||||
if($latestContent === null)
|
||||
$latestContent = $document->getLatestContent();
|
||||
$this->printTimelineJs('out.ViewDocument.php?action=timelinedata&documentid='.$latestContent->getDocument()->getID(), 300, '', date('Y-m-d'));
|
||||
}
|
||||
$this->printDocumentChooserJs("form1");
|
||||
$this->printDeleteDocumentButtonJs();
|
||||
|
@ -356,7 +359,9 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
|
||||
$accessop = $this->params['accessobject'];
|
||||
if($accessop->check_controller_access('ViewOnline', array('action'=>'version'))) {
|
||||
$latestContent = $document->getLatestContent();
|
||||
$latestContent = $this->callHook('documentLatestContent', $document);
|
||||
if($latestContent === null)
|
||||
$latestContent = $document->getLatestContent();
|
||||
$txt = $this->callHook('preDocumentPreview', $latestContent);
|
||||
if(is_string($txt))
|
||||
echo $txt;
|
||||
|
@ -372,7 +377,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
$this->contentHeading(getMLText("preview"));
|
||||
?>
|
||||
<audio controls style="width: 100%;">
|
||||
<source src="../op/op.ViewOnline.php?documentid=<?php echo $document->getID(); ?>&version=<?php echo $latestContent->getVersion(); ?>" type="audio/mpeg">
|
||||
<source src="../op/op.ViewOnline.php?documentid=<?php echo $latestContent->getDocument()->getID(); ?>&version=<?php echo $latestContent->getVersion(); ?>" type="audio/mpeg">
|
||||
</audio>
|
||||
<?php
|
||||
break;
|
||||
|
@ -447,7 +452,9 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
$timeout = $this->params['timeout'];
|
||||
$xsendfile = $this->params['xsendfile'];
|
||||
|
||||
$versions = $document->getContent();
|
||||
$versions = $this->callHook('documentVersions', $document);
|
||||
if($versions === null)
|
||||
$versions = $document->getContent();
|
||||
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
|
||||
$this->htmlAddHeader('<link href="../styles/'.$this->theme.'/timeline/timeline.css" rel="stylesheet">'."\n", 'css');
|
||||
|
@ -474,7 +481,9 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
}
|
||||
|
||||
/* Retrieve latest content and attacheѕ files */
|
||||
$latestContent = $document->getLatestContent();
|
||||
$latestContent = $this->callHook('documentLatestContent', $document);
|
||||
if($latestContent === null)
|
||||
$latestContent = $document->getLatestContent();
|
||||
$files = $document->getDocumentFiles($latestContent->getVersion());
|
||||
$files = SeedDMS_Core_DMS::filterDocumentFiles($user, $files);
|
||||
|
||||
|
@ -1793,7 +1802,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
</div>
|
||||
<?php
|
||||
if($user->isAdmin()) {
|
||||
$timeline = $document->getTimeline();
|
||||
$timeline = $latestContent->getDocument()->getTimeline();
|
||||
if($timeline) {
|
||||
/*
|
||||
$this->contentHeading(getMLText("timeline"));
|
||||
|
@ -1809,7 +1818,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
|||
$msg = getMLText('timeline_'.$item['type'], array('document'=>$item['document']->getName(), 'version'=> $item['version'], 'status'=> getOverallStatusText($item['status'])));
|
||||
break;
|
||||
default:
|
||||
$msg = $this->callHook('getTimelineMsg', $document, $item);
|
||||
$msg = $this->callHook('getTimelineMsg', $latestContent->getDocument(), $item);
|
||||
if(!is_string($msg))
|
||||
$msg = '???';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user