diff --git a/comment.php b/comment.php index ed32f6f43..73efa55bf 100644 --- a/comment.php +++ b/comment.php @@ -24,6 +24,11 @@ require_once('class2.php'); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); + if (vartrue(e107::getPref('comments_disabled'))) + { + exit; + } + if(e_AJAX_REQUEST) // TODO improve security { @@ -33,8 +38,24 @@ if(e_AJAX_REQUEST) // TODO improve security exit; } + + + $ret = array(); + + + if(varset($_GET['mode']) == 'reply' && vartrue($_POST['itemid'])) + { + $status = e107::getComment()->replyComment($_POST['itemid']); + $ret['msg'] = "Couldn't delete comment"; + $ret['error'] = ($status) ? false : true; + $ret['html'] = $status; + echo json_encode($ret); + exit; + } + + if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid'])) { $status = e107::getComment()->deleteComment($_POST['itemid']); @@ -53,6 +74,7 @@ if(e_AJAX_REQUEST) // TODO improve security echo json_encode($ret); exit; } + if(!vartrue($_POST['comment']) && varset($_GET['mode']) == 'submit') { @@ -68,13 +90,15 @@ if(e_AJAX_REQUEST) // TODO improve security $error = e107::getComment()->updateComment($_POST['itemid'],$_POST['comment']); $ret['error'] = ($error) ? true : false; - $ret['msg'] = ($error) ? $error : "Saved!!!"; //TODO Common LAN + $ret['msg'] = ($error) ? $error : "Updated Successfully."; //TODO Common LAN echo json_encode($ret); exit; } + + // Insert Comment and return rendered html. if(vartrue($_POST['comment']) && USERID) // ajax render comment { @@ -100,8 +124,10 @@ if(e_AJAX_REQUEST) // TODO improve security $row['comment_datestamp'] = time(); $row['comment_blocked'] = (vartrue($pref['comments_moderate']) ? 2 : 0); + $width = ($pid) ? 5 : 0; + $ret['html'] = "\n\n"; - $ret['html'] .= e107::getComment()->render_comment($row,'comment',intval($_POST['itemid'])); + $ret['html'] .= e107::getComment()->render_comment($row,'comments','comment',intval($_POST['itemid']),$width); $ret['html'] .= "\n\n"; $ret['error'] = false; diff --git a/e107_admin/theme.php b/e107_admin/theme.php index c00b364c2..a955ff19a 100644 --- a/e107_admin/theme.php +++ b/e107_admin/theme.php @@ -32,7 +32,7 @@ e107::css("inline"," .admin-theme-options { transition: opacity .20s ease-in-out; -moz-transition: opacity .20s ease-in-out; -webkit-transition: opacity .20s ease-in-out; - opacity:0.1; + opacity:0; width:100%; height:80px; padding-top:50px; diff --git a/e107_core/shortcodes/batch/comment_shortcodes.php b/e107_core/shortcodes/batch/comment_shortcodes.php index 0d46b881e..daf4d62e2 100644 --- a/e107_core/shortcodes/batch/comment_shortcodes.php +++ b/e107_core/shortcodes/batch/comment_shortcodes.php @@ -91,7 +91,7 @@ class comment_shortcodes extends e_shortcode { if ($thisaction == "comment" && $pref['nested_comments']) { - $REPLY = "".COMLAN_326.""; + $REPLY = "".COMLAN_326.""; } } return $REPLY; @@ -209,9 +209,10 @@ class comment_shortcodes extends e_shortcode if($this->mode == 'edit') { - $value = (varset($this->var['eaction']) == "edit" ? COMLAN_320 : COMLAN_9); + $value = (varset($this->var['eaction']) == "edit" ? COMLAN_320 : COMLAN_9); + $pid = ($this->var['action'] == 'reply') ? $this->var['pid'] : 0; - return ""; + return ""; } } diff --git a/e107_files/jslib/core/front.jquery.js b/e107_files/jslib/core/front.jquery.js index 31f5efb62..1739c8b2b 100644 --- a/e107_files/jslib/core/front.jquery.js +++ b/e107_files/jslib/core/front.jquery.js @@ -2,30 +2,37 @@ $(document).ready(function() { - $(":input").tipsy({gravity: 'w',fade: true}); + $(":input").tipsy({gravity: 'w',fade: true, live: true}); - $(".e-tip").tipsy({gravity: 'sw',fade: true}); + $(".e-tip").tipsy({gravity: 'sw',fade: true, live: true}); - $(".e-comment-submit").click(function(){ + $(".e-comment-submit").live("click", function(){ - var url = $(this).attr("data-target"); - var sort = $(this).attr("data-sort"); - var data = $("form#e-comment-form").serialize(); - var total = parseInt($("#e-comment-total").text()); + var url = $(this).attr("data-target"); + var sort = $(this).attr("data-sort"); + var pid = parseInt($(this).attr("data-pid")); + var formid = (pid != '0') ? "#e-comment-form-reply" : "#e-comment-form"; + var data = $('form'+formid).serialize() ; + var total = parseInt($("#e-comment-total").text()); $.ajax({ type: 'POST', url: url + '?ajax_used=1&mode=submit', data: data, - success: function(html) { + success: function(data) { - console.log(html); - var a = $.parseJSON(html); + // console.log(data); + var a = $.parseJSON(data); $("#comment").val(''); - if(sort == 'desc') + + if(pid != 0) + { + $('#comment-'+pid).after(a.html).hide().slideDown(800); + } + else if(sort == 'desc') { $(a.html).prependTo('#comments-container').hide().slideDown(800); } @@ -37,7 +44,12 @@ $(document).ready(function() if(!a.error) { - $("#e-comment-total").text(total + 1); + $("#e-comment-total").text(total + 1); + if(pid != '0') + { + $(formid).hide(); + } + } else { @@ -53,6 +65,47 @@ $(document).ready(function() + + + + $(".e-comment-reply").live("click", function(){ + + var url = $(this).attr("data-target"); + var table = $(this).attr("data-type"); + var sp = $(this).attr('id').split("-"); + var id = "#comment-" + sp[3]; + + if($('.e-comment-edit-save').length != 0) //prevent creating save button twice. + { + return false; + } + + $.ajax({ + type: 'POST', + url: url + '?ajax_used=1&mode=reply', + data: { itemid: sp[3], table: table }, + success: function(data) { + var a = $.parseJSON(data); + + if(!a.error) + { + // alert(a.html); + $(id).after(a.html).hide().slideDown(800); + } + + } + }); + + return false; + }); + + + + + + + + $(".e-comment-edit").live("click", function(){ var url = $(this).attr("data-target"); @@ -195,14 +248,18 @@ $(document).ready(function() - $(".e-rate-thumb").click(function(){ + + + + $(".e-rate-thumb").live("click", function(){ - var src = $(this).attr("href"); - - var tmp = src.split('#'); - id = tmp[1]; - src = tmp[0]; + var src = $(this).attr("href"); + var thumb = $(this); + var tmp = src.split('#'); + var id = tmp[1]; + var src = tmp[0]; + $.ajax({ type: "POST", url: src, @@ -221,7 +278,7 @@ $(document).ready(function() $('#'+id +'-up').text(up); $('#'+id +'-down').text(down); - $(this).attr('title','Thanks for voting'); + thumb.attr('title','Thanks for voting'); // alert('Thanks for liking'); } }); diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 7abc1b5b7..7359c305a 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -113,6 +113,27 @@ class comment } + + + + function replyComment($id) // Ajax Reply. + { + $sql = e107::getDb(); + if($sql->db_Select("comments","*","comment_id= ".intval($id)." LIMIT 1")) + { + $row = $sql->db_Fetch(); + // [comment_id] => 65 + + return $this->form_comment('reply', $row['comment_type'], $row['comment_item_id'], $row['comment_subject'], false, true,false,false,$id); + + } + } + + + + + + /** * Display the comment editing form * @@ -125,7 +146,7 @@ class comment * @param unknown_type $rating * @return unknown */ - function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE) + function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE,$pid = false) { //rating : boolean, to show rating system in comment @@ -222,8 +243,11 @@ class comment // ------------------------------------------------------------- - $text = "\n