Beispiel #1
0
 /**
  * 获取指定微博的评论列表 --using
  *
  * @param
  *        	integer feed_id 微博ID
  * @param
  *        	integer max_id 上次返回的最后一条评论ID
  * @param
  *        	integer count 评论条数
  * @return array 评论列表
  */
 public function weibo_comments($feed_id, $count)
 {
     if (!$feed_id) {
         $feed_id = $this->data['feed_id'];
     }
     $comment_list = array();
     $where = 'is_del=0 and row_id=' . $feed_id;
     if (!$count) {
         $count = $this->count;
         !empty($this->max_id) && ($where .= " AND comment_id < {$this->max_id}");
     }
     $comments = model('Comment')->where($where)->order('comment_id DESC')->limit($count)->findAll();
     foreach ($comments as $v) {
         switch ($v['type']) {
             case '2':
                 $type = '转发了此微博';
                 break;
             case '3':
                 $type = '分享了此微博';
                 break;
             case '4':
                 $type = '赞了此微博';
                 break;
             default:
                 $type = '评论了此微博';
                 break;
         }
         $comment_info['type'] = $type;
         $comment_info['user_info'] = $this->get_user_info($v['uid']);
         $comment_info['comment_id'] = $v['comment_id'];
         $comment_info['content'] = parse_remark($v['content']);
         $comment_info['ctime'] = $v['ctime'];
         $comment_info['digg_count'] = $v['digg_count'];
         $diggarr = model('CommentDigg')->checkIsDigg($v['comment_id'], $GLOBALS['ts']['mid']);
         $comment_info['is_digg'] = t($diggarr[$v['comment_id']] ? 1 : 0);
         /* # 将评论里面的emoji解析 */
         $comment_info['content'] = formatEmoji(false, $comment_info['content']);
         $comment_list[] = $comment_info;
     }
     return $comment_list;
 }
Beispiel #2
0
 /**
  * 获取指定分享的评论列表 --using
  *
  * @param
  *        	integer feed_id 分享ID // 修改为 帖子post_id
  * @param
  *        	integer max_id 上次返回的最后一条评论ID
  * @param
  *        	integer count 评论条数
  * @return array 评论列表
  */
 public function weiba_comments($feed_id, $count)
 {
     if (!$feed_id) {
         // $feed_id = $this->data ['feed_id'];
         $feed_id = M('weiba_post')->where(array('feed_id' => $this->data['feed_id']))->getField('post_id');
     }
     $comment_list = array();
     // $where = 'is_del=0 and row_id=' . $feed_id;
     $where = 'is_del=0 and post_id=' . $feed_id;
     if (!$count) {
         $count = $this->count;
         // ! empty($this->max_id) && $where .= " AND comment_id < {$this->max_id}";
         !empty($this->max_id) && ($where .= " AND reply_id < {$this->max_id}");
     }
     $floor = '';
     if ($this->max_id) {
         // $floor = M('comment')->where('is_del=0 and row_id=' . $feed_id . ' and comment_id <' . $this->max_id)->count();
         $floor = M('weiba_reply')->where(array('is_del' => 0, 'post_id' => $feed_id, 'reply_id' => array('gt', $this->max_id)))->count();
     } else {
         // $floor = M('comment')->where('is_del=0 and row_id=' . $feed_id)->count();
         $floor = M('weiba_reply')->where(array('is_del' => 0, 'post_id' => $feed_id))->count();
     }
     // $comments = model('Comment')->where($where)->order('comment_id DESC')->limit($count)->findAll();
     $comments = M('weiba_reply')->where($where)->order('reply_id DESC')->limit($count)->findAll();
     foreach ($comments as $v) {
         // switch ($v ['type']) {
         //     case '2' :
         //         $type = '转发了此贴';
         //         break;
         //     case '3' :
         //         $type = '分享了此贴';
         //         break;
         //     case '4' :
         //         $type = '赞了此贴';
         //         break;
         //     default :
         //         $type = '评论了此贴';
         //         break;
         // }
         // $comment_info ['type'] = $type;
         $comment_info['type'] = '评论了此贴';
         $comment_info['floor'] = $floor;
         $floor--;
         $comment_info['user_info'] = $this->get_user_info($v['uid']);
         // $comment_info ['comment_id'] = $v ['comment_id'];
         $comment_info['comment_id'] = $v['reply_id'];
         $comment_info['content'] = parse_remark($v['content']);
         /* # 解析出emoji' */
         $comment_info['content'] = formatEmoji(false, $comment_info['content']);
         $comment_info['ctime'] = $v['ctime'];
         $comment_info['digg_count'] = $v['digg_count'];
         // $diggarr = model('CommentDigg')->checkIsDigg($v ['comment_id'], $GLOBALS ['ts'] ['mid']);
         $diggarr = D('WeibaReplyDigg', 'weiba')->checkIsDigg($v['reply_id'], $GLOBALS['ts']['mid']);
         $comment_info['is_digg'] = t($diggarr[$v['reply_id']] ? 1 : 0);
         $comment_list[] = $comment_info;
     }
     return $comment_list;
 }