Beispiel #1
0
 /**
  * 	Gathers results for a general search
  */
 function GeneralSearch()
 {
     global $GEDCOM, $GEDCOMS;
     $oldged = $GEDCOM;
     // 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);
     }
     // Get a list of gedcom IDs to search
     // TODO: don't we already have this somewhere?
     $ged_ids = array();
     foreach ($this->sgeds as $gedcom) {
         $ged_ids[] = get_id_from_gedcom($gedcom);
     }
     //-- perform the search
     if ($query_terms && $ged_ids) {
         // Write a log entry
         $logstring = "Type: General<br />Query: " . $this->query;
         AddToSearchlog($logstring, $this->sgeds);
         // Search the indi's
         if (isset($this->srindi)) {
             $this->myindilist = search_indis($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on');
         } else {
             $this->myindilist = array();
         }
         // Search the fams
         if (isset($this->srfams)) {
             $this->myfamlist = array_merge(search_fams($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on'), search_fams_names($query_terms, $ged_ids, 'AND'));
             $this->myfamlist = array_unique($this->myfamlist);
         } else {
             $this->myfamlist = array();
         }
         // Search the sources
         if (isset($this->srsour)) {
             if (!empty($this->query)) {
                 $this->mysourcelist = search_sources($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on');
             }
         } else {
             $this->mysourcelist = array();
         }
         // Search the notes
         if (isset($this->srnote)) {
             if (!empty($this->query)) {
                 $this->mynotelist = search_notes($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on');
             }
         } else {
             $this->mynotelist = array();
         }
         // 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 = $this->myindilist[0];
             if (!count_linked_indi($indi->getXref(), 'ASSO', $indi->getGedId()) && !count_linked_fam($indi->getXref(), 'ASSO', $indi->getGedId()) && $indi->canDisplayName()) {
                 header("Location: " . encode_url($indi->getLinkUrl(), false));
                 exit;
             }
         }
         if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) {
             $fam = $this->myfamlist[0];
             if ($fam->canDisplayName()) {
                 header("Location: " . encode_url($fam->getLinkUrl(), false));
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) {
             $sour = $this->mysourcelist[0];
             if ($sour->canDisplayName()) {
                 header("Location: " . encode_url($sour->getLinkUrl(), false));
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) {
             $note = $this->mynotelist[0];
             if ($note->canDisplayName()) {
                 header("Location: " . encode_url($note->getLinkUrl(), false));
                 exit;
             }
         }
     }
 }
Beispiel #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>', WT_I18N::translate('Repositories found'), " ", count($repo_list), '</p>';
        } else {
            echo '<p>', WT_I18N::translate('No results found.'), '</p>';
        }
        echo '</div>';
    }
    // Output Shared Notes
    if ($type == "note") {
        echo '<div id="find-output">';
        if ($filter) {
            $mynotelist = search_notes($filter_array, array(WT_GED_ID), 'AND', true);
        } else {
            $mynotelist = get_note_list(WT_GED_ID);
        }
        if ($mynotelist) {
            usort($mynotelist, array('WT_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>', WT_I18N::translate('Shared notes found'), ' ', count($mynotelist), '</p>';
        } else {
            echo '<p>', WT_I18N::translate('No results found.'), '</p>';
        }
        echo '</div>';
Beispiel #3
0
 /**
  * Gathers results for a general search
  */
 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->sgeds) {
         // Write a log entry
         $logstring = "Type: General\nQuery: " . $this->query;
         AddToSearchlog($logstring, $this->sgeds);
         // Search the individuals
         if (isset($this->srindi)) {
             $this->myindilist = search_indis($query_terms, array_keys($this->sgeds), 'AND');
         } else {
             $this->myindilist = array();
         }
         // Search the fams
         if (isset($this->srfams)) {
             $this->myfamlist = array_merge(search_fams($query_terms, array_keys($this->sgeds), 'AND'), search_fams_names($query_terms, array_keys($this->sgeds), 'AND'));
             $this->myfamlist = array_unique($this->myfamlist);
         } else {
             $this->myfamlist = array();
         }
         // Search the sources
         if (isset($this->srsour)) {
             if (!empty($this->query)) {
                 $this->mysourcelist = search_sources($query_terms, array_keys($this->sgeds), 'AND');
             }
         } else {
             $this->mysourcelist = array();
         }
         // Search the notes
         if (isset($this->srnote)) {
             if (!empty($this->query)) {
                 $this->mynotelist = search_notes($query_terms, array_keys($this->sgeds), 'AND');
             }
         } else {
             $this->mynotelist = array();
         }
         // 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 = $this->myindilist[0];
             if ($indi->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $indi->getRawUrl());
                 exit;
             }
         }
         if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) {
             $fam = $this->myfamlist[0];
             if ($fam->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $fam->getRawUrl());
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) {
             $sour = $this->mysourcelist[0];
             if ($sour->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $sour->getRawUrl());
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) {
             $note = $this->mynotelist[0];
             if ($note->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $note->getRawUrl());
                 exit;
             }
         }
     }
 }