&$row) { switch ($row['type']) { case 'HTML Block': $page = Qs_SiteMap::findFirst(array(), array('type' => 'HtmlBlock_', 'number' => $row['idBlock'])); if(!$page) { unset($list[$k]); } $row['url'] = $page['url']; $row['title'] = $page['title']; break; /* case 'Page Title': $page = Qs_SiteMap::findFirst(array('id' => $row['idBlock'])); $row['url'] = $page['url']; break; */ case 'History': $page = Qs_SiteMap::findFirst(array(), array('type' => 'History_', 'idGroup' => 1)); $row['searchContent'] = $row['title'] . ' | ' . $row['searchContent']; $row['title'] = $page['title']; $row['url'] = $page['url']; break; default: break; } Qs_Text_Mark::setWordSplitters(array()); $row['searchContent'] = Qs_Text_Mark::markSearchWords($row['searchContent'], trim($_REQUEST['query'])); $row['title'] = Qs_Text_Mark::markSearchWords($row['title'], trim($_REQUEST['query'])); } return true; } protected function _getExIdBlock() { $select = $this->db->select(); $select->from($this->_getPair('HtmlBlockContent', true), 'idBlock') ->join($this->_getPair('PageItem', true), '`HtmlBlockContent`.`idBlock` = `PageItem`.`number`', '' ) ->join($this->_getPair('Page', true), '`PageItem`.`idPage` = `Page`.`id`', '' ) ->where('`Page`.`alias` = ' . $this->db->quote(Qs_SiteMap::getAliasByItem('Search_Content_'))) ->limit(1); $idBlock = $this->db->fetchOne($select); return is_numeric($idBlock) ? $idBlock : false; } public function getListSelect($options = array()) { $query = $this->_filter['query']; $htmlBlockSelect = $this->_db->select() ->from($this->_getPair(), array('idBlock', 'title' => new Zend_Db_Expr('""'), 'searchContent', 'image' => new Zend_Db_Expr('""'), 'type' => new Zend_Db_Expr('"HTML Block"'))); if (false != ($idBlock = $this->_getExIdBlock())) { $htmlBlockSelect->where('`idBlock` <> ' . $this->db->quote($idBlock, 'integer')); } $anyWordResultHtml = clone $htmlBlockSelect; $simpleResultHtml = clone $htmlBlockSelect; Qs_Db_Filter::match($htmlBlockSelect, $this->_filterFields, $query, true); Qs_Db_Filter::match($anyWordResultHtml, $this->_filterFields, $query); Qs_Db_Filter::where($simpleResultHtml, $this->_filterFields, $query); /* $pageSelect = $this->_db->select() ->from($this->_getPair('PageContent'), array('idPage', 'title', 'searchContent' => new Zend_Db_Expr('""'), 'image' => new Zend_Db_Expr('""'), 'type' => new Zend_Db_Expr('"Page Title"'))); $anyWordResultPage = clone $pageSelect; $simpleResultPage = clone $pageSelect; Qs_Db_Filter::match($pageSelect, array('title'), $query, true); Qs_Db_Filter::match($anyWordResultPage, array('title'), $query); Qs_Db_Filter::where($simpleResultPage, array('title'), $query); */ $historySelect = $this->_db->select() ->from($this->_getPair('History', false), array('id', 'year', 'searchContent', 'image', 'type' => new Zend_Db_Expr('"History"'))); $anyWordResultHistory = clone $historySelect; $simpleResultHistory = clone $historySelect; Qs_Db_Filter::match($historySelect, array('year', 'searchContent'), $query, true); Qs_Db_Filter::match($anyWordResultHistory, array('year', 'searchContent'), $query); Qs_Db_Filter::where($simpleResultHistory, array('year', 'searchContent'), $query); $this->select->reset()->union(array( $htmlBlockSelect, $anyWordResultHtml, $simpleResultHtml, // $pageSelect, $anyWordResultPage, $simpleResultPage, $historySelect, $anyWordResultHistory, $simpleResultHistory )); $this->_prepareListOptions($options); return $this->select; } public function getList($options = array()) { $stmt = $this->getListStatement($options); $list = $stmt->fetchAll(); $this->_prepareList($list); if (is_array($list) && count($list)) { $session = new Qs_Session_Namespace('JC_SEARCH'); $session->flagContent = true; } return $list; } public function getPaginatorAdapter() { $select = $this->_getSelect()->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET); return $select; } protected function _filterWhere(Zend_Db_Select $select) { if (!empty($this->_filterFields) && array_key_exists('query', $this->_filter)) { Qs_Db_Filter::where($select, $this->_filterFields, $this->_filter['query']); } return $select; } }