@@ -31,471 +31,471 @@ |
||
31 | 31 | $type = Filter::get('field'); |
32 | 32 | |
33 | 33 | switch ($type) { |
34 | -case 'ASSO': // Associates of an individuals, whose name contains the search terms |
|
35 | - $data = array(); |
|
36 | - // Fetch all data, regardless of privacy |
|
37 | - $rows = Database::prepare( |
|
38 | - "SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" . |
|
39 | - " FROM `##individuals`" . |
|
40 | - " JOIN `##name` ON i_id = n_id AND i_file = n_file" . |
|
41 | - " WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" . |
|
42 | - " ORDER BY n_full COLLATE :collate" |
|
43 | - )->execute(array( |
|
44 | - 'term_1' => $term, |
|
45 | - 'term_2' => $term, |
|
46 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
47 | - 'collate' => I18N::collation(), |
|
48 | - ))->fetchAll(); |
|
49 | - |
|
50 | - // Filter for privacy and whether they could be alive at the right time |
|
51 | - $event_date = Filter::get('extra'); |
|
52 | - $date = new Date($event_date); |
|
53 | - $event_jd = $date->julianDay(); |
|
54 | - foreach ($rows as $row) { |
|
55 | - $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
56 | - if ($person->canShow()) { |
|
57 | - if ($event_jd) { |
|
58 | - // Exclude individuals who were born after the event. |
|
59 | - $person_birth_jd = $person->getEstimatedBirthDate()->minimumJulianDay(); |
|
60 | - if ($person_birth_jd && $person_birth_jd > $event_jd) { |
|
61 | - continue; |
|
34 | + case 'ASSO': // Associates of an individuals, whose name contains the search terms |
|
35 | + $data = array(); |
|
36 | + // Fetch all data, regardless of privacy |
|
37 | + $rows = Database::prepare( |
|
38 | + "SELECT 'INDI' AS type, i_id AS xref, i_gedcom AS gedcom, n_full" . |
|
39 | + " FROM `##individuals`" . |
|
40 | + " JOIN `##name` ON i_id = n_id AND i_file = n_file" . |
|
41 | + " WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" . |
|
42 | + " ORDER BY n_full COLLATE :collate" |
|
43 | + )->execute(array( |
|
44 | + 'term_1' => $term, |
|
45 | + 'term_2' => $term, |
|
46 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
47 | + 'collate' => I18N::collation(), |
|
48 | + ))->fetchAll(); |
|
49 | + |
|
50 | + // Filter for privacy and whether they could be alive at the right time |
|
51 | + $event_date = Filter::get('extra'); |
|
52 | + $date = new Date($event_date); |
|
53 | + $event_jd = $date->julianDay(); |
|
54 | + foreach ($rows as $row) { |
|
55 | + $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
56 | + if ($person->canShow()) { |
|
57 | + if ($event_jd) { |
|
58 | + // Exclude individuals who were born after the event. |
|
59 | + $person_birth_jd = $person->getEstimatedBirthDate()->minimumJulianDay(); |
|
60 | + if ($person_birth_jd && $person_birth_jd > $event_jd) { |
|
61 | + continue; |
|
62 | + } |
|
63 | + // Exclude individuals who died before the event. |
|
64 | + $person_death_jd = $person->getEstimatedDeathDate()->maximumJulianDay(); |
|
65 | + if ($person_death_jd && $person_death_jd < $event_jd) { |
|
66 | + continue; |
|
67 | + } |
|
62 | 68 | } |
63 | - // Exclude individuals who died before the event. |
|
64 | - $person_death_jd = $person->getEstimatedDeathDate()->maximumJulianDay(); |
|
65 | - if ($person_death_jd && $person_death_jd < $event_jd) { |
|
66 | - continue; |
|
69 | + // Add the age (if we have it) or the lifespan (if we do not). |
|
70 | + $label = $person->getFullName(); |
|
71 | + if ($event_jd && $person->getBirthDate()->isOK()) { |
|
72 | + $label .= ', <span class="age">(' . I18N::translate('Age') . ' ' . Date::getAge($person->getBirthDate(), $date, 0) . ')</span>'; |
|
73 | + } else { |
|
74 | + $label .= ', <i>' . $person->getLifeSpan() . '</i>'; |
|
67 | 75 | } |
68 | - } |
|
69 | - // Add the age (if we have it) or the lifespan (if we do not). |
|
70 | - $label = $person->getFullName(); |
|
71 | - if ($event_jd && $person->getBirthDate()->isOK()) { |
|
72 | - $label .= ', <span class="age">(' . I18N::translate('Age') . ' ' . Date::getAge($person->getBirthDate(), $date, 0) . ')</span>'; |
|
73 | - } else { |
|
74 | - $label .= ', <i>' . $person->getLifeSpan() . '</i>'; |
|
75 | - } |
|
76 | - $data[$row->xref] = array('value' => $row->xref, 'label' => $label); |
|
77 | - } |
|
78 | - } |
|
79 | - echo json_encode($data); |
|
80 | - |
|
81 | - return; |
|
82 | - |
|
83 | -case 'CEME': // Cemetery fields, that contain the search term |
|
84 | - $data = array(); |
|
85 | - // Fetch all data, regardless of privacy |
|
86 | - $rows = Database::prepare( |
|
87 | - "SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" . |
|
88 | - " FROM `##individuals`" . |
|
89 | - " WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" . |
|
90 | - " ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation" |
|
91 | - )->execute(array( |
|
92 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
93 | - 'collation' => I18N::collation(), |
|
94 | - ))->fetchAll(); |
|
95 | - // Filter for privacy |
|
96 | - foreach ($rows as $row) { |
|
97 | - $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
98 | - if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) { |
|
99 | - if (!in_array($match[1], $data)) { |
|
100 | - $data[] = $match[1]; |
|
76 | + $data[$row->xref] = array('value' => $row->xref, 'label' => $label); |
|
101 | 77 | } |
102 | 78 | } |
103 | - } |
|
104 | - echo json_encode($data); |
|
105 | - |
|
106 | - return; |
|
107 | - |
|
108 | -case 'FAM': // Families, whose name contains the search terms |
|
109 | - $data = array(); |
|
110 | - // Fetch all data, regardless of privacy |
|
111 | - $rows = get_FAM_rows($WT_TREE, $term); |
|
112 | - // Filter for privacy |
|
113 | - foreach ($rows as $row) { |
|
114 | - $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
115 | - if ($family->canShowName()) { |
|
116 | - $marriage_year = $family->getMarriageYear(); |
|
117 | - if ($marriage_year) { |
|
118 | - $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); |
|
119 | - } else { |
|
120 | - $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - echo json_encode($data); |
|
125 | - |
|
126 | - return; |
|
127 | - |
|
128 | -case 'GIVN': // Given names, that start with the search term |
|
129 | - // Do not filter by privacy. Given names on their own do not identify individuals. |
|
130 | - echo json_encode( |
|
131 | - Database::prepare( |
|
132 | - "SELECT SQL_CACHE DISTINCT n_givn" . |
|
133 | - " FROM `##name`" . |
|
134 | - " WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" . |
|
135 | - " ORDER BY n_givn COLLATE :collation" |
|
79 | + echo json_encode($data); |
|
80 | + |
|
81 | + return; |
|
82 | + |
|
83 | + case 'CEME': // Cemetery fields, that contain the search term |
|
84 | + $data = array(); |
|
85 | + // Fetch all data, regardless of privacy |
|
86 | + $rows = Database::prepare( |
|
87 | + "SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" . |
|
88 | + " FROM `##individuals`" . |
|
89 | + " WHERE i_gedcom LIKE '%\n2 CEME %' AND i_file = :tree_id" . |
|
90 | + " ORDER BY SUBSTRING_INDEX(i_gedcom, '\n2 CEME ', -1) COLLATE :collation" |
|
136 | 91 | )->execute(array( |
137 | - 'term' => $term, |
|
138 | 92 | 'tree_id' => $WT_TREE->getTreeId(), |
139 | 93 | 'collation' => I18N::collation(), |
140 | - ))->fetchOneColumn() |
|
141 | - ); |
|
142 | - |
|
143 | - return; |
|
144 | - |
|
145 | -case 'INDI': // Individuals, whose name contains the search terms |
|
146 | - $data = array(); |
|
147 | - // Fetch all data, regardless of privacy |
|
148 | - $rows = Database::prepare( |
|
149 | - "SELECT i_id AS xref, i_gedcom AS gedcom, n_full" . |
|
150 | - " FROM `##individuals`" . |
|
151 | - " JOIN `##name` ON i_id = n_id AND i_file = n_file" . |
|
152 | - " WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" . |
|
153 | - " ORDER BY n_full COLLATE :collation" |
|
154 | - )->execute(array( |
|
155 | - 'term_1' => $term, |
|
156 | - 'term_2' => $term, |
|
157 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
158 | - 'collation' => I18N::collation(), |
|
159 | - ))->fetchAll(); |
|
160 | - // Filter for privacy |
|
161 | - foreach ($rows as $row) { |
|
162 | - $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
163 | - if ($person->canShowName()) { |
|
164 | - $data[] = array('value' => $row->xref, '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>'); |
|
165 | - } |
|
166 | - } |
|
167 | - echo json_encode($data); |
|
168 | - |
|
169 | - return; |
|
170 | - |
|
171 | -case 'NOTE': // Notes which contain the search terms |
|
172 | - $data = array(); |
|
173 | - // Fetch all data, regardless of privacy |
|
174 | - $rows = get_NOTE_rows($WT_TREE, $term); |
|
175 | - // Filter for privacy |
|
176 | - foreach ($rows as $row) { |
|
177 | - $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
178 | - if ($note->canShowName()) { |
|
179 | - $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName()); |
|
180 | - } |
|
181 | - } |
|
182 | - echo json_encode($data); |
|
183 | - |
|
184 | - return; |
|
185 | - |
|
186 | -case 'OBJE': |
|
187 | - $data = array(); |
|
188 | - // Fetch all data, regardless of privacy |
|
189 | - $rows = get_OBJE_rows($WT_TREE, $term); |
|
190 | - // Filter for privacy |
|
191 | - foreach ($rows as $row) { |
|
192 | - $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
193 | - if ($media->canShowName()) { |
|
194 | - $data[] = array('value' => $row->xref, 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName()); |
|
195 | - } |
|
196 | - } |
|
197 | - echo json_encode($data); |
|
198 | - |
|
199 | - return; |
|
200 | - |
|
201 | -case 'PLAC': // Place names (with hierarchy), that include the search term |
|
202 | - // Do not filter by privacy. Place names on their own do not identify individuals. |
|
203 | - $data = array(); |
|
204 | - foreach (Place::findPlaces($term, $WT_TREE) as $place) { |
|
205 | - $data[] = $place->getGedcomName(); |
|
206 | - } |
|
207 | - if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) { |
|
208 | - // No place found? Use an external gazetteer |
|
209 | - $url = |
|
210 | - "http://api.geonames.org/searchJSON" . |
|
211 | - "?name_startsWith=" . urlencode($term) . |
|
212 | - "&lang=" . WT_LOCALE . |
|
213 | - "&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" . |
|
214 | - "&style=full" . |
|
215 | - "&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT'); |
|
216 | - // try to use curl when file_get_contents not allowed |
|
217 | - if (ini_get('allow_url_fopen')) { |
|
218 | - $json = file_get_contents($url); |
|
219 | - } elseif (function_exists('curl_init')) { |
|
220 | - $ch = curl_init(); |
|
221 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
222 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
223 | - $json = curl_exec($ch); |
|
224 | - curl_close($ch); |
|
225 | - } else { |
|
226 | - return $data; |
|
94 | + ))->fetchAll(); |
|
95 | + // Filter for privacy |
|
96 | + foreach ($rows as $row) { |
|
97 | + $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
98 | + if (preg_match('/\n2 CEME (.*' . preg_quote($term, '/') . '.*)/i', $person->getGedcom(), $match)) { |
|
99 | + if (!in_array($match[1], $data)) { |
|
100 | + $data[] = $match[1]; |
|
101 | + } |
|
102 | + } |
|
227 | 103 | } |
228 | - $places = json_decode($json, true); |
|
229 | - if (isset($places['geonames']) && is_array($places['geonames'])) { |
|
230 | - foreach ($places['geonames'] as $k => $place) { |
|
231 | - $data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName']; |
|
104 | + echo json_encode($data); |
|
105 | + |
|
106 | + return; |
|
107 | + |
|
108 | + case 'FAM': // Families, whose name contains the search terms |
|
109 | + $data = array(); |
|
110 | + // Fetch all data, regardless of privacy |
|
111 | + $rows = get_FAM_rows($WT_TREE, $term); |
|
112 | + // Filter for privacy |
|
113 | + foreach ($rows as $row) { |
|
114 | + $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
115 | + if ($family->canShowName()) { |
|
116 | + $marriage_year = $family->getMarriageYear(); |
|
117 | + if ($marriage_year) { |
|
118 | + $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); |
|
119 | + } else { |
|
120 | + $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); |
|
121 | + } |
|
232 | 122 | } |
233 | 123 | } |
234 | - } |
|
235 | - echo json_encode($data); |
|
236 | - |
|
237 | - return; |
|
238 | - |
|
239 | -case 'PLAC2': // Place names (without hierarchy), that include the search term |
|
240 | - // Do not filter by privacy. Place names on their own do not identify individuals. |
|
241 | - echo json_encode( |
|
242 | - Database::prepare( |
|
243 | - "SELECT SQL_CACHE p_place" . |
|
244 | - " FROM `##places`" . |
|
245 | - " WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" . |
|
246 | - " ORDER BY p_place COLLATE :collation" |
|
124 | + echo json_encode($data); |
|
125 | + |
|
126 | + return; |
|
127 | + |
|
128 | + case 'GIVN': // Given names, that start with the search term |
|
129 | + // Do not filter by privacy. Given names on their own do not identify individuals. |
|
130 | + echo json_encode( |
|
131 | + Database::prepare( |
|
132 | + "SELECT SQL_CACHE DISTINCT n_givn" . |
|
133 | + " FROM `##name`" . |
|
134 | + " WHERE n_givn LIKE CONCAT(:term, '%') AND n_file = :tree_id" . |
|
135 | + " ORDER BY n_givn COLLATE :collation" |
|
136 | + )->execute(array( |
|
137 | + 'term' => $term, |
|
138 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
139 | + 'collation' => I18N::collation(), |
|
140 | + ))->fetchOneColumn() |
|
141 | + ); |
|
142 | + |
|
143 | + return; |
|
144 | + |
|
145 | + case 'INDI': // Individuals, whose name contains the search terms |
|
146 | + $data = array(); |
|
147 | + // Fetch all data, regardless of privacy |
|
148 | + $rows = Database::prepare( |
|
149 | + "SELECT i_id AS xref, i_gedcom AS gedcom, n_full" . |
|
150 | + " FROM `##individuals`" . |
|
151 | + " JOIN `##name` ON i_id = n_id AND i_file = n_file" . |
|
152 | + " WHERE (n_full LIKE CONCAT('%', REPLACE(:term_1, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(:term_2, ' ', '%'), '%')) AND i_file = :tree_id" . |
|
153 | + " ORDER BY n_full COLLATE :collation" |
|
247 | 154 | )->execute(array( |
248 | - 'term' => $term, |
|
155 | + 'term_1' => $term, |
|
156 | + 'term_2' => $term, |
|
249 | 157 | 'tree_id' => $WT_TREE->getTreeId(), |
250 | 158 | 'collation' => I18N::collation(), |
251 | - ))->fetchOneColumn() |
|
252 | - ); |
|
253 | - |
|
254 | - return; |
|
255 | - |
|
256 | -case 'REPO': // Repositories, that include the search terms |
|
257 | - $data = array(); |
|
258 | - // Fetch all data, regardless of privacy |
|
259 | - $rows = get_REPO_rows($WT_TREE, $term); |
|
260 | - // Filter for privacy |
|
261 | - foreach ($rows as $row) { |
|
262 | - $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
263 | - if ($record->canShowName()) { |
|
264 | - foreach ($record->getFacts('NAME') as $fact) { |
|
265 | - $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue()); |
|
159 | + ))->fetchAll(); |
|
160 | + // Filter for privacy |
|
161 | + foreach ($rows as $row) { |
|
162 | + $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
163 | + if ($person->canShowName()) { |
|
164 | + $data[] = array('value' => $row->xref, '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>'); |
|
266 | 165 | } |
267 | 166 | } |
268 | - } |
|
269 | - echo json_encode($data); |
|
270 | - |
|
271 | - return; |
|
272 | - |
|
273 | -case 'REPO_NAME': // Repository names, that include the search terms |
|
274 | - $data = array(); |
|
275 | - // Fetch all data, regardless of privacy |
|
276 | - $rows = get_REPO_rows($WT_TREE, $term); |
|
277 | - // Filter for privacy |
|
278 | - foreach ($rows as $row) { |
|
279 | - $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
280 | - if ($record->canShowName()) { |
|
281 | - $data[] = strip_tags($record->getFullName()); |
|
167 | + echo json_encode($data); |
|
168 | + |
|
169 | + return; |
|
170 | + |
|
171 | + case 'NOTE': // Notes which contain the search terms |
|
172 | + $data = array(); |
|
173 | + // Fetch all data, regardless of privacy |
|
174 | + $rows = get_NOTE_rows($WT_TREE, $term); |
|
175 | + // Filter for privacy |
|
176 | + foreach ($rows as $row) { |
|
177 | + $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
178 | + if ($note->canShowName()) { |
|
179 | + $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName()); |
|
180 | + } |
|
282 | 181 | } |
283 | - } |
|
284 | - echo json_encode($data); |
|
285 | - |
|
286 | - return; |
|
287 | - |
|
288 | -case 'SOUR': // Sources, that include the search terms |
|
289 | - $data = array(); |
|
290 | - // Fetch all data, regardless of privacy |
|
291 | - $rows = get_SOUR_rows($WT_TREE, $term); |
|
292 | - // Filter for privacy |
|
293 | - foreach ($rows as $row) { |
|
294 | - $record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
295 | - if ($record->canShowName()) { |
|
296 | - foreach ($record->getFacts('TITL') as $fact) { |
|
297 | - $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue()); |
|
182 | + echo json_encode($data); |
|
183 | + |
|
184 | + return; |
|
185 | + |
|
186 | + case 'OBJE': |
|
187 | + $data = array(); |
|
188 | + // Fetch all data, regardless of privacy |
|
189 | + $rows = get_OBJE_rows($WT_TREE, $term); |
|
190 | + // Filter for privacy |
|
191 | + foreach ($rows as $row) { |
|
192 | + $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
193 | + if ($media->canShowName()) { |
|
194 | + $data[] = array('value' => $row->xref, 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName()); |
|
298 | 195 | } |
299 | 196 | } |
300 | - } |
|
301 | - echo json_encode($data); |
|
197 | + echo json_encode($data); |
|
302 | 198 | |
303 | - return; |
|
199 | + return; |
|
304 | 200 | |
305 | -case 'PAGE': // Citation details, for a given source, that contain the search term |
|
306 | - $data = array(); |
|
307 | - $sid = Filter::get('extra', WT_REGEX_XREF); |
|
308 | - // Fetch all data, regardless of privacy |
|
309 | - $rows = Database::prepare( |
|
310 | - "SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" . |
|
311 | - " FROM `##individuals`" . |
|
312 | - " WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id" |
|
313 | - )->execute(array( |
|
314 | - 'xref' => $sid, |
|
315 | - 'term' => $term, |
|
316 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
317 | - ))->fetchAll(); |
|
318 | - // Filter for privacy |
|
319 | - foreach ($rows as $row) { |
|
320 | - $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
321 | - if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) { |
|
322 | - $data[] = $match[1]; |
|
201 | + case 'PLAC': // Place names (with hierarchy), that include the search term |
|
202 | + // Do not filter by privacy. Place names on their own do not identify individuals. |
|
203 | + $data = array(); |
|
204 | + foreach (Place::findPlaces($term, $WT_TREE) as $place) { |
|
205 | + $data[] = $place->getGedcomName(); |
|
323 | 206 | } |
324 | - if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) { |
|
325 | - $data[] = $match[1]; |
|
207 | + if (!$data && $WT_TREE->getPreference('GEONAMES_ACCOUNT')) { |
|
208 | + // No place found? Use an external gazetteer |
|
209 | + $url = |
|
210 | + "http://api.geonames.org/searchJSON" . |
|
211 | + "?name_startsWith=" . urlencode($term) . |
|
212 | + "&lang=" . WT_LOCALE . |
|
213 | + "&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC" . |
|
214 | + "&style=full" . |
|
215 | + "&username=" . $WT_TREE->getPreference('GEONAMES_ACCOUNT'); |
|
216 | + // try to use curl when file_get_contents not allowed |
|
217 | + if (ini_get('allow_url_fopen')) { |
|
218 | + $json = file_get_contents($url); |
|
219 | + } elseif (function_exists('curl_init')) { |
|
220 | + $ch = curl_init(); |
|
221 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
222 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
223 | + $json = curl_exec($ch); |
|
224 | + curl_close($ch); |
|
225 | + } else { |
|
226 | + return $data; |
|
227 | + } |
|
228 | + $places = json_decode($json, true); |
|
229 | + if (isset($places['geonames']) && is_array($places['geonames'])) { |
|
230 | + foreach ($places['geonames'] as $k => $place) { |
|
231 | + $data[] = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName']; |
|
232 | + } |
|
233 | + } |
|
326 | 234 | } |
327 | - } |
|
328 | - // Fetch all data, regardless of privacy |
|
329 | - $rows = Database::prepare( |
|
330 | - "SELECT SQL_CACHE f_id AS xref, f_gedcom AS gedcom" . |
|
331 | - " FROM `##families`" . |
|
332 | - " WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id" |
|
333 | - )->execute(array( |
|
334 | - 'xref' => $sid, |
|
335 | - 'term' => $term, |
|
336 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
337 | - ))->fetchAll(); |
|
338 | - // Filter for privacy |
|
339 | - foreach ($rows as $row) { |
|
340 | - $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
341 | - if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) { |
|
342 | - $data[] = $match[1]; |
|
235 | + echo json_encode($data); |
|
236 | + |
|
237 | + return; |
|
238 | + |
|
239 | + case 'PLAC2': // Place names (without hierarchy), that include the search term |
|
240 | + // Do not filter by privacy. Place names on their own do not identify individuals. |
|
241 | + echo json_encode( |
|
242 | + Database::prepare( |
|
243 | + "SELECT SQL_CACHE p_place" . |
|
244 | + " FROM `##places`" . |
|
245 | + " WHERE p_place LIKE CONCAT('%', :term, '%') AND p_file = :tree_id" . |
|
246 | + " ORDER BY p_place COLLATE :collation" |
|
247 | + )->execute(array( |
|
248 | + 'term' => $term, |
|
249 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
250 | + 'collation' => I18N::collation(), |
|
251 | + ))->fetchOneColumn() |
|
252 | + ); |
|
253 | + |
|
254 | + return; |
|
255 | + |
|
256 | + case 'REPO': // Repositories, that include the search terms |
|
257 | + $data = array(); |
|
258 | + // Fetch all data, regardless of privacy |
|
259 | + $rows = get_REPO_rows($WT_TREE, $term); |
|
260 | + // Filter for privacy |
|
261 | + foreach ($rows as $row) { |
|
262 | + $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
263 | + if ($record->canShowName()) { |
|
264 | + foreach ($record->getFacts('NAME') as $fact) { |
|
265 | + $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue()); |
|
266 | + } |
|
267 | + } |
|
343 | 268 | } |
344 | - if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) { |
|
345 | - $data[] = $match[1]; |
|
269 | + echo json_encode($data); |
|
270 | + |
|
271 | + return; |
|
272 | + |
|
273 | + case 'REPO_NAME': // Repository names, that include the search terms |
|
274 | + $data = array(); |
|
275 | + // Fetch all data, regardless of privacy |
|
276 | + $rows = get_REPO_rows($WT_TREE, $term); |
|
277 | + // Filter for privacy |
|
278 | + foreach ($rows as $row) { |
|
279 | + $record = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
280 | + if ($record->canShowName()) { |
|
281 | + $data[] = strip_tags($record->getFullName()); |
|
282 | + } |
|
346 | 283 | } |
347 | - } |
|
348 | - // array_unique() converts the keys from integer to string, which breaks |
|
349 | - // the JSON encoding - so need to call array_values() to convert them |
|
350 | - // back into integers. |
|
351 | - $data = array_values(array_unique($data)); |
|
352 | - echo json_encode($data); |
|
353 | - |
|
354 | - return; |
|
355 | - |
|
356 | -case 'SOUR_TITL': // Source titles, that include the search terms |
|
357 | - $data = array(); |
|
358 | - // Fetch all data, regardless of privacy |
|
359 | - $rows = Database::prepare( |
|
360 | - "SELECT s_id AS xref, s_gedcom AS gedcom, s_name" . |
|
361 | - " FROM `##sources`" . |
|
362 | - " WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" . |
|
363 | - " ORDER BY s_name COLLATE :collation" |
|
364 | - )->execute(array( |
|
365 | - 'term' => $term, |
|
366 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
367 | - 'collation' => I18N::collation(), |
|
368 | - ))->fetchAll(); |
|
369 | - // Filter for privacy |
|
370 | - foreach ($rows as $row) { |
|
371 | - $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
372 | - if ($source->canShowName()) { |
|
373 | - $data[] = $row->s_name; |
|
284 | + echo json_encode($data); |
|
285 | + |
|
286 | + return; |
|
287 | + |
|
288 | + case 'SOUR': // Sources, that include the search terms |
|
289 | + $data = array(); |
|
290 | + // Fetch all data, regardless of privacy |
|
291 | + $rows = get_SOUR_rows($WT_TREE, $term); |
|
292 | + // Filter for privacy |
|
293 | + foreach ($rows as $row) { |
|
294 | + $record = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
295 | + if ($record->canShowName()) { |
|
296 | + foreach ($record->getFacts('TITL') as $fact) { |
|
297 | + $data[] = array('value' => $record->getXref(), 'label' => $fact->getValue()); |
|
298 | + } |
|
299 | + } |
|
374 | 300 | } |
375 | - } |
|
376 | - echo json_encode($data); |
|
377 | - |
|
378 | - return; |
|
379 | - |
|
380 | -case 'SURN': // Surnames, that start with the search term |
|
381 | - // Do not filter by privacy. Surnames on their own do not identify individuals. |
|
382 | - echo json_encode( |
|
383 | - Database::prepare( |
|
384 | - "SELECT SQL_CACHE DISTINCT n_surname" . |
|
385 | - " FROM `##name`" . |
|
386 | - " WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" . |
|
387 | - " ORDER BY n_surname COLLATE :collation" |
|
301 | + echo json_encode($data); |
|
302 | + |
|
303 | + return; |
|
304 | + |
|
305 | + case 'PAGE': // Citation details, for a given source, that contain the search term |
|
306 | + $data = array(); |
|
307 | + $sid = Filter::get('extra', WT_REGEX_XREF); |
|
308 | + // Fetch all data, regardless of privacy |
|
309 | + $rows = Database::prepare( |
|
310 | + "SELECT SQL_CACHE i_id AS xref, i_gedcom AS gedcom" . |
|
311 | + " FROM `##individuals`" . |
|
312 | + " WHERE i_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND i_file = :tree_id" |
|
313 | + )->execute(array( |
|
314 | + 'xref' => $sid, |
|
315 | + 'term' => $term, |
|
316 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
317 | + ))->fetchAll(); |
|
318 | + // Filter for privacy |
|
319 | + foreach ($rows as $row) { |
|
320 | + $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
321 | + if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) { |
|
322 | + $data[] = $match[1]; |
|
323 | + } |
|
324 | + if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $person->getGedcom(), $match)) { |
|
325 | + $data[] = $match[1]; |
|
326 | + } |
|
327 | + } |
|
328 | + // Fetch all data, regardless of privacy |
|
329 | + $rows = Database::prepare( |
|
330 | + "SELECT SQL_CACHE f_id AS xref, f_gedcom AS gedcom" . |
|
331 | + " FROM `##families`" . |
|
332 | + " WHERE f_gedcom LIKE CONCAT('%\n_ SOUR @', :xref, '@%', REPLACE(:term, ' ', '%'), '%') AND f_file = :tree_id" |
|
333 | + )->execute(array( |
|
334 | + 'xref' => $sid, |
|
335 | + 'term' => $term, |
|
336 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
337 | + ))->fetchAll(); |
|
338 | + // Filter for privacy |
|
339 | + foreach ($rows as $row) { |
|
340 | + $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
341 | + if (preg_match('/\n1 SOUR @' . $sid . '@(?:\n[2-9].*)*\n2 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) { |
|
342 | + $data[] = $match[1]; |
|
343 | + } |
|
344 | + if (preg_match('/\n2 SOUR @' . $sid . '@(?:\n[3-9].*)*\n3 PAGE (.*' . str_replace(' ', '.+', preg_quote($term, '/')) . '.*)/i', $family->getGedcom(), $match)) { |
|
345 | + $data[] = $match[1]; |
|
346 | + } |
|
347 | + } |
|
348 | + // array_unique() converts the keys from integer to string, which breaks |
|
349 | + // the JSON encoding - so need to call array_values() to convert them |
|
350 | + // back into integers. |
|
351 | + $data = array_values(array_unique($data)); |
|
352 | + echo json_encode($data); |
|
353 | + |
|
354 | + return; |
|
355 | + |
|
356 | + case 'SOUR_TITL': // Source titles, that include the search terms |
|
357 | + $data = array(); |
|
358 | + // Fetch all data, regardless of privacy |
|
359 | + $rows = Database::prepare( |
|
360 | + "SELECT s_id AS xref, s_gedcom AS gedcom, s_name" . |
|
361 | + " FROM `##sources`" . |
|
362 | + " WHERE s_name LIKE CONCAT('%', REPLACE(:term, ' ', '%'), '%') AND s_file = :tree_id" . |
|
363 | + " ORDER BY s_name COLLATE :collation" |
|
388 | 364 | )->execute(array( |
389 | 365 | 'term' => $term, |
390 | 366 | 'tree_id' => $WT_TREE->getTreeId(), |
391 | 367 | 'collation' => I18N::collation(), |
392 | - ))->fetchOneColumn() |
|
393 | - ); |
|
394 | - |
|
395 | - return; |
|
396 | - |
|
397 | -case 'IFSRO': |
|
398 | - $data = array(); |
|
399 | - // Fetch all data, regardless of privacy |
|
400 | - $rows = get_INDI_rows($WT_TREE, $term); |
|
401 | - // Filter for privacy |
|
402 | - foreach ($rows as $row) { |
|
403 | - $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
404 | - if ($person->canShowName()) { |
|
405 | - $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>'); |
|
368 | + ))->fetchAll(); |
|
369 | + // Filter for privacy |
|
370 | + foreach ($rows as $row) { |
|
371 | + $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
372 | + if ($source->canShowName()) { |
|
373 | + $data[] = $row->s_name; |
|
374 | + } |
|
406 | 375 | } |
407 | - } |
|
408 | - // Fetch all data, regardless of privacy |
|
409 | - $rows = get_SOUR_rows($WT_TREE, $term); |
|
410 | - // Filter for privacy |
|
411 | - foreach ($rows as $row) { |
|
412 | - $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
413 | - if ($source->canShowName()) { |
|
414 | - $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName()); |
|
376 | + echo json_encode($data); |
|
377 | + |
|
378 | + return; |
|
379 | + |
|
380 | + case 'SURN': // Surnames, that start with the search term |
|
381 | + // Do not filter by privacy. Surnames on their own do not identify individuals. |
|
382 | + echo json_encode( |
|
383 | + Database::prepare( |
|
384 | + "SELECT SQL_CACHE DISTINCT n_surname" . |
|
385 | + " FROM `##name`" . |
|
386 | + " WHERE n_surname LIKE CONCAT(:term, '%') AND n_file = :tree_id" . |
|
387 | + " ORDER BY n_surname COLLATE :collation" |
|
388 | + )->execute(array( |
|
389 | + 'term' => $term, |
|
390 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
391 | + 'collation' => I18N::collation(), |
|
392 | + ))->fetchOneColumn() |
|
393 | + ); |
|
394 | + |
|
395 | + return; |
|
396 | + |
|
397 | + case 'IFSRO': |
|
398 | + $data = array(); |
|
399 | + // Fetch all data, regardless of privacy |
|
400 | + $rows = get_INDI_rows($WT_TREE, $term); |
|
401 | + // Filter for privacy |
|
402 | + foreach ($rows as $row) { |
|
403 | + $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
404 | + if ($person->canShowName()) { |
|
405 | + $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>'); |
|
406 | + } |
|
415 | 407 | } |
416 | - } |
|
417 | - // Fetch all data, regardless of privacy |
|
418 | - $rows = get_REPO_rows($WT_TREE, $term); |
|
419 | - // Filter for privacy |
|
420 | - foreach ($rows as $row) { |
|
421 | - $repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
422 | - if ($repository->canShowName()) { |
|
423 | - $data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName()); |
|
408 | + // Fetch all data, regardless of privacy |
|
409 | + $rows = get_SOUR_rows($WT_TREE, $term); |
|
410 | + // Filter for privacy |
|
411 | + foreach ($rows as $row) { |
|
412 | + $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
413 | + if ($source->canShowName()) { |
|
414 | + $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName()); |
|
415 | + } |
|
424 | 416 | } |
425 | - } |
|
426 | - // Fetch all data, regardless of privacy |
|
427 | - $rows = get_OBJE_rows($WT_TREE, $term); |
|
428 | - // Filter for privacy |
|
429 | - foreach ($rows as $row) { |
|
430 | - $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
431 | - if ($media->canShowName()) { |
|
432 | - $data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName()); |
|
417 | + // Fetch all data, regardless of privacy |
|
418 | + $rows = get_REPO_rows($WT_TREE, $term); |
|
419 | + // Filter for privacy |
|
420 | + foreach ($rows as $row) { |
|
421 | + $repository = Repository::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
422 | + if ($repository->canShowName()) { |
|
423 | + $data[] = array('value' => $repository->getXref(), 'label' => $repository->getFullName()); |
|
424 | + } |
|
433 | 425 | } |
434 | - } |
|
435 | - // Fetch all data, regardless of privacy |
|
436 | - $rows = get_FAM_rows($WT_TREE, $term); |
|
437 | - // Filter for privacy |
|
438 | - foreach ($rows as $row) { |
|
439 | - $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
440 | - if ($family->canShowName()) { |
|
441 | - $marriage_year = $family->getMarriageYear(); |
|
442 | - if ($marriage_year) { |
|
443 | - $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); |
|
444 | - } else { |
|
445 | - $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); |
|
426 | + // Fetch all data, regardless of privacy |
|
427 | + $rows = get_OBJE_rows($WT_TREE, $term); |
|
428 | + // Filter for privacy |
|
429 | + foreach ($rows as $row) { |
|
430 | + $media = Media::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
431 | + if ($media->canShowName()) { |
|
432 | + $data[] = array('value' => $media->getXref(), 'label' => '<img src="' . $media->getHtmlUrlDirect() . '" width="25"> ' . $media->getFullName()); |
|
433 | + } |
|
434 | + } |
|
435 | + // Fetch all data, regardless of privacy |
|
436 | + $rows = get_FAM_rows($WT_TREE, $term); |
|
437 | + // Filter for privacy |
|
438 | + foreach ($rows as $row) { |
|
439 | + $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
440 | + if ($family->canShowName()) { |
|
441 | + $marriage_year = $family->getMarriageYear(); |
|
442 | + if ($marriage_year) { |
|
443 | + $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); |
|
444 | + } else { |
|
445 | + $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); |
|
446 | + } |
|
446 | 447 | } |
447 | 448 | } |
448 | - } |
|
449 | - // Fetch all data, regardless of privacy |
|
450 | - $rows = get_NOTE_rows($WT_TREE, $term); |
|
451 | - // Filter for privacy |
|
452 | - foreach ($rows as $row) { |
|
453 | - $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
454 | - if ($note->canShowName()) { |
|
455 | - $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName()); |
|
449 | + // Fetch all data, regardless of privacy |
|
450 | + $rows = get_NOTE_rows($WT_TREE, $term); |
|
451 | + // Filter for privacy |
|
452 | + foreach ($rows as $row) { |
|
453 | + $note = Note::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
454 | + if ($note->canShowName()) { |
|
455 | + $data[] = array('value' => $note->getXref(), 'label' => $note->getFullName()); |
|
456 | + } |
|
456 | 457 | } |
457 | - } |
|
458 | - echo json_encode($data); |
|
459 | - |
|
460 | - return; |
|
461 | - |
|
462 | -case 'IFS': |
|
463 | - $data = array(); |
|
464 | - // Fetch all data, regardless of privacy |
|
465 | - $rows = get_INDI_rows($WT_TREE, $term); |
|
466 | - // Filter for privacy |
|
467 | - foreach ($rows as $row) { |
|
468 | - $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
469 | - if ($person->canShowName()) { |
|
470 | - $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>'); |
|
458 | + echo json_encode($data); |
|
459 | + |
|
460 | + return; |
|
461 | + |
|
462 | + case 'IFS': |
|
463 | + $data = array(); |
|
464 | + // Fetch all data, regardless of privacy |
|
465 | + $rows = get_INDI_rows($WT_TREE, $term); |
|
466 | + // Filter for privacy |
|
467 | + foreach ($rows as $row) { |
|
468 | + $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
469 | + if ($person->canShowName()) { |
|
470 | + $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>'); |
|
471 | + } |
|
471 | 472 | } |
472 | - } |
|
473 | - // Fetch all data, regardless of privacy |
|
474 | - $rows = get_SOUR_rows($WT_TREE, $term); |
|
475 | - // Filter for privacy |
|
476 | - foreach ($rows as $row) { |
|
477 | - $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
478 | - if ($source->canShowName()) { |
|
479 | - $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName()); |
|
473 | + // Fetch all data, regardless of privacy |
|
474 | + $rows = get_SOUR_rows($WT_TREE, $term); |
|
475 | + // Filter for privacy |
|
476 | + foreach ($rows as $row) { |
|
477 | + $source = Source::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
478 | + if ($source->canShowName()) { |
|
479 | + $data[] = array('value' => $source->getXref(), 'label' => $source->getFullName()); |
|
480 | + } |
|
480 | 481 | } |
481 | - } |
|
482 | - // Fetch all data, regardless of privacy |
|
483 | - $rows = get_FAM_rows($WT_TREE, $term); |
|
484 | - // Filter for privacy |
|
485 | - foreach ($rows as $row) { |
|
486 | - $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
487 | - if ($family->canShowName()) { |
|
488 | - $marriage_year = $family->getMarriageYear(); |
|
489 | - if ($marriage_year) { |
|
490 | - $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); |
|
491 | - } else { |
|
492 | - $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); |
|
482 | + // Fetch all data, regardless of privacy |
|
483 | + $rows = get_FAM_rows($WT_TREE, $term); |
|
484 | + // Filter for privacy |
|
485 | + foreach ($rows as $row) { |
|
486 | + $family = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
487 | + if ($family->canShowName()) { |
|
488 | + $marriage_year = $family->getMarriageYear(); |
|
489 | + if ($marriage_year) { |
|
490 | + $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName() . ', <i>' . $marriage_year . '</i>'); |
|
491 | + } else { |
|
492 | + $data[] = array('value' => $family->getXref(), 'label' => $family->getFullName()); |
|
493 | + } |
|
493 | 494 | } |
494 | 495 | } |
495 | - } |
|
496 | - echo json_encode($data); |
|
496 | + echo json_encode($data); |
|
497 | 497 | |
498 | - return; |
|
498 | + return; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -38,75 +38,75 @@ discard block |
||
38 | 38 | |
39 | 39 | // Form actions |
40 | 40 | switch (Filter::post('action')) { |
41 | -case 'save': |
|
42 | - if (Filter::checkCsrf()) { |
|
43 | - $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
44 | - $ip_address_start = Filter::post('ip_address_start', WT_REGEX_IPV4); |
|
45 | - $ip_address_end = Filter::post('ip_address_end', WT_REGEX_IPV4); |
|
46 | - $user_agent_pattern = Filter::post('user_agent_pattern'); |
|
47 | - $rule = Filter::post('rule', 'allow|deny|robot'); |
|
48 | - $comment = Filter::post('comment'); |
|
49 | - $user_agent_string = Filter::server('HTTP_USER_AGENT'); |
|
50 | - $ip_address = WT_CLIENT_IP; |
|
51 | - |
|
52 | - if ($ip_address_start !== null && $ip_address_end !== null && $user_agent_pattern !== null && $rule !== null) { |
|
53 | - // This doesn't work with named placeholders. The :user_agent_string parameter is not recognised. |
|
54 | - $oops = $rule !== 'allow' && Database::prepare( |
|
55 | - "SELECT INET_ATON(:ip_address) BETWEEN INET_ATON(:ip_address_start) AND INET_ATON(:ip_address_end)" . |
|
56 | - " AND :user_agent_string LIKE :user_agent_pattern" |
|
57 | - )->execute(array( |
|
58 | - 'ip_address' => $ip_address, |
|
59 | - 'ip_address_start' => $ip_address_start, |
|
60 | - 'ip_address_end' => $ip_address_end, |
|
61 | - 'user_agent_string' => $user_agent_string, |
|
62 | - 'user_agent_pattern' => $user_agent_pattern, |
|
63 | - ))->fetchOne(); |
|
64 | - |
|
65 | - if ($oops) { |
|
66 | - FlashMessages::addMessage(I18N::translate('You cannot create a rule which would prevent yourself from accessing the website.'), 'danger'); |
|
67 | - } elseif ($site_access_rule_id === null) { |
|
68 | - Database::prepare( |
|
69 | - "INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, rule, comment) VALUES (INET_ATON(:ip_address_start), INET_ATON(:ip_address_end), :user_agent_pattern, :rule, :comment)" |
|
70 | - )->execute(array( |
|
71 | - 'ip_address_start' => $ip_address_start, |
|
72 | - 'ip_address_end' => $ip_address_end, |
|
73 | - 'user_agent_pattern' => $user_agent_pattern, |
|
74 | - 'rule' => $rule, |
|
75 | - 'comment' => $comment, |
|
76 | - )); |
|
77 | - FlashMessages::addMessage(I18N::translate('The website access rule has been created.'), 'success'); |
|
78 | - } else { |
|
79 | - Database::prepare( |
|
80 | - "UPDATE `##site_access_rule` SET ip_address_start = INET_ATON(:ip_address_start), ip_address_end = INET_ATON(:ip_address_end), user_agent_pattern = :user_agent_pattern, rule = :rule, comment = :comment WHERE site_access_rule_id = :site_access_rule_id" |
|
41 | + case 'save': |
|
42 | + if (Filter::checkCsrf()) { |
|
43 | + $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
44 | + $ip_address_start = Filter::post('ip_address_start', WT_REGEX_IPV4); |
|
45 | + $ip_address_end = Filter::post('ip_address_end', WT_REGEX_IPV4); |
|
46 | + $user_agent_pattern = Filter::post('user_agent_pattern'); |
|
47 | + $rule = Filter::post('rule', 'allow|deny|robot'); |
|
48 | + $comment = Filter::post('comment'); |
|
49 | + $user_agent_string = Filter::server('HTTP_USER_AGENT'); |
|
50 | + $ip_address = WT_CLIENT_IP; |
|
51 | + |
|
52 | + if ($ip_address_start !== null && $ip_address_end !== null && $user_agent_pattern !== null && $rule !== null) { |
|
53 | + // This doesn't work with named placeholders. The :user_agent_string parameter is not recognised. |
|
54 | + $oops = $rule !== 'allow' && Database::prepare( |
|
55 | + "SELECT INET_ATON(:ip_address) BETWEEN INET_ATON(:ip_address_start) AND INET_ATON(:ip_address_end)" . |
|
56 | + " AND :user_agent_string LIKE :user_agent_pattern" |
|
81 | 57 | )->execute(array( |
82 | - 'ip_address_start' => $ip_address_start, |
|
83 | - 'ip_address_end' => $ip_address_end, |
|
84 | - 'user_agent_pattern' => $user_agent_pattern, |
|
85 | - 'rule' => $rule, |
|
86 | - 'comment' => $comment, |
|
87 | - 'site_access_rule_id' => $site_access_rule_id, |
|
88 | - )); |
|
89 | - FlashMessages::addMessage(I18N::translate('The website access rule has been updated.'), 'success'); |
|
58 | + 'ip_address' => $ip_address, |
|
59 | + 'ip_address_start' => $ip_address_start, |
|
60 | + 'ip_address_end' => $ip_address_end, |
|
61 | + 'user_agent_string' => $user_agent_string, |
|
62 | + 'user_agent_pattern' => $user_agent_pattern, |
|
63 | + ))->fetchOne(); |
|
64 | + |
|
65 | + if ($oops) { |
|
66 | + FlashMessages::addMessage(I18N::translate('You cannot create a rule which would prevent yourself from accessing the website.'), 'danger'); |
|
67 | + } elseif ($site_access_rule_id === null) { |
|
68 | + Database::prepare( |
|
69 | + "INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, rule, comment) VALUES (INET_ATON(:ip_address_start), INET_ATON(:ip_address_end), :user_agent_pattern, :rule, :comment)" |
|
70 | + )->execute(array( |
|
71 | + 'ip_address_start' => $ip_address_start, |
|
72 | + 'ip_address_end' => $ip_address_end, |
|
73 | + 'user_agent_pattern' => $user_agent_pattern, |
|
74 | + 'rule' => $rule, |
|
75 | + 'comment' => $comment, |
|
76 | + )); |
|
77 | + FlashMessages::addMessage(I18N::translate('The website access rule has been created.'), 'success'); |
|
78 | + } else { |
|
79 | + Database::prepare( |
|
80 | + "UPDATE `##site_access_rule` SET ip_address_start = INET_ATON(:ip_address_start), ip_address_end = INET_ATON(:ip_address_end), user_agent_pattern = :user_agent_pattern, rule = :rule, comment = :comment WHERE site_access_rule_id = :site_access_rule_id" |
|
81 | + )->execute(array( |
|
82 | + 'ip_address_start' => $ip_address_start, |
|
83 | + 'ip_address_end' => $ip_address_end, |
|
84 | + 'user_agent_pattern' => $user_agent_pattern, |
|
85 | + 'rule' => $rule, |
|
86 | + 'comment' => $comment, |
|
87 | + 'site_access_rule_id' => $site_access_rule_id, |
|
88 | + )); |
|
89 | + FlashMessages::addMessage(I18N::translate('The website access rule has been updated.'), 'success'); |
|
90 | + } |
|
90 | 91 | } |
91 | 92 | } |
92 | - } |
|
93 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
93 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
94 | 94 | |
95 | - return; |
|
95 | + return; |
|
96 | 96 | |
97 | -case 'delete': |
|
98 | - if (Filter::checkCsrf()) { |
|
99 | - $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
100 | - Database::prepare( |
|
101 | - "DELETE FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
102 | - )->execute(array( |
|
103 | - 'site_access_rule_id' => $site_access_rule_id, |
|
104 | - )); |
|
105 | - FlashMessages::addMessage(I18N::translate('The website access rule has been deleted.'), 'success'); |
|
106 | - } |
|
107 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
97 | + case 'delete': |
|
98 | + if (Filter::checkCsrf()) { |
|
99 | + $site_access_rule_id = Filter::postInteger('site_access_rule_id'); |
|
100 | + Database::prepare( |
|
101 | + "DELETE FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
102 | + )->execute(array( |
|
103 | + 'site_access_rule_id' => $site_access_rule_id, |
|
104 | + )); |
|
105 | + FlashMessages::addMessage(I18N::translate('The website access rule has been deleted.'), 'success'); |
|
106 | + } |
|
107 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | 108 | |
109 | - return; |
|
109 | + return; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Delete any "unknown" visitors that are now "known". |
@@ -128,50 +128,50 @@ discard block |
||
128 | 128 | |
129 | 129 | $action = Filter::get('action'); |
130 | 130 | switch ($action) { |
131 | -case 'load': |
|
132 | - // AJAX callback for datatables |
|
133 | - $search = Filter::get('search'); |
|
134 | - $search = $search['value']; |
|
135 | - $start = Filter::getInteger('start'); |
|
136 | - $length = Filter::getInteger('length'); |
|
137 | - |
|
138 | - $sql = |
|
139 | - "SELECT SQL_CACHE SQL_CALC_FOUND_ROWS" . |
|
140 | - " '', INET_NTOA(ip_address_start), ip_address_start, INET_NTOA(ip_address_end), ip_address_end, user_agent_pattern, rule, comment, site_access_rule_id" . |
|
141 | - " FROM `##site_access_rule`"; |
|
142 | - $args = array(); |
|
143 | - |
|
144 | - if ($search) { |
|
145 | - $sql .= |
|
146 | - " WHERE (INET_ATON(:search_1) BETWEEN ip_address_start AND ip_address_end" . |
|
147 | - " OR INET_NTOA(ip_address_start) LIKE CONCAT('%', :search_2, '%')" . |
|
148 | - " OR INET_NTOA(ip_address_end) LIKE CONCAT('%', :search_3, '%')" . |
|
149 | - " OR user_agent_pattern LIKE CONCAT('%', :search_4, '%')" . |
|
150 | - " OR comment LIKE CONCAT('%', :search_5, '%'))"; |
|
151 | - $args['search_1'] = Filter::escapeLike($search); |
|
152 | - $args['search_2'] = Filter::escapeLike($search); |
|
153 | - $args['search_3'] = Filter::escapeLike($search); |
|
154 | - $args['search_4'] = Filter::escapeLike($search); |
|
155 | - $args['search_5'] = Filter::escapeLike($search); |
|
156 | - } |
|
131 | + case 'load': |
|
132 | + // AJAX callback for datatables |
|
133 | + $search = Filter::get('search'); |
|
134 | + $search = $search['value']; |
|
135 | + $start = Filter::getInteger('start'); |
|
136 | + $length = Filter::getInteger('length'); |
|
137 | + |
|
138 | + $sql = |
|
139 | + "SELECT SQL_CACHE SQL_CALC_FOUND_ROWS" . |
|
140 | + " '', INET_NTOA(ip_address_start), ip_address_start, INET_NTOA(ip_address_end), ip_address_end, user_agent_pattern, rule, comment, site_access_rule_id" . |
|
141 | + " FROM `##site_access_rule`"; |
|
142 | + $args = array(); |
|
143 | + |
|
144 | + if ($search) { |
|
145 | + $sql .= |
|
146 | + " WHERE (INET_ATON(:search_1) BETWEEN ip_address_start AND ip_address_end" . |
|
147 | + " OR INET_NTOA(ip_address_start) LIKE CONCAT('%', :search_2, '%')" . |
|
148 | + " OR INET_NTOA(ip_address_end) LIKE CONCAT('%', :search_3, '%')" . |
|
149 | + " OR user_agent_pattern LIKE CONCAT('%', :search_4, '%')" . |
|
150 | + " OR comment LIKE CONCAT('%', :search_5, '%'))"; |
|
151 | + $args['search_1'] = Filter::escapeLike($search); |
|
152 | + $args['search_2'] = Filter::escapeLike($search); |
|
153 | + $args['search_3'] = Filter::escapeLike($search); |
|
154 | + $args['search_4'] = Filter::escapeLike($search); |
|
155 | + $args['search_5'] = Filter::escapeLike($search); |
|
156 | + } |
|
157 | 157 | |
158 | - $order = Filter::getArray('order'); |
|
159 | - $sql .= ' ORDER BY'; |
|
160 | - if ($order) { |
|
161 | - foreach ($order as $key => $value) { |
|
162 | - if ($key > 0) { |
|
163 | - $sql .= ','; |
|
164 | - } |
|
165 | - // Datatables numbers columns 0, 1, 2 |
|
166 | - // MySQL numbers columns 1, 2, 3 |
|
167 | - switch ($value['dir']) { |
|
168 | - case 'asc': |
|
169 | - $sql .= " :col_" . $key . " ASC"; |
|
170 | - break; |
|
171 | - case 'desc': |
|
172 | - $sql .= " :col_" . $key . " DESC"; |
|
173 | - break; |
|
174 | - } |
|
158 | + $order = Filter::getArray('order'); |
|
159 | + $sql .= ' ORDER BY'; |
|
160 | + if ($order) { |
|
161 | + foreach ($order as $key => $value) { |
|
162 | + if ($key > 0) { |
|
163 | + $sql .= ','; |
|
164 | + } |
|
165 | + // Datatables numbers columns 0, 1, 2 |
|
166 | + // MySQL numbers columns 1, 2, 3 |
|
167 | + switch ($value['dir']) { |
|
168 | + case 'asc': |
|
169 | + $sql .= " :col_" . $key . " ASC"; |
|
170 | + break; |
|
171 | + case 'desc': |
|
172 | + $sql .= " :col_" . $key . " DESC"; |
|
173 | + break; |
|
174 | + } |
|
175 | 175 | $args['col_' . $key] = 1 + $value['column']; |
176 | 176 | } |
177 | 177 | } else { |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | )); |
211 | 211 | break; |
212 | 212 | |
213 | -case 'edit': |
|
214 | -case 'create': |
|
215 | - if (Filter::get('action') === 'edit') { |
|
216 | - $controller->setPageTitle(I18N::translate('Edit a website access rule')); |
|
217 | - } else { |
|
218 | - $controller->setPageTitle(I18N::translate('Create a website access rule')); |
|
219 | - } |
|
213 | + case 'edit': |
|
214 | + case 'create': |
|
215 | + if (Filter::get('action') === 'edit') { |
|
216 | + $controller->setPageTitle(I18N::translate('Edit a website access rule')); |
|
217 | + } else { |
|
218 | + $controller->setPageTitle(I18N::translate('Create a website access rule')); |
|
219 | + } |
|
220 | 220 | |
221 | - $controller->pageHeader(); |
|
221 | + $controller->pageHeader(); |
|
222 | 222 | |
223 | - $site_access_rule = Database::prepare( |
|
224 | - "SELECT site_access_rule_id, INET_NTOA(ip_address_start) AS ip_address_start, INET_NTOA(ip_address_end) AS ip_address_end, user_agent_pattern, rule, comment" . |
|
225 | - " FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
226 | - )->execute(array( |
|
227 | - 'site_access_rule_id' => Filter::getInteger('site_access_rule_id'), |
|
228 | - ))->fetchOneRow(); |
|
223 | + $site_access_rule = Database::prepare( |
|
224 | + "SELECT site_access_rule_id, INET_NTOA(ip_address_start) AS ip_address_start, INET_NTOA(ip_address_end) AS ip_address_end, user_agent_pattern, rule, comment" . |
|
225 | + " FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id" |
|
226 | + )->execute(array( |
|
227 | + 'site_access_rule_id' => Filter::getInteger('site_access_rule_id'), |
|
228 | + ))->fetchOneRow(); |
|
229 | 229 | |
230 | - $site_access_rule_id = $site_access_rule ? $site_access_rule->site_access_rule_id : null; |
|
231 | - $ip_address_start = $site_access_rule ? $site_access_rule->ip_address_start : '0.0.0.0'; |
|
232 | - $ip_address_end = $site_access_rule ? $site_access_rule->ip_address_end : '255.255.255.255'; |
|
233 | - $user_agent_pattern = $site_access_rule ? $site_access_rule->user_agent_pattern : '%'; |
|
234 | - $rule = $site_access_rule ? $site_access_rule->rule : 'allow'; |
|
235 | - $comment = $site_access_rule ? $site_access_rule->comment : ''; |
|
230 | + $site_access_rule_id = $site_access_rule ? $site_access_rule->site_access_rule_id : null; |
|
231 | + $ip_address_start = $site_access_rule ? $site_access_rule->ip_address_start : '0.0.0.0'; |
|
232 | + $ip_address_end = $site_access_rule ? $site_access_rule->ip_address_end : '255.255.255.255'; |
|
233 | + $user_agent_pattern = $site_access_rule ? $site_access_rule->user_agent_pattern : '%'; |
|
234 | + $rule = $site_access_rule ? $site_access_rule->rule : 'allow'; |
|
235 | + $comment = $site_access_rule ? $site_access_rule->comment : ''; |
|
236 | 236 | |
237 | - ?> |
|
237 | + ?> |
|
238 | 238 | <ol class="breadcrumb small"> |
239 | 239 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
240 | 240 | <li><a href="admin_site_access.php"><?php echo I18N::translate('Website access rules'); ?></a></li> |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | </form> |
312 | 312 | |
313 | 313 | <?php |
314 | - break; |
|
314 | + break; |
|
315 | 315 | |
316 | -default: |
|
317 | - $controller |
|
318 | - ->pageHeader() |
|
319 | - ->addInlineJavascript(' |
|
316 | + default: |
|
317 | + $controller |
|
318 | + ->pageHeader() |
|
319 | + ->addInlineJavascript(' |
|
320 | 320 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
321 | 321 | jQuery.fn.dataTableExt.oSort["unicode-desc"]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
322 | 322 | jQuery(".table-site-access-rules").dataTable({ |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | }); |
341 | 341 | '); |
342 | 342 | |
343 | - ?> |
|
343 | + ?> |
|
344 | 344 | <ol class="breadcrumb small"> |
345 | 345 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
346 | 346 | <li class="active"><?php echo $controller->getPageTitle(); ?></li> |
@@ -381,5 +381,5 @@ discard block |
||
381 | 381 | } |
382 | 382 | </script> |
383 | 383 | <?php |
384 | - break; |
|
384 | + break; |
|
385 | 385 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | $show_marnm = Filter::get('show_marnm', 'no|yes'); |
48 | 48 | switch ($show_marnm) { |
49 | -case 'no': |
|
50 | -case 'yes': |
|
51 | - Auth::user()->setPreference(WT_SCRIPT_NAME . '_show_marnm', $show_marnm); |
|
52 | - break; |
|
53 | -default: |
|
54 | - $show_marnm = Auth::user()->getPreference(WT_SCRIPT_NAME . '_show_marnm'); |
|
49 | + case 'no': |
|
50 | + case 'yes': |
|
51 | + Auth::user()->setPreference(WT_SCRIPT_NAME . '_show_marnm', $show_marnm); |
|
52 | + break; |
|
53 | + default: |
|
54 | + $show_marnm = Auth::user()->getPreference(WT_SCRIPT_NAME . '_show_marnm'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Make sure selections are consistent. |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | } |
92 | 92 | $url = WT_SCRIPT_NAME . '?surname=' . rawurlencode($surname) . '&ged=' . $WT_TREE->getNameUrl(); |
93 | 93 | switch ($falpha) { |
94 | - case '': |
|
95 | - break; |
|
96 | - case '@': |
|
97 | - $legend .= ', ' . I18N::translateContext('Unknown given name', '…'); |
|
98 | - $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); |
|
99 | - break; |
|
100 | - default: |
|
101 | - $legend .= ', ' . Filter::escapeHtml($falpha) . '…'; |
|
102 | - $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); |
|
103 | - break; |
|
94 | + case '': |
|
95 | + break; |
|
96 | + case '@': |
|
97 | + $legend .= ', ' . I18N::translateContext('Unknown given name', '…'); |
|
98 | + $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); |
|
99 | + break; |
|
100 | + default: |
|
101 | + $legend .= ', ' . Filter::escapeHtml($falpha) . '…'; |
|
102 | + $url .= '&falpha=' . rawurlencode($falpha) . '&ged=' . $WT_TREE->getNameUrl(); |
|
103 | + break; |
|
104 | 104 | } |
105 | 105 | $show = 'indi'; // SURN list makes no sense here |
106 | 106 | } elseif ($alpha === '@') { |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | $list = array(); |
137 | 137 | foreach (QueryName::surnameAlpha($WT_TREE, $show_marnm === 'yes', true) as $letter => $count) { |
138 | 138 | switch ($letter) { |
139 | - case '@': |
|
140 | - $html = I18N::translateContext('Unknown surname', '…'); |
|
141 | - break; |
|
142 | - case ',': |
|
143 | - $html = I18N::translate('None'); |
|
144 | - break; |
|
145 | - default: |
|
146 | - $html = Filter::escapeHtml($letter); |
|
147 | - break; |
|
139 | + case '@': |
|
140 | + $html = I18N::translateContext('Unknown surname', '…'); |
|
141 | + break; |
|
142 | + case ',': |
|
143 | + $html = I18N::translate('None'); |
|
144 | + break; |
|
145 | + default: |
|
146 | + $html = Filter::escapeHtml($letter); |
|
147 | + break; |
|
148 | 148 | } |
149 | 149 | if ($count) { |
150 | 150 | if ($letter == $alpha) { |
@@ -194,16 +194,16 @@ discard block |
||
194 | 194 | if ($show === 'surn') { |
195 | 195 | // Show the surname list |
196 | 196 | switch ($WT_TREE->getPreference('SURNAME_LIST_STYLE')) { |
197 | - case 'style1': |
|
198 | - echo FunctionsPrintLists::surnameList($surns, 3, true, WT_SCRIPT_NAME, $WT_TREE); |
|
199 | - break; |
|
200 | - case 'style3': |
|
201 | - echo FunctionsPrintLists::surnameTagCloud($surns, WT_SCRIPT_NAME, true, $WT_TREE); |
|
202 | - break; |
|
203 | - case 'style2': |
|
204 | - default: |
|
205 | - echo FunctionsPrintLists::surnameTable($surns, WT_SCRIPT_NAME, $WT_TREE); |
|
206 | - break; |
|
197 | + case 'style1': |
|
198 | + echo FunctionsPrintLists::surnameList($surns, 3, true, WT_SCRIPT_NAME, $WT_TREE); |
|
199 | + break; |
|
200 | + case 'style3': |
|
201 | + echo FunctionsPrintLists::surnameTagCloud($surns, WT_SCRIPT_NAME, true, $WT_TREE); |
|
202 | + break; |
|
203 | + case 'style2': |
|
204 | + default: |
|
205 | + echo FunctionsPrintLists::surnameTable($surns, WT_SCRIPT_NAME, $WT_TREE); |
|
206 | + break; |
|
207 | 207 | } |
208 | 208 | } else { |
209 | 209 | // Show the list |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | $list = array(); |
227 | 227 | foreach ($givn_initials as $givn_initial => $count) { |
228 | 228 | switch ($givn_initial) { |
229 | - case '@': |
|
230 | - $html = I18N::translateContext('Unknown given name', '…'); |
|
231 | - break; |
|
232 | - default: |
|
233 | - $html = Filter::escapeHtml($givn_initial); |
|
234 | - break; |
|
229 | + case '@': |
|
230 | + $html = I18N::translateContext('Unknown given name', '…'); |
|
231 | + break; |
|
232 | + default: |
|
233 | + $html = Filter::escapeHtml($givn_initial); |
|
234 | + break; |
|
235 | 235 | } |
236 | 236 | if ($count) { |
237 | 237 | if ($show === 'indi' && $givn_initial === $falpha && $show_all_firstnames === 'no') { |
@@ -50,116 +50,116 @@ discard block |
||
50 | 50 | } |
51 | 51 | // Process POST actions |
52 | 52 | switch (Filter::post('action')) { |
53 | -case 'delete': |
|
54 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
55 | - if (Filter::checkCsrf() && $gedcom_id) { |
|
56 | - $tree = Tree::findById($gedcom_id); |
|
57 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
58 | - $tree->delete(); |
|
59 | - } |
|
60 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
61 | - |
|
62 | - return; |
|
63 | -case 'setdefault': |
|
64 | - if (Filter::checkCsrf()) { |
|
65 | - Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); |
|
66 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); |
|
67 | - } |
|
68 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
69 | - |
|
70 | - return; |
|
71 | -case 'new_tree': |
|
72 | - $basename = basename(Filter::post('tree_name')); |
|
73 | - $tree_title = Filter::post('tree_title'); |
|
74 | - |
|
75 | - if (Filter::checkCsrf() && $basename && $tree_title) { |
|
76 | - if (Tree::findByName($basename)) { |
|
77 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger'); |
|
78 | - } else { |
|
79 | - Tree::create($basename, $tree_title); |
|
80 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success'); |
|
53 | + case 'delete': |
|
54 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
55 | + if (Filter::checkCsrf() && $gedcom_id) { |
|
56 | + $tree = Tree::findById($gedcom_id); |
|
57 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
58 | + $tree->delete(); |
|
81 | 59 | } |
82 | - } |
|
83 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename)); |
|
84 | - |
|
85 | - return; |
|
86 | -case 'replace_upload': |
|
87 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
88 | - $keep_media = Filter::post('keep_media', '1', '0'); |
|
89 | - $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
90 | - $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
91 | - $tree = Tree::findById($gedcom_id); |
|
92 | - |
|
93 | - if (Filter::checkCsrf() && $tree) { |
|
94 | - $tree->setPreference('keep_media', $keep_media); |
|
95 | - $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
96 | - $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
97 | - if (isset($_FILES['tree_name'])) { |
|
98 | - if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { |
|
99 | - $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); |
|
100 | - } else { |
|
101 | - FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); |
|
102 | - } |
|
103 | - } else { |
|
104 | - FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
105 | - } |
|
106 | - } |
|
107 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | - |
|
109 | - return; |
|
110 | -case 'replace_import': |
|
111 | - $basename = basename(Filter::post('tree_name')); |
|
112 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
113 | - $keep_media = Filter::post('keep_media', '1', '0'); |
|
114 | - $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
115 | - $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
116 | - $tree = Tree::findById($gedcom_id); |
|
117 | - |
|
118 | - if (Filter::checkCsrf() && $tree) { |
|
119 | - $tree->setPreference('keep_media', $keep_media); |
|
120 | - $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
121 | - $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
122 | - if ($basename) { |
|
123 | - $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); |
|
124 | - } else { |
|
125 | - FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
126 | - } |
|
127 | - } |
|
128 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
129 | - |
|
130 | - return; |
|
60 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
131 | 61 | |
132 | -case 'synchronize': |
|
133 | - if (Filter::checkCsrf()) { |
|
134 | - $basenames = array(); |
|
62 | + return; |
|
63 | + case 'setdefault': |
|
64 | + if (Filter::checkCsrf()) { |
|
65 | + Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); |
|
66 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); |
|
67 | + } |
|
68 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
135 | 69 | |
136 | - foreach ($gedcom_files as $gedcom_file) { |
|
137 | - $filemtime = filemtime($gedcom_file); // Only import files that have changed |
|
138 | - $basename = basename($gedcom_file); |
|
139 | - $basenames[] = $basename; |
|
70 | + return; |
|
71 | + case 'new_tree': |
|
72 | + $basename = basename(Filter::post('tree_name')); |
|
73 | + $tree_title = Filter::post('tree_title'); |
|
140 | 74 | |
141 | - $tree = Tree::findByName($basename); |
|
142 | - if (!$tree) { |
|
143 | - $tree = Tree::create($basename, $basename); |
|
75 | + if (Filter::checkCsrf() && $basename && $tree_title) { |
|
76 | + if (Tree::findByName($basename)) { |
|
77 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger'); |
|
78 | + } else { |
|
79 | + Tree::create($basename, $tree_title); |
|
80 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success'); |
|
144 | 81 | } |
145 | - if ($tree->getPreference('filemtime') != $filemtime) { |
|
146 | - $tree->importGedcomFile($gedcom_file, $basename); |
|
147 | - $tree->setPreference('filemtime', $filemtime); |
|
148 | - FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); |
|
82 | + } |
|
83 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename)); |
|
84 | + |
|
85 | + return; |
|
86 | + case 'replace_upload': |
|
87 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
88 | + $keep_media = Filter::post('keep_media', '1', '0'); |
|
89 | + $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
90 | + $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
91 | + $tree = Tree::findById($gedcom_id); |
|
92 | + |
|
93 | + if (Filter::checkCsrf() && $tree) { |
|
94 | + $tree->setPreference('keep_media', $keep_media); |
|
95 | + $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
96 | + $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
97 | + if (isset($_FILES['tree_name'])) { |
|
98 | + if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { |
|
99 | + $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); |
|
100 | + } else { |
|
101 | + FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); |
|
102 | + } |
|
103 | + } else { |
|
104 | + FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
149 | 105 | } |
150 | 106 | } |
151 | - |
|
152 | - foreach (Tree::getAll() as $tree) { |
|
153 | - if (!in_array($tree->getName(), $basenames)) { |
|
154 | - FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
155 | - $tree->delete(); |
|
107 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | + |
|
109 | + return; |
|
110 | + case 'replace_import': |
|
111 | + $basename = basename(Filter::post('tree_name')); |
|
112 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
113 | + $keep_media = Filter::post('keep_media', '1', '0'); |
|
114 | + $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
115 | + $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
116 | + $tree = Tree::findById($gedcom_id); |
|
117 | + |
|
118 | + if (Filter::checkCsrf() && $tree) { |
|
119 | + $tree->setPreference('keep_media', $keep_media); |
|
120 | + $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
121 | + $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
122 | + if ($basename) { |
|
123 | + $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); |
|
124 | + } else { |
|
125 | + FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
156 | 126 | } |
157 | 127 | } |
128 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
129 | + |
|
130 | + return; |
|
131 | + |
|
132 | + case 'synchronize': |
|
133 | + if (Filter::checkCsrf()) { |
|
134 | + $basenames = array(); |
|
135 | + |
|
136 | + foreach ($gedcom_files as $gedcom_file) { |
|
137 | + $filemtime = filemtime($gedcom_file); // Only import files that have changed |
|
138 | + $basename = basename($gedcom_file); |
|
139 | + $basenames[] = $basename; |
|
140 | + |
|
141 | + $tree = Tree::findByName($basename); |
|
142 | + if (!$tree) { |
|
143 | + $tree = Tree::create($basename, $basename); |
|
144 | + } |
|
145 | + if ($tree->getPreference('filemtime') != $filemtime) { |
|
146 | + $tree->importGedcomFile($gedcom_file, $basename); |
|
147 | + $tree->setPreference('filemtime', $filemtime); |
|
148 | + FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); |
|
149 | + } |
|
150 | + } |
|
158 | 151 | |
159 | - } |
|
160 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
152 | + foreach (Tree::getAll() as $tree) { |
|
153 | + if (!in_array($tree->getName(), $basenames)) { |
|
154 | + FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
155 | + $tree->delete(); |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + } |
|
160 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
161 | 161 | |
162 | - return; |
|
162 | + return; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $default_tree_title = /* I18N: Default name for a new tree */ I18N::translate('My family tree'); |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | |
174 | 174 | // Process GET actions |
175 | 175 | switch (Filter::get('action')) { |
176 | -case 'importform': |
|
177 | - $controller |
|
178 | - ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) |
|
179 | - ->pageHeader(); |
|
176 | + case 'importform': |
|
177 | + $controller |
|
178 | + ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) |
|
179 | + ->pageHeader(); |
|
180 | 180 | |
181 | - ?> |
|
181 | + ?> |
|
182 | 182 | <ol class="breadcrumb small"> |
183 | 183 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
184 | 184 | <li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?></a></li> |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | <h1><?php echo $controller->getPageTitle(); ?></h1> |
189 | 189 | <?php |
190 | 190 | |
191 | - $tree = Tree::findById(Filter::getInteger('gedcom_id')); |
|
192 | - // Check it exists |
|
193 | - if (!$tree) { |
|
194 | - break; |
|
195 | - } |
|
196 | - $gedcom_filename = $tree->getPreference('gedcom_filename') |
|
197 | - ?> |
|
198 | - <p> |
|
191 | + $tree = Tree::findById(Filter::getInteger('gedcom_id')); |
|
192 | + // Check it exists |
|
193 | + if (!$tree) { |
|
194 | + break; |
|
195 | + } |
|
196 | + $gedcom_filename = $tree->getPreference('gedcom_filename') |
|
197 | + ?> |
|
198 | + <p> |
|
199 | 199 | <?php echo /* I18N: %s is the name of a family tree */ I18N::translate('This will delete all the genealogy data from “%s” and replace it with data from a GEDCOM file.', $tree->getTitleHtml()); ?> |
200 | 200 | </p> |
201 | 201 | <form class="form form-horizontal" name="gedcomimportform" method="post" enctype="multipart/form-data" onsubmit="return checkGedcomImportForm('<?php echo Filter::escapeHtml(I18N::translate('You have selected a GEDCOM file with a different name. Is this correct?')); ?>');"> |
@@ -228,35 +228,35 @@ discard block |
||
228 | 228 | <div class="input-group"> |
229 | 229 | <span class="input-group-addon"> |
230 | 230 | <?php echo WT_DATA_DIR; ?> |
231 | - </span> |
|
231 | + </span> |
|
232 | 232 | <?php |
233 | - $d = opendir(WT_DATA_DIR); |
|
234 | - $files = array(); |
|
235 | - while (($f = readdir($d)) !== false) { |
|
236 | - if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { |
|
237 | - $fp = fopen(WT_DATA_DIR . $f, 'rb'); |
|
238 | - $header = fread($fp, 64); |
|
239 | - fclose($fp); |
|
240 | - if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { |
|
241 | - $files[] = $f; |
|
233 | + $d = opendir(WT_DATA_DIR); |
|
234 | + $files = array(); |
|
235 | + while (($f = readdir($d)) !== false) { |
|
236 | + if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { |
|
237 | + $fp = fopen(WT_DATA_DIR . $f, 'rb'); |
|
238 | + $header = fread($fp, 64); |
|
239 | + fclose($fp); |
|
240 | + if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { |
|
241 | + $files[] = $f; |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | + echo '<select name="tree_name" class="form-control" id="import-server-file">'; |
|
246 | + echo '<option value=""></option>'; |
|
247 | + sort($files); |
|
248 | + foreach ($files as $gedcom_file) { |
|
249 | + echo '<option value="', Filter::escapeHtml($gedcom_file), '" '; |
|
250 | + if ($gedcom_file === $gedcom_filename) { |
|
251 | + echo ' selected'; |
|
242 | 252 | } |
253 | + echo'>', Filter::escapeHtml($gedcom_file), '</option>'; |
|
243 | 254 | } |
244 | - } |
|
245 | - echo '<select name="tree_name" class="form-control" id="import-server-file">'; |
|
246 | - echo '<option value=""></option>'; |
|
247 | - sort($files); |
|
248 | - foreach ($files as $gedcom_file) { |
|
249 | - echo '<option value="', Filter::escapeHtml($gedcom_file), '" '; |
|
250 | - if ($gedcom_file === $gedcom_filename) { |
|
251 | - echo ' selected'; |
|
255 | + if (!$files) { |
|
256 | + echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>'; |
|
252 | 257 | } |
253 | - echo'>', Filter::escapeHtml($gedcom_file), '</option>'; |
|
254 | - } |
|
255 | - if (!$files) { |
|
256 | - echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>'; |
|
257 | - } |
|
258 | - echo '</select>'; |
|
259 | - ?> |
|
258 | + echo '</select>'; |
|
259 | + ?> |
|
260 | 260 | </div> |
261 | 261 | </div> |
262 | 262 | </div> |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | > |
299 | 299 | <p class="small text-muted"> |
300 | 300 | <?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. A “path” is something like “C:\Documents\Genealogy\Photos\John_Smith.jpeg” */ I18N::translate('Some genealogy software creates GEDCOM files that contain media filenames with full paths. These paths will not exist on the web-server. To allow webtrees to find the file, the first part of the path must be removed.'); ?> |
301 | - <?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>'); ?> |
|
301 | + <?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>'); ?> |
|
302 | 302 | </p> |
303 | 303 | </div> |
304 | 304 | </fieldset> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | </form> |
314 | 314 | <?php |
315 | 315 | |
316 | - return; |
|
316 | + return; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | if (!Tree::getAll()) { |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | public function getTarget() { |
93 | 93 | $xref = trim($this->getValue(), '@'); |
94 | 94 | switch ($this->tag) { |
95 | - case 'FAMC': |
|
96 | - case 'FAMS': |
|
97 | - return Family::getInstance($xref, $this->getParent()->getTree()); |
|
98 | - case 'HUSB': |
|
99 | - case 'WIFE': |
|
100 | - case 'CHIL': |
|
101 | - return Individual::getInstance($xref, $this->getParent()->getTree()); |
|
102 | - case 'SOUR': |
|
103 | - return Source::getInstance($xref, $this->getParent()->getTree()); |
|
104 | - case 'OBJE': |
|
105 | - return Media::getInstance($xref, $this->getParent()->getTree()); |
|
106 | - case 'REPO': |
|
107 | - return Repository::getInstance($xref, $this->getParent()->getTree()); |
|
108 | - case 'NOTE': |
|
109 | - return Note::getInstance($xref, $this->getParent()->getTree()); |
|
110 | - default: |
|
111 | - return GedcomRecord::getInstance($xref, $this->getParent()->getTree()); |
|
95 | + case 'FAMC': |
|
96 | + case 'FAMS': |
|
97 | + return Family::getInstance($xref, $this->getParent()->getTree()); |
|
98 | + case 'HUSB': |
|
99 | + case 'WIFE': |
|
100 | + case 'CHIL': |
|
101 | + return Individual::getInstance($xref, $this->getParent()->getTree()); |
|
102 | + case 'SOUR': |
|
103 | + return Source::getInstance($xref, $this->getParent()->getTree()); |
|
104 | + case 'OBJE': |
|
105 | + return Media::getInstance($xref, $this->getParent()->getTree()); |
|
106 | + case 'REPO': |
|
107 | + return Repository::getInstance($xref, $this->getParent()->getTree()); |
|
108 | + case 'NOTE': |
|
109 | + return Note::getInstance($xref, $this->getParent()->getTree()); |
|
110 | + default: |
|
111 | + return GedcomRecord::getInstance($xref, $this->getParent()->getTree()); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -262,15 +262,15 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function getLabel() { |
264 | 264 | switch ($this->tag) { |
265 | - case 'EVEN': |
|
266 | - case 'FACT': |
|
267 | - if ($this->getAttribute('TYPE')) { |
|
268 | - // Custom FACT/EVEN - with a TYPE |
|
269 | - return I18N::translate(Filter::escapeHtml($this->getAttribute('TYPE'))); |
|
270 | - } |
|
271 | - // no break - drop into next case |
|
272 | - default: |
|
273 | - return GedcomTag::getLabel($this->tag, $this->parent); |
|
265 | + case 'EVEN': |
|
266 | + case 'FACT': |
|
267 | + if ($this->getAttribute('TYPE')) { |
|
268 | + // Custom FACT/EVEN - with a TYPE |
|
269 | + return I18N::translate(Filter::escapeHtml($this->getAttribute('TYPE'))); |
|
270 | + } |
|
271 | + // no break - drop into next case |
|
272 | + default: |
|
273 | + return GedcomTag::getLabel($this->tag, $this->parent); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 |
@@ -34,85 +34,85 @@ discard block |
||
34 | 34 | */ |
35 | 35 | private static function getAlphabetForLocale($locale) { |
36 | 36 | switch ($locale) { |
37 | - case 'ar': |
|
38 | - return array( |
|
39 | - 'ا', 'ب', 'ت', 'ث', 'ج', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ك', 'ل', 'م', 'ن', 'ه', 'و', 'ي', 'آ', 'ة', 'ى', 'ی', |
|
40 | - ); |
|
41 | - case 'cs': |
|
42 | - return array( |
|
43 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'CH', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
44 | - ); |
|
45 | - case 'da': |
|
46 | - case 'nb': |
|
47 | - case 'nn': |
|
48 | - return array( |
|
49 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Æ', 'Ø', 'Å', |
|
50 | - ); |
|
51 | - case 'el': |
|
52 | - return array( |
|
53 | - 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', |
|
54 | - ); |
|
55 | - case 'es': |
|
56 | - return array( |
|
57 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
58 | - ); |
|
59 | - case 'et': |
|
60 | - return array( |
|
61 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'Z', 'Ž', 'T', 'U', 'V', 'W', 'Õ', 'Ä', 'Ö', 'Ü', 'X', 'Y', |
|
62 | - ); |
|
63 | - case 'fi': |
|
64 | - case 'sv': |
|
65 | - return array( |
|
66 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Å', 'Ä', 'Ö', |
|
67 | - ); |
|
68 | - case 'he': |
|
69 | - return array( |
|
70 | - 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק', 'ר', 'ש', 'ת', |
|
71 | - ); |
|
72 | - case 'hu': |
|
73 | - return array( |
|
74 | - 'A', 'B', 'C', 'CS', 'D', 'DZ', 'DZS', 'E', 'F', 'G', 'GY', 'H', 'I', 'J', 'K', 'L', 'LY', 'M', 'N', 'NY', 'O', 'Ö', 'P', 'Q', 'R', 'S', 'SZ', 'T', 'TY', 'U', 'Ü', 'V', 'W', 'X', 'Y', 'Z', 'ZS', |
|
75 | - ); |
|
76 | - case 'lt': |
|
77 | - return array( |
|
78 | - 'A', 'Ą', 'B', 'C', 'Č', 'D', 'E', 'Ę', 'Ė', 'F', 'G', 'H', 'I', 'Y', 'Į', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'Ų', 'Ū', 'V', 'Z', 'Ž', |
|
79 | - ); |
|
80 | - case 'nl': |
|
81 | - return array( |
|
82 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'IJ', |
|
83 | - ); |
|
84 | - case 'pl': |
|
85 | - return array( |
|
86 | - 'A', 'B', 'C', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'Ł', 'M', 'N', 'O', 'Ó', 'P', 'Q', 'R', 'S', 'Ś', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ź', 'Ż', |
|
87 | - ); |
|
88 | - case 'ro': |
|
89 | - return array( |
|
90 | - 'A', 'Ă', 'Â', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Î', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Ş', 'T', 'Ţ', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
91 | - ); |
|
92 | - case 'ru': |
|
93 | - return array( |
|
94 | - 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', |
|
95 | - ); |
|
96 | - case 'sk': |
|
97 | - return array( |
|
98 | - 'A', 'Á', 'Ä', 'B', 'C', 'Č', 'D', 'Ď', 'E', 'É', 'F', 'G', 'H', 'I', 'Í', 'J', 'K', 'L', 'Ľ', 'Ĺ', 'M', 'N', 'Ň', 'O', 'Ó', 'Ô', 'P', 'Q', 'R', 'Ŕ', 'S', 'Š', 'T', 'Ť', 'U', 'Ú', 'V', 'W', 'X', 'Y', 'Ý', 'Z', 'Ž', |
|
99 | - ); |
|
100 | - case 'sl': |
|
101 | - return array( |
|
102 | - 'A', 'B', 'C', 'Č', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ž', |
|
103 | - ); |
|
104 | - case 'sr': |
|
105 | - return array( |
|
106 | - 'A', 'B', 'C', 'Č', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ž', |
|
107 | - ); |
|
108 | - case 'tr': |
|
109 | - return array( |
|
110 | - 'A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G', 'Ğ', 'H', 'I', 'İ', 'J', 'K', 'L', 'M', 'N', 'O', 'Ö', 'P', 'R', 'S', 'Ş', 'T', 'U', 'Ü', 'V', 'Y', 'Z', |
|
111 | - ); |
|
112 | - default: |
|
113 | - return array( |
|
114 | - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
115 | - ); |
|
37 | + case 'ar': |
|
38 | + return array( |
|
39 | + 'ا', 'ب', 'ت', 'ث', 'ج', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ك', 'ل', 'م', 'ن', 'ه', 'و', 'ي', 'آ', 'ة', 'ى', 'ی', |
|
40 | + ); |
|
41 | + case 'cs': |
|
42 | + return array( |
|
43 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'CH', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
44 | + ); |
|
45 | + case 'da': |
|
46 | + case 'nb': |
|
47 | + case 'nn': |
|
48 | + return array( |
|
49 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Æ', 'Ø', 'Å', |
|
50 | + ); |
|
51 | + case 'el': |
|
52 | + return array( |
|
53 | + 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω', |
|
54 | + ); |
|
55 | + case 'es': |
|
56 | + return array( |
|
57 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
58 | + ); |
|
59 | + case 'et': |
|
60 | + return array( |
|
61 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'Z', 'Ž', 'T', 'U', 'V', 'W', 'Õ', 'Ä', 'Ö', 'Ü', 'X', 'Y', |
|
62 | + ); |
|
63 | + case 'fi': |
|
64 | + case 'sv': |
|
65 | + return array( |
|
66 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Å', 'Ä', 'Ö', |
|
67 | + ); |
|
68 | + case 'he': |
|
69 | + return array( |
|
70 | + 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק', 'ר', 'ש', 'ת', |
|
71 | + ); |
|
72 | + case 'hu': |
|
73 | + return array( |
|
74 | + 'A', 'B', 'C', 'CS', 'D', 'DZ', 'DZS', 'E', 'F', 'G', 'GY', 'H', 'I', 'J', 'K', 'L', 'LY', 'M', 'N', 'NY', 'O', 'Ö', 'P', 'Q', 'R', 'S', 'SZ', 'T', 'TY', 'U', 'Ü', 'V', 'W', 'X', 'Y', 'Z', 'ZS', |
|
75 | + ); |
|
76 | + case 'lt': |
|
77 | + return array( |
|
78 | + 'A', 'Ą', 'B', 'C', 'Č', 'D', 'E', 'Ę', 'Ė', 'F', 'G', 'H', 'I', 'Y', 'Į', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'Ų', 'Ū', 'V', 'Z', 'Ž', |
|
79 | + ); |
|
80 | + case 'nl': |
|
81 | + return array( |
|
82 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'IJ', |
|
83 | + ); |
|
84 | + case 'pl': |
|
85 | + return array( |
|
86 | + 'A', 'B', 'C', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'Ł', 'M', 'N', 'O', 'Ó', 'P', 'Q', 'R', 'S', 'Ś', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ź', 'Ż', |
|
87 | + ); |
|
88 | + case 'ro': |
|
89 | + return array( |
|
90 | + 'A', 'Ă', 'Â', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Î', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Ş', 'T', 'Ţ', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
91 | + ); |
|
92 | + case 'ru': |
|
93 | + return array( |
|
94 | + 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', |
|
95 | + ); |
|
96 | + case 'sk': |
|
97 | + return array( |
|
98 | + 'A', 'Á', 'Ä', 'B', 'C', 'Č', 'D', 'Ď', 'E', 'É', 'F', 'G', 'H', 'I', 'Í', 'J', 'K', 'L', 'Ľ', 'Ĺ', 'M', 'N', 'Ň', 'O', 'Ó', 'Ô', 'P', 'Q', 'R', 'Ŕ', 'S', 'Š', 'T', 'Ť', 'U', 'Ú', 'V', 'W', 'X', 'Y', 'Ý', 'Z', 'Ž', |
|
99 | + ); |
|
100 | + case 'sl': |
|
101 | + return array( |
|
102 | + 'A', 'B', 'C', 'Č', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ž', |
|
103 | + ); |
|
104 | + case 'sr': |
|
105 | + return array( |
|
106 | + 'A', 'B', 'C', 'Č', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ž', |
|
107 | + ); |
|
108 | + case 'tr': |
|
109 | + return array( |
|
110 | + 'A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G', 'Ğ', 'H', 'I', 'İ', 'J', 'K', 'L', 'M', 'N', 'O', 'Ö', 'P', 'R', 'S', 'Ş', 'T', 'U', 'Ü', 'V', 'Y', 'Z', |
|
111 | + ); |
|
112 | + default: |
|
113 | + return array( |
|
114 | + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
115 | + ); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -126,44 +126,44 @@ discard block |
||
126 | 126 | public static function initialLetter($name) { |
127 | 127 | $name = I18N::strtoupper($name); |
128 | 128 | switch (WT_LOCALE) { |
129 | - case 'cs': |
|
130 | - if (substr($name, 0, 2) == 'CH') { |
|
131 | - return 'CH'; |
|
132 | - } |
|
133 | - break; |
|
134 | - case 'da': |
|
135 | - case 'nb': |
|
136 | - case 'nn': |
|
137 | - if (substr($name, 0, 2) == 'AA') { |
|
138 | - return 'Å'; |
|
139 | - } |
|
140 | - break; |
|
141 | - case 'hu': |
|
142 | - if (substr($name, 0, 2) == 'CS') { |
|
143 | - return 'CS'; |
|
144 | - } elseif (substr($name, 0, 3) == 'DZS') { |
|
145 | - return 'DZS'; |
|
146 | - } elseif (substr($name, 0, 2) == 'DZ') { |
|
147 | - return 'DZ'; |
|
148 | - } elseif (substr($name, 0, 2) == 'GY') { |
|
149 | - return 'GY'; |
|
150 | - } elseif (substr($name, 0, 2) == 'LY') { |
|
151 | - return 'LY'; |
|
152 | - } elseif (substr($name, 0, 2) == 'NY') { |
|
153 | - return 'NY'; |
|
154 | - } elseif (substr($name, 0, 2) == 'SZ') { |
|
155 | - return 'SZ'; |
|
156 | - } elseif (substr($name, 0, 2) == 'TY') { |
|
157 | - return 'TY'; |
|
158 | - } elseif (substr($name, 0, 2) == 'ZS') { |
|
159 | - return 'ZS'; |
|
160 | - } |
|
161 | - break; |
|
162 | - case 'nl': |
|
163 | - if (substr($name, 0, 2) == 'IJ') { |
|
164 | - return 'IJ'; |
|
165 | - } |
|
166 | - break; |
|
129 | + case 'cs': |
|
130 | + if (substr($name, 0, 2) == 'CH') { |
|
131 | + return 'CH'; |
|
132 | + } |
|
133 | + break; |
|
134 | + case 'da': |
|
135 | + case 'nb': |
|
136 | + case 'nn': |
|
137 | + if (substr($name, 0, 2) == 'AA') { |
|
138 | + return 'Å'; |
|
139 | + } |
|
140 | + break; |
|
141 | + case 'hu': |
|
142 | + if (substr($name, 0, 2) == 'CS') { |
|
143 | + return 'CS'; |
|
144 | + } elseif (substr($name, 0, 3) == 'DZS') { |
|
145 | + return 'DZS'; |
|
146 | + } elseif (substr($name, 0, 2) == 'DZ') { |
|
147 | + return 'DZ'; |
|
148 | + } elseif (substr($name, 0, 2) == 'GY') { |
|
149 | + return 'GY'; |
|
150 | + } elseif (substr($name, 0, 2) == 'LY') { |
|
151 | + return 'LY'; |
|
152 | + } elseif (substr($name, 0, 2) == 'NY') { |
|
153 | + return 'NY'; |
|
154 | + } elseif (substr($name, 0, 2) == 'SZ') { |
|
155 | + return 'SZ'; |
|
156 | + } elseif (substr($name, 0, 2) == 'TY') { |
|
157 | + return 'TY'; |
|
158 | + } elseif (substr($name, 0, 2) == 'ZS') { |
|
159 | + return 'ZS'; |
|
160 | + } |
|
161 | + break; |
|
162 | + case 'nl': |
|
163 | + if (substr($name, 0, 2) == 'IJ') { |
|
164 | + return 'IJ'; |
|
165 | + } |
|
166 | + break; |
|
167 | 167 | } |
168 | 168 | // No special rules - just take the first character |
169 | 169 | return mb_substr($name, 0, 1); |
@@ -191,37 +191,37 @@ discard block |
||
191 | 191 | */ |
192 | 192 | private static function getInitialSql($field, $letter) { |
193 | 193 | switch (WT_LOCALE) { |
194 | - case 'cs': |
|
195 | - switch ($letter) { |
|
196 | - case 'C': return $field . " LIKE 'C%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'CH%' COLLATE " . I18N::collation(); |
|
197 | - } |
|
194 | + case 'cs': |
|
195 | + switch ($letter) { |
|
196 | + case 'C': return $field . " LIKE 'C%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'CH%' COLLATE " . I18N::collation(); |
|
197 | + } |
|
198 | 198 | break; |
199 | - case 'da': |
|
200 | - case 'nb': |
|
201 | - case 'nn': |
|
202 | - switch ($letter) { |
|
203 | - // AA gets listed under Å |
|
204 | - case 'A': return $field . " LIKE 'A%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'AA%' COLLATE " . I18N::collation(); |
|
205 | - case 'Å': return "(" . $field . " LIKE 'Å%' COLLATE " . I18N::collation() . " OR " . $field . " LIKE 'AA%' COLLATE " . I18N::collation() . ")"; |
|
206 | - } |
|
199 | + case 'da': |
|
200 | + case 'nb': |
|
201 | + case 'nn': |
|
202 | + switch ($letter) { |
|
203 | + // AA gets listed under Å |
|
204 | + case 'A': return $field . " LIKE 'A%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'AA%' COLLATE " . I18N::collation(); |
|
205 | + case 'Å': return "(" . $field . " LIKE 'Å%' COLLATE " . I18N::collation() . " OR " . $field . " LIKE 'AA%' COLLATE " . I18N::collation() . ")"; |
|
206 | + } |
|
207 | 207 | break; |
208 | - case 'hu': |
|
209 | - switch ($letter) { |
|
210 | - case 'C': return $field . " LIKE 'C%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'CS%' COLLATE " . I18N::collation(); |
|
211 | - case 'D': return $field . " LIKE 'D%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'DZ%' COLLATE " . I18N::collation(); |
|
212 | - case 'DZ': return $field . " LIKE 'DZ%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'DZS%' COLLATE " . I18N::collation(); |
|
213 | - case 'G': return $field . " LIKE 'G%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'GY%' COLLATE " . I18N::collation(); |
|
214 | - case 'L': return $field . " LIKE 'L%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'LY%' COLLATE " . I18N::collation(); |
|
215 | - case 'N': return $field . " LIKE 'N%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'NY%' COLLATE " . I18N::collation(); |
|
216 | - case 'S': return $field . " LIKE 'S%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'SZ%' COLLATE " . I18N::collation(); |
|
217 | - case 'T': return $field . " LIKE 'T%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'TY%' COLLATE " . I18N::collation(); |
|
218 | - case 'Z': return $field . " LIKE 'Z%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'ZS%' COLLATE " . I18N::collation(); |
|
219 | - } |
|
208 | + case 'hu': |
|
209 | + switch ($letter) { |
|
210 | + case 'C': return $field . " LIKE 'C%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'CS%' COLLATE " . I18N::collation(); |
|
211 | + case 'D': return $field . " LIKE 'D%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'DZ%' COLLATE " . I18N::collation(); |
|
212 | + case 'DZ': return $field . " LIKE 'DZ%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'DZS%' COLLATE " . I18N::collation(); |
|
213 | + case 'G': return $field . " LIKE 'G%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'GY%' COLLATE " . I18N::collation(); |
|
214 | + case 'L': return $field . " LIKE 'L%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'LY%' COLLATE " . I18N::collation(); |
|
215 | + case 'N': return $field . " LIKE 'N%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'NY%' COLLATE " . I18N::collation(); |
|
216 | + case 'S': return $field . " LIKE 'S%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'SZ%' COLLATE " . I18N::collation(); |
|
217 | + case 'T': return $field . " LIKE 'T%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'TY%' COLLATE " . I18N::collation(); |
|
218 | + case 'Z': return $field . " LIKE 'Z%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'ZS%' COLLATE " . I18N::collation(); |
|
219 | + } |
|
220 | 220 | break; |
221 | - case 'nl': |
|
222 | - switch ($letter) { |
|
223 | - case 'I': return $field . " LIKE 'I%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'IJ%' COLLATE " . I18N::collation(); |
|
224 | - } |
|
221 | + case 'nl': |
|
222 | + switch ($letter) { |
|
223 | + case 'I': return $field . " LIKE 'I%' COLLATE " . I18N::collation() . " AND " . $field . " NOT LIKE 'IJ%' COLLATE " . I18N::collation(); |
|
224 | + } |
|
225 | 225 | break; |
226 | 226 | } |
227 | 227 |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | |
105 | 105 | // Include / exclude subfolders (but always include external) |
106 | 106 | switch ($subfolders) { |
107 | - case 'include': |
|
108 | - $sql .= " AND (m_filename LIKE CONCAT(?, '%') $sql_external)"; |
|
109 | - $args[] = Filter::escapeLike($folder); |
|
110 | - break; |
|
111 | - case 'exclude': |
|
112 | - $sql .= " AND (m_filename LIKE CONCAT(?, '%') AND m_filename NOT LIKE CONCAT(?, '%/%') $sql_external)"; |
|
113 | - $args[] = Filter::escapeLike($folder); |
|
114 | - $args[] = Filter::escapeLike($folder); |
|
115 | - break; |
|
116 | - default: |
|
117 | - throw new \Exception('Bad argument (subfolders=' . $subfolders . ') in QueryMedia::mediaList()'); |
|
107 | + case 'include': |
|
108 | + $sql .= " AND (m_filename LIKE CONCAT(?, '%') $sql_external)"; |
|
109 | + $args[] = Filter::escapeLike($folder); |
|
110 | + break; |
|
111 | + case 'exclude': |
|
112 | + $sql .= " AND (m_filename LIKE CONCAT(?, '%') AND m_filename NOT LIKE CONCAT(?, '%/%') $sql_external)"; |
|
113 | + $args[] = Filter::escapeLike($folder); |
|
114 | + $args[] = Filter::escapeLike($folder); |
|
115 | + break; |
|
116 | + default: |
|
117 | + throw new \Exception('Bad argument (subfolders=' . $subfolders . ') in QueryMedia::mediaList()'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Apply search terms |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | switch ($sort) { |
133 | - case 'file': |
|
134 | - $sql .= " ORDER BY m_filename"; |
|
135 | - break; |
|
136 | - case 'title': |
|
137 | - $sql .= " ORDER BY m_titl"; |
|
138 | - break; |
|
139 | - default: |
|
140 | - throw new \Exception('Bad argument (sort=' . $sort . ') in QueryMedia::mediaList()'); |
|
133 | + case 'file': |
|
134 | + $sql .= " ORDER BY m_filename"; |
|
135 | + break; |
|
136 | + case 'title': |
|
137 | + $sql .= " ORDER BY m_titl"; |
|
138 | + break; |
|
139 | + default: |
|
140 | + throw new \Exception('Bad argument (sort=' . $sort . ') in QueryMedia::mediaList()'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $rows = Database::prepare($sql)->execute($args)->fetchAll(); |
@@ -39,17 +39,17 @@ |
||
39 | 39 | public function newParentNames($child_name, $parent_sex) { |
40 | 40 | if (preg_match(self::REGEX_SPFX_SURN, $child_name, $match)) { |
41 | 41 | switch ($parent_sex) { |
42 | - case 'M': |
|
43 | - return array_filter(array( |
|
44 | - 'NAME' => $match['NAME'], |
|
45 | - 'SPFX' => $match['SPFX'], |
|
46 | - 'SURN' => $match['SURN'], |
|
47 | - )); |
|
48 | - case 'F': |
|
49 | - return array( |
|
50 | - 'NAME' => '//', |
|
51 | - '_MARNM' => '/' . trim($match['SPFX'] . ' ' . $match['SURN']) . '/', |
|
52 | - ); |
|
42 | + case 'M': |
|
43 | + return array_filter(array( |
|
44 | + 'NAME' => $match['NAME'], |
|
45 | + 'SPFX' => $match['SPFX'], |
|
46 | + 'SURN' => $match['SURN'], |
|
47 | + )); |
|
48 | + case 'F': |
|
49 | + return array( |
|
50 | + 'NAME' => '//', |
|
51 | + '_MARNM' => '/' . trim($match['SPFX'] . ' ' . $match['SURN']) . '/', |
|
52 | + ); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -62,16 +62,16 @@ |
||
62 | 62 | public function newParentNames($child_name, $parent_sex) { |
63 | 63 | if (preg_match(self::REGEX_SURNS, $child_name, $match)) { |
64 | 64 | switch ($parent_sex) { |
65 | - case 'M': |
|
66 | - return array( |
|
67 | - 'NAME' => '// /' . $match['SURN1'] . '/', |
|
68 | - 'SURN' => $match['SURN1'], |
|
69 | - ); |
|
70 | - case 'F': |
|
71 | - return array( |
|
72 | - 'NAME' => '// /' . $match['SURN2'] . '/', |
|
73 | - 'SURN' => $match['SURN2'], |
|
74 | - ); |
|
65 | + case 'M': |
|
66 | + return array( |
|
67 | + 'NAME' => '// /' . $match['SURN1'] . '/', |
|
68 | + 'SURN' => $match['SURN1'], |
|
69 | + ); |
|
70 | + case 'F': |
|
71 | + return array( |
|
72 | + 'NAME' => '// /' . $match['SURN2'] . '/', |
|
73 | + 'SURN' => $match['SURN2'], |
|
74 | + ); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 |