mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 13:11:31 +00:00
move delivery of document into controller
done for being able to call a viewOnline::version hook
This commit is contained in:
parent
2d08f870c7
commit
f793ee8a28
48
controllers/class.ViewOnline.php
Normal file
48
controllers/class.ViewOnline.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,10 +23,14 @@ include("../inc/inc.LogInit.php");
|
||||||
include("../inc/inc.DBInit.php");
|
include("../inc/inc.DBInit.php");
|
||||||
include("../inc/inc.Language.php");
|
include("../inc/inc.Language.php");
|
||||||
include("../inc/inc.ClassUI.php");
|
include("../inc/inc.ClassUI.php");
|
||||||
|
include("../inc/inc.ClassController.php");
|
||||||
include("../inc/inc.Authentication.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"];
|
$documentid = $_GET["documentid"];
|
||||||
|
|
||||||
if (!isset($documentid) || !is_numeric($documentid) || intval($documentid)<1) {
|
if (!isset($documentid) || !is_numeric($documentid) || intval($documentid)<1) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
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"));
|
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)) {
|
$controller->setParam('content', $content);
|
||||||
header("Content-Type: " . $content->getMimeType());
|
$controller->setParam('type', 'version');
|
||||||
}
|
$controller->run();
|
||||||
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());
|
|
||||||
} elseif(isset($_GET["file"])) {
|
} elseif(isset($_GET["file"])) {
|
||||||
$fileid = $_GET["file"];
|
$fileid = $_GET["file"];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user