SearchAction::blog PHP Method

blog() public method

public blog ( )
    public function blog()
    {
        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 . '%');
            $list = M('blog')->where($map)->findPage(20);
            foreach ($list['data'] as $k => $v) {
                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('blog_digg')->where('post_id=' . $v['id'] . ' and uid=' . $this->mid)->find();
                $list['data'][$k]['digg'] = $is_digg ? 'digg' : 'undigg';
                if (count($list[$k]['img']) == '0') {
                    $list['data'][$k]['img'][] = '';
                    // 默认图
                }
                $list['data'][$k]['content'] = t($list['data'][$k]['content']);
            }
            //dump($list);exit;
            $this->assign('searchResult', $list);
        }
        $this->display();
    }