/** * 处理搜索 * * @access private * @param Typecho_Db_Query $select 查询对象 * @param boolean $hasPushed 是否已经压入队列 * @return void */ private function searchHandle(Typecho_Db_Query $select, &$hasPushed) { /** 增加自定义搜索引擎接口 */ //~ fix issue 40 $keywords = $this->request->filter('url', 'search')->keywords; $this->pluginHandle()->trigger($hasPushed)->search($keywords, $this); if (!$hasPushed) { $searchQuery = '%' . str_replace(' ', '%', $keywords) . '%'; /** 搜索无法进入隐私项保护归档 */ $select->where('table.contents.password IS NULL')->where('table.contents.title LIKE ? OR table.contents.text LIKE ?', $searchQuery, $searchQuery)->where('table.contents.type = ?', 'post'); } /** 设置关键词 */ $this->_keywords = $keywords; /** 设置分页 */ $this->_pageRow = array('keywords' => urlencode($keywords)); /** 设置头部feed */ /** RSS 2.0 */ $this->_feedUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedUrl); /** RSS 1.0 */ $this->_feedRssUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedAtomUrl); /** ATOM 1.0 */ $this->_feedAtomUrl = Typecho_Router::url('search', array('keywords' => $keywords), $this->options->feedAtomUrl); /** 设置标题 */ $this->_archiveTitle = $keywords; /** 设置归档类型 */ $this->_archiveType = 'search'; /** 插件接口 */ $this->pluginHandle()->searchHandle($this, $select); }