modified : comment system improved for testing for 2.8

This commit is contained in:
Fahad Abbas 2015-09-18 14:52:46 +00:00
parent 4973345ebe
commit ae23cec7bb
13 changed files with 88 additions and 159 deletions

View file

@ -672,24 +672,6 @@ if(!empty($mode))
}
break;
/**
* Getting reply box for comment
*/
case 'get_reply_box';
{
$id = mysql_clean($_POST['cid']);
$new_com = $myquery->get_comment($id);
assign('id',$new_com['type_id']);
assign('type',$new_com['type']);
assign('comment_id',$id);
assign('mode','reply_box');
//getting parent id if it is a reply comment
echo json_encode(array("form"=>Fetch('blocks/comments/comment.html')));
}
break;
case 'count_comments';
echo '5';
@ -1563,7 +1545,7 @@ if(!empty($mode))
{
$params = array();
$limit = config('comments_per_page');
$limit = config('comment_per_page') ? config('comment_per_page') : 10;
$page = $_POST['page'];
$params['type'] = mysql_clean($_POST['type']);
$params['type_id'] = mysql_clean($_POST['type_id']);
@ -1583,7 +1565,7 @@ if(!empty($mode))
assign('object_type',mysql_clean($_POST['object_type']));
//Pagination
$pages->paginate($total_pages,$page,NULL,NULL,'<li><a href="javascript:void(0)"
onClick="getComments(\''.$params['type'].'\',\''.$params['type_id'].'\',\''.$params['last_update'].'\',
onClick="_cb.getAllComments(\''.$params['type'].'\',\''.$params['type_id'].'\',\''.$params['last_update'].'\',
\'#page#\',\''.$_POST['total_comments'].'\',\''.mysql_clean($_POST['object_type']).'\',\''.$admin.'\')">#page#</a></li>');
@ -1598,17 +1580,12 @@ if(!empty($mode))
assign('comments_voting',$_POST['comments_voting']);
assign('commentPagination','yes');
if($_POST['admin']=='yes' && has_access('admin_access',true))
Template(BASEDIR.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/cbv2/layout/blocks/comments.html',false);
else
Template('blocks/comments/comments.html');
assign('commentPagination','yes');
if(SMARTY_VERSION > 2 )
Template('blocks/pagination.html');
// Template('blocks/common/pagination.html');
else
Template('blocks/pagination.html');
}

View file

@ -1578,6 +1578,8 @@ class Collections extends CBCategory
);
insert_log('collection_comment',$log_array);
//Updating Number of comments of collection if comment is not a reply
if ($reply_to < 1)
$this->update_total_comments($obj_id);
}
return $comment;
@ -1590,7 +1592,7 @@ class Collections extends CBCategory
function update_total_comments($cid)
{
global $db;
$count = $db->count(tbl("comments"),"comment_id"," type = 'cl' AND type_id = '$cid'");
$count = $db->count(tbl("comments"),"comment_id"," type = 'cl' AND type_id = '$cid' AND parent_id='0'");
$db->update(tbl($this->section_tbl),array("total_comments","last_commented"),array($count,now())," collection_id = '$cid'");
}

View file

@ -1609,7 +1609,8 @@ class CBGroups extends CBCategory
);
insert_log('topic_comment',$log_array);
//Updating Number of comments of topics
//Updating Number of comments of group if comment is not a reply
if ($reply_to < 1)
$this->update_comments_count($obj_id);
}
return $add_comment;
@ -1671,7 +1672,7 @@ class CBGroups extends CBCategory
function count_topic_comments($id)
{
global $db;
$total_comments = $db->count(tbl('comments'),"comment_id","type='t' AND type_id='$id'");
$total_comments = $db->count(tbl('comments'),"comment_id","type='t' AND type_id='$id' AND parent_id='0'");
return $total_comments;
}

View file

