public function render($__data__ = null, $__view__ = null) { //get friend message if (isset($__data__['code']) && $__data__['code'] > 0) { $__data__['msg'] = Core::get_lang_text($__data__['code']); } //json $response = json_encode($__data__, JSON_UNESCAPED_UNICODE); if (!empty($_GET['callback'])) { //jsonp if (!preg_match('/^[a-z0-9\\._]+$/i', $_GET['callback'])) { throw new Exception("callback error,callback:{$_GET['callback']}", Errno::PARAM_INVALID); } $response = $_GET['callback'] . "({$response})"; //for iframe submit mode if (substr($_GET['callback'], 0, 7) == 'parent.') { header('Content-Type: text/html; charset=utf-8'); $response = "<script type='text/javascript'>{$response}</script>"; } } echo $response; }
/** * read current id index from database * * @return void */ protected function read_data() { $db = Core::get_database($this->driver, $this->database); $condition = '`id`=' . intval($this->id); $items = $db->get($this->table, $condition); if (empty($items)) { $data = array(); for ($i = 0; $i < $this->columns; $i++) { $data[] = array(); } } else { $data = $this->unpack($items[0]['data']); } $this->index_data = $data; }
public function __construct() { $this->db_handle = Core::get_database($this->driver, $this->database); }