Do comment add in a single request, some code cleanup.

This commit is contained in:
Jozef Selesi
2008-11-15 17:39:14 +00:00
parent 5e10b44a95
commit fbc810098f
2 changed files with 18 additions and 15 deletions

View File

@@ -77,14 +77,21 @@ class Comment_Controller extends REST_Controller {
$comment->datetime = time();
$comment->item_id = $this->input->post('item_id');
$comment->save();
$data = array('valid' => true, 'html' => sprintf(comment::show_comment_list($item_id)));
} else {
print $form->render("form.html");
$data = array('valid' => false, 'html' => sprintf($form->render("form.html")));
}
if (request::method() == "get") {
print $data['html'];
} else if (request::method() == "post") {
print json_encode($data);
}
}
public function get_item_comments($item_id) {
$v = comment::show_comment_list($item_id);
print $v;
print comment::show_comment_list($item_id);
}
/**