@@ -43,14 +43,14 @@ |
||
| 43 | 43 | <?php endforeach ?> |
| 44 | 44 | </td> |
| 45 | 45 | |
| 46 | - <td class="text-center" data-sort="<?= array_sum(array_map(function(array $x) { return count($x); }, $surns)) ?>"> |
|
| 46 | + <td class="text-center" data-sort="<?= array_sum(array_map(function (array $x) { return count($x); }, $surns)) ?>"> |
|
| 47 | 47 | <?php foreach ($surns as $indis): ?> |
| 48 | 48 | <?= I18N::number(count($indis)) ?> |
| 49 | 49 | <br> |
| 50 | 50 | <?php endforeach ?> |
| 51 | 51 | |
| 52 | 52 | <?php if (count($surns) > 1): ?> |
| 53 | - <?= I18N::number(array_sum(array_map(function(array $x) { return count($x); }, $surns))) ?> |
|
| 53 | + <?= I18N::number(array_sum(array_map(function (array $x) { return count($x); }, $surns))) ?> |
|
| 54 | 54 | <?php endif ?> |
| 55 | 55 | </td> |
| 56 | 56 | </tr> |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | foreach ($search_terms as $n => $q) { |
| 605 | 605 | $queryregex[] = preg_quote(I18N::strtoupper($q), '/'); |
| 606 | - $sql .= " AND f_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 606 | + $sql .= " AND f_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 607 | 607 | $args['collate_' . $n] = I18N::collation(); |
| 608 | 608 | $args['query_' . $n] = Database::escapeLike($q); |
| 609 | 609 | } |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | * @return Family[] |
| 651 | 651 | */ |
| 652 | 652 | private function searchFamilyNames(array $search_terms, array $search_trees): array { |
| 653 | - $sql = |
|
| 653 | + $sql = |
|
| 654 | 654 | "SELECT DISTINCT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . |
| 655 | 655 | " FROM `##families`" . |
| 656 | 656 | " LEFT JOIN `##name` husb ON f_husb = husb.n_id AND f_file = husb.n_file" . |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | $args = []; |
| 660 | 660 | |
| 661 | 661 | foreach ($search_terms as $n => $q) { |
| 662 | - $sql .= " AND (husb.n_full COLLATE :husb_collate_" . $n . " LIKE CONCAT('%', :husb_query_" . $n . ", '%') OR wife.n_full COLLATE :wife_collate_" . $n . " LIKE CONCAT('%', :wife_query_" . $n . ", '%'))"; |
|
| 662 | + $sql .= " AND (husb.n_full COLLATE :husb_collate_" . $n . " LIKE CONCAT('%', :husb_query_" . $n . ", '%') OR wife.n_full COLLATE :wife_collate_" . $n . " LIKE CONCAT('%', :wife_query_" . $n . ", '%'))"; |
|
| 663 | 663 | $args['husb_collate_' . $n] = I18N::collation(); |
| 664 | 664 | $args['husb_query_' . $n] = Database::escapeLike($q); |
| 665 | 665 | $args['wife_collate_' . $n] = I18N::collation(); |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | foreach ($search_terms as $n => $q) { |
| 712 | 712 | $queryregex[] = preg_quote(I18N::strtoupper($q), '/'); |
| 713 | - $sql .= " AND i_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 713 | + $sql .= " AND i_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 714 | 714 | $args['collate_' . $n] = I18N::collation(); |
| 715 | 715 | $args['query_' . $n] = Database::escapeLike($q); |
| 716 | 716 | } |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | // Add the where clause |
| 858 | - $sql .= " WHERE ind.i_file=?"; |
|
| 858 | + $sql .= " WHERE ind.i_file=?"; |
|
| 859 | 859 | $bind[] = $this->tree()->getTreeId(); |
| 860 | 860 | |
| 861 | 861 | foreach ($fields as $field_name => $field_value) { |
@@ -866,15 +866,15 @@ discard block |
||
| 866 | 866 | case 'GIVN': |
| 867 | 867 | switch ($modifiers[$field_name]) { |
| 868 | 868 | case 'EXACT': |
| 869 | - $sql .= " AND i_n.n_givn=?"; |
|
| 869 | + $sql .= " AND i_n.n_givn=?"; |
|
| 870 | 870 | $bind[] = $field_value; |
| 871 | 871 | break; |
| 872 | 872 | case 'BEGINS': |
| 873 | - $sql .= " AND i_n.n_givn LIKE CONCAT(?, '%')"; |
|
| 873 | + $sql .= " AND i_n.n_givn LIKE CONCAT(?, '%')"; |
|
| 874 | 874 | $bind[] = $field_value; |
| 875 | 875 | break; |
| 876 | 876 | case 'CONTAINS': |
| 877 | - $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 877 | + $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 878 | 878 | $bind[] = $field_value; |
| 879 | 879 | break; |
| 880 | 880 | case 'SDX_STD': |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; |
| 889 | 889 | } else { |
| 890 | 890 | // No phonetic content? Use a substring match |
| 891 | - $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 891 | + $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 892 | 892 | $bind[] = $field_value; |
| 893 | 893 | } |
| 894 | 894 | break; |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; |
| 905 | 905 | } else { |
| 906 | 906 | // No phonetic content? Use a substring match |
| 907 | - $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 907 | + $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 908 | 908 | $bind[] = $field_value; |
| 909 | 909 | } |
| 910 | 910 | break; |
@@ -913,15 +913,15 @@ discard block |
||
| 913 | 913 | case 'SURN': |
| 914 | 914 | switch ($modifiers[$field_name]) { |
| 915 | 915 | case 'EXACT': |
| 916 | - $sql .= " AND i_n.n_surname=?"; |
|
| 916 | + $sql .= " AND i_n.n_surname=?"; |
|
| 917 | 917 | $bind[] = $field_value; |
| 918 | 918 | break; |
| 919 | 919 | case 'BEGINS': |
| 920 | - $sql .= " AND i_n.n_surname LIKE CONCAT(?, '%')"; |
|
| 920 | + $sql .= " AND i_n.n_surname LIKE CONCAT(?, '%')"; |
|
| 921 | 921 | $bind[] = $field_value; |
| 922 | 922 | break; |
| 923 | 923 | case 'CONTAINS': |
| 924 | - $sql .= " AND i_n.n_surname LIKE CONCAT('%', ?, '%')"; |
|
| 924 | + $sql .= " AND i_n.n_surname LIKE CONCAT('%', ?, '%')"; |
|
| 925 | 925 | $bind[] = $field_value; |
| 926 | 926 | break; |
| 927 | 927 | case 'SDX_STD': |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | $sql .= " AND (" . implode(' OR ', $sdx) . ")"; |
| 936 | 936 | } else { |
| 937 | 937 | // No phonetic content? Use a substring match |
| 938 | - $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; |
|
| 938 | + $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; |
|
| 939 | 939 | $bind[] = $field_value; |
| 940 | 940 | } |
| 941 | 941 | break; |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | break; |
| 953 | 953 | } else { |
| 954 | 954 | // No phonetic content? Use a substring match |
| 955 | - $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; |
|
| 955 | + $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; |
|
| 956 | 956 | $bind[] = $field_value; |
| 957 | 957 | } |
| 958 | 958 | } |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | case '_MARNM': |
| 962 | 962 | case '_HEB': |
| 963 | 963 | case '_AKA': |
| 964 | - $sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')"; |
|
| 964 | + $sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')"; |
|
| 965 | 965 | $bind[] = $parts[1]; |
| 966 | 966 | $bind[] = $field_value; |
| 967 | 967 | break; |
@@ -971,7 +971,7 @@ discard block |
||
| 971 | 971 | $date = new Date($field_value); |
| 972 | 972 | if ($date->isOK()) { |
| 973 | 973 | $delta = 365 * ($modifiers[$field_name] ?? 0); |
| 974 | - $sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?"; |
|
| 974 | + $sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?"; |
|
| 975 | 975 | $bind[] = $parts[0]; |
| 976 | 976 | $bind[] = $date->minimumJulianDay() - $delta; |
| 977 | 977 | $bind[] = $date->maximumJulianDay() + $delta; |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | $date = new Date($field_value); |
| 982 | 982 | if ($date->isOK()) { |
| 983 | 983 | $delta = 365 * $modifiers[$field_name]; |
| 984 | - $sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?"; |
|
| 984 | + $sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?"; |
|
| 985 | 985 | $bind[] = $parts[1]; |
| 986 | 986 | $bind[] = $date->minimumJulianDay() - $delta; |
| 987 | 987 | $bind[] = $date->maximumJulianDay() + $delta; |
@@ -989,12 +989,12 @@ discard block |
||
| 989 | 989 | } elseif ($parts[1] === 'PLAC') { |
| 990 | 990 | // *:PLAC |
| 991 | 991 | // SQL can only link a place to a person/family, not to an event. |
| 992 | - $sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')"; |
|
| 992 | + $sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')"; |
|
| 993 | 993 | $bind[] = $field_value; |
| 994 | 994 | } elseif ($parts[0] === 'FAMS' && $parts[2] === 'PLAC') { |
| 995 | 995 | // FAMS:*:PLAC |
| 996 | 996 | // SQL can only link a place to a person/family, not to an event. |
| 997 | - $sql .= " AND f_p.place LIKE CONCAT('%', ?, '%')"; |
|
| 997 | + $sql .= " AND f_p.place LIKE CONCAT('%', ?, '%')"; |
|
| 998 | 998 | $bind[] = $field_value; |
| 999 | 999 | } elseif ($parts[0] === 'FAMC' && $parts[2] === 'NAME') { |
| 1000 | 1000 | $table = $parts[1] === 'HUSB' ? 'f_n' : 'm_n'; |
@@ -1003,15 +1003,15 @@ discard block |
||
| 1003 | 1003 | case 'GIVN': |
| 1004 | 1004 | switch ($modifiers[$field_name]) { |
| 1005 | 1005 | case 'EXACT': |
| 1006 | - $sql .= " AND {$table}.n_givn=?"; |
|
| 1006 | + $sql .= " AND {$table}.n_givn=?"; |
|
| 1007 | 1007 | $bind[] = $field_value; |
| 1008 | 1008 | break; |
| 1009 | 1009 | case 'BEGINS': |
| 1010 | - $sql .= " AND {$table}.n_givn LIKE CONCAT(?, '%')"; |
|
| 1010 | + $sql .= " AND {$table}.n_givn LIKE CONCAT(?, '%')"; |
|
| 1011 | 1011 | $bind[] = $field_value; |
| 1012 | 1012 | break; |
| 1013 | 1013 | case 'CONTAINS': |
| 1014 | - $sql .= " AND {$table}.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 1014 | + $sql .= " AND {$table}.n_givn LIKE CONCAT('%', ?, '%')"; |
|
| 1015 | 1015 | $bind[] = $field_value; |
| 1016 | 1016 | break; |
| 1017 | 1017 | case 'SDX_STD': |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; |
| 1026 | 1026 | } else { |
| 1027 | 1027 | // No phonetic content? Use a substring match |
| 1028 | - $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; |
|
| 1028 | + $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; |
|
| 1029 | 1029 | $bind[] = $field_value; |
| 1030 | 1030 | } |
| 1031 | 1031 | break; |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | break; |
| 1043 | 1043 | } else { |
| 1044 | 1044 | // No phonetic content? Use a substring match |
| 1045 | - $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; |
|
| 1045 | + $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; |
|
| 1046 | 1046 | $bind[] = $field_value; |
| 1047 | 1047 | } |
| 1048 | 1048 | } |
@@ -1050,15 +1050,15 @@ discard block |
||
| 1050 | 1050 | case 'SURN': |
| 1051 | 1051 | switch ($modifiers[$field_name]) { |
| 1052 | 1052 | case 'EXACT': |
| 1053 | - $sql .= " AND {$table}.n_surname=?"; |
|
| 1053 | + $sql .= " AND {$table}.n_surname=?"; |
|
| 1054 | 1054 | $bind[] = $field_value; |
| 1055 | 1055 | break; |
| 1056 | 1056 | case 'BEGINS': |
| 1057 | - $sql .= " AND {$table}.n_surname LIKE CONCAT(?, '%')"; |
|
| 1057 | + $sql .= " AND {$table}.n_surname LIKE CONCAT(?, '%')"; |
|
| 1058 | 1058 | $bind[] = $field_value; |
| 1059 | 1059 | break; |
| 1060 | 1060 | case 'CONTAINS': |
| 1061 | - $sql .= " AND {$table}.n_surname LIKE CONCAT('%', ?, '%')"; |
|
| 1061 | + $sql .= " AND {$table}.n_surname LIKE CONCAT('%', ?, '%')"; |
|
| 1062 | 1062 | $bind[] = $field_value; |
| 1063 | 1063 | break; |
| 1064 | 1064 | case 'SDX_STD': |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; |
| 1073 | 1073 | } else { |
| 1074 | 1074 | // No phonetic content? Use a substring match |
| 1075 | - $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; |
|
| 1075 | + $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; |
|
| 1076 | 1076 | $bind[] = $field_value; |
| 1077 | 1077 | } |
| 1078 | 1078 | break; |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; |
| 1089 | 1089 | } else { |
| 1090 | 1090 | // No phonetic content? Use a substring match |
| 1091 | - $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; |
|
| 1091 | + $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; |
|
| 1092 | 1092 | $bind[] = $field_value; |
| 1093 | 1093 | } |
| 1094 | 1094 | break; |
@@ -1097,17 +1097,17 @@ discard block |
||
| 1097 | 1097 | } |
| 1098 | 1098 | } elseif ($parts[0] === 'FAMS') { |
| 1099 | 1099 | // e.g. searches for occupation, religion, note, etc. |
| 1100 | - $sql .= " AND fam.f_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)"; |
|
| 1100 | + $sql .= " AND fam.f_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)"; |
|
| 1101 | 1101 | $bind[] = $parts[1]; |
| 1102 | 1102 | $bind[] = $field_value; |
| 1103 | 1103 | } elseif ($parts[1] === 'TYPE') { |
| 1104 | 1104 | // e.g. FACT:TYPE or EVEN:TYPE |
| 1105 | - $sql .= " AND ind.i_gedcom REGEXP CONCAT('\n1 ', ?, '.*(\n[2-9] .*)*\n2 TYPE .*', ?)"; |
|
| 1105 | + $sql .= " AND ind.i_gedcom REGEXP CONCAT('\n1 ', ?, '.*(\n[2-9] .*)*\n2 TYPE .*', ?)"; |
|
| 1106 | 1106 | $bind[] = $parts[0]; |
| 1107 | 1107 | $bind[] = $field_value; |
| 1108 | 1108 | } else { |
| 1109 | 1109 | // e.g. searches for occupation, religion, note, etc. |
| 1110 | - $sql .= " AND ind.i_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)"; |
|
| 1110 | + $sql .= " AND ind.i_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)"; |
|
| 1111 | 1111 | $bind[] = $parts[0]; |
| 1112 | 1112 | $bind[] = $field_value; |
| 1113 | 1113 | } |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | $sql .= ")"; |
| 1186 | 1186 | |
| 1187 | 1187 | if ($givn_sdx !== '') { |
| 1188 | - $sql .= " AND ("; |
|
| 1188 | + $sql .= " AND ("; |
|
| 1189 | 1189 | $givn_sdx = explode(':', $givn_sdx); |
| 1190 | 1190 | foreach ($givn_sdx as $n => $sdx) { |
| 1191 | 1191 | $sql .= $n > 0 ? " OR " : ""; |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | if ($surn_sdx !== '') { |
| 1206 | - $sql .= " AND ("; |
|
| 1206 | + $sql .= " AND ("; |
|
| 1207 | 1207 | $surn_sdx = explode(':', $surn_sdx); |
| 1208 | 1208 | foreach ($surn_sdx as $n => $sdx) { |
| 1209 | 1209 | $sql .= $n ? " OR " : ""; |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | if ($plac_sdx !== '') { |
| 1224 | - $sql .= " AND ("; |
|
| 1224 | + $sql .= " AND ("; |
|
| 1225 | 1225 | $plac_sdx = explode(':', $plac_sdx); |
| 1226 | 1226 | foreach ($plac_sdx as $n => $sdx) { |
| 1227 | 1227 | $sql .= $n ? " OR " : ""; |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | |
| 1268 | 1268 | foreach ($search_terms as $n => $q) { |
| 1269 | 1269 | $queryregex[] = preg_quote(I18N::strtoupper($q), '/'); |
| 1270 | - $sql .= " AND o_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 1270 | + $sql .= " AND o_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 1271 | 1271 | $args['collate_' . $n] = I18N::collation(); |
| 1272 | 1272 | $args['query_' . $n] = Database::escapeLike($q); |
| 1273 | 1273 | } |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | |
| 1323 | 1323 | foreach ($search_terms as $n => $q) { |
| 1324 | 1324 | $queryregex[] = preg_quote(I18N::strtoupper($q), '/'); |
| 1325 | - $sql .= " AND o_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 1325 | + $sql .= " AND o_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 1326 | 1326 | $args['collate_' . $n] = I18N::collation(); |
| 1327 | 1327 | $args['query_' . $n] = Database::escapeLike($q); |
| 1328 | 1328 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | |
| 1378 | 1378 | foreach ($search_terms as $n => $q) { |
| 1379 | 1379 | $queryregex[] = preg_quote(I18N::strtoupper($q), '/'); |
| 1380 | - $sql .= " AND s_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 1380 | + $sql .= " AND s_gedcom COLLATE :collate_" . $n . " LIKE CONCAT('%', :query_" . $n . ", '%')"; |
|
| 1381 | 1381 | $args['collate_' . $n] = I18N::collation(); |
| 1382 | 1382 | $args['query_' . $n] = Database::escapeLike($q); |
| 1383 | 1383 | } |