@@ -41,10 +41,10 @@ |
||
41 | 41 | protected function flashMessageContainer(\stdClass $message) { |
42 | 42 | // This theme uses jQueryUI markup. |
43 | 43 | switch ($message->status) { |
44 | - case 'danger': |
|
45 | - return '<p class="ui-state-error">' . $message->text . '</p>'; |
|
46 | - default: |
|
47 | - return '<p class="ui-state-highlight">' . $message->text . '</p>'; |
|
44 | + case 'danger': |
|
45 | + return '<p class="ui-state-error">' . $message->text . '</p>'; |
|
46 | + default: |
|
47 | + return '<p class="ui-state-highlight">' . $message->text . '</p>'; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 |
@@ -41,10 +41,10 @@ |
||
41 | 41 | protected function flashMessageContainer(\stdClass $message) { |
42 | 42 | // This theme uses jQueryUI markup. |
43 | 43 | switch ($message->status) { |
44 | - case 'danger': |
|
45 | - return '<p class="ui-state-error">' . $message->text . '</p>'; |
|
46 | - default: |
|
47 | - return '<p class="ui-state-highlight">' . $message->text . '</p>'; |
|
44 | + case 'danger': |
|
45 | + return '<p class="ui-state-error">' . $message->text . '</p>'; |
|
46 | + default: |
|
47 | + return '<p class="ui-state-highlight">' . $message->text . '</p>'; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 |
@@ -41,10 +41,10 @@ |
||
41 | 41 | protected function flashMessageContainer(\stdClass $message) { |
42 | 42 | // This theme uses jQueryUI markup. |
43 | 43 | switch ($message->status) { |
44 | - case 'danger': |
|
45 | - return '<p class="ui-state-error">' . $message->text . '</p>'; |
|
46 | - default: |
|
47 | - return '<p class="ui-state-highlight">' . $message->text . '</p>'; |
|
44 | + case 'danger': |
|
45 | + return '<p class="ui-state-error">' . $message->text . '</p>'; |
|
46 | + default: |
|
47 | + return '<p class="ui-state-highlight">' . $message->text . '</p>'; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 |
@@ -75,37 +75,37 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | switch ($mod_action) { |
78 | - case 'ajax': |
|
79 | - $html = $this->getSidebarAjaxContent(); |
|
80 | - header('Content-Type: text/html; charset=UTF-8'); |
|
81 | - echo $html; |
|
82 | - break; |
|
83 | - case 'index': |
|
84 | - global $controller, $WT_TREE; |
|
85 | - |
|
86 | - $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'); |
|
87 | - |
|
88 | - $clip_ctrl = new ClippingsCartController; |
|
89 | - $cart = Session::get('cart'); |
|
90 | - |
|
91 | - $controller = new PageController; |
|
92 | - $controller |
|
93 | - ->setPageTitle($this->getTitle()) |
|
94 | - ->pageHeader() |
|
95 | - ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) |
|
96 | - ->addInlineJavascript('autocomplete();'); |
|
97 | - |
|
98 | - echo '<script>'; |
|
99 | - echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}'; |
|
100 | - echo '</script>'; |
|
101 | - |
|
102 | - if (!$cart[$WT_TREE->getTreeId()]) { |
|
103 | - echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>'; |
|
104 | - } |
|
78 | + case 'ajax': |
|
79 | + $html = $this->getSidebarAjaxContent(); |
|
80 | + header('Content-Type: text/html; charset=UTF-8'); |
|
81 | + echo $html; |
|
82 | + break; |
|
83 | + case 'index': |
|
84 | + global $controller, $WT_TREE; |
|
85 | + |
|
86 | + $MAX_PEDIGREE_GENERATIONS = $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'); |
|
87 | + |
|
88 | + $clip_ctrl = new ClippingsCartController; |
|
89 | + $cart = Session::get('cart'); |
|
90 | + |
|
91 | + $controller = new PageController; |
|
92 | + $controller |
|
93 | + ->setPageTitle($this->getTitle()) |
|
94 | + ->pageHeader() |
|
95 | + ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) |
|
96 | + ->addInlineJavascript('autocomplete();'); |
|
97 | + |
|
98 | + echo '<script>'; |
|
99 | + echo 'function radAncestors(elementid) {var radFamilies=document.getElementById(elementid);radFamilies.checked=true;}'; |
|
100 | + echo '</script>'; |
|
101 | + |
|
102 | + if (!$cart[$WT_TREE->getTreeId()]) { |
|
103 | + echo '<h2>', I18N::translate('Family tree clippings cart'), '</h2>'; |
|
104 | + } |
|
105 | 105 | |
106 | - if ($clip_ctrl->action == 'add') { |
|
107 | - $record = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE); |
|
108 | - if ($clip_ctrl->type === 'FAM') { ?> |
|
106 | + if ($clip_ctrl->action == 'add') { |
|
107 | + $record = GedcomRecord::getInstance($clip_ctrl->id, $WT_TREE); |
|
108 | + if ($clip_ctrl->type === 'FAM') { ?> |
|
109 | 109 | <form action="module.php" method="get"> |
110 | 110 | <input type="hidden" name="mod" value="clippings"> |
111 | 111 | <input type="hidden" name="mod_action" value="index"> |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | <td class="optionbox"> |
132 | 132 | <input type="radio" name="others" value="members" checked> |
133 | 133 | <?php echo /* I18N: %s is a family (husband + wife) */ |
134 | - I18N::translate('%s and their children', $record->getFullName()); ?> |
|
134 | + I18N::translate('%s and their children', $record->getFullName()); ?> |
|
135 | 135 | </td> |
136 | 136 | </tr> |
137 | 137 | <tr> |
138 | 138 | <td class="optionbox"> |
139 | 139 | <input type="radio" name="others" value="descendants"> |
140 | 140 | <?php echo /* I18N: %s is a family (husband + wife) */ |
141 | - I18N::translate('%s and their descendants', $record->getFullName()); ?> |
|
141 | + I18N::translate('%s and their descendants', $record->getFullName()); ?> |
|
142 | 142 | </td> |
143 | 143 | </tr> |
144 | 144 | </tbody> |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | <label> |
180 | 180 | <input type="radio" name="others" value="parents"> |
181 | 181 | <?php |
182 | - if ($record->getSex() === 'F') { |
|
183 | - echo /* I18N: %s is a woman's name */ |
|
184 | - I18N::translate('%s, her parents and siblings', $record->getFullName()); |
|
185 | - } else { |
|
186 | - echo /* I18N: %s is a man's name */ |
|
187 | - I18N::translate('%s, his parents and siblings', $record->getFullName()); |
|
188 | - } |
|
189 | - ?> |
|
182 | + if ($record->getSex() === 'F') { |
|
183 | + echo /* I18N: %s is a woman's name */ |
|
184 | + I18N::translate('%s, her parents and siblings', $record->getFullName()); |
|
185 | + } else { |
|
186 | + echo /* I18N: %s is a man's name */ |
|
187 | + I18N::translate('%s, his parents and siblings', $record->getFullName()); |
|
188 | + } |
|
189 | + ?> |
|
190 | 190 | </label> |
191 | 191 | </td> |
192 | 192 | </tr> |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | <label> |
196 | 196 | <input type="radio" name="others" value="members"> |
197 | 197 | <?php |
198 | - if ($record->getSex() === 'F') { |
|
199 | - echo /* I18N: %s is a woman's name */ |
|
200 | - I18N::translate('%s, her spouses and children', $record->getFullName()); |
|
201 | - } else { |
|
202 | - echo /* I18N: %s is a man's name */ |
|
203 | - I18N::translate('%s, his spouses and children', $record->getFullName()); |
|
204 | - } |
|
205 | - ?> |
|
198 | + if ($record->getSex() === 'F') { |
|
199 | + echo /* I18N: %s is a woman's name */ |
|
200 | + I18N::translate('%s, her spouses and children', $record->getFullName()); |
|
201 | + } else { |
|
202 | + echo /* I18N: %s is a man's name */ |
|
203 | + I18N::translate('%s, his spouses and children', $record->getFullName()); |
|
204 | + } |
|
205 | + ?> |
|
206 | 206 | </label> |
207 | 207 | </td> |
208 | 208 | </tr> |
@@ -211,18 +211,18 @@ discard block |
||
211 | 211 | <label> |
212 | 212 | <input type="radio" name="others" value="ancestors" id="ancestors"> |
213 | 213 | <?php |
214 | - if ($record->getSex() === 'F') { |
|
215 | - echo /* I18N: %s is a woman's name */ |
|
216 | - I18N::translate('%s and her ancestors', $record->getFullName()); |
|
217 | - } else { |
|
218 | - echo /* I18N: %s is a man's name */ |
|
219 | - I18N::translate('%s and his ancestors', $record->getFullName()); |
|
220 | - } |
|
221 | - ?> |
|
214 | + if ($record->getSex() === 'F') { |
|
215 | + echo /* I18N: %s is a woman's name */ |
|
216 | + I18N::translate('%s and her ancestors', $record->getFullName()); |
|
217 | + } else { |
|
218 | + echo /* I18N: %s is a man's name */ |
|
219 | + I18N::translate('%s and his ancestors', $record->getFullName()); |
|
220 | + } |
|
221 | + ?> |
|
222 | 222 | </label> |
223 | 223 | <br> |
224 | 224 | <?php echo I18N::translate('Number of generations'); ?> |
225 | - <input type="text" size="5" name="level1" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestors');"> |
|
225 | + <input type="text" size="5" name="level1" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestors');"> |
|
226 | 226 | </td> |
227 | 227 | </tr> |
228 | 228 | <tr> |
@@ -230,18 +230,18 @@ discard block |
||
230 | 230 | <label> |
231 | 231 | <input type="radio" name="others" value="ancestorsfamilies" id="ancestorsfamilies"> |
232 | 232 | <?php |
233 | - if ($record->getSex() === 'F') { |
|
234 | - echo /* I18N: %s is a woman's name */ |
|
235 | - I18N::translate('%s, her ancestors and their families', $record->getFullName()); |
|
236 | - } else { |
|
237 | - echo /* I18N: %s is a man's name */ |
|
238 | - I18N::translate('%s, his ancestors and their families', $record->getFullName()); |
|
239 | - } |
|
240 | - ?> |
|
233 | + if ($record->getSex() === 'F') { |
|
234 | + echo /* I18N: %s is a woman's name */ |
|
235 | + I18N::translate('%s, her ancestors and their families', $record->getFullName()); |
|
236 | + } else { |
|
237 | + echo /* I18N: %s is a man's name */ |
|
238 | + I18N::translate('%s, his ancestors and their families', $record->getFullName()); |
|
239 | + } |
|
240 | + ?> |
|
241 | 241 | </label> |
242 | 242 | <br> |
243 | 243 | <?php echo I18N::translate('Number of generations'); ?> |
244 | - <input type="text" size="5" name="level2" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestorsfamilies');"> |
|
244 | + <input type="text" size="5" name="level2" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('ancestorsfamilies');"> |
|
245 | 245 | </td> |
246 | 246 | </tr> |
247 | 247 | <tr> |
@@ -249,18 +249,18 @@ discard block |
||
249 | 249 | <label> |
250 | 250 | <input type="radio" name="others" value="descendants" id="descendants"> |
251 | 251 | <?php |
252 | - if ($record->getSex() === 'F') { |
|
253 | - echo /* I18N: %s is a woman's name */ |
|
254 | - I18N::translate('%s, her spouses and descendants', $record->getFullName()); |
|
255 | - } else { |
|
256 | - echo /* I18N: %s is a man's name */ |
|
257 | - I18N::translate('%s, his spouses and descendants', $record->getFullName()); |
|
258 | - } |
|
259 | - ?> |
|
252 | + if ($record->getSex() === 'F') { |
|
253 | + echo /* I18N: %s is a woman's name */ |
|
254 | + I18N::translate('%s, her spouses and descendants', $record->getFullName()); |
|
255 | + } else { |
|
256 | + echo /* I18N: %s is a man's name */ |
|
257 | + I18N::translate('%s, his spouses and descendants', $record->getFullName()); |
|
258 | + } |
|
259 | + ?> |
|
260 | 260 | </label> |
261 | 261 | <br> |
262 | 262 | <?php echo I18N::translate('Number of generations'); ?> |
263 | - <input type="text" size="5" name="level3" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('descendants');"> |
|
263 | + <input type="text" size="5" name="level3" value="<?php echo $MAX_PEDIGREE_GENERATIONS; ?>" onfocus="radAncestors('descendants');"> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | 266 | </tbody> |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | <label> |
303 | 303 | <input type="radio" name="others" value="linked"> |
304 | 304 | <?php echo /* I18N: %s is the name of a source */ |
305 | - I18N::translate('%s and the individuals that reference it.', $record->getFullName()); ?> |
|
305 | + I18N::translate('%s and the individuals that reference it.', $record->getFullName()); ?> |
|
306 | 306 | </label> |
307 | 307 | </td> |
308 | 308 | </tr> |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | </table> |
318 | 318 | </form> |
319 | 319 | <?php } |
320 | - } |
|
320 | + } |
|
321 | 321 | |
322 | - if (!$cart[$WT_TREE->getTreeId()]) { |
|
323 | - if ($clip_ctrl->action != 'add') { |
|
324 | - echo I18N::translate('The clippings cart allows you to take extracts from this family tree and download them as a GEDCOM file.'); |
|
325 | - ?> |
|
322 | + if (!$cart[$WT_TREE->getTreeId()]) { |
|
323 | + if ($clip_ctrl->action != 'add') { |
|
324 | + echo I18N::translate('The clippings cart allows you to take extracts from this family tree and download them as a GEDCOM file.'); |
|
325 | + ?> |
|
326 | 326 | <form method="get" name="addin" action="module.php"> |
327 | 327 | <input type="hidden" name="mod" value="clippings"> |
328 | 328 | <input type="hidden" name="mod_action" value="index"> |
@@ -342,25 +342,25 @@ discard block |
||
342 | 342 | </td> |
343 | 343 | <td class="optionbox"> |
344 | 344 | <?php echo FunctionsPrint::printFindIndividualLink('cart_item_id'); ?> |
345 | - <?php echo FunctionsPrint::printFindFamilyLink('cart_item_id'); ?> |
|
346 | - <?php echo FunctionsPrint::printFindSourceLink('cart_item_id', ''); ?> |
|
347 | - <input type="submit" value="<?php echo /* I18N: A button label. */ I18N::translate('add'); ?>"> |
|
345 | + <?php echo FunctionsPrint::printFindFamilyLink('cart_item_id'); ?> |
|
346 | + <?php echo FunctionsPrint::printFindSourceLink('cart_item_id', ''); ?> |
|
347 | + <input type="submit" value="<?php echo /* I18N: A button label. */ I18N::translate('add'); ?>"> |
|
348 | 348 | </td> |
349 | 349 | </tr> |
350 | 350 | </tbody> |
351 | 351 | </table> |
352 | 352 | </form> |
353 | 353 | <?php |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | - // -- end new lines |
|
357 | - echo I18N::translate('Your clippings cart is empty.'); |
|
358 | - } else { |
|
359 | - // Keep track of the INDI from the parent page, otherwise it will |
|
360 | - // get lost after ajax updates |
|
361 | - $pid = Filter::get('pid', WT_REGEX_XREF); |
|
356 | + // -- end new lines |
|
357 | + echo I18N::translate('Your clippings cart is empty.'); |
|
358 | + } else { |
|
359 | + // Keep track of the INDI from the parent page, otherwise it will |
|
360 | + // get lost after ajax updates |
|
361 | + $pid = Filter::get('pid', WT_REGEX_XREF); |
|
362 | 362 | |
363 | - if ($clip_ctrl->action !== 'download' && $clip_ctrl->action !== 'add') { ?> |
|
363 | + if ($clip_ctrl->action !== 'download' && $clip_ctrl->action !== 'add') { ?> |
|
364 | 364 | <form method="get" action="module.php"> |
365 | 365 | <input type="hidden" name="mod" value="clippings"> |
366 | 366 | <input type="hidden" name="mod_action" value="index"> |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | </td> |
469 | 469 | <td class="optionbox"> |
470 | 470 | <?php echo FunctionsPrint::printFindIndividualLink('cart_item_id'); ?> |
471 | - <?php echo FunctionsPrint::printFindFamilyLink('cart_item_id'); ?> |
|
472 | - <?php echo FunctionsPrint::printFindSourceLink('cart_item_id'); ?> |
|
473 | - <input type="submit" value="<?php echo /* I18N: A button label. */ I18N::translate('add'); ?>"> |
|
471 | + <?php echo FunctionsPrint::printFindFamilyLink('cart_item_id'); ?> |
|
472 | + <?php echo FunctionsPrint::printFindSourceLink('cart_item_id'); ?> |
|
473 | + <input type="submit" value="<?php echo /* I18N: A button label. */ I18N::translate('add'); ?>"> |
|
474 | 474 | </td> |
475 | 475 | </tr> |
476 | 476 | </tbody> |
@@ -500,32 +500,32 @@ discard block |
||
500 | 500 | </thead> |
501 | 501 | <tbody> |
502 | 502 | <?php |
503 | - foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) { |
|
504 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
505 | - if ($record) { |
|
506 | - switch ($record::RECORD_TYPE) { |
|
507 | - case 'INDI': |
|
508 | - $icon = 'icon-indis'; |
|
509 | - break; |
|
510 | - case 'FAM': |
|
511 | - $icon = 'icon-sfamily'; |
|
512 | - break; |
|
513 | - case 'SOUR': |
|
514 | - $icon = 'icon-source'; |
|
515 | - break; |
|
516 | - case 'REPO': |
|
517 | - $icon = 'icon-repository'; |
|
518 | - break; |
|
519 | - case 'NOTE': |
|
520 | - $icon = 'icon-note'; |
|
521 | - break; |
|
522 | - case 'OBJE': |
|
523 | - $icon = 'icon-media'; |
|
524 | - break; |
|
525 | - default: |
|
526 | - $icon = 'icon-clippings'; |
|
527 | - break; |
|
528 | - } |
|
503 | + foreach (array_keys($cart[$WT_TREE->getTreeId()]) as $xref) { |
|
504 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
505 | + if ($record) { |
|
506 | + switch ($record::RECORD_TYPE) { |
|
507 | + case 'INDI': |
|
508 | + $icon = 'icon-indis'; |
|
509 | + break; |
|
510 | + case 'FAM': |
|
511 | + $icon = 'icon-sfamily'; |
|
512 | + break; |
|
513 | + case 'SOUR': |
|
514 | + $icon = 'icon-source'; |
|
515 | + break; |
|
516 | + case 'REPO': |
|
517 | + $icon = 'icon-repository'; |
|
518 | + break; |
|
519 | + case 'NOTE': |
|
520 | + $icon = 'icon-note'; |
|
521 | + break; |
|
522 | + case 'OBJE': |
|
523 | + $icon = 'icon-media'; |
|
524 | + break; |
|
525 | + default: |
|
526 | + $icon = 'icon-clippings'; |
|
527 | + break; |
|
528 | + } |
|
529 | 529 | ?> |
530 | 530 | <tr> |
531 | 531 | <td class="list_value"> |
@@ -544,9 +544,9 @@ discard block |
||
544 | 544 | <?php |
545 | 545 | } |
546 | 546 | break; |
547 | - default: |
|
548 | - http_response_code(404); |
|
549 | - break; |
|
547 | + default: |
|
548 | + http_response_code(404); |
|
549 | + break; |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
@@ -695,12 +695,12 @@ discard block |
||
695 | 695 | $record = GedcomRecord::getInstance($xref, $WT_TREE); |
696 | 696 | if ($record instanceof Individual || $record instanceof Family) { |
697 | 697 | switch ($record::RECORD_TYPE) { |
698 | - case 'INDI': |
|
699 | - $icon = 'icon-indis'; |
|
700 | - break; |
|
701 | - case 'FAM': |
|
702 | - $icon = 'icon-sfamily'; |
|
703 | - break; |
|
698 | + case 'INDI': |
|
699 | + $icon = 'icon-indis'; |
|
700 | + break; |
|
701 | + case 'FAM': |
|
702 | + $icon = 'icon-sfamily'; |
|
703 | + break; |
|
704 | 704 | } |
705 | 705 | $out .= '<li>'; |
706 | 706 | if (!empty($icon)) { |
@@ -169,22 +169,22 @@ discard block |
||
169 | 169 | } |
170 | 170 | // Now construct an object of the correct type |
171 | 171 | switch ($cal) { |
172 | - case '@#DGREGORIAN@': |
|
173 | - return new GregorianDate(array($y, $m, $d)); |
|
174 | - case '@#DJULIAN@': |
|
175 | - return new JulianDate(array($y, $m, $d)); |
|
176 | - case '@#DHEBREW@': |
|
177 | - return new JewishDate(array($y, $m, $d)); |
|
178 | - case '@#DHIJRI@': |
|
179 | - return new HijriDate(array($y, $m, $d)); |
|
180 | - case '@#DFRENCH R@': |
|
181 | - return new FrenchDate(array($y, $m, $d)); |
|
182 | - case '@#DJALALI@': |
|
183 | - return new JalaliDate(array($y, $m, $d)); |
|
184 | - case '@#DROMAN@': |
|
185 | - return new RomanDate(array($y, $m, $d)); |
|
186 | - default: |
|
187 | - throw new \DomainException('Invalid calendar'); |
|
172 | + case '@#DGREGORIAN@': |
|
173 | + return new GregorianDate(array($y, $m, $d)); |
|
174 | + case '@#DJULIAN@': |
|
175 | + return new JulianDate(array($y, $m, $d)); |
|
176 | + case '@#DHEBREW@': |
|
177 | + return new JewishDate(array($y, $m, $d)); |
|
178 | + case '@#DHIJRI@': |
|
179 | + return new HijriDate(array($y, $m, $d)); |
|
180 | + case '@#DFRENCH R@': |
|
181 | + return new FrenchDate(array($y, $m, $d)); |
|
182 | + case '@#DJALALI@': |
|
183 | + return new JalaliDate(array($y, $m, $d)); |
|
184 | + case '@#DROMAN@': |
|
185 | + return new RomanDate(array($y, $m, $d)); |
|
186 | + default: |
|
187 | + throw new \DomainException('Invalid calendar'); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -291,42 +291,42 @@ discard block |
||
291 | 291 | |
292 | 292 | // Localise the date |
293 | 293 | switch ($q1 . $q2) { |
294 | - case '': |
|
295 | - $tmp = $d1 . $conv1; |
|
296 | - break; |
|
297 | - case 'ABT': |
|
298 | - $tmp = /* I18N: Gedcom ABT dates */ I18N::translate('about %s', $d1 . $conv1); |
|
299 | - break; |
|
300 | - case 'CAL': |
|
301 | - $tmp = /* I18N: Gedcom CAL dates */ I18N::translate('calculated %s', $d1 . $conv1); |
|
302 | - break; |
|
303 | - case 'EST': |
|
304 | - $tmp = /* I18N: Gedcom EST dates */ I18N::translate('estimated %s', $d1 . $conv1); |
|
305 | - break; |
|
306 | - case 'INT': |
|
307 | - $tmp = /* I18N: Gedcom INT dates */ I18N::translate('interpreted %s (%s)', $d1 . $conv1, Filter::escapeHtml($this->text)); |
|
308 | - break; |
|
309 | - case 'BEF': |
|
310 | - $tmp = /* I18N: Gedcom BEF dates */ I18N::translate('before %s', $d1 . $conv1); |
|
311 | - break; |
|
312 | - case 'AFT': |
|
313 | - $tmp = /* I18N: Gedcom AFT dates */ I18N::translate('after %s', $d1 . $conv1); |
|
314 | - break; |
|
315 | - case 'FROM': |
|
316 | - $tmp = /* I18N: Gedcom FROM dates */ I18N::translate('from %s', $d1 . $conv1); |
|
317 | - break; |
|
318 | - case 'TO': |
|
319 | - $tmp = /* I18N: Gedcom TO dates */ I18N::translate('to %s', $d1 . $conv1); |
|
320 | - break; |
|
321 | - case 'BETAND': |
|
322 | - $tmp = /* I18N: Gedcom BET-AND dates */ I18N::translate('between %s and %s', $d1 . $conv1, $d2 . $conv2); |
|
323 | - break; |
|
324 | - case 'FROMTO': |
|
325 | - $tmp = /* I18N: Gedcom FROM-TO dates */ I18N::translate('from %s to %s', $d1 . $conv1, $d2 . $conv2); |
|
326 | - break; |
|
327 | - default: |
|
328 | - $tmp = I18N::translate('Invalid date'); |
|
329 | - break; // e.g. BET without AND |
|
294 | + case '': |
|
295 | + $tmp = $d1 . $conv1; |
|
296 | + break; |
|
297 | + case 'ABT': |
|
298 | + $tmp = /* I18N: Gedcom ABT dates */ I18N::translate('about %s', $d1 . $conv1); |
|
299 | + break; |
|
300 | + case 'CAL': |
|
301 | + $tmp = /* I18N: Gedcom CAL dates */ I18N::translate('calculated %s', $d1 . $conv1); |
|
302 | + break; |
|
303 | + case 'EST': |
|
304 | + $tmp = /* I18N: Gedcom EST dates */ I18N::translate('estimated %s', $d1 . $conv1); |
|
305 | + break; |
|
306 | + case 'INT': |
|
307 | + $tmp = /* I18N: Gedcom INT dates */ I18N::translate('interpreted %s (%s)', $d1 . $conv1, Filter::escapeHtml($this->text)); |
|
308 | + break; |
|
309 | + case 'BEF': |
|
310 | + $tmp = /* I18N: Gedcom BEF dates */ I18N::translate('before %s', $d1 . $conv1); |
|
311 | + break; |
|
312 | + case 'AFT': |
|
313 | + $tmp = /* I18N: Gedcom AFT dates */ I18N::translate('after %s', $d1 . $conv1); |
|
314 | + break; |
|
315 | + case 'FROM': |
|
316 | + $tmp = /* I18N: Gedcom FROM dates */ I18N::translate('from %s', $d1 . $conv1); |
|
317 | + break; |
|
318 | + case 'TO': |
|
319 | + $tmp = /* I18N: Gedcom TO dates */ I18N::translate('to %s', $d1 . $conv1); |
|
320 | + break; |
|
321 | + case 'BETAND': |
|
322 | + $tmp = /* I18N: Gedcom BET-AND dates */ I18N::translate('between %s and %s', $d1 . $conv1, $d2 . $conv2); |
|
323 | + break; |
|
324 | + case 'FROMTO': |
|
325 | + $tmp = /* I18N: Gedcom FROM-TO dates */ I18N::translate('from %s to %s', $d1 . $conv1, $d2 . $conv2); |
|
326 | + break; |
|
327 | + default: |
|
328 | + $tmp = I18N::translate('Invalid date'); |
|
329 | + break; // e.g. BET without AND |
|
330 | 330 | } |
331 | 331 | if ($this->text && !$q1) { |
332 | 332 | $tmp = I18N::translate('%1$s (%2$s)', $tmp, $this->text); |
@@ -445,33 +445,33 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | switch ($format) { |
448 | - case 0: |
|
449 | - // Years - integer only (for statistics, rather than for display) |
|
450 | - if ($jd && $d1->minimumJulianDay() && $d1->minimumJulianDay() <= $jd) { |
|
451 | - return $d1->minimumDate()->getAge(false, $jd, false); |
|
452 | - } else { |
|
453 | - return -1; |
|
454 | - } |
|
455 | - case 1: |
|
456 | - // Days - integer only (for sorting, rather than for display) |
|
457 | - if ($jd && $d1->minimumJulianDay()) { |
|
458 | - return $jd - $d1->minimumJulianDay(); |
|
459 | - } else { |
|
460 | - return -1; |
|
461 | - } |
|
462 | - case 2: |
|
463 | - // Just years, in local digits, with warning for negative/ |
|
464 | - if ($jd && $d1->minimumJulianDay()) { |
|
465 | - if ($d1->minimumJulianDay() > $jd) { |
|
466 | - return '<i class="icon-warning"></i>'; |
|
448 | + case 0: |
|
449 | + // Years - integer only (for statistics, rather than for display) |
|
450 | + if ($jd && $d1->minimumJulianDay() && $d1->minimumJulianDay() <= $jd) { |
|
451 | + return $d1->minimumDate()->getAge(false, $jd, false); |
|
467 | 452 | } else { |
468 | - return I18N::number($d1->minimumDate()->getAge(false, $jd)); |
|
453 | + return -1; |
|
469 | 454 | } |
470 | - } else { |
|
471 | - return ''; |
|
472 | - } |
|
473 | - default: |
|
474 | - throw new \InvalidArgumentException('format: ' . $format); |
|
455 | + case 1: |
|
456 | + // Days - integer only (for sorting, rather than for display) |
|
457 | + if ($jd && $d1->minimumJulianDay()) { |
|
458 | + return $jd - $d1->minimumJulianDay(); |
|
459 | + } else { |
|
460 | + return -1; |
|
461 | + } |
|
462 | + case 2: |
|
463 | + // Just years, in local digits, with warning for negative/ |
|
464 | + if ($jd && $d1->minimumJulianDay()) { |
|
465 | + if ($d1->minimumJulianDay() > $jd) { |
|
466 | + return '<i class="icon-warning"></i>'; |
|
467 | + } else { |
|
468 | + return I18N::number($d1->minimumDate()->getAge(false, $jd)); |
|
469 | + } |
|
470 | + } else { |
|
471 | + return ''; |
|
472 | + } |
|
473 | + default: |
|
474 | + throw new \InvalidArgumentException('format: ' . $format); |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
@@ -515,32 +515,32 @@ discard block |
||
515 | 515 | public static function compare(Date $a, Date $b) { |
516 | 516 | // Get min/max JD for each date. |
517 | 517 | switch ($a->qual1) { |
518 | - case 'BEF': |
|
519 | - $amin = $a->minimumJulianDay() - 1; |
|
520 | - $amax = $amin; |
|
521 | - break; |
|
522 | - case 'AFT': |
|
523 | - $amax = $a->maximumJulianDay() + 1; |
|
524 | - $amin = $amax; |
|
525 | - break; |
|
526 | - default: |
|
527 | - $amin = $a->minimumJulianDay(); |
|
528 | - $amax = $a->maximumJulianDay(); |
|
529 | - break; |
|
518 | + case 'BEF': |
|
519 | + $amin = $a->minimumJulianDay() - 1; |
|
520 | + $amax = $amin; |
|
521 | + break; |
|
522 | + case 'AFT': |
|
523 | + $amax = $a->maximumJulianDay() + 1; |
|
524 | + $amin = $amax; |
|
525 | + break; |
|
526 | + default: |
|
527 | + $amin = $a->minimumJulianDay(); |
|
528 | + $amax = $a->maximumJulianDay(); |
|
529 | + break; |
|
530 | 530 | } |
531 | 531 | switch ($b->qual1) { |
532 | - case 'BEF': |
|
533 | - $bmin = $b->minimumJulianDay() - 1; |
|
534 | - $bmax = $bmin; |
|
535 | - break; |
|
536 | - case 'AFT': |
|
537 | - $bmax = $b->maximumJulianDay() + 1; |
|
538 | - $bmin = $bmax; |
|
539 | - break; |
|
540 | - default: |
|
541 | - $bmin = $b->minimumJulianDay(); |
|
542 | - $bmax = $b->maximumJulianDay(); |
|
543 | - break; |
|
532 | + case 'BEF': |
|
533 | + $bmin = $b->minimumJulianDay() - 1; |
|
534 | + $bmax = $bmin; |
|
535 | + break; |
|
536 | + case 'AFT': |
|
537 | + $bmax = $b->maximumJulianDay() + 1; |
|
538 | + $bmin = $bmax; |
|
539 | + break; |
|
540 | + default: |
|
541 | + $bmin = $b->minimumJulianDay(); |
|
542 | + $bmax = $b->maximumJulianDay(); |
|
543 | + break; |
|
544 | 544 | } |
545 | 545 | if ($amax < $bmin) { |
546 | 546 | return -1; |
@@ -303,22 +303,22 @@ discard block |
||
303 | 303 | */ |
304 | 304 | private function getPercentage($total, $type) { |
305 | 305 | switch ($type) { |
306 | - case 'individual': |
|
307 | - $type = $this->totalIndividualsQuery(); |
|
308 | - break; |
|
309 | - case 'family': |
|
310 | - $type = $this->totalFamiliesQuery(); |
|
311 | - break; |
|
312 | - case 'source': |
|
313 | - $type = $this->totalSourcesQuery(); |
|
314 | - break; |
|
315 | - case 'note': |
|
316 | - $type = $this->totalNotesQuery(); |
|
317 | - break; |
|
318 | - case 'all': |
|
319 | - default: |
|
320 | - $type = $this->totalIndividualsQuery() + $this->totalFamiliesQuery() + $this->totalSourcesQuery(); |
|
321 | - break; |
|
306 | + case 'individual': |
|
307 | + $type = $this->totalIndividualsQuery(); |
|
308 | + break; |
|
309 | + case 'family': |
|
310 | + $type = $this->totalFamiliesQuery(); |
|
311 | + break; |
|
312 | + case 'source': |
|
313 | + $type = $this->totalSourcesQuery(); |
|
314 | + break; |
|
315 | + case 'note': |
|
316 | + $type = $this->totalNotesQuery(); |
|
317 | + break; |
|
318 | + case 'all': |
|
319 | + default: |
|
320 | + $type = $this->totalIndividualsQuery() + $this->totalFamiliesQuery() + $this->totalSourcesQuery(); |
|
321 | + break; |
|
322 | 322 | } |
323 | 323 | if ($type == 0) { |
324 | 324 | return I18N::percentage(0, 1); |
@@ -1444,29 +1444,29 @@ discard block |
||
1444 | 1444 | $row = $rows[0]; |
1445 | 1445 | $record = GedcomRecord::getInstance($row['d_gid'], $this->tree); |
1446 | 1446 | switch ($type) { |
1447 | - default: |
|
1448 | - case 'full': |
|
1449 | - if ($record->canShow()) { |
|
1450 | - $result = $record->formatList('span', false, $record->getFullName()); |
|
1451 | - } else { |
|
1452 | - $result = I18N::translate('This information is private and cannot be shown.'); |
|
1453 | - } |
|
1454 | - break; |
|
1455 | - case 'year': |
|
1456 | - $date = new Date($row['d_type'] . ' ' . $row['d_year']); |
|
1457 | - $result = $date->display(); |
|
1458 | - break; |
|
1459 | - case 'name': |
|
1460 | - $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>"; |
|
1461 | - break; |
|
1462 | - case 'place': |
|
1463 | - $fact = GedcomRecord::getInstance($row['d_gid'], $this->tree)->getFirstFact($row['d_fact']); |
|
1464 | - if ($fact) { |
|
1465 | - $result = FunctionsPrint::formatFactPlace($fact, true, true, true); |
|
1466 | - } else { |
|
1467 | - $result = I18N::translate('Private'); |
|
1468 | - } |
|
1469 | - break; |
|
1447 | + default: |
|
1448 | + case 'full': |
|
1449 | + if ($record->canShow()) { |
|
1450 | + $result = $record->formatList('span', false, $record->getFullName()); |
|
1451 | + } else { |
|
1452 | + $result = I18N::translate('This information is private and cannot be shown.'); |
|
1453 | + } |
|
1454 | + break; |
|
1455 | + case 'year': |
|
1456 | + $date = new Date($row['d_type'] . ' ' . $row['d_year']); |
|
1457 | + $result = $date->display(); |
|
1458 | + break; |
|
1459 | + case 'name': |
|
1460 | + $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>"; |
|
1461 | + break; |
|
1462 | + case 'place': |
|
1463 | + $fact = GedcomRecord::getInstance($row['d_gid'], $this->tree)->getFirstFact($row['d_fact']); |
|
1464 | + if ($fact) { |
|
1465 | + $result = FunctionsPrint::formatFactPlace($fact, true, true, true); |
|
1466 | + } else { |
|
1467 | + $result = I18N::translate('Private'); |
|
1468 | + } |
|
1469 | + break; |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | return $result; |
@@ -1631,96 +1631,96 @@ discard block |
||
1631 | 1631 | } |
1632 | 1632 | I18N::init(WT_LOCALE); |
1633 | 1633 | switch ($chart_type) { |
1634 | - case 'surname_distribution_chart': |
|
1635 | - if ($surname == "") { |
|
1636 | - $surname = $this->getCommonSurname(); |
|
1637 | - } |
|
1638 | - $chart_title = I18N::translate('Surname distribution chart') . ': ' . $surname; |
|
1639 | - // Count how many people are events in each country |
|
1640 | - $surn_countries = array(); |
|
1641 | - $indis = QueryName::individuals($this->tree, I18N::strtoupper($surname), '', '', false, false); |
|
1642 | - foreach ($indis as $person) { |
|
1643 | - if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $person->getGedcom(), $matches)) { |
|
1644 | - // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. |
|
1645 | - foreach ($matches[1] as $country) { |
|
1646 | - if (array_key_exists($country, $country_to_iso3166)) { |
|
1647 | - if (array_key_exists($country_to_iso3166[$country], $surn_countries)) { |
|
1648 | - $surn_countries[$country_to_iso3166[$country]]++; |
|
1649 | - } else { |
|
1650 | - $surn_countries[$country_to_iso3166[$country]] = 1; |
|
1634 | + case 'surname_distribution_chart': |
|
1635 | + if ($surname == "") { |
|
1636 | + $surname = $this->getCommonSurname(); |
|
1637 | + } |
|
1638 | + $chart_title = I18N::translate('Surname distribution chart') . ': ' . $surname; |
|
1639 | + // Count how many people are events in each country |
|
1640 | + $surn_countries = array(); |
|
1641 | + $indis = QueryName::individuals($this->tree, I18N::strtoupper($surname), '', '', false, false); |
|
1642 | + foreach ($indis as $person) { |
|
1643 | + if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $person->getGedcom(), $matches)) { |
|
1644 | + // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. |
|
1645 | + foreach ($matches[1] as $country) { |
|
1646 | + if (array_key_exists($country, $country_to_iso3166)) { |
|
1647 | + if (array_key_exists($country_to_iso3166[$country], $surn_countries)) { |
|
1648 | + $surn_countries[$country_to_iso3166[$country]]++; |
|
1649 | + } else { |
|
1650 | + $surn_countries[$country_to_iso3166[$country]] = 1; |
|
1651 | + } |
|
1651 | 1652 | } |
1652 | 1653 | } |
1653 | 1654 | } |
1654 | - } |
|
1655 | - }; |
|
1656 | - break; |
|
1657 | - case 'birth_distribution_chart': |
|
1658 | - $chart_title = I18N::translate('Birth by country'); |
|
1659 | - // Count how many people were born in each country |
|
1660 | - $surn_countries = array(); |
|
1661 | - $b_countries = $this->statsPlaces('INDI', 'BIRT', 0, true); |
|
1662 | - foreach ($b_countries as $place => $count) { |
|
1663 | - $country = $place; |
|
1664 | - if (array_key_exists($country, $country_to_iso3166)) { |
|
1665 | - if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1666 | - $surn_countries[$country_to_iso3166[$country]] = $count; |
|
1667 | - } else { |
|
1668 | - $surn_countries[$country_to_iso3166[$country]] += $count; |
|
1655 | + }; |
|
1656 | + break; |
|
1657 | + case 'birth_distribution_chart': |
|
1658 | + $chart_title = I18N::translate('Birth by country'); |
|
1659 | + // Count how many people were born in each country |
|
1660 | + $surn_countries = array(); |
|
1661 | + $b_countries = $this->statsPlaces('INDI', 'BIRT', 0, true); |
|
1662 | + foreach ($b_countries as $place => $count) { |
|
1663 | + $country = $place; |
|
1664 | + if (array_key_exists($country, $country_to_iso3166)) { |
|
1665 | + if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1666 | + $surn_countries[$country_to_iso3166[$country]] = $count; |
|
1667 | + } else { |
|
1668 | + $surn_countries[$country_to_iso3166[$country]] += $count; |
|
1669 | + } |
|
1669 | 1670 | } |
1670 | 1671 | } |
1671 | - } |
|
1672 | - break; |
|
1673 | - case 'death_distribution_chart': |
|
1674 | - $chart_title = I18N::translate('Death by country'); |
|
1675 | - // Count how many people were death in each country |
|
1676 | - $surn_countries = array(); |
|
1677 | - $d_countries = $this->statsPlaces('INDI', 'DEAT', 0, true); |
|
1678 | - foreach ($d_countries as $place => $count) { |
|
1679 | - $country = $place; |
|
1680 | - if (array_key_exists($country, $country_to_iso3166)) { |
|
1681 | - if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1682 | - $surn_countries[$country_to_iso3166[$country]] = $count; |
|
1683 | - } else { |
|
1684 | - $surn_countries[$country_to_iso3166[$country]] += $count; |
|
1672 | + break; |
|
1673 | + case 'death_distribution_chart': |
|
1674 | + $chart_title = I18N::translate('Death by country'); |
|
1675 | + // Count how many people were death in each country |
|
1676 | + $surn_countries = array(); |
|
1677 | + $d_countries = $this->statsPlaces('INDI', 'DEAT', 0, true); |
|
1678 | + foreach ($d_countries as $place => $count) { |
|
1679 | + $country = $place; |
|
1680 | + if (array_key_exists($country, $country_to_iso3166)) { |
|
1681 | + if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1682 | + $surn_countries[$country_to_iso3166[$country]] = $count; |
|
1683 | + } else { |
|
1684 | + $surn_countries[$country_to_iso3166[$country]] += $count; |
|
1685 | + } |
|
1685 | 1686 | } |
1686 | 1687 | } |
1687 | - } |
|
1688 | - break; |
|
1689 | - case 'marriage_distribution_chart': |
|
1690 | - $chart_title = I18N::translate('Marriage by country'); |
|
1691 | - // Count how many families got marriage in each country |
|
1692 | - $surn_countries = array(); |
|
1693 | - $m_countries = $this->statsPlaces('FAM'); |
|
1694 | - // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. |
|
1695 | - foreach ($m_countries as $place) { |
|
1696 | - $country = $place['country']; |
|
1697 | - if (array_key_exists($country, $country_to_iso3166)) { |
|
1698 | - if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1699 | - $surn_countries[$country_to_iso3166[$country]] = $place['tot']; |
|
1700 | - } else { |
|
1701 | - $surn_countries[$country_to_iso3166[$country]] += $place['tot']; |
|
1688 | + break; |
|
1689 | + case 'marriage_distribution_chart': |
|
1690 | + $chart_title = I18N::translate('Marriage by country'); |
|
1691 | + // Count how many families got marriage in each country |
|
1692 | + $surn_countries = array(); |
|
1693 | + $m_countries = $this->statsPlaces('FAM'); |
|
1694 | + // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. |
|
1695 | + foreach ($m_countries as $place) { |
|
1696 | + $country = $place['country']; |
|
1697 | + if (array_key_exists($country, $country_to_iso3166)) { |
|
1698 | + if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1699 | + $surn_countries[$country_to_iso3166[$country]] = $place['tot']; |
|
1700 | + } else { |
|
1701 | + $surn_countries[$country_to_iso3166[$country]] += $place['tot']; |
|
1702 | + } |
|
1702 | 1703 | } |
1703 | 1704 | } |
1704 | - } |
|
1705 | - break; |
|
1706 | - case 'indi_distribution_chart': |
|
1707 | - default: |
|
1708 | - $chart_title = I18N::translate('Individual distribution chart'); |
|
1709 | - // Count how many people have events in each country |
|
1710 | - $surn_countries = array(); |
|
1711 | - $a_countries = $this->statsPlaces('INDI'); |
|
1712 | - // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. |
|
1713 | - foreach ($a_countries as $place) { |
|
1714 | - $country = $place['country']; |
|
1715 | - if (array_key_exists($country, $country_to_iso3166)) { |
|
1716 | - if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1717 | - $surn_countries[$country_to_iso3166[$country]] = $place['tot']; |
|
1718 | - } else { |
|
1719 | - $surn_countries[$country_to_iso3166[$country]] += $place['tot']; |
|
1705 | + break; |
|
1706 | + case 'indi_distribution_chart': |
|
1707 | + default: |
|
1708 | + $chart_title = I18N::translate('Individual distribution chart'); |
|
1709 | + // Count how many people have events in each country |
|
1710 | + $surn_countries = array(); |
|
1711 | + $a_countries = $this->statsPlaces('INDI'); |
|
1712 | + // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. |
|
1713 | + foreach ($a_countries as $place) { |
|
1714 | + $country = $place['country']; |
|
1715 | + if (array_key_exists($country, $country_to_iso3166)) { |
|
1716 | + if (!isset($surn_countries[$country_to_iso3166[$country]])) { |
|
1717 | + $surn_countries[$country_to_iso3166[$country]] = $place['tot']; |
|
1718 | + } else { |
|
1719 | + $surn_countries[$country_to_iso3166[$country]] += $place['tot']; |
|
1720 | + } |
|
1720 | 1721 | } |
1721 | 1722 | } |
1722 | - } |
|
1723 | - break; |
|
1723 | + break; |
|
1724 | 1724 | } |
1725 | 1725 | $chart_url = "https://chart.googleapis.com/chart?cht=t&chtm=" . $chart_shows; |
1726 | 1726 | $chart_url .= "&chco=" . $WT_STATS_CHART_COLOR1 . "," . $WT_STATS_CHART_COLOR3 . "," . $WT_STATS_CHART_COLOR2; // country colours |
@@ -2259,20 +2259,20 @@ discard block |
||
2259 | 2259 | $row = $rows[0]; |
2260 | 2260 | $person = Individual::getInstance($row['id'], $this->tree); |
2261 | 2261 | switch ($type) { |
2262 | - default: |
|
2263 | - case 'full': |
|
2264 | - if ($person->canShowName()) { |
|
2265 | - $result = $person->formatList('span', false, $person->getFullName()); |
|
2266 | - } else { |
|
2267 | - $result = I18N::translate('This information is private and cannot be shown.'); |
|
2268 | - } |
|
2269 | - break; |
|
2270 | - case 'age': |
|
2271 | - $result = I18N::number((int) ($row['age'] / 365.25)); |
|
2272 | - break; |
|
2273 | - case 'name': |
|
2274 | - $result = "<a href=\"" . $person->getHtmlUrl() . "\">" . $person->getFullName() . "</a>"; |
|
2275 | - break; |
|
2262 | + default: |
|
2263 | + case 'full': |
|
2264 | + if ($person->canShowName()) { |
|
2265 | + $result = $person->formatList('span', false, $person->getFullName()); |
|
2266 | + } else { |
|
2267 | + $result = I18N::translate('This information is private and cannot be shown.'); |
|
2268 | + } |
|
2269 | + break; |
|
2270 | + case 'age': |
|
2271 | + $result = I18N::number((int) ($row['age'] / 365.25)); |
|
2272 | + break; |
|
2273 | + case 'name': |
|
2274 | + $result = "<a href=\"" . $person->getHtmlUrl() . "\">" . $person->getFullName() . "</a>"; |
|
2275 | + break; |
|
2276 | 2276 | } |
2277 | 2277 | |
2278 | 2278 | return $result; |
@@ -2942,36 +2942,36 @@ discard block |
||
2942 | 2942 | $row = $rows[0]; |
2943 | 2943 | $record = GedcomRecord::getInstance($row['id'], $this->tree); |
2944 | 2944 | switch ($type) { |
2945 | - default: |
|
2946 | - case 'full': |
|
2947 | - if ($record->canShow()) { |
|
2948 | - $result = $record->formatList('span', false, $record->getFullName()); |
|
2949 | - } else { |
|
2950 | - $result = I18N::translate('This information is private and cannot be shown.'); |
|
2951 | - } |
|
2952 | - break; |
|
2953 | - case 'year': |
|
2954 | - $date = new Date($row['type'] . ' ' . $row['year']); |
|
2955 | - $result = $date->display(); |
|
2956 | - break; |
|
2957 | - case 'type': |
|
2958 | - if (isset($eventTypes[$row['fact']])) { |
|
2959 | - $result = $eventTypes[$row['fact']]; |
|
2960 | - } else { |
|
2961 | - $result = GedcomTag::getLabel($row['fact']); |
|
2962 | - } |
|
2963 | - break; |
|
2964 | - case 'name': |
|
2965 | - $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>"; |
|
2966 | - break; |
|
2967 | - case 'place': |
|
2968 | - $fact = $record->getFirstFact($row['fact']); |
|
2969 | - if ($fact) { |
|
2970 | - $result = FunctionsPrint::formatFactPlace($fact, true, true, true); |
|
2971 | - } else { |
|
2972 | - $result = I18N::translate('Private'); |
|
2973 | - } |
|
2974 | - break; |
|
2945 | + default: |
|
2946 | + case 'full': |
|
2947 | + if ($record->canShow()) { |
|
2948 | + $result = $record->formatList('span', false, $record->getFullName()); |
|
2949 | + } else { |
|
2950 | + $result = I18N::translate('This information is private and cannot be shown.'); |
|
2951 | + } |
|
2952 | + break; |
|
2953 | + case 'year': |
|
2954 | + $date = new Date($row['type'] . ' ' . $row['year']); |
|
2955 | + $result = $date->display(); |
|
2956 | + break; |
|
2957 | + case 'type': |
|
2958 | + if (isset($eventTypes[$row['fact']])) { |
|
2959 | + $result = $eventTypes[$row['fact']]; |
|
2960 | + } else { |
|
2961 | + $result = GedcomTag::getLabel($row['fact']); |
|
2962 | + } |
|
2963 | + break; |
|
2964 | + case 'name': |
|
2965 | + $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>"; |
|
2966 | + break; |
|
2967 | + case 'place': |
|
2968 | + $fact = $record->getFirstFact($row['fact']); |
|
2969 | + if ($fact) { |
|
2970 | + $result = FunctionsPrint::formatFactPlace($fact, true, true, true); |
|
2971 | + } else { |
|
2972 | + $result = I18N::translate('Private'); |
|
2973 | + } |
|
2974 | + break; |
|
2975 | 2975 | } |
2976 | 2976 | |
2977 | 2977 | return $result; |
@@ -3116,32 +3116,32 @@ discard block |
||
3116 | 3116 | $person = Individual::getInstance($row['i_id'], $this->tree); |
3117 | 3117 | } |
3118 | 3118 | switch ($type) { |
3119 | - default: |
|
3120 | - case 'full': |
|
3121 | - if ($family->canShow()) { |
|
3122 | - $result = $family->formatList('span', false, $person->getFullName()); |
|
3123 | - } else { |
|
3124 | - $result = I18N::translate('This information is private and cannot be shown.'); |
|
3125 | - } |
|
3126 | - break; |
|
3127 | - case 'name': |
|
3128 | - $result = '<a href="' . $family->getHtmlUrl() . '">' . $person->getFullName() . '</a>'; |
|
3129 | - break; |
|
3130 | - case 'age': |
|
3131 | - $age = $row['age']; |
|
3132 | - if ($show_years) { |
|
3133 | - if ((int) ($age / 365.25) > 0) { |
|
3134 | - $age = (int) ($age / 365.25) . 'y'; |
|
3135 | - } elseif ((int) ($age / 30.4375) > 0) { |
|
3136 | - $age = (int) ($age / 30.4375) . 'm'; |
|
3119 | + default: |
|
3120 | + case 'full': |
|
3121 | + if ($family->canShow()) { |
|
3122 | + $result = $family->formatList('span', false, $person->getFullName()); |
|
3137 | 3123 | } else { |
3138 | - $age = $age . 'd'; |
|
3124 | + $result = I18N::translate('This information is private and cannot be shown.'); |
|
3139 | 3125 | } |
3140 | - $result = FunctionsDate::getAgeAtEvent($age); |
|
3141 | - } else { |
|
3142 | - $result = I18N::number((int) ($age / 365.25)); |
|
3143 | - } |
|
3144 | - break; |
|
3126 | + break; |
|
3127 | + case 'name': |
|
3128 | + $result = '<a href="' . $family->getHtmlUrl() . '">' . $person->getFullName() . '</a>'; |
|
3129 | + break; |
|
3130 | + case 'age': |
|
3131 | + $age = $row['age']; |
|
3132 | + if ($show_years) { |
|
3133 | + if ((int) ($age / 365.25) > 0) { |
|
3134 | + $age = (int) ($age / 365.25) . 'y'; |
|
3135 | + } elseif ((int) ($age / 30.4375) > 0) { |
|
3136 | + $age = (int) ($age / 30.4375) . 'm'; |
|
3137 | + } else { |
|
3138 | + $age = $age . 'd'; |
|
3139 | + } |
|
3140 | + $result = FunctionsDate::getAgeAtEvent($age); |
|
3141 | + } else { |
|
3142 | + $result = I18N::number((int) ($age / 365.25)); |
|
3143 | + } |
|
3144 | + break; |
|
3145 | 3145 | } |
3146 | 3146 | |
3147 | 3147 | return $result; |
@@ -3414,32 +3414,32 @@ discard block |
||
3414 | 3414 | $person = Individual::getInstance($row['id'], $this->tree); |
3415 | 3415 | } |
3416 | 3416 | switch ($type) { |
3417 | - default: |
|
3418 | - case 'full': |
|
3419 | - if ($person->canShow()) { |
|
3420 | - $result = $person->formatList('span', false, $person->getFullName()); |
|
3421 | - } else { |
|
3422 | - $result = I18N::translate('This information is private and cannot be shown.'); |
|
3423 | - } |
|
3424 | - break; |
|
3425 | - case 'name': |
|
3426 | - $result = '<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a>'; |
|
3427 | - break; |
|
3428 | - case 'age': |
|
3429 | - $age = $row['age']; |
|
3430 | - if ($show_years) { |
|
3431 | - if ((int) ($age / 365.25) > 0) { |
|
3432 | - $age = (int) ($age / 365.25) . 'y'; |
|
3433 | - } elseif ((int) ($age / 30.4375) > 0) { |
|
3434 | - $age = (int) ($age / 30.4375) . 'm'; |
|
3417 | + default: |
|
3418 | + case 'full': |
|
3419 | + if ($person->canShow()) { |
|
3420 | + $result = $person->formatList('span', false, $person->getFullName()); |
|
3435 | 3421 | } else { |
3436 | - $age = $age . 'd'; |
|
3422 | + $result = I18N::translate('This information is private and cannot be shown.'); |
|
3437 | 3423 | } |
3438 | - $result = FunctionsDate::getAgeAtEvent($age); |
|
3439 | - } else { |
|
3440 | - $result = (int) ($age / 365.25); |
|
3441 | - } |
|
3442 | - break; |
|
3424 | + break; |
|
3425 | + case 'name': |
|
3426 | + $result = '<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a>'; |
|
3427 | + break; |
|
3428 | + case 'age': |
|
3429 | + $age = $row['age']; |
|
3430 | + if ($show_years) { |
|
3431 | + if ((int) ($age / 365.25) > 0) { |
|
3432 | + $age = (int) ($age / 365.25) . 'y'; |
|
3433 | + } elseif ((int) ($age / 30.4375) > 0) { |
|
3434 | + $age = (int) ($age / 30.4375) . 'm'; |
|
3435 | + } else { |
|
3436 | + $age = $age . 'd'; |
|
3437 | + } |
|
3438 | + $result = FunctionsDate::getAgeAtEvent($age); |
|
3439 | + } else { |
|
3440 | + $result = (int) ($age / 365.25); |
|
3441 | + } |
|
3442 | + break; |
|
3443 | 3443 | } |
3444 | 3444 | |
3445 | 3445 | return $result; |
@@ -4397,20 +4397,20 @@ discard block |
||
4397 | 4397 | $row = $rows[0]; |
4398 | 4398 | $family = Family::getInstance($row['id'], $this->tree); |
4399 | 4399 | switch ($type) { |
4400 | - default: |
|
4401 | - case 'full': |
|
4402 | - if ($family->canShow()) { |
|
4403 | - $result = $family->formatList('span', false, $family->getFullName()); |
|
4404 | - } else { |
|
4405 | - $result = I18N::translate('This information is private and cannot be shown.'); |
|
4406 | - } |
|
4407 | - break; |
|
4408 | - case 'size': |
|
4409 | - $result = I18N::number($row['tot']); |
|
4410 | - break; |
|
4411 | - case 'name': |
|
4412 | - $result = "<a href=\"" . $family->getHtmlUrl() . "\">" . $family->getFullName() . '</a>'; |
|
4413 | - break; |
|
4400 | + default: |
|
4401 | + case 'full': |
|
4402 | + if ($family->canShow()) { |
|
4403 | + $result = $family->formatList('span', false, $family->getFullName()); |
|
4404 | + } else { |
|
4405 | + $result = I18N::translate('This information is private and cannot be shown.'); |
|
4406 | + } |
|
4407 | + break; |
|
4408 | + case 'size': |
|
4409 | + $result = I18N::number($row['tot']); |
|
4410 | + break; |
|
4411 | + case 'name': |
|
4412 | + $result = "<a href=\"" . $family->getHtmlUrl() . "\">" . $family->getFullName() . '</a>'; |
|
4413 | + break; |
|
4414 | 4414 | } |
4415 | 4415 | |
4416 | 4416 | return $result; |
@@ -4689,43 +4689,43 @@ discard block |
||
4689 | 4689 | foreach ($rows as $values) { |
4690 | 4690 | $counts[] = round(100 * $values['total'] / $tot, 0); |
4691 | 4691 | switch ($values['d_month']) { |
4692 | - default: |
|
4693 | - case 'JAN': |
|
4694 | - $values['d_month'] = 1; |
|
4695 | - break; |
|
4696 | - case 'FEB': |
|
4697 | - $values['d_month'] = 2; |
|
4698 | - break; |
|
4699 | - case 'MAR': |
|
4700 | - $values['d_month'] = 3; |
|
4701 | - break; |
|
4702 | - case 'APR': |
|
4703 | - $values['d_month'] = 4; |
|
4704 | - break; |
|
4705 | - case 'MAY': |
|
4706 | - $values['d_month'] = 5; |
|
4707 | - break; |
|
4708 | - case 'JUN': |
|
4709 | - $values['d_month'] = 6; |
|
4710 | - break; |
|
4711 | - case 'JUL': |
|
4712 | - $values['d_month'] = 7; |
|
4713 | - break; |
|
4714 | - case 'AUG': |
|
4715 | - $values['d_month'] = 8; |
|
4716 | - break; |
|
4717 | - case 'SEP': |
|
4718 | - $values['d_month'] = 9; |
|
4719 | - break; |
|
4720 | - case 'OCT': |
|
4721 | - $values['d_month'] = 10; |
|
4722 | - break; |
|
4723 | - case 'NOV': |
|
4724 | - $values['d_month'] = 11; |
|
4725 | - break; |
|
4726 | - case 'DEC': |
|
4727 | - $values['d_month'] = 12; |
|
4728 | - break; |
|
4692 | + default: |
|
4693 | + case 'JAN': |
|
4694 | + $values['d_month'] = 1; |
|
4695 | + break; |
|
4696 | + case 'FEB': |
|
4697 | + $values['d_month'] = 2; |
|
4698 | + break; |
|
4699 | + case 'MAR': |
|
4700 | + $values['d_month'] = 3; |
|
4701 | + break; |
|
4702 | + case 'APR': |
|
4703 | + $values['d_month'] = 4; |
|
4704 | + break; |
|
4705 | + case 'MAY': |
|
4706 | + $values['d_month'] = 5; |
|
4707 | + break; |
|
4708 | + case 'JUN': |
|
4709 | + $values['d_month'] = 6; |
|
4710 | + break; |
|
4711 | + case 'JUL': |
|
4712 | + $values['d_month'] = 7; |
|
4713 | + break; |
|
4714 | + case 'AUG': |
|
4715 | + $values['d_month'] = 8; |
|
4716 | + break; |
|
4717 | + case 'SEP': |
|
4718 | + $values['d_month'] = 9; |
|
4719 | + break; |
|
4720 | + case 'OCT': |
|
4721 | + $values['d_month'] = 10; |
|
4722 | + break; |
|
4723 | + case 'NOV': |
|
4724 | + $values['d_month'] = 11; |
|
4725 | + break; |
|
4726 | + case 'DEC': |
|
4727 | + $values['d_month'] = 12; |
|
4728 | + break; |
|
4729 | 4729 | } |
4730 | 4730 | $text .= I18N::translate(ucfirst(strtolower(($values['d_month'])))) . ' - ' . $values['total'] . '|'; |
4731 | 4731 | } |
@@ -5316,16 +5316,16 @@ discard block |
||
5316 | 5316 | } |
5317 | 5317 | |
5318 | 5318 | switch ($sorting) { |
5319 | - default: |
|
5320 | - case 'alpha': |
|
5321 | - uksort($surname_list, '\Fisharebest\Webtrees\I18N::strcasecmp'); |
|
5322 | - break; |
|
5323 | - case 'count': |
|
5324 | - asort($surname_list); |
|
5325 | - break; |
|
5326 | - case 'rcount': |
|
5327 | - arsort($surname_list); |
|
5328 | - break; |
|
5319 | + default: |
|
5320 | + case 'alpha': |
|
5321 | + uksort($surname_list, '\Fisharebest\Webtrees\I18N::strcasecmp'); |
|
5322 | + break; |
|
5323 | + case 'count': |
|
5324 | + asort($surname_list); |
|
5325 | + break; |
|
5326 | + case 'rcount': |
|
5327 | + arsort($surname_list); |
|
5328 | + break; |
|
5329 | 5329 | } |
5330 | 5330 | |
5331 | 5331 | // Note that we count/display SPFX SURN, but sort/group under just SURN |
@@ -5439,9 +5439,9 @@ discard block |
||
5439 | 5439 | } |
5440 | 5440 | } |
5441 | 5441 | switch ($SURNAME_TRADITION) { |
5442 | - case 'polish': |
|
5443 | - // most common surname should be in male variant (Kowalski, not Kowalska) |
|
5444 | - $top_name = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $top_name); |
|
5442 | + case 'polish': |
|
5443 | + // most common surname should be in male variant (Kowalski, not Kowalska) |
|
5444 | + $top_name = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $top_name); |
|
5445 | 5445 | } |
5446 | 5446 | $per = round(100 * $count_per / $tot_indi, 0); |
5447 | 5447 | $chd .= $this->arrayToExtendedEncoding(array($per)); |
@@ -5481,19 +5481,19 @@ discard block |
||
5481 | 5481 | } |
5482 | 5482 | |
5483 | 5483 | switch ($sex) { |
5484 | - case 'M': |
|
5485 | - $sex_sql = "i_sex='M'"; |
|
5486 | - break; |
|
5487 | - case 'F': |
|
5488 | - $sex_sql = "i_sex='F'"; |
|
5489 | - break; |
|
5490 | - case 'U': |
|
5491 | - $sex_sql = "i_sex='U'"; |
|
5492 | - break; |
|
5493 | - case 'B': |
|
5494 | - default: |
|
5495 | - $sex_sql = "i_sex<>'U'"; |
|
5496 | - break; |
|
5484 | + case 'M': |
|
5485 | + $sex_sql = "i_sex='M'"; |
|
5486 | + break; |
|
5487 | + case 'F': |
|
5488 | + $sex_sql = "i_sex='F'"; |
|
5489 | + break; |
|
5490 | + case 'U': |
|
5491 | + $sex_sql = "i_sex='U'"; |
|
5492 | + break; |
|
5493 | + case 'B': |
|
5494 | + default: |
|
5495 | + $sex_sql = "i_sex<>'U'"; |
|
5496 | + break; |
|
5497 | 5497 | } |
5498 | 5498 | $ged_id = $this->tree->getTreeId(); |
5499 | 5499 | |
@@ -5538,25 +5538,25 @@ discard block |
||
5538 | 5538 | $tot = ''; |
5539 | 5539 | } |
5540 | 5540 | switch ($type) { |
5541 | - case 'table': |
|
5542 | - $common[] = '<tr><td>' . $given . '</td><td>' . I18N::number($total) . '</td><td>' . $total . '</td></tr>'; |
|
5543 | - break; |
|
5544 | - case 'list': |
|
5545 | - $common[] = '<li><span dir="auto">' . $given . '</span>' . $tot . '</li>'; |
|
5546 | - break; |
|
5547 | - case 'nolist': |
|
5548 | - $common[] = '<span dir="auto">' . $given . '</span>' . $tot; |
|
5549 | - break; |
|
5541 | + case 'table': |
|
5542 | + $common[] = '<tr><td>' . $given . '</td><td>' . I18N::number($total) . '</td><td>' . $total . '</td></tr>'; |
|
5543 | + break; |
|
5544 | + case 'list': |
|
5545 | + $common[] = '<li><span dir="auto">' . $given . '</span>' . $tot . '</li>'; |
|
5546 | + break; |
|
5547 | + case 'nolist': |
|
5548 | + $common[] = '<span dir="auto">' . $given . '</span>' . $tot; |
|
5549 | + break; |
|
5550 | 5550 | } |
5551 | 5551 | } |
5552 | 5552 | if ($common) { |
5553 | 5553 | switch ($type) { |
5554 | - case 'table': |
|
5555 | - global $controller; |
|
5556 | - $table_id = Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page |
|
5557 | - $controller |
|
5558 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
5559 | - ->addInlineJavascript(' |
|
5554 | + case 'table': |
|
5555 | + global $controller; |
|
5556 | + $table_id = Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page |
|
5557 | + $controller |
|
5558 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
5559 | + ->addInlineJavascript(' |
|
5560 | 5560 | jQuery("#' . $table_id . '").dataTable({ |
5561 | 5561 | dom: \'t\', |
5562 | 5562 | autoWidth: false, |
@@ -5574,15 +5574,15 @@ discard block |
||
5574 | 5574 | }); |
5575 | 5575 | jQuery("#' . $table_id . '").css("visibility", "visible"); |
5576 | 5576 | '); |
5577 | - $lookup = array('M' => I18N::translate('Male'), 'F' => I18N::translate('Female'), 'U' => I18N::translateContext('unknown gender', 'Unknown'), 'B' => I18N::translate('All')); |
|
5577 | + $lookup = array('M' => I18N::translate('Male'), 'F' => I18N::translate('Female'), 'U' => I18N::translateContext('unknown gender', 'Unknown'), 'B' => I18N::translate('All')); |
|
5578 | 5578 | |
5579 | - return '<table id="' . $table_id . '" class="givn-list"><thead><tr><th class="ui-state-default" colspan="3">' . $lookup[$sex] . '</th></tr><tr><th>' . I18N::translate('Name') . '</th><th>' . I18N::translate('Count') . '</th><th>COUNT</th></tr></thead><tbody>' . implode('', $common) . '</tbody></table>'; |
|
5580 | - case 'list': |
|
5581 | - return '<ul>' . implode('', $common) . '</ul>'; |
|
5582 | - case 'nolist': |
|
5583 | - return implode(I18N::$list_separator, $common); |
|
5584 | - default: |
|
5585 | - return ''; |
|
5579 | + return '<table id="' . $table_id . '" class="givn-list"><thead><tr><th class="ui-state-default" colspan="3">' . $lookup[$sex] . '</th></tr><tr><th>' . I18N::translate('Name') . '</th><th>' . I18N::translate('Count') . '</th><th>COUNT</th></tr></thead><tbody>' . implode('', $common) . '</tbody></table>'; |
|
5580 | + case 'list': |
|
5581 | + return '<ul>' . implode('', $common) . '</ul>'; |
|
5582 | + case 'nolist': |
|
5583 | + return implode(I18N::$list_separator, $common); |
|
5584 | + default: |
|
5585 | + return ''; |
|
5586 | 5586 | } |
5587 | 5587 | } else { |
5588 | 5588 | return ''; |
@@ -6069,42 +6069,42 @@ discard block |
||
6069 | 6069 | } |
6070 | 6070 | |
6071 | 6071 | switch ($type) { |
6072 | - default: |
|
6073 | - case 'userid': |
|
6074 | - return $user->getUserId(); |
|
6075 | - case 'username': |
|
6076 | - return Filter::escapeHtml($user->getUserName()); |
|
6077 | - case 'fullname': |
|
6078 | - return $user->getRealNameHtml(); |
|
6079 | - case 'regdate': |
|
6080 | - if (is_array($params) && isset($params[0]) && $params[0] != '') { |
|
6081 | - $datestamp = $params[0]; |
|
6082 | - } else { |
|
6083 | - $datestamp = I18N::dateFormat(); |
|
6084 | - } |
|
6072 | + default: |
|
6073 | + case 'userid': |
|
6074 | + return $user->getUserId(); |
|
6075 | + case 'username': |
|
6076 | + return Filter::escapeHtml($user->getUserName()); |
|
6077 | + case 'fullname': |
|
6078 | + return $user->getRealNameHtml(); |
|
6079 | + case 'regdate': |
|
6080 | + if (is_array($params) && isset($params[0]) && $params[0] != '') { |
|
6081 | + $datestamp = $params[0]; |
|
6082 | + } else { |
|
6083 | + $datestamp = I18N::dateFormat(); |
|
6084 | + } |
|
6085 | 6085 | |
6086 | - return FunctionsDate::timestampToGedcomDate($user->getPreference('reg_timestamp'))->display(false, $datestamp); |
|
6087 | - case 'regtime': |
|
6088 | - if (is_array($params) && isset($params[0]) && $params[0] != '') { |
|
6089 | - $datestamp = $params[0]; |
|
6090 | - } else { |
|
6091 | - $datestamp = str_replace('%', '', I18N::timeFormat()); |
|
6092 | - } |
|
6086 | + return FunctionsDate::timestampToGedcomDate($user->getPreference('reg_timestamp'))->display(false, $datestamp); |
|
6087 | + case 'regtime': |
|
6088 | + if (is_array($params) && isset($params[0]) && $params[0] != '') { |
|
6089 | + $datestamp = $params[0]; |
|
6090 | + } else { |
|
6091 | + $datestamp = str_replace('%', '', I18N::timeFormat()); |
|
6092 | + } |
|
6093 | 6093 | |
6094 | - return date($datestamp, $user->getPreference('reg_timestamp')); |
|
6095 | - case 'loggedin': |
|
6096 | - if (is_array($params) && isset($params[0]) && $params[0] != '') { |
|
6097 | - $yes = $params[0]; |
|
6098 | - } else { |
|
6099 | - $yes = I18N::translate('yes'); |
|
6100 | - } |
|
6101 | - if (is_array($params) && isset($params[1]) && $params[1] != '') { |
|
6102 | - $no = $params[1]; |
|
6103 | - } else { |
|
6104 | - $no = I18N::translate('no'); |
|
6105 | - } |
|
6094 | + return date($datestamp, $user->getPreference('reg_timestamp')); |
|
6095 | + case 'loggedin': |
|
6096 | + if (is_array($params) && isset($params[0]) && $params[0] != '') { |
|
6097 | + $yes = $params[0]; |
|
6098 | + } else { |
|
6099 | + $yes = I18N::translate('yes'); |
|
6100 | + } |
|
6101 | + if (is_array($params) && isset($params[1]) && $params[1] != '') { |
|
6102 | + $no = $params[1]; |
|
6103 | + } else { |
|
6104 | + $no = I18N::translate('no'); |
|
6105 | + } |
|
6106 | 6106 | |
6107 | - return Database::prepare("SELECT 1 FROM `##session` WHERE user_id=? LIMIT 1")->execute(array($user->getUserId()))->fetchOne() ? $yes : $no; |
|
6107 | + return Database::prepare("SELECT 1 FROM `##session` WHERE user_id=? LIMIT 1")->execute(array($user->getUserId()))->fetchOne() ? $yes : $no; |
|
6108 | 6108 | } |
6109 | 6109 | } |
6110 | 6110 | |
@@ -6941,50 +6941,50 @@ discard block |
||
6941 | 6941 | } |
6942 | 6942 | // The current chart engine (Google charts) can't handle <sup></sup> markup |
6943 | 6943 | switch ($century) { |
6944 | - case 21: |
|
6945 | - return strip_tags(I18N::translateContext('CENTURY', '21st')); |
|
6946 | - case 20: |
|
6947 | - return strip_tags(I18N::translateContext('CENTURY', '20th')); |
|
6948 | - case 19: |
|
6949 | - return strip_tags(I18N::translateContext('CENTURY', '19th')); |
|
6950 | - case 18: |
|
6951 | - return strip_tags(I18N::translateContext('CENTURY', '18th')); |
|
6952 | - case 17: |
|
6953 | - return strip_tags(I18N::translateContext('CENTURY', '17th')); |
|
6954 | - case 16: |
|
6955 | - return strip_tags(I18N::translateContext('CENTURY', '16th')); |
|
6956 | - case 15: |
|
6957 | - return strip_tags(I18N::translateContext('CENTURY', '15th')); |
|
6958 | - case 14: |
|
6959 | - return strip_tags(I18N::translateContext('CENTURY', '14th')); |
|
6960 | - case 13: |
|
6961 | - return strip_tags(I18N::translateContext('CENTURY', '13th')); |
|
6962 | - case 12: |
|
6963 | - return strip_tags(I18N::translateContext('CENTURY', '12th')); |
|
6964 | - case 11: |
|
6965 | - return strip_tags(I18N::translateContext('CENTURY', '11th')); |
|
6966 | - case 10: |
|
6967 | - return strip_tags(I18N::translateContext('CENTURY', '10th')); |
|
6968 | - case 9: |
|
6969 | - return strip_tags(I18N::translateContext('CENTURY', '9th')); |
|
6970 | - case 8: |
|
6971 | - return strip_tags(I18N::translateContext('CENTURY', '8th')); |
|
6972 | - case 7: |
|
6973 | - return strip_tags(I18N::translateContext('CENTURY', '7th')); |
|
6974 | - case 6: |
|
6975 | - return strip_tags(I18N::translateContext('CENTURY', '6th')); |
|
6976 | - case 5: |
|
6977 | - return strip_tags(I18N::translateContext('CENTURY', '5th')); |
|
6978 | - case 4: |
|
6979 | - return strip_tags(I18N::translateContext('CENTURY', '4th')); |
|
6980 | - case 3: |
|
6981 | - return strip_tags(I18N::translateContext('CENTURY', '3rd')); |
|
6982 | - case 2: |
|
6983 | - return strip_tags(I18N::translateContext('CENTURY', '2nd')); |
|
6984 | - case 1: |
|
6985 | - return strip_tags(I18N::translateContext('CENTURY', '1st')); |
|
6986 | - default: |
|
6987 | - return ($century - 1) . '01-' . $century . '00'; |
|
6944 | + case 21: |
|
6945 | + return strip_tags(I18N::translateContext('CENTURY', '21st')); |
|
6946 | + case 20: |
|
6947 | + return strip_tags(I18N::translateContext('CENTURY', '20th')); |
|
6948 | + case 19: |
|
6949 | + return strip_tags(I18N::translateContext('CENTURY', '19th')); |
|
6950 | + case 18: |
|
6951 | + return strip_tags(I18N::translateContext('CENTURY', '18th')); |
|
6952 | + case 17: |
|
6953 | + return strip_tags(I18N::translateContext('CENTURY', '17th')); |
|
6954 | + case 16: |
|
6955 | + return strip_tags(I18N::translateContext('CENTURY', '16th')); |
|
6956 | + case 15: |
|
6957 | + return strip_tags(I18N::translateContext('CENTURY', '15th')); |
|
6958 | + case 14: |
|
6959 | + return strip_tags(I18N::translateContext('CENTURY', '14th')); |
|
6960 | + case 13: |
|
6961 | + return strip_tags(I18N::translateContext('CENTURY', '13th')); |
|
6962 | + case 12: |
|
6963 | + return strip_tags(I18N::translateContext('CENTURY', '12th')); |
|
6964 | + case 11: |
|
6965 | + return strip_tags(I18N::translateContext('CENTURY', '11th')); |
|
6966 | + case 10: |
|
6967 | + return strip_tags(I18N::translateContext('CENTURY', '10th')); |
|
6968 | + case 9: |
|
6969 | + return strip_tags(I18N::translateContext('CENTURY', '9th')); |
|
6970 | + case 8: |
|
6971 | + return strip_tags(I18N::translateContext('CENTURY', '8th')); |
|
6972 | + case 7: |
|
6973 | + return strip_tags(I18N::translateContext('CENTURY', '7th')); |
|
6974 | + case 6: |
|
6975 | + return strip_tags(I18N::translateContext('CENTURY', '6th')); |
|
6976 | + case 5: |
|
6977 | + return strip_tags(I18N::translateContext('CENTURY', '5th')); |
|
6978 | + case 4: |
|
6979 | + return strip_tags(I18N::translateContext('CENTURY', '4th')); |
|
6980 | + case 3: |
|
6981 | + return strip_tags(I18N::translateContext('CENTURY', '3rd')); |
|
6982 | + case 2: |
|
6983 | + return strip_tags(I18N::translateContext('CENTURY', '2nd')); |
|
6984 | + case 1: |
|
6985 | + return strip_tags(I18N::translateContext('CENTURY', '1st')); |
|
6986 | + default: |
|
6987 | + return ($century - 1) . '01-' . $century . '00'; |
|
6988 | 6988 | } |
6989 | 6989 | } |
6990 | 6990 | } |
@@ -44,44 +44,44 @@ |
||
44 | 44 | $text = Filter::post('text'); |
45 | 45 | |
46 | 46 | switch ($action) { |
47 | -case 'compose': |
|
48 | - if (Module::getModuleByName('ckeditor')) { |
|
49 | - CkeditorModule::enableEditor($controller); |
|
50 | - } |
|
47 | + case 'compose': |
|
48 | + if (Module::getModuleByName('ckeditor')) { |
|
49 | + CkeditorModule::enableEditor($controller); |
|
50 | + } |
|
51 | 51 | |
52 | - echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>'; |
|
53 | - echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">'; |
|
54 | - if ($news_id) { |
|
55 | - $news = Database::prepare("SELECT news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC); |
|
56 | - } else { |
|
57 | - $news = array(); |
|
58 | - $news['user_id'] = $user_id; |
|
59 | - $news['gedcom_id'] = $gedcom_id; |
|
60 | - $news['date'] = WT_TIMESTAMP; |
|
61 | - $news['subject'] = ''; |
|
62 | - $news['body'] = ''; |
|
63 | - } |
|
64 | - echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">'; |
|
65 | - echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">'; |
|
66 | - echo '<input type="hidden" name="date" value="' . $news['date'] . '">'; |
|
67 | - echo '<table>'; |
|
68 | - echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>'; |
|
69 | - echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>'; |
|
70 | - echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>'; |
|
71 | - echo '<tr><td>'; |
|
72 | - echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>'; |
|
73 | - echo '</td></tr>'; |
|
74 | - echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>'; |
|
75 | - echo '</table>'; |
|
76 | - echo '</form>'; |
|
77 | - break; |
|
78 | -case 'save': |
|
79 | - if ($news_id) { |
|
80 | - Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id)); |
|
81 | - } else { |
|
82 | - Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text)); |
|
83 | - } |
|
52 | + echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>'; |
|
53 | + echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">'; |
|
54 | + if ($news_id) { |
|
55 | + $news = Database::prepare("SELECT news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC); |
|
56 | + } else { |
|
57 | + $news = array(); |
|
58 | + $news['user_id'] = $user_id; |
|
59 | + $news['gedcom_id'] = $gedcom_id; |
|
60 | + $news['date'] = WT_TIMESTAMP; |
|
61 | + $news['subject'] = ''; |
|
62 | + $news['body'] = ''; |
|
63 | + } |
|
64 | + echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">'; |
|
65 | + echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">'; |
|
66 | + echo '<input type="hidden" name="date" value="' . $news['date'] . '">'; |
|
67 | + echo '<table>'; |
|
68 | + echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>'; |
|
69 | + echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>'; |
|
70 | + echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>'; |
|
71 | + echo '<tr><td>'; |
|
72 | + echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>'; |
|
73 | + echo '</td></tr>'; |
|
74 | + echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>'; |
|
75 | + echo '</table>'; |
|
76 | + echo '</form>'; |
|
77 | + break; |
|
78 | + case 'save': |
|
79 | + if ($news_id) { |
|
80 | + Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id)); |
|
81 | + } else { |
|
82 | + Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text)); |
|
83 | + } |
|
84 | 84 | |
85 | - $controller->addInlineJavascript('window.opener.location.reload();window.close();'); |
|
86 | - break; |
|
85 | + $controller->addInlineJavascript('window.opener.location.reload();window.close();'); |
|
86 | + break; |
|
87 | 87 | } |
@@ -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 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 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 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 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 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 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 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 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 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 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 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 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_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_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 | } |