From fbc810098f797d6cacecadb39fab2016ab9a8429 Mon Sep 17 00:00:00 2001 From: Jozef Selesi Date: Sat, 15 Nov 2008 17:39:14 +0000 Subject: Do comment add in a single request, some code cleanup. --- modules/comment/controllers/comment.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'modules/comment/controllers') diff --git a/modules/comment/controllers/comment.php b/modules/comment/controllers/comment.php index fab18498..67a4897b 100644 --- a/modules/comment/controllers/comment.php +++ b/modules/comment/controllers/comment.php @@ -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); } /** -- cgit v1.2.3