/** * Gathers results for a general search */ private function generalSearch() { // Split search terms into an array $query_terms = array(); $query = $this->query; // Words in double quotes stay together while (preg_match('/"([^"]+)"/', $query, $match)) { $query_terms[] = trim($match[1]); $query = str_replace($match[0], '', $query); } // Other words get treated separately while (preg_match('/[\\S]+/', $query, $match)) { $query_terms[] = trim($match[0]); $query = str_replace($match[0], '', $query); } //-- perform the search if ($query_terms && $this->search_trees) { // Write a log entry $logstring = "Type: General\nQuery: " . $this->query; Log::AddSearchlog($logstring, $this->search_trees); // Search the individuals if ($this->srindi && $query_terms) { $this->myindilist = FunctionsDb::searchIndividuals($query_terms, $this->search_trees); } // Search the fams if ($this->srfams && $query_terms) { $this->myfamlist = array_merge(FunctionsDb::searchFamilies($query_terms, $this->search_trees), FunctionsDb::searchFamilyNames($query_terms, $this->search_trees)); $this->myfamlist = array_unique($this->myfamlist); } // Search the sources if ($this->srsour && $query_terms) { $this->mysourcelist = FunctionsDb::searchSources($query_terms, $this->search_trees); } // Search the notes if ($this->srnote && $query_terms) { $this->mynotelist = FunctionsDb::searchNotes($query_terms, $this->search_trees); } // If only 1 item is returned, automatically forward to that item // If ID cannot be displayed, continue to the search page. if (count($this->myindilist) == 1 && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) { $indi = reset($this->myindilist); if ($indi->canShowName()) { header('Location: ' . WT_BASE_URL . $indi->getRawUrl()); exit; } } if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) { $fam = reset($this->myfamlist); if ($fam->canShowName()) { header('Location: ' . WT_BASE_URL . $fam->getRawUrl()); exit; } } if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) { $sour = reset($this->mysourcelist); if ($sour->canShowName()) { header('Location: ' . WT_BASE_URL . $sour->getRawUrl()); exit; } } if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) { $note = reset($this->mynotelist); if ($note->canShowName()) { header('Location: ' . WT_BASE_URL . $note->getRawUrl()); exit; } } } }
foreach ($myindilist as $indi) { echo $indi->formatList('li', true); } echo '</ul> <p>', I18N::translate('Total individuals: %s', count($myindilist)), '</p>'; } else { echo '<p>', I18N::translate('No results found.'), '</p>'; } echo '</div>'; } // Output Family if ($type == "fam") { echo '<div id="find-output">'; // Get the famrecs with hits on names from the family table // Get the famrecs with hits in the gedcom record from the family table $myfamlist = array_unique(array_merge(FunctionsDb::searchFamilyNames($filter_array, array($WT_TREE)), FunctionsDb::searchFamilies($filter_array, array($WT_TREE)))); if ($myfamlist) { echo '<ul>'; usort($myfamlist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare'); foreach ($myfamlist as $family) { echo $family->formatList('li', true); } echo '</ul> <p>', I18N::translate('Total families: %s', count($myfamlist)), '</p>'; } else { echo '<p>', I18N::translate('No results found.'), '</p>'; } echo '</div>'; } // Output Media if ($type === 'media') {