&$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 'Testimonial': $page = Qs_SiteMap::findFirst(array(), array('type' => 'Testimonial_', 'idGroup' => 1)); $row['searchContent'] = $row['title'] . ' | ' . $row['searchContent']; $row['title'] = $page['title']; $row['url'] = $page['url']; break; // case 'Newsletter': // $page = Qs_SiteMap::findFirst(array(), array('type' => 'ChimesNewsletter_', 'idGroup' => 1)); // $row['url'] = $page['url'] . '/' . date('Y', strtotime($row['searchContent'])); // $row['searchContent'] = $row['title'] . ' | ' . date('F Y', strtotime($row['searchContent'])); // $row['title'] = $page['title']; // 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); */ $testimonialSelect = $this->_db->select() ->from($this->_getPair('Testimonial', false), array('id', 'name', 'testimonial', 'image' => new Zend_Db_Expr('""'), 'type' => new Zend_Db_Expr('"Testimonial`"'))); $anyWordResultTestimonial = clone $testimonialSelect; $simpleResultTestimonial = clone $testimonialSelect; Qs_Db_Filter::match($testimonialSelect, array('name', 'testimonial'), $query, true); Qs_Db_Filter::match($anyWordResultTestimonial, array('name', 'testimonial'), $query); Qs_Db_Filter::where($simpleResultTestimonial, array('name', 'testimonial'), $query); // $newsletterSelect = $this->_db->select() // ->from($this->_getPair('ChimesNewsletter', false), // array('id', 'headline', 'published', 'image' => new Zend_Db_Expr('""'), // 'type' => new Zend_Db_Expr('"Newsletter"'))); // $anyWordResultNewsletter = clone $newsletterSelect; // $simpleResultNewsletter = clone $newsletterSelect; // // Qs_Db_Filter::match($newsletterSelect, array('headline'), $query, true); // Qs_Db_Filter::match($anyWordResultNewsletter, array('headline'), $query); // Qs_Db_Filter::where($simpleResultNewsletter, array('headline'), $query); $this->select->reset()->union(array( $htmlBlockSelect, $anyWordResultHtml, $simpleResultHtml, // $pageSelect, $anyWordResultPage, $simpleResultPage, $testimonialSelect, $anyWordResultTestimonial, $simpleResultTestimonial, // $newsletterSelect, $anyWordResultNewsletter, $simpleResultNewsletter )); $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; } }