move delivery of document into controller

done for being able to call a viewOnline::version hook
This commit is contained in:
Uwe Steinmann 2013-07-23 17:35:46 +02:00
parent 2d08f870c7
commit f793ee8a28
2 changed files with 56 additions and 11 deletions

View File

@ -0,0 +1,48 @@
<?php
/**
* Implementation of ViewOnline 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 downloading 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_ViewOnline extends SeedDMS_Controller_Common {
public function run() {
$dms = $this->params['dms'];
$type = $this->params['type'];
$content = $this->params['content'];
$document = $content->getDocument();
switch($type) {
case "version":
if(!$this->callHook('version')) {
if (isset($settings->_viewOnlineFileTypes) && is_array($settings->_viewOnlineFileTypes) && in_array(strtolower($content->getFileType()), $settings->_viewOnlineFileTypes)) {
header("Content-Type: " . $content->getMimeType());
}
header("Content-Disposition: filename=\"" . $document->getName().$content->getFileType()) . "\"";
header("Content-Length: " . filesize($dms->contentDir . $content->getPath()));
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($dms->contentDir . $content->getPath());
}
break;
}
}
}

View File

@ -23,10 +23,14 @@ include("../inc/inc.LogInit.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassController.php");
include("../inc/inc.Authentication.php");
include("../inc/inc.Extension.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$controller = Controller::factory($tmp[1]);
$documentid = $_GET["documentid"];
if (!isset($documentid) || !is_numeric($documentid) || intval($documentid)<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
@ -54,16 +58,9 @@ if(isset($_GET["version"])) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
}
if (isset($settings->_viewOnlineFileTypes) && is_array($settings->_viewOnlineFileTypes) && in_array(strtolower($content->getFileType()), $settings->_viewOnlineFileTypes)) {
header("Content-Type: " . $content->getMimeType());
}
header("Content-Disposition: filename=\"" . $document->getName().$content->getFileType()) . "\"";
header("Content-Length: " . filesize($dms->contentDir . $content->getPath()));
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($dms->contentDir . $content->getPath());
$controller->setParam('content', $content);
$controller->setParam('type', 'version');
$controller->run();
} elseif(isset($_GET["file"])) {
$fileid = $_GET["file"];