1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
<?php
namespace oroboros\core\views;
final class AjaxView extends \oroboros\core\abstracts\views\AbstractAjaxView
implements \oroboros\core\interfaces\api\HTTPStatusCodeApi
{
const DEFAULT_RESPONSE_TYPE = 'text';
private $_request_types = array(
'get' => self::FLAG_TYPE_GET,
'post' => self::FLAG_TYPE_POST,
'put' => self::FLAG_TYPE_PUT,
'delete' => self::FLAG_TYPE_DELETE,
'options' => self::FLAG_TYPE_OPTIONS,
'head' => self::FLAG_TYPE_HEAD,
);
private $_request_type;
private $_request;
private $_response_types = array(
'text',
'json',
'html',
'scripts',
'flash',
'css'
);
private $_response_data = array();
private $_response_headers = array();
private $_response_type = self::DEFAULT_RESPONSE_TYPE;
private $_encoding = array();
private $_schema;
private $_errors;
public function __construct(array $params = array(), array $flags = array()) {
parent::__construct($params, $flags);
ob_start();
}
public function __destruct() {
print ob_get_clean();
parent::__destruct();
}
public function mode($mode = self::DEFAULT_RESPONSE_TYPE) {
if (!in_array($mode, $this->_response_types)) {
throw new \oroboros\core\utilities\exception\Exception("Invalid render mode [" . $mode . "] specified for AJAX View.", self::ERROR_LOGIC_BAD_PARAMETERS);
}
$this->_response_type = $mode;
}
public function render(array $params = array(), array $flags = array()) {
echo '{"view": "static"}';
exit();
}
}