34 lines
848 B
PHP
Raw Normal View History

2013-07-19 18:52:33 +03:00
<?php
namespace OCA\Office\Download;
2013-08-07 21:14:36 +03:00
use OCA\Office\View;
2013-07-19 18:52:33 +03:00
class Simple extends \OCA\Office\Download {
2013-08-07 21:41:11 +03:00
public function __construct($view, $filepath){
$this->view = $view;
2013-07-19 18:52:33 +03:00
$this->filepath = $filepath;
}
public function sendResponse(){
2013-08-07 21:14:36 +03:00
$this->view = View::initOfficeView(\OCP\User::getUser());
2013-07-19 18:52:33 +03:00
header( 'Content-Type:' . $this->getMimeType() );
$encodedName = rawurlencode($this->getFilename());
if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])){
header(
'Content-Disposition: attachment; filepath="' . $encodedName . '"'
);
} else {
header('Content-Disposition: attachment; filepath*=UTF-8\'\'' . $encodedName
. '; filepath="' . $encodedName . '"');
}
2013-08-07 21:14:36 +03:00
header('Content-Length: ' . $this->view->filesize($this->filepath));
2013-07-19 18:52:33 +03:00
\OC_Util::obEnd();
2013-08-07 21:14:36 +03:00
$this->view->readfile($this->filepath);
2013-07-19 18:52:33 +03:00
}
}