2013-07-21 09:51:59 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of Download 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_Download extends SeedDMS_Controller_Common {
|
|
|
|
|
|
|
|
public function run() {
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$type = $this->params['type'];
|
|
|
|
|
|
|
|
switch($type) {
|
|
|
|
case "version":
|
2015-06-08 19:59:56 +00:00
|
|
|
$content = $this->params['content'];
|
2013-07-21 09:51:59 +00:00
|
|
|
|
|
|
|
if(!$this->callHook('version')) {
|
2016-02-18 19:34:16 +00:00
|
|
|
if(file_exists($dms->contentDir . $content->getPath())) {
|
2016-02-15 16:08:01 +00:00
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
|
header("Content-Length: " . filesize($dms->contentDir . $content->getPath() ));
|
|
|
|
$efilename = rawurlencode($content->getOriginalFileName());
|
|
|
|
header("Content-Disposition: attachment; filename=\"" . $efilename . "\"; filename*=UTF-8''".$efilename);
|
|
|
|
header("Content-Type: " . $content->getMimeType());
|
|
|
|
header("Cache-Control: must-revalidate");
|
2013-07-21 09:51:59 +00:00
|
|
|
|
2016-02-15 16:08:01 +00:00
|
|
|
readfile($dms->contentDir . $content->getPath());
|
|
|
|
}
|
2013-07-21 09:51:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-06-08 19:59:56 +00:00
|
|
|
case "file":
|
|
|
|
$file = $this->params['file'];
|
|
|
|
|
|
|
|
if(!$this->callHook('file')) {
|
2016-02-18 19:35:56 +00:00
|
|
|
if(file_exists($dms->contentDir . $file->getPath())) {
|
2016-02-15 19:45:05 +00:00
|
|
|
header("Content-Type: application/force-download; name=\"" . $file->getOriginalFileName() . "\"");
|
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
|
header("Content-Length: " . filesize($dms->contentDir . $file->getPath() ));
|
|
|
|
header("Content-Disposition: attachment; filename=\"" . $file->getOriginalFileName() . "\"");
|
|
|
|
//header("Expires: 0");
|
|
|
|
header("Content-Type: " . $file->getMimeType());
|
|
|
|
//header("Cache-Control: no-cache, must-revalidate");
|
|
|
|
header("Cache-Control: must-revalidate");
|
|
|
|
//header("Pragma: no-cache");
|
2015-06-08 19:59:56 +00:00
|
|
|
|
2016-02-15 19:45:05 +00:00
|
|
|
readfile($dms->contentDir . $file->getPath());
|
|
|
|
}
|
2015-06-08 19:59:56 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-07-21 09:51:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|