foreach ($myindilist as $indi) { echo $indi->format_list('li', true); } echo '</ul> <p>', WT_I18N::translate('Total individuals: %s', count($myindilist)), '</p>'; } else { echo '<p>', WT_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(search_fams_names($filter_array, array(WT_GED_ID), 'AND'), search_fams($filter_array, array(WT_GED_ID), 'AND', true))); if ($myfamlist) { $curged = $GEDCOM; echo '<ul>'; usort($myfamlist, array('WT_GedcomRecord', 'Compare')); foreach ($myfamlist as $family) { echo $family->format_list('li', true); } echo '</ul> <p>', WT_I18N::translate('Total families: %s', count($myfamlist)), '</p>'; } else { echo '<p>', WT_I18N::translate('No results found.'), '</p>'; } echo '</div>'; } // Output Media
/** * 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; } } } }
echo $indi->format_list('li', true); } echo '</ul></td></tr><tr><td class="list_label">', $pgv_lang['total_indis'], ' ', count($myindilist), '</tr></td>'; } else { echo "<td class=\"list_value_wrap\">"; echo $pgv_lang["no_results"]; echo "</td></tr>"; } echo "</table>"; } // Output Family if ($type == "fam") { echo "<table class=\"tabs_table {$TEXT_DIRECTION} width90\"><tr>"; // 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 = pgv_array_merge(search_fams_names($filter_array, array(PGV_GED_ID), 'AND'), search_fams($filter_array, array(PGV_GED_ID), 'AND', true)); if ($myfamlist) { $curged = $GEDCOM; echo "<td class=\"list_value_wrap {$TEXT_DIRECTION}\"><ul>"; usort($myfamlist, array('GedcomRecord', 'Compare')); foreach ($myfamlist as $family) { echo $family->format_list('li', true); } echo '</ul></td></tr><tr><td class="list_label">', $pgv_lang['total_fams'], ' ', count($myfamlist), '</tr></td>'; } else { echo "<td class=\"list_value_wrap\">"; echo $pgv_lang["no_results"]; echo "</td></tr>"; } echo "</table>"; }
/** * 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; } } } }