From 317021a28364dec2f8742eba2675c1f789fe65db Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sun, 21 Jul 2013 11:51:59 +0200 Subject: [PATCH] new controller class for downloading document version --- controllers/class.Download.php | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 controllers/class.Download.php diff --git a/controllers/class.Download.php b/controllers/class.Download.php new file mode 100644 index 000000000..36d7b8186 --- /dev/null +++ b/controllers/class.Download.php @@ -0,0 +1,45 @@ + + * @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 + * @copyright Copyright (C) 2010-2013 Uwe Steinmann + * @version Release: @package_version@ + */ +class SeedDMS_Controller_Download extends SeedDMS_Controller_Common { + + public function run() { + $dms = $this->params['dms']; + $type = $this->params['type']; + $content = $this->params['content']; + + switch($type) { + case "version": + + if(!$this->callHook('version')) { + header("Content-Transfer-Encoding: binary"); + header("Content-Length: " . filesize($dms->contentDir . $content->getPath() )); + header("Content-Disposition: attachment; filename=\"" . $content->getOriginalFileName() . "\""); + header("Content-Type: " . $content->getMimeType()); + header("Cache-Control: must-revalidate"); + + readfile($dms->contentDir . $content->getPath()); + } + break; + } + } +}