@ -737,6 +737,8 @@ class myquery {
if($type_id!='*')
$typeid_query = "AND type_id='$type_id' ";
if(!$count_only)
{
@ -768,60 +770,33 @@ class myquery {
if(!$results)
return false;
$parent_cond = '';
$parents_array = array();
//getting relies of comments
if($results)
{
$parents_array = array();
foreach($results as $result)
{
if($result['parent_id'] && !in_array($result['parent_id'],$parents_array))
$query = "SELECT * FROM ".tbl('comments');
$query .= " WHERE type='$type' $typeid_query AND parent_id='".$result['comment_id']."' ";
$replies = db_select($query);
if ($replies )
{
if($parent_cond)
$parent_cond .= " OR ";
$parent_cond .= " comment_id='".$result['parent_id']."' " ;
$parents_array[] = $result['parent_id'];
$replies = array("comments"=>$replies);
$result['children'] = $replies;
}
}
// //Getting Parents
// $parents = $db->select(tbl("comments"),'*'
// ," type='$type' AND ($parent_cond) ",NULL,$order);
// if($parents)
// foreach($parents as $parent)
// $new_parents[$parent['comment_id']] = $parent;
//Inserting user data
$new_results = array();
//pr($results,true);
if($results)
foreach($results as $com)
else
{
$userid = $com['userid'];
$uservar = 'user_'.$userid;
if($userid && !$$uservar)
$$uservar = $userquery->get_user_details($userid);
if($$uservar)
$com = array_merge($com,$$uservar);
$params['parent_id'] = $com['comment_id'];
$params['get_reply_only'] = $com['comment_id'];
$children = $this->getComments($params);
$com['children'] = $children;
$new_results[] = $com;
$result['children'] = '';
}
$comment['comments'] = $new_results;
//$comment['parents'] = $new_parents;
$parents_array[] = $result;
}
}
$comment['comments'] = $parents_array;
//Deleting any other previuos comment file

View file

@ -2473,6 +2473,8 @@ class CBPhotos
$comment = $myquery->add_comment($comment,$obj_id,$reply_to,'p',$ownerID,$photoLink,$force_name_email);
if($comment)
{
//Updating Number of comments of photo if comment is not a reply
if ($reply_to < 1)
$this->update_total_comments($obj_id);
}
return $comment;
@ -2485,7 +2487,7 @@ class CBPhotos
function update_total_comments($pid)
{
global $db;
$count = $db->count(tbl("comments"),"comment_id"," type = 'p' AND type_id = '$pid'");
$count = $db->count(tbl("comments"),"comment_id"," type = 'p' AND type_id = '$pid' AND parent_id='0'");
$db->update(tbl('photos'),array("total_comments","last_commented"),array($count,now())," photo_id = '$pid'");
}

View file

@ -2035,7 +2035,7 @@ class userquery extends CBCategory{
function count_profile_comments($id)
{
global $db;
$total_comments = $db->count(tbl('comments'),"comment_id","type='c' AND type_id='$id'");
$total_comments = $db->count(tbl('comments'),"comment_id","type='c' AND type_id='$id' AND parent_id='0'");
return $total_comments;
}
function count_channel_comments($id){ return $this->count_profile_comments($id); }
@ -2094,7 +2094,8 @@ class userquery extends CBCategory{
);
insert_log('profile_comment',$log_array);
//Updating Number of comments of video
//Updating Number of comments of user if comment is not a reply
if ($reply_to < 1)
$this->update_comments_count($obj_id);
}
return $add_comment;

View file

@ -1175,7 +1175,7 @@ class CBvideo extends CBCategory
function count_video_comments($id)
{
global $db;
$total_comments = $db->count(tbl('comments'),"comment_id","type='v' AND type_id='$id'");
$total_comments = $db->count(tbl('comments'),"comment_id","type='v' AND type_id='$id' AND parent_id='0'");
return $total_comments;
}
@ -1218,8 +1218,11 @@ class CBvideo extends CBCategory
);
insert_log('video_comment',$log_array);
//Updating Number of comments of video
//Updating Number of comments of video if comment is not a reply
if ($reply_to < 1)
$this->update_comments_count($obj_id);
}
return $add_comment;
}

View file

