2015-03-03 14:52:27 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 18:07:57 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2015-06-25 12:43:55 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 18:07:57 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-03-03 14:52:27 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-03 14:52:27 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCP\AppFramework\Http;
|
|
|
|
|
|
|
|
use OCP\AppFramework\Http;
|
|
|
|
|
2015-04-16 18:00:08 +03:00
|
|
|
/**
|
|
|
|
* Class DataDisplayResponse
|
|
|
|
*
|
|
|
|
* @since 8.1.0
|
|
|
|
*/
|
2015-03-03 14:52:27 +03:00
|
|
|
class DataDisplayResponse extends Response {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* response data
|
2017-10-18 15:15:03 +03:00
|
|
|
* @var string
|
2015-03-03 14:52:27 +03:00
|
|
|
*/
|
|
|
|
protected $data;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $data the data to display
|
|
|
|
* @param int $statusCode the Http status code, defaults to 200
|
|
|
|
* @param array $headers additional key value based headers
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-03 14:52:27 +03:00
|
|
|
*/
|
2020-10-05 16:12:57 +03:00
|
|
|
public function __construct($data = '', $statusCode = Http::STATUS_OK,
|
|
|
|
$headers = []) {
|
2019-04-03 19:42:34 +03:00
|
|
|
parent::__construct();
|
|
|
|
|
2015-03-03 14:52:27 +03:00
|
|
|
$this->data = $data;
|
|
|
|
$this->setStatus($statusCode);
|
|
|
|
$this->setHeaders(array_merge($this->getHeaders(), $headers));
|
|
|
|
$this->addHeader('Content-Disposition', 'inline; filename=""');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Outputs data. No processing is done.
|
|
|
|
* @return string
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-03 14:52:27 +03:00
|
|
|
*/
|
|
|
|
public function render() {
|
|
|
|
return $this->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets values in the data
|
|
|
|
* @param string $data the data to display
|
|
|
|
* @return DataDisplayResponse Reference to this object
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-03 14:52:27 +03:00
|
|
|
*/
|
2020-04-09 14:53:40 +03:00
|
|
|
public function setData($data) {
|
2015-03-03 14:52:27 +03:00
|
|
|
$this->data = $data;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to get the set parameters
|
|
|
|
* @return string the data
|
2015-04-16 18:00:08 +03:00
|
|
|
* @since 8.1.0
|
2015-03-03 14:52:27 +03:00
|
|
|
*/
|
2020-04-09 14:53:40 +03:00
|
|
|
public function getData() {
|
2015-03-03 14:52:27 +03:00
|
|
|
return $this->data;
|
|
|
|
}
|
|
|
|
}
|