public function post()
{
if ($this->key != '') {
if (t($_GET['Stime']) && t($_GET['Etime'])) {
$Stime = strtotime(t($_GET['Stime']));
$Etime = strtotime(t($_GET['Etime']));
$this->assign('Stime', t($_GET['Stime']));
$this->assign('Etime', t($_GET['Etime']));
}
$map['title'] = array('like', '%' . $this->key . '%');
$map['is_del'] = 0;
$list = M('weiba_post')->where($map)->findPage(20);
$weiba_ids = getSubByKey($list['data'], 'weiba_id');
$nameArr = $this->_getWeibaName($weiba_ids);
foreach ($list['data'] as $k => $v) {
$list['data'][$k]['weiba'] = $nameArr[$v['weiba_id']];
$list['data'][$k]['user'] = model('User')->getUserInfo($v['post_uid']);
$list['data'][$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']);
// $images = matchImages($v['content']);
// $images[0] && $list['data'][$k]['image'] = array_slice( $images , 0 , 5 );
$image = getEditorImages($v['content']);
!empty($image) && ($list['data'][$k]['image'] = array($image));
//匹配图片的src
preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $v['content'], $match);
foreach ($match[1] as $imgurl) {
$imgurl = $imgurl;
if (!empty($imgurl)) {
$list['data'][$k]['img'][] = $imgurl;
}
}
$is_digg = M('weiba_post_digg')->where('post_id=' . $v['post_id'] . ' and uid=' . $this->mid)->find();
$list['data'][$k]['digg'] = $is_digg ? 'digg' : 'undigg';
$list['data'][$k]['content'] = t($list['data'][$k]['content']);
//去掉微吧已经删除的
$is_del = D('weiba')->where('weiba_id=' . $v['weiba_id'])->getField('is_del');
if ($is_del == 1 || $is_del === null) {
unset($list['data'][$k]);
}
}
//dump($list);exit;
$this->assign('searchResult', $list);
}
$this->display();
}