|
|
@ -105,7 +105,6 @@ class Engine {
|
|
|
|
$this->set('flight.handle_errors', true);
|
|
|
|
$this->set('flight.handle_errors', true);
|
|
|
|
$this->set('flight.log_errors', false);
|
|
|
|
$this->set('flight.log_errors', false);
|
|
|
|
$this->set('flight.views.path', './views');
|
|
|
|
$this->set('flight.views.path', './views');
|
|
|
|
$this->set('flight.jsonp.callback', 'jsonp');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$initialized = true;
|
|
|
|
$initialized = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -454,19 +453,20 @@ class Engine {
|
|
|
|
* Sends a JSONP response.
|
|
|
|
* Sends a JSONP response.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param mixed $data JSON data
|
|
|
|
* @param mixed $data JSON data
|
|
|
|
|
|
|
|
* @param string $param Query parameter that specifies the callback name.
|
|
|
|
* @param int $code HTTP status code
|
|
|
|
* @param int $code HTTP status code
|
|
|
|
* @param bool $encode Whether to perform JSON encoding
|
|
|
|
* @param bool $encode Whether to perform JSON encoding
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function _jsonp($data, $code = 200, $encode = true) {
|
|
|
|
public function _jsonp($data, $param = 'jsonp', $code = 200, $encode = true) {
|
|
|
|
$json = ($encode) ? json_encode($data) : $data;
|
|
|
|
$json = ($encode) ? json_encode($data) : $data;
|
|
|
|
|
|
|
|
|
|
|
|
$callback = $this->request()->query[$this->get('flight.jsonp.callback')];
|
|
|
|
$callback = $this->request()->query[$param];
|
|
|
|
|
|
|
|
|
|
|
|
$this->json(
|
|
|
|
$this->response(false)
|
|
|
|
$callback.'('.$json.');',
|
|
|
|
->status($code)
|
|
|
|
$code,
|
|
|
|
->header('Content-Type', 'application/javascript')
|
|
|
|
!$encode
|
|
|
|
->write($callback.'('.$json.');')
|
|
|
|
);
|
|
|
|
->send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|