示例#1
0
 /**
  * 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;
             }
         }
     }
 }
示例#2
0
            echo '<ul>';
            foreach ($repo_list as $repo) {
                echo '<li><a href="', $repo->getHtmlUrl(), '" onclick="pasteid(\'', $repo->getXref(), '\');"><span class="list_item">', $repo->getFullName(), '</span></a></li>';
            }
            echo '</ul>
			<p>', I18N::translate('Repositories found'), " ", count($repo_list), '</p>';
        } else {
            echo '<p>', I18N::translate('No results found.'), '</p>';
        }
        echo '</div>';
    }
    // Output Shared Notes
    if ($type == "note") {
        echo '<div id="find-output">';
        if ($filter) {
            $mynotelist = FunctionsDb::searchNotes($filter_array, array($WT_TREE));
        } else {
            $mynotelist = FunctionsDb::getNoteList($WT_TREE);
        }
        if ($mynotelist) {
            usort($mynotelist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare');
            echo '<ul>';
            foreach ($mynotelist as $note) {
                echo '<li><a href="', $note->getHtmlUrl(), '" onclick="pasteid(\'', $note->getXref(), '\');"><span class="list_item">', $note->getFullName(), '</span></a></li>';
            }
            echo '</ul>
			<p>', I18N::translate('Shared notes found'), ' ', count($mynotelist), '</p>';
        } else {
            echo '<p>', I18N::translate('No results found.'), '</p>';
        }
        echo '</div>';