foreach ($rows as $row) { $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); if ($family->canShowName()) { $marriage_year = $family->getMarriageYear(); if ($marriage_year) { $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); } else { $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); } } } // Fetch all data, regardless of privacy $rows = get_NOTE_rows($WT_TREE, $term); // Filter for privacy foreach ($rows as $row) { $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom); if ($note->canShowName()) { $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName()); } } echo json_encode($data); return; case 'IFS': $data = array(); // Fetch all data, regardless of privacy $rows = get_INDI_rows($WT_TREE, $term); // Filter for privacy foreach ($rows as $row) { $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); if ($person->canShowName()) { $data[] = array('value' => $person->getXref(), 'label' => str_replace(array('@N.N.', '@P.N.'), array(I18N::translateContext('Unknown surname', '…'), I18N::translateContext('Unknown given name', '…')), $row->n_full) . ', <i>' . $person->getLifeSpan() . '</i>');
/** * returns NOTEs (Shared) matching filter * @return Array of string */ function autocomplete_NOTE($FILTER) { global $TBLPREFIX, $gBitDb; $sql = "SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec FROM {$TBLPREFIX}other WHERE o_gedcom LIKE '%{$FILTER}%' AND o_type='NOTE' AND o_file=" . PGV_GED_ID; $rows = $gBitDb->query($sql, array("%{$FILTER}%", PGV_GED_ID), PGV_AUTOCOMPLETE_LIMIT); $data = array(); while ($row = $rows->fetchRow()) { $note = Note::getInstance($row); if ($note->canDisplayName()) { $data[$row['xref']] = $note->getFullName(); } } return $data; }
/** * returns NOTEs (Shared) matching filter * @return Array of string */ function autocomplete_NOTE($FILTER) { $rows = get_autocomplete_NOTE($FILTER); $data = array(); foreach ($rows as $row) { $note = Note::getInstance($row); if ($note->canDisplayName()) { $data[$row["xref"]] = $note->getFullName(); } } return $data; }
function search_notes($query, $geds, $match, $skip) { global $TBLPREFIX, $GEDCOM, $DB_UTF8_COLLATION, $gBitDb; // No query => no results if (!$query) { return array(); } // Convert the query into a SQL expression $querysql = array(); // Convert the query into a regular expression $queryregex = array(); foreach ($query as $q) { $queryregex[] = preg_quote(UTF8_strtoupper($q), '/'); if ($DB_UTF8_COLLATION || !has_utf8($q)) { $querysql[] = "o_gedcom LIKE '%{$q}%'"; } else { $querysql[] = "(o_gedcom LIKE '%{$q}% OR o_gedcom LIKE '%" . UTF8_strtoupper($q) . "%' OR o_gedcom LIKE '%" . UTF8_strtolower($q) . "%'"; } } $sql = "SELECT 'NOTE' AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec FROM {$TBLPREFIX}other WHERE (" . implode(" {$match} ", $querysql) . ") AND o_type='NOTE' AND o_file IN (" . implode(',', $geds) . ')'; // Group results by gedcom, to minimise switching between privacy files $sql .= ' ORDER BY ged_id'; // Tags we might not want to search if (PGV_USER_IS_ADMIN) { $skipregex = '/^\\d (_UID|_PGVU|FILE|FORM|TYPE|CHAN|SUBM|REFN) .*(' . implode('|', $queryregex) . ')/im'; } else { $skipregex = '/^\\d (_UID|_PGVU|FILE|FORM|TYPE|CHAN|SUBM|REFN|RESN) .*(' . implode('|', $queryregex) . ')/im'; } $list = array(); $result = $gBitDb->query($sql); $GED_ID = PGV_GED_ID; while ($row = $result->fetchRow()) { // Switch privacy file if necessary if ($row['ged_id'] != $GED_ID) { $GEDCOM = get_gedcom_from_id($row['ged_id']); load_privacy_file($row['ged_id']); $GED_ID = $row['ged_id']; } $note = Note::getInstance($row); // SQL may have matched on private data or gedcom tags, so check again against privatized data. $gedrec = UTF8_strtoupper($note->getGedcomRecord()); foreach ($queryregex as $q) { if (!preg_match('/(\\n\\d|^0 @' . PGV_REGEX_XREF . '@) ' . PGV_REGEX_TAG . ' .*' . $q . '/i', $gedrec)) { continue 2; } } if ($skip && preg_match($skipregex, $gedrec)) { continue; } $list[] = $note; } // Switch privacy file if necessary if ($GED_ID != PGV_GED_ID) { $GEDCOM = get_gedcom_from_id(PGV_GED_ID); load_privacy_file(PGV_GED_ID); } return $list; }