public function action_search() { $text = trim($this->get_query('term', '')); $json = array(); if ($text) { $order_by = array('problem_id' => Model_Base::ORDER_DESC); $result = Model_Problem::search($text, 'title', $order_by, $show_all = true); foreach ($result as $item) { $tmp = array('id' => $item->problem_id, 'title' => $item['title']); array_push($json, $tmp); } } $this->response->body(json_encode($json)); }
public function action_search() { // init $text = $this->get_query('text'); $area = $this->get_query('area'); if ($text === NULL) { // TODO: add better handler $this->action_list(); } // TODO: validation $list = Model_Problem::search($text, $area); $this->template_data['area'] = $area; $this->template_data['search_text'] = $text; $this->template_data['problemlist'] = $list; $this->template_data['title'] = __(':text_search_result', array(':text' => $text)); }