40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
namespace Dict;
|
|
use Nette;
|
|
/**
|
|
* CSV download response.
|
|
* Under New BSD license.
|
|
*
|
|
* @package Nette\Application\Responses
|
|
*/
|
|
class OggResponse extends Nette\Object implements Nette\Application\IResponse
|
|
{
|
|
private $directory;
|
|
private $contentType;
|
|
private $addHeading;
|
|
private $filename;
|
|
private $id;
|
|
|
|
public function __construct($id = null,$filename = null, $basepath = __DIR__ . "/../../www", $addHeading = TRUE,$contentType = 'audio/ogg')
|
|
{
|
|
$this->contentType = $contentType;
|
|
$this->addHeading = $addHeading;
|
|
$this->directory = $basepath . "/media/";
|
|
$this->filename = $this->directory . "/".$filename;
|
|
$this->id = $id;
|
|
}
|
|
|
|
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
|
|
{
|
|
$httpResponse->setContentType($this->contentType);
|
|
$attachment = 'attachment';
|
|
if (!empty($this->id)) {
|
|
$attachment .= '; filename="' . $this->id .".ogg" . '"';
|
|
}
|
|
$httpResponse->setHeader('Content-Disposition', $attachment);
|
|
$httpResponse->setHeader('Content-Length', filesize($this->filename));
|
|
readfile($this->filename);
|
|
}
|
|
|
|
}
|