-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJController.php
More file actions
33 lines (31 loc) · 913 Bytes
/
Copy pathJController.php
File metadata and controls
33 lines (31 loc) · 913 Bytes
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
<?php
class JController extends CController
{
/**
* Render json template
* @param string $view
* @param type $data
* @param type $return
* @return type
*/
public function renderJSON($view, $data = null, $return = false)
{
$this->layout = false;
$view .= '_json';
if (($view = $this->getViewFile($view)) === false) {
echo CJSON::encode($data);
} else {
if ($data !== null) {
JB::setVar($data);
}
return parent::render($view, $data, $return);
}
}
public function render($view, $data = null, $return = false)
{
if (strtolower(Yii::app()->getRequest()->getParam('_format')) === 'json') {
return $this->renderJSON($view, $data, $return);
}
return parent::render($view, $data, $return);
}
}