Doc = $Doc; parent::DBObj($id); } function setSearchString($data) { $this->search_data = (array)$data; $this->search_data['str'] = stripslashes(trim($this->search_data['str'])); $this->search_data['no_str'] = stripslashes(trim($this->search_data['no_str'])); return true; } function parseFilterString($string) { $spliter = ' '; $filter = array(); $j = 0; for ($i = 0; $i < strlen($string); $i ++) { if ($string[$i] == '"' && $spliter != '"') { // çàíéøëè â³äêðèâàþ÷ó äóæêó if (strpos($string, '"', $i + 1)) { // ÿêùî º ïàðíà äóæêà, òî ì³íÿºì ðîçä³ëüêèê $spliter = '"'; $j++; continue; } } elseif ($string[$i] == '"' && $spliter == '"') { // çàíéøëè çàêðèâàþ÷ó äóæêó $spliter = ' '; $j++; continue; } if ($string[$i] == $spliter) { $j++; continue; } $filter[$j] .= $string[$i]; } foreach ($filter as $k => $v) { $filter[$k] = mysql_escape_string($v); } $this->search_array = $filter; return $filter; } function getList4Grid($opt = array() ) { $start = 0; $ipp = 0; $where = ''; $ipp = 1024; extract($opt); $list = array(); if ($this->search_data['no_keywords'] != 'y') { $this->_getList4Keywords($opt); } if ($this->search_data['pages'] == 'y') { $list['list']['pages'] = $this->_getList4Pages($opt); } if ($this->search_data['emails'] == 'y') { $list['list']['emails'] = $this->_getList4Emails($opt); } if ($this->search_data['announcements'] == 'y') { $list['list']['announcements'] = $this->_getList4Announcements($opt); } $list['num_rows'] = 0; $list['num_pages'] = 0; $fl = false; foreach ($list['list'] as $content) { if (!empty($content)){ $fl = true; } } if (!$fl) { $list['list'] = null; } return $list; } function _getList4Keywords() { $Keywords = SiteMap::getObj('Keyword/Keyword.php'); require_once 'class/HTTP.php'; if ($cDestination = $Keywords->db->queryOne('SELECT destination FROM mn_Keyword WHERE keyword=' . $Keywords->db->quote(preg_replace('/[^a-zA-Z0-9]/','',$this->search_data['str'])))) { $search_data = Session::getData('search', 'search_data'); $search_data['no_keywords'] = 'y'; Session::setData('search', 'search_data', $search_data); skHTTP::redirect($Keywords->Tag2baseUrl($cDestination)); } return array(); } function _getList4Pages($opt = array()) { $start = 0; $ipp = 0; $where = ''; $ipp = 1024; extract($opt); $sql = "select SQL_CALC_FOUND_ROWS sc.table_id, sc.title, sc.url, sc.data from {$this->db->tblSiteCache} as sc " . $this->_getWhere4Pages(); $this->db->setLimit($ipp, $start); $list['items'] = $this->db->queryAll($sql); $list['tpl'] = BASE_PATH . '/tpl/Search/section_list.tpl'; $list['ipp'] = $ipp; $list['num_rows'] = $this->db->queryOne('SELECT FOUND_ROWS()'); $list['num_pages'] = 1 + floor(($list['num_rows'] - 1) / $ipp) ; $list['item_name'] = 'Results site pages'; $list['all_item_name'] = 'Show all site pages results'; $list['type'] = 'pages'; $list = $this->checkList($list); return $list; } function _getWhere4Pages() { $where_arr = array(); $where = ""; $arr = $this->parseFilterString($this->search_data['str']); if (is_array($arr) && !empty($arr)) { foreach ($arr as $pat) { if ($pat != '') { $where_arr[] = "(sc.data like \"%" . $pat . "%\" or sc.title like \"%" . $pat . "%\")"; } } } $arr = $this->parseFilterString($this->search_data['no_str']); if (is_array($arr) && !empty($arr)) { foreach ($arr as $pat) { if ($pat != '') { $where_arr[] = "(sc.data not like \"%" . $pat . "%\" or sc.title not like \"%" . $pat . "%\")"; } } } if (count($where_arr)) { $where = " and (" . implode(" and ", $where_arr) . ") and sc.table_name = 'zz_Doc'"; } return "where 1" . $where; } function _getList4Emails($opt = array()) { $start = 0; $ipp = 0; $where = ''; $ipp = 1024; extract($opt); $list = array(); $user = $this->Doc->MemberAuth->getData(); if ($this->Doc->checkAcces2DocItem('BroadcastEmail/Repository/Show')) { $emails = SiteMap::getObj('BroadcastEmail/Repository/MemberRepository.php', null, $user['id']); $emails->setFilter(array( 'query' => $this->search_data['str'], 'no_query' => $this->search_data['no_str'], )); $list = $emails->getList4Grid($opt); $list['items'] = $list['list']; unset($list['list']); $list['tpl'] = BASE_PATH . '/tpl/Search/section_emails_list.tpl'; $list['ipp'] = $ipp; } $list['item_name'] = 'Results from broadcast email archive'; $list['all_item_name'] = 'Show all broadcast email archive results'; $list['type'] = 'emails'; $list = $this->checkList($list); return $list; } function _getList4Announcements($opt = array()) { return null; } function _getWhere4Announcements() { return null; } function checkList($list) { if (empty($list['items'])) { return null; } else { return $list; } } }