&%{};]*'); // All indis with this surname. NB - allow ' and " $search =safe_GET('search'); $last = array('alpha'=>$alpha, 'surname'=>$surname, 'search'=>$search); $_SESSION['sb_families_last'] = $last; if (!empty($search)) return $this->search($search); else if (empty($surname)) return $this->getAlphaSurnames($alpha, $surname); else return $this->getSurnameFams($alpha, $surname); } // Implement WT_Module_Sidebar public function getSidebarContent() { global $SHOW_MARRIED_NAMES, $WT_IMAGES; // Fetch a list of the initial letters of all surnames in the database $initials=get_indilist_salpha($SHOW_MARRIED_NAMES, false, WT_GED_ID); $out = '

'; foreach ($initials as $letter=>$count) { switch ($letter) { case '@': $html=i18n::translate('(unknown)'); break; case ',': $html=i18n::translate('None'); break; default: $html=$letter; break; } $html=''.PrintReady($html).''; $out .= $html." "; } $out .= '

'; $out .= '
'; if (isset($_SESSION['sb_families_last'])) { $last = $_SESSION['sb_families_last']; $alpha = $last['alpha']; $search = $last['search']; $surname = $last['surname']; if (!empty($search)) $out.= $this->search($search); else if (!empty($alpha)) $out.= $this->getAlphaSurnames($alpha, $surname); } $out .= '
'; return $out; } public function getAlphaSurnames($alpha, $surname1='') { global $SHOW_MARRIED_NAMES; $surns=get_indilist_surns('', $alpha, $SHOW_MARRIED_NAMES, true, WT_GED_ID); $out = ''; return $out; } public function getSurnameFams($alpha, $surname) { global $SHOW_MARRIED_NAMES; $families=get_famlist_fams($surname, $alpha, '', $SHOW_MARRIED_NAMES, WT_GED_ID); $out = ''; return $out; } public function search($query) { if (strlen($query)<2) return ''; //-- search for INDI names $rows=WT_DB::prepare( "SELECT ? AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex". " FROM `##individuals`, `##name`". " WHERE (i_id LIKE ? OR n_sort LIKE ?)". " AND i_id=n_id AND i_file=n_file AND i_file=?". " ORDER BY n_sort LIMIT ".WT_AUTOCOMPLETE_LIMIT ) ->execute(array('INDI', "%{$query}%", "%{$query}%", WT_GED_ID)) ->fetchAll(PDO::FETCH_ASSOC); $ids = array(); foreach ($rows as $row) { $ids[] = $row['xref']; } $vars=array('FAM'); if (empty($ids)) { //-- no match : search for FAM id $where = "f_id LIKE ?"; $vars[]="%{$FILTER}%"; } else { //-- search for spouses $qs=implode(',', array_fill(0, count($ids), '?')); $where = "(f_husb IN ($qs) OR f_wife IN ($qs))"; $vars=array_merge($vars, $ids, $ids); } $vars[]=WT_GED_ID; $rows=WT_DB::prepare("SELECT ? AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec, f_husb, f_wife, f_numchil FROM `##families` WHERE {$where} AND f_file=? LIMIT ".WT_AUTOCOMPLETE_LIMIT) ->execute($vars) ->fetchAll(PDO::FETCH_ASSOC); $out = ''; return $out; } }