@ -647,10 +647,11 @@ var loading_img_2 = "<img style='vertical-align:middle' src='"+imageurl+"/ajax-l
if(data.msg)
{
alert(data.msg);
$(".reply-"+cid).fadeOut("slow");
$("#comment_"+cid).fadeOut("slow");
$("#spam_comment_"+cid).fadeOut("slow");;
$("#comment_msg_output").html(data.msg+" !");
$("#comment_msg_output").fadeIn("slow");
setTimeout(function(){ $("#comment_msg_output").fadeOut(); }, 3000);
}
if(data.err)
alert(data.err);
@ -1742,7 +1743,7 @@ function decode64(input) {
//so we can forward details to ajax.php
var formObjectData = $('#' + form_id).serialize() + '&mode=add_comment';
console.log(formObjectData);
$.post(page,formObjectData,
function(data)
{
@ -1754,9 +1755,9 @@ function decode64(input) {
$("#add_comment_result").css("display","block");
if(data.err!='')
{
$("#comment_output").fadeIn();
$("#comment_output").html(data.err);
setTimeout(function(){ $("#comment_output").fadeOut(); }, 3000);
$("#comment_err_output").fadeIn();
$("#comment_err_output").html(data.err);
setTimeout(function(){ $("#comment_err_output").fadeOut(); }, 3000);
var str = data.err;
var string_finder = str.substring(0, 12);
@ -1805,7 +1806,6 @@ function decode64(input) {
}
else
{
console.log(data);
$(data.li_data).hide().prependTo('#comments-ul').slideDown("slow");
}
}
@ -1814,23 +1814,25 @@ function decode64(input) {
}
function reply_box(cid)
function reply_box(cid,type,type_id)
{
$.ajax({
url : page,
type : 'POST',
dataType : 'json',
data : ({ mode : "get_reply_box", cid : cid}),
success : function(data){
$('.reply-box-' + cid).html(data.form).slideDown("slow");
var html = '<form name="reply_form" method="post" id="reply_form_'+cid+'" onsubmit="return false;">';
html += '<input type="hidden" name="reply_to" id="reply_to" value="'+cid+'">';
html += '<input type="hidden" name="obj_id" id="obj_id" value="'+type_id+'">';
html += '<input type="hidden" name="type" value="'+type+'" />';
html += '<div class="textarea-comment clearfix">';
html += '<textarea name="comment" id="reply_box_'+cid+'" class="form-control" placeholder="Reply..."></textarea>';
html += '<i class="remove-'+cid+' remove-icon" onclick="remove_reply_box('+cid+')">';
html += '<span style="color:#e50000;cursor:pointer">';
html += '<strong>X</strong>';
html += '</span>';
html += '</i>';
html += '</div>';
html += '<input type="button" name="add_reply" id="add_reply_button_'+cid+'" class="btn btn-danger pull-right add-reply" onclick="add_comment_js(\'reply_form_'+cid+'\',\''+type+'\')" value="Reply">';
html += '</form>';
$('.reply-box-' + cid).html(html).slideDown("slow");
$('#reply_box_' + cid).focus();
}
});
}
function remove_reply_box(cid){

View file

@ -2,7 +2,8 @@
{if $userquery->login_check('',true) || $Cbucket->configs.anonym_comments == 'yes' }
<form name="comment_form" method="post" action="" id="comment_form" onsubmit="return false;">
<div class="col-lg-12">
<span id="comment_output" class="alert alert-danger comment_output pull-left" style="display:none;"></span>
<span id="comment_err_output" class="alert alert-danger comment_err_output pull-left" style="display:none;"></span>
<span id="comment_msg_output" class="alert alert-success comment_msg_output pull-left" style="display:none;"></span>
<input type="hidden" name="reply_to" id="reply_to" value="0">
<input type="hidden" name="obj_id" id="obj_id" value="{$id}">
<input type="hidden" name="type" value="{$type}" />

View file

@ -7,7 +7,6 @@
{/if}
{if $rep_mode}
<li id="reply-{$comment.comment_id}" class="commentBox clearfix reply-{$comment.comment_id}">
<div class="replay-holder">
<div class="comments-box clearfix">
@ -43,24 +42,6 @@
</li>
{elseif $mode == 'reply_box'}
<form name="reply_form" method="post" action="" id="reply_form_{$comment_id}" onsubmit="return false;">
<input type="hidden" name="reply_to" id="reply_to" value="{$comment_id}">
<input type="hidden" name="obj_id" id="obj_id" value="{$id}">
<input type="hidden" name="type" value="{$type}" />
{ANCHOR place='before_compose_box'}
<div class="textarea-comment clearfix">
<textarea name="comment" id="reply_box_{$comment_id}" class="form-control" placeholder="Reply..."></textarea>
<i class="remove-{$comment_id} remove-icon" onclick="remove_reply_box({$comment_id})"><span style="color:#e50000;cursor:pointer"><strong>X</strong></span></i>
</div>
<input type="button" name="add_reply" id="add_reply_button_{$comment_id}" class="btn btn-danger pull-right add-reply" onclick="add_comment_js('reply_form_{$comment_id}','{$type}')" value='{lang code="Reply"}'>
</form>
{else}
<li id="comment_{$comment.comment_id}" class="clearfix" {$comment_attr}>
@ -88,10 +69,10 @@
</div> -->
<div class="reply">
<div class="sizeSmaller bold" style="font-size:12px;">
{$video = $cbvid->get_video($type_id)}
{if $myquery->is_commentable($video,'v') && $userquery->login_check('',true)}
<a href="javascript:void(0)" onclick="reply_box('{$comment.comment_id}')">{lang code='reply'}</a>
{if $userquery->login_check('',true)}
<a href="javascript:void(0)" onclick="reply_box('{$comment.comment_id}','{$comment.type}','{$comment.type_id}')">{lang code='reply'}</a>
{/if}
{if !$comment.userid==userid() || has_access('admin_access',true)}
&middot; <a href="javascript:void(0)" onclick="spam_comment('{$comment.comment_id}','{$type}','{$type_id}')">{lang code='spam'}</a>
@ -126,7 +107,7 @@
<div class="view-date clearfix">
<span>
<i class="glyphicon glyphicon-time"></i>
{$comment.date_added|niceTime}
{$reply.date_added|niceTime}
</span>
</div>
</div>
@ -162,7 +143,7 @@
<div class="view-date clearfix">
<span>
<i class="glyphicon glyphicon-time"></i>
{$comment.date_added|niceTime}
{$reply.date_added|niceTime}
</span>
</div>
</div>

View file

@ -17,21 +17,18 @@
{elseif $commentPagination}
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 mtl">
<ul align="center" class="pagination pagination-center">
<!-- <li class="prev disabled">
<a href="#">
<i class="icon-double-angle-left"></i></a></li> -->
{if $first_link !=''}
<li> <a href="javascript:void(0)"
onclick="getComments('{$type}','{$type_id}','{$last_update}','1','{$total}','{$object_type}')" >
onclick="_cb.getAllComments('{$type}','{$type_id}','{$last_update}','1','{$total}','{$object_type}')" >
<i class="fa fa-angle-double-left"></i></a></li>
{/if}
{if $pre_link !=''}<li><a href="javascript:void(0)"
onclick="getComments('{$type}','{$type_id}','{$last_update}','{$pre_page}','{$total}','{$object_type}')" >
onclick="_cb.getAllComments('{$type}','{$type_id}','{$last_update}','{$pre_page}','{$total}','{$object_type}')" >
<i class="fa fa-angle-left"></i></a>
</li>{/if}
@ -39,13 +36,13 @@
{if $next_link !=''}<li><a href="javascript:void(0)"
onclick="getComments('{$type}','{$type_id}','{$last_update}','{$next_page}','{$total}','{$object_type}')" >
onclick="_cb.getAllComments('{$type}','{$type_id}','{$last_update}','{$next_page}','{$total}','{$object_type}')" >
<i class="fa fa-angle-right"></i></a>
</li>{/if}
{if $last_link !=''}
<li> <a href="javascript:void(0)"
onclick=" getComments('{$type}','{$type_id}','{$last_update}','{$total_pages}','{$total}','{$object_type}')" >
onclick="_cb.getAllComments('{$type}','{$type_id}','{$last_update}','{$total_pages}','{$total}','{$object_type}')" >
<i class="fa fa-angle-double-right"></i></a></li>
{/if}
</ul>

View file

@ -69,7 +69,7 @@
<link href="{$theme}/css/jquery.mCustomScrollbar.css" rel="stylesheet" />
<link rel="stylesheet" href="{$theme}/css/font-awesome.min.css">
{if this_page('watch_video') || this_page('view_item') || this_page('view_channel')}
{if this_page('watch_video') || this_page('view_item') || this_page('view_channel') || this_page('view_topic')}
<link rel="stylesheet" href="{$theme}/css/watch-video.css">
<link rel="stylesheet" href="{$theme}/css/comments.css" />
{/if}

View file

@ -62,32 +62,19 @@
<div id="reply" class="clearfix">
<div class="pad-bottom">
<div class="addComment clearfix">
<!-- <h3 >{lang('Comments')}:&nbsp;
<span class="com_count" id="com_count"></span>
</h3> -->
<div class="com_count" id="com_count"><span>{lang('Comments')}: </span> {$topic.total_replies}</div>
<div class="com_count" id="com_count">
<span>{lang('Comments')}: </span>
{$topic.total_replies}
</div>
{include file="$style_dir/blocks/comments/add_comment.html" id=$topic.topic_id type=t}
</div>
<script>
/*$(document).ready(function()
{ldelim}
comments_voting = 'no';
getComments('t','{$topic.topic_id}','{$topic.last_post_time}',1,'{$topic.total_replies }','{$object_type}')
{rdelim}
);*/
$(document).ready(function(){
_cb.getAllComments(
't','{$topic.topic_id}','{$topic.last_post_time}',1,'{$topic.total_replies}','{$object_type}'
);
});
</script>
<!-- <div class="topic_comments">
<a href="#" style="font:bold 11px Tahoma; text-decoration:none; text-align:right; display:block;" onclick="getComments('t','{$topic.topic_id}','{$topic.last_post_time}',1,'{$topic.total_replies }','{$object_type}'); return false;">Re-load Posts</a>
</div> -->
<div id="comments">
<ul class="list-unstyled" id="userCommentsList"></ul>
</div>