diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-02-12 16:02:22 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-02-12 16:02:22 +0000 |
| commit | e0fdecc9061febee5d102975a79c436704fa0519 (patch) | |
| tree | 272353ef4ebc7281d6a4368d262de556ed9cee61 | |
| parent | 82dbc12da40b48a33dcef151b11ee1605a45d76e (diff) | |
| download | webtrees-e0fdecc9061febee5d102975a79c436704fa0519.tar.gz webtrees-e0fdecc9061febee5d102975a79c436704fa0519.tar.bz2 webtrees-e0fdecc9061febee5d102975a79c436704fa0519.zip | |
Unused code
| -rw-r--r-- | app/Controller/SearchController.php | 34 | ||||
| -rw-r--r-- | find.php | 8 | ||||
| -rw-r--r-- | includes/functions/functions_db.php | 81 | ||||
| -rw-r--r-- | modules_v3/GEDFact_assistant/_CENS/census_3_find.php | 2 | ||||
| -rw-r--r-- | modules_v3/GEDFact_assistant/module.php | 2 |
5 files changed, 34 insertions, 93 deletions
diff --git a/app/Controller/SearchController.php b/app/Controller/SearchController.php index ccdc05bbe4..1ae89e0f80 100644 --- a/app/Controller/SearchController.php +++ b/app/Controller/SearchController.php @@ -304,40 +304,32 @@ class SearchController extends PageController { $logstring = "Type: General\nQuery: " . $this->query; Log::AddSearchlog($logstring, $this->search_trees); + $this->myindilist = array(); // Search the individuals - if (isset ($this->srindi)) { - $this->myindilist = search_indis($query_terms, array_keys($this->search_trees), 'AND'); - } else { - $this->myindilist = array(); + if (isset ($this->srindi) && $query_terms) { + $this->myindilist = search_indis($query_terms, array_keys($this->search_trees)); } // Search the fams - if (isset ($this->srfams)) { + $this->myfamlist = array(); + if (isset ($this->srfams) && $query_terms) { $this->myfamlist = array_merge( - search_fams($query_terms, array_keys($this->search_trees), 'AND'), - search_fams_names($query_terms, array_keys($this->search_trees), 'AND') + search_fams($query_terms, array_keys($this->search_trees)), + search_fams_names($query_terms, array_keys($this->search_trees)) ); $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->search_trees), 'AND'); - } - } else { - $this->mysourcelist = array(); + $this->mysourcelist = array(); + if (isset ($this->srsour) && $query_terms) { + $this->mysourcelist = search_sources($query_terms, array_keys($this->search_trees)); } // Search the notes - if (isset ($this->srnote)) { - if (!empty ($this->query)) { - $this->mynotelist = search_notes($query_terms, array_keys($this->search_trees), 'AND'); - } - } else { - $this->mynotelist = array(); + $this->mynotelist = array(); + if (isset ($this->srnote) && $query_terms) { + $this->mynotelist = search_notes($query_terms, array_keys($this->search_trees)); } // If only 1 item is returned, automatically forward to that item @@ -484,7 +484,7 @@ if ($action == "filter") { // Output Individual if ($type == "indi") { echo '<div id="find-output">'; - $myindilist = search_indis_names($filter_array, array(WT_GED_ID), 'AND'); + $myindilist = search_indis_names($filter_array, array(WT_GED_ID)); if ($myindilist) { echo '<ul>'; usort($myindilist, __NAMESPACE__ . '\GedcomRecord::compare'); @@ -505,8 +505,8 @@ if ($action == "filter") { // 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') + search_fams_names($filter_array, array(WT_GED_ID)), + search_fams($filter_array, array(WT_GED_ID)) )); if ($myfamlist) { @@ -612,7 +612,7 @@ if ($action == "filter") { if ($type == "repo") { echo '<div id="find-output">'; if ($filter) { - $repo_list = search_repos($filter_array, array(WT_GED_ID), 'AND'); + $repo_list = search_repos($filter_array, array(WT_GED_ID)); } else { $repo_list = get_repo_list(WT_GED_ID); } diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php index bdeb44a48a..c0fb5633a2 100644 --- a/includes/functions/functions_db.php +++ b/includes/functions/functions_db.php @@ -123,16 +123,10 @@ function get_note_list($ged_id) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Individual[] */ -function search_indis($query, $geds, $match) { - // No query => no results - if (!$query) { - return array(); - } - +function search_indis(array $query, array $geds) { // Convert the query into a SQL expression $querysql = array(); // Convert the query into a regular expression @@ -143,10 +137,7 @@ function search_indis($query, $geds, $match) { $querysql[] = "i_gedcom LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "'"; } - $sql = "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom FROM `##individuals` WHERE (" . implode(" {$match} ", $querysql) . ') AND i_file IN (' . implode(',', $geds) . ')'; - - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; + $sql = "SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom FROM `##individuals` WHERE (" . implode(" AND ", $querysql) . ') AND i_file IN (' . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); @@ -175,11 +166,10 @@ function search_indis($query, $geds, $match) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Individual[] */ -function search_indis_names($query, $geds, $match) { +function search_indis_names(array $query, array $geds) { // No query => no results if (!$query) { return array(); @@ -190,10 +180,7 @@ function search_indis_names($query, $geds, $match) { foreach ($query as $q) { $querysql[] = "n_full LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "'"; } - $sql = "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, n_full FROM `##individuals` JOIN `##name` ON i_id=n_id AND i_file=n_file WHERE (" . implode(" {$match} ", $querysql) . ') AND i_file IN (' . implode(',', $geds) . ')'; - - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; + $sql = "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, n_full FROM `##individuals` JOIN `##name` ON i_id=n_id AND i_file=n_file WHERE (" . implode(" AND ", $querysql) . ') AND i_file IN (' . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); @@ -229,7 +216,7 @@ function search_indis_names($query, $geds, $match) { * * @return Individual[] */ -function search_indis_soundex($soundex, $lastname, $firstname, $place, $geds) { +function search_indis_soundex($soundex, $lastname, $firstname, $place, array $geds) { $sql = "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom FROM `##individuals`"; if ($place) { $sql .= " JOIN `##placelinks` ON (pl_file=i_file AND pl_gid=i_id)"; @@ -287,9 +274,6 @@ function search_indis_soundex($soundex, $lastname, $firstname, $place, $geds) { $sql .= ' AND (' . implode(' OR ', $plac_sdx) . ')'; } - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; - $list = array(); $rows = Database::prepare($sql)->execute($sql_args)->fetchAll(); foreach ($rows as $row) { @@ -374,16 +358,10 @@ function search_indis_dates($day, $month, $year, $facts) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Family[] */ -function search_fams($query, $geds, $match) { - // No query => no results - if (!$query) { - return array(); - } - +function search_fams($query, $geds) { // Convert the query into a SQL expression $querysql = array(); // Convert the query into a regular expression @@ -394,10 +372,7 @@ function search_fams($query, $geds, $match) { $querysql[] = "f_gedcom LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "'"; } - $sql = "SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE (" . implode(" {$match} ", $querysql) . ') AND f_file IN (' . implode(',', $geds) . ')'; - - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; + $sql = "SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE (" . implode(" AND ", $querysql) . ') AND f_file IN (' . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); @@ -428,11 +403,10 @@ function search_fams($query, $geds, $match) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Family[] */ -function search_fams_names($query, $geds, $match) { +function search_fams_names($query, $geds) { // No query => no results if (!$query) { return array(); @@ -444,10 +418,7 @@ function search_fams_names($query, $geds, $match) { $querysql[] = "(husb.n_full LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "' OR wife.n_full LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "')"; } - $sql = "SELECT DISTINCT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` LEFT OUTER JOIN `##name` husb ON f_husb=husb.n_id AND f_file=husb.n_file LEFT OUTER JOIN `##name` wife ON f_wife=wife.n_id AND f_file=wife.n_file WHERE (" . implode(" {$match} ", $querysql) . ') AND f_file IN (' . implode(',', $geds) . ')'; - - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; + $sql = "SELECT DISTINCT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` LEFT OUTER JOIN `##name` husb ON f_husb=husb.n_id AND f_file=husb.n_file LEFT OUTER JOIN `##name` wife ON f_wife=wife.n_id AND f_file=wife.n_file WHERE (" . implode(" AND ", $querysql) . ') AND f_file IN (' . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); @@ -466,16 +437,10 @@ function search_fams_names($query, $geds, $match) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Source[] */ -function search_sources($query, $geds, $match) { - // No query => no results - if (!$query) { - return array(); - } - +function search_sources($query, $geds) { // Convert the query into a SQL expression $querysql = array(); // Convert the query into a regular expression @@ -486,10 +451,7 @@ function search_sources($query, $geds, $match) { $querysql[] = "s_gedcom LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "'"; } - $sql = "SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom FROM `##sources` WHERE (" . implode(" {$match} ", $querysql) . ') AND s_file IN (' . implode(',', $geds) . ')'; - - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; + $sql = "SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom FROM `##sources` WHERE (" . implode(" AND ", $querysql) . ') AND s_file IN (' . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); @@ -520,16 +482,10 @@ function search_sources($query, $geds, $match) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Note[] */ -function search_notes($query, $geds, $match) { - // No query => no results - if (!$query) { - return array(); - } - +function search_notes($query, $geds) { // Convert the query into a SQL expression $querysql = array(); // Convert the query into a regular expression @@ -540,10 +496,7 @@ function search_notes($query, $geds, $match) { $querysql[] = "o_gedcom LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "'"; } - $sql = "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom FROM `##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 gedcom_id'; + $sql = "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom FROM `##other` WHERE (" . implode(" AND ", $querysql) . ") AND o_type='NOTE' AND o_file IN (" . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); @@ -575,11 +528,10 @@ function search_notes($query, $geds, $match) { * * @param string[] $query array of search terms * @param integer[] $geds array of gedcoms to search - * @param string $match AND or OR * * @return Repository[] */ -function search_repos($query, $geds, $match) { +function search_repos($query, $geds) { // No query => no results if (!$query) { return array(); @@ -595,10 +547,7 @@ function search_repos($query, $geds, $match) { $querysql[] = "o_gedcom LIKE " . Database::quote("%{$q}%") . " COLLATE '" . I18N::$collation . "'"; } - $sql = "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom FROM `##other` WHERE (" . implode(" {$match} ", $querysql) . ") AND o_type='REPO' AND o_file IN (" . implode(',', $geds) . ')'; - - // Group results by gedcom, to minimise switching between privacy files - $sql .= ' ORDER BY gedcom_id'; + $sql = "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom FROM `##other` WHERE (" . implode(" AND ", $querysql) . ") AND o_type='REPO' AND o_file IN (" . implode(',', $geds) . ')'; $list = array(); $rows = Database::prepare($sql)->fetchAll(); diff --git a/modules_v3/GEDFact_assistant/_CENS/census_3_find.php b/modules_v3/GEDFact_assistant/_CENS/census_3_find.php index 5109abf644..2a4f2f6daf 100644 --- a/modules_v3/GEDFact_assistant/_CENS/census_3_find.php +++ b/modules_v3/GEDFact_assistant/_CENS/census_3_find.php @@ -67,7 +67,7 @@ if ($action == "filter") { // Output Individual for GEDFact Assistant ====================== echo "<table class=\"tabs_table width90\">"; - $myindilist = search_indis_names($filter_array, array(WT_GED_ID), 'AND'); + $myindilist = search_indis_names($filter_array, array(WT_GED_ID)); if ($myindilist) { echo "<tr><td class=\"list_value_wrap\"><ul>"; usort($myindilist, __NAMESPACE__ . '\GedcomRecord::compare'); diff --git a/modules_v3/GEDFact_assistant/module.php b/modules_v3/GEDFact_assistant/module.php index 5d9a14b35a..0cbc6706cb 100644 --- a/modules_v3/GEDFact_assistant/module.php +++ b/modules_v3/GEDFact_assistant/module.php @@ -117,7 +117,7 @@ class GEDFact_assistant_WT_Module extends Module { $filter = trim($filter); $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); echo "<table class=\"tabs_table width90\"><tr>"; - $myindilist = search_indis_names($filter_array, array(WT_GED_ID), 'AND'); + $myindilist = search_indis_names($filter_array, array(WT_GED_ID)); if ($myindilist) { echo "<td class=\"list_value_wrap\"><ul>"; usort($myindilist, __NAMESPACE__ . '\GedcomRecord::compare'); |
