public function articleview() { $id = I('id'); $this->db->where(array('id' => $id))->setInc('countclick'); $article = $this->db->where(array('id' => $id))->find(); $thumb = $this->img_upload->where(array('itemid' => $id))->find(); $content = $this->content->where(array('id' => $id))->find(); $count = $this->comment->where(array('wid' => $id))->count(); $where['id'] = array(array('gt', $id)); $map['id'] = array(array('lt', $id)); $next = $this->db->where($where)->find(); $prex = $this->db->where($map)->order('id desc')->find(); $commentlimit = 5; $comment = $this->comment->where(array('wid' => $id))->limit($commentlimit)->select(); foreach ($comment as $key => $value) { $comment[$key]['newtime'] = date('d M ,Y', $value['addtime']); $comment[$key]['newcontent'] = replace_weibo($value['content']); } $this->assign('article', $article); $this->assign('prex', $prex); $this->assign('next', $next); $this->assign('thumb', $thumb); $this->assign('content', $content); $this->assign('comment', $comment); $this->assign('count', $count); $this->display(); }
public function ajaxpage() { $comment = M('comment'); $limit = 5; $pageclickednumber = I('post.p'); $mid = I('post.mid'); p($mid); exit; $indexnum = $comment->where(array('wid' => $mid))->limit(($pageclickednumber - 1) * $limit, $limit)->select(); foreach ($indexnum as $key => $value) { $indexnum[$key]['newtime'] = date('Y-m-d', $value['time']); $indexnum[$key]['newcontent'] = replace_weibo($value['content']); } echo json_encode($indexnum); }
public function jqgrid() { $client_arr = M('message')->select(); foreach ($client_arr as $k => $v) { $client_arr[$k]['newtime'] = date('Y-m-d', $v['addtime']); $client_arr[$k]['content'] = replace_weibo($v['content']); if ($v['status'] == '1') { $client_arr[$k]['status'] = 'Yes'; } else { $client_arr[$k]['status'] = 'No'; } } $this->assign('state', 'jqgrid'); $this->assign('client_arr', json_encode($client_arr)); $this->display('jqgrid'); }
public function replyComment() { if (!IS_POST) { E('页面不存在'); } $wid = intval($_POST['wid']); $content = htmlspecialchars($_POST['content']); $me = session('uid'); $db = M('comment'); $data = array('time' => time(), 'content' => $content, 'wid' => $wid, 'uid' => $me); $count = $db->where(array('uid' => $me))->count(); if ($cid = $db->data($data)->add()) { //评论成功 M('weibo')->where(array('id' => $wid))->setInc('comment'); //weibo评论+1 $myComment = D('CommentView')->where(array('cid' => $cid))->find(); //格式化内容和时间 $myComment['time'] = time_format($myComment['time']); $myComment['content'] = replace_weibo($myComment['content']); $json = array('status' => 1, 'count' => $count + 1, 'myReply' => $myComment); echo json_encode($json); } else { echo 0; } }
<div class="wb_turn"> <dl> <!--原作者--> <dt class='turn_name'> <a href="<?php echo U('/' . $v['isturn']['uid']); ?> ">@<?php echo $v["isturn"]["username"]; ?> </a> </dt> <!--原微博内容--> <dd class='turn_cons'> <p><?php echo replace_weibo($v["isturn"]["content"]); ?> </p> </dd> <!--原微博图片--> <?php if ($v["isturn"]["max"]) { ?> <dd> <div class="turn_img"> <!--小图--> <img src="/turingca/Uploads/Pic/<?php echo $v["isturn"]["mini"]; ?> " class='turn_mini_img'/> <div class="turn_img_tool hidden">
public function getComment() { if (!IS_POST) { E('页面不存在'); } $wid = intval($_POST['wid']); $comments = D('CommentView')->where(array('wid' => $wid))->order('time DESC')->select(); $json = array('status' => 0, 'commentList' => ''); if (!empty($comments)) { $json['status'] = 1; foreach ($comments as $k => $v) { $v['content'] = replace_weibo($v['content']); $v['time'] = time_format($v['time']); $comments[$k] = $v; } $json['commentList'] = $comments; } echo json_encode($json); }
public function getComment() { if (!IS_AJAX) { $this->error('页面不存在'); } $wid = I('wid', '', 'intval'); $where = array('wid' => $wid); //数据的总条数 $count = M('comment')->where($where)->count(); // 查询满足要求的 总记录数 //数据可分的总页数 $total = ceil($count / 10); //总页数 $page = $_POST['page'] ? I('page', '', 'intval') : 1; //现在第几页,默认第一页。 $limit = $page < 2 ? '0,10' : 10 * ($page - 1) . ',10'; $result = D('Comment')->where($where)->order('time DESC')->limit($limit)->select(); if ($result) { $str = ''; foreach ($result as $v) { $str .= '<dl class="comment_content">'; $str .= '<dt><a href="' . U('/' . $v['uid']) . '">'; $str .= '<img src="'; $str .= __ROOT__; if ($v['face']) { $str .= '/Uploads/Face/' . $v['face']; } else { $str .= '/Public/Images/noface.gif'; } $str .= '"alt="' . $v['username'] . '" width="30" height="30"/>'; $str .= '</a></dt><dd>'; $str .= '<a href="' . $v['uid'] . '" class="comment_name">'; $str .= $v['username'] . " : " . replace_weibo($v['content']); $str .= " (" . time_format($v['time']) . ")"; $str .= '<div class="reply">'; $str .= '<a href="">回复</a>'; $str .= '</div></dd></dl>'; } if ($total > 1) { $str .= '<dl class="comment-page">'; switch ($page) { case $page > 1 && $page < $total: //不是第一页和尾页 $str .= '<dd page=" ' . ($page - 1) . ' " wid=" ' . $wid . ' ">上一页</dd>'; $str .= '<dd page=" ' . ($page + 1) . ' " wid=" ' . $wid . ' ">下一页</dd>'; break; case $page < $total: //第一页 $str .= '<dd page="' . ($page + 1) . '" wid="' . $wid . '">下一页</dd>'; break; case $page == $total: //最后一页 $str .= '<dd page=" ' . ($page - 1) . ' " wid="' . $wid . '">上一页</dd>'; break; } $str .= '</dl>'; } echo $str; } else { echo 'false'; } }