@@ -84,7 +84,6 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @param Individual $individual |
| 87 | - * @param CensusInterface $census |
|
| 88 | 87 | */ |
| 89 | 88 | public function createCensusAssistant(Individual $individual) { |
| 90 | 89 | ?> |
@@ -287,7 +286,7 @@ discard block |
||
| 287 | 286 | * @param string $ca_title |
| 288 | 287 | * @param string $ca_place |
| 289 | 288 | * @param string $ca_citation |
| 290 | - * @param string[][] $ca_individuals |
|
| 289 | + * @param string[] $ca_individuals |
|
| 291 | 290 | * @param string $ca_notes |
| 292 | 291 | * |
| 293 | 292 | * @return string |
@@ -21,13 +21,11 @@ |
||
| 21 | 21 | use Fisharebest\Webtrees\Family; |
| 22 | 22 | use Fisharebest\Webtrees\Filter; |
| 23 | 23 | use Fisharebest\Webtrees\FontAwesome; |
| 24 | -use Fisharebest\Webtrees\Functions\Functions; |
|
| 25 | 24 | use Fisharebest\Webtrees\Functions\FunctionsDb; |
| 26 | 25 | use Fisharebest\Webtrees\Functions\FunctionsEdit; |
| 27 | 26 | use Fisharebest\Webtrees\GedcomRecord; |
| 28 | 27 | use Fisharebest\Webtrees\I18N; |
| 29 | 28 | use Fisharebest\Webtrees\Individual; |
| 30 | -use Fisharebest\Webtrees\Menu; |
|
| 31 | 29 | use Fisharebest\Webtrees\Note; |
| 32 | 30 | use Fisharebest\Webtrees\Soundex; |
| 33 | 31 | |
@@ -35,59 +35,59 @@ discard block |
||
| 35 | 35 | * Class CensusAssistantModule |
| 36 | 36 | */ |
| 37 | 37 | class CensusAssistantModule extends AbstractModule { |
| 38 | - /** {@inheritdoc} */ |
|
| 39 | - public function getTitle() { |
|
| 40 | - return /* I18N: Name of a module */ |
|
| 41 | - I18N::translate('Census assistant'); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** {@inheritdoc} */ |
|
| 45 | - public function getDescription() { |
|
| 46 | - return /* I18N: Description of the “Census assistant” module */ |
|
| 47 | - I18N::translate('An alternative way to enter census transcripts and link them to individuals.'); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * This is a general purpose hook, allowing modules to respond to routes |
|
| 52 | - * of the form module.php?mod=FOO&mod_action=BAR |
|
| 53 | - * |
|
| 54 | - * @param string $mod_action |
|
| 55 | - */ |
|
| 56 | - public function modAction($mod_action) { |
|
| 57 | - global $WT_TREE; |
|
| 58 | - |
|
| 59 | - switch ($mod_action) { |
|
| 60 | - case 'census-header': |
|
| 61 | - header('Content-Type: text/html; charset=utf8'); |
|
| 62 | - $census = Filter::get('census'); |
|
| 63 | - echo $this->censusTableHeader(new $census); |
|
| 64 | - break; |
|
| 65 | - |
|
| 66 | - case 'census-individual': |
|
| 67 | - header('Content-Type: text/html; charset=utf8'); |
|
| 68 | - $census = Filter::get('census'); |
|
| 69 | - $individual = Individual::getInstance(Filter::get('xref'), $WT_TREE); |
|
| 70 | - $head = Individual::getInstance(Filter::get('head'), $WT_TREE); |
|
| 71 | - echo $this->censusTableRow(new $census, $individual, $head); |
|
| 72 | - break; |
|
| 73 | - |
|
| 74 | - case 'media_find': |
|
| 75 | - self::mediaFind(); |
|
| 76 | - break; |
|
| 77 | - case 'media_query_3a': |
|
| 78 | - self::mediaQuery(); |
|
| 79 | - break; |
|
| 80 | - default: |
|
| 81 | - http_response_code(404); |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @param Individual $individual |
|
| 87 | - * @param CensusInterface $census |
|
| 88 | - */ |
|
| 89 | - public function createCensusAssistant(Individual $individual) { |
|
| 90 | - ?> |
|
| 38 | + /** {@inheritdoc} */ |
|
| 39 | + public function getTitle() { |
|
| 40 | + return /* I18N: Name of a module */ |
|
| 41 | + I18N::translate('Census assistant'); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** {@inheritdoc} */ |
|
| 45 | + public function getDescription() { |
|
| 46 | + return /* I18N: Description of the “Census assistant” module */ |
|
| 47 | + I18N::translate('An alternative way to enter census transcripts and link them to individuals.'); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * This is a general purpose hook, allowing modules to respond to routes |
|
| 52 | + * of the form module.php?mod=FOO&mod_action=BAR |
|
| 53 | + * |
|
| 54 | + * @param string $mod_action |
|
| 55 | + */ |
|
| 56 | + public function modAction($mod_action) { |
|
| 57 | + global $WT_TREE; |
|
| 58 | + |
|
| 59 | + switch ($mod_action) { |
|
| 60 | + case 'census-header': |
|
| 61 | + header('Content-Type: text/html; charset=utf8'); |
|
| 62 | + $census = Filter::get('census'); |
|
| 63 | + echo $this->censusTableHeader(new $census); |
|
| 64 | + break; |
|
| 65 | + |
|
| 66 | + case 'census-individual': |
|
| 67 | + header('Content-Type: text/html; charset=utf8'); |
|
| 68 | + $census = Filter::get('census'); |
|
| 69 | + $individual = Individual::getInstance(Filter::get('xref'), $WT_TREE); |
|
| 70 | + $head = Individual::getInstance(Filter::get('head'), $WT_TREE); |
|
| 71 | + echo $this->censusTableRow(new $census, $individual, $head); |
|
| 72 | + break; |
|
| 73 | + |
|
| 74 | + case 'media_find': |
|
| 75 | + self::mediaFind(); |
|
| 76 | + break; |
|
| 77 | + case 'media_query_3a': |
|
| 78 | + self::mediaQuery(); |
|
| 79 | + break; |
|
| 80 | + default: |
|
| 81 | + http_response_code(404); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param Individual $individual |
|
| 87 | + * @param CensusInterface $census |
|
| 88 | + */ |
|
| 89 | + public function createCensusAssistant(Individual $individual) { |
|
| 90 | + ?> |
|
| 91 | 91 | |
| 92 | 92 | <div id="census-assistant-link" hidden> |
| 93 | 93 | <a href="#"> |
@@ -245,85 +245,85 @@ discard block |
||
| 245 | 245 | document.querySelector('#census-assistant-head').addEventListener('click', censusAssistantHead); |
| 246 | 246 | </script> |
| 247 | 247 | <?php |
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * @param Individual $individual |
|
| 252 | - * @param string $newged |
|
| 253 | - * |
|
| 254 | - * @return string |
|
| 255 | - */ |
|
| 256 | - public function updateCensusAssistant(Individual $individual, $fact_id, $newged, $keep_chan) { |
|
| 257 | - $ca_title = Filter::post('ca_title'); |
|
| 258 | - $ca_place = Filter::post('ca_place'); |
|
| 259 | - $ca_citation = Filter::post('ca_citation'); |
|
| 260 | - $ca_individuals = Filter::postArray('ca_individuals'); |
|
| 261 | - $ca_notes = Filter::post('ca_notes'); |
|
| 262 | - $ca_census = Filter::post('ca_census', 'Fisharebest\\\\Webtrees\\\\Census\\\\CensusOf[A-Za-z0-9]+'); |
|
| 263 | - |
|
| 264 | - if ($ca_census !== '' && !empty($ca_individuals)) { |
|
| 265 | - $census = new $ca_census; |
|
| 266 | - |
|
| 267 | - $note_text = $this->createNoteText($census, $ca_title, $ca_place, $ca_citation, $ca_individuals, $ca_notes); |
|
| 268 | - $note_gedcom = '0 @new@ NOTE ' . str_replace("\n", "\n1 CONT ", $note_text); |
|
| 269 | - $note = $individual->getTree()->createRecord($note_gedcom); |
|
| 270 | - |
|
| 271 | - $newged .= "\n2 NOTE @" . $note->getXref() . '@'; |
|
| 272 | - |
|
| 273 | - // Add the census fact to the rest of the household |
|
| 274 | - foreach (array_keys($ca_individuals) as $xref) { |
|
| 275 | - if ($xref !== $individual->getXref()) { |
|
| 276 | - Individual::getInstance($xref, $individual->getTree()) |
|
| 277 | - ->updateFact($fact_id, $newged, !$keep_chan); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - return $newged; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * @param CensusInterface $census |
|
| 287 | - * @param string $ca_title |
|
| 288 | - * @param string $ca_place |
|
| 289 | - * @param string $ca_citation |
|
| 290 | - * @param string[][] $ca_individuals |
|
| 291 | - * @param string $ca_notes |
|
| 292 | - * |
|
| 293 | - * @return string |
|
| 294 | - */ |
|
| 295 | - private function createNoteText(CensusInterface $census, $ca_title, $ca_place, $ca_citation, $ca_individuals, $ca_notes) { |
|
| 296 | - $text = $ca_title . "\n" . $ca_citation . "\n" . $ca_place . "\n\n.start_formatted_area.\n\n"; |
|
| 297 | - |
|
| 298 | - foreach ($census->columns() as $n => $column) { |
|
| 299 | - if ($n > 0) { |
|
| 300 | - $text .= '|'; |
|
| 301 | - } |
|
| 302 | - $text .= '.b.' . $column->abbreviation(); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - foreach ($ca_individuals as $xref => $columns) { |
|
| 306 | - $text .= "\n" . implode('|', $columns); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $text . "\n.end_formatted_area.\n\n" . $ca_notes; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Find a media object. |
|
| 314 | - */ |
|
| 315 | - private static function mediaFind() { |
|
| 316 | - global $WT_TREE; |
|
| 317 | - |
|
| 318 | - $controller = new SimpleController; |
|
| 319 | - $filter = Filter::get('filter'); |
|
| 320 | - $multiple = Filter::getBool('multiple'); |
|
| 321 | - |
|
| 322 | - $controller |
|
| 323 | - ->setPageTitle(I18N::translate('Find an individual')) |
|
| 324 | - ->pageHeader(); |
|
| 325 | - |
|
| 326 | - ?> |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * @param Individual $individual |
|
| 252 | + * @param string $newged |
|
| 253 | + * |
|
| 254 | + * @return string |
|
| 255 | + */ |
|
| 256 | + public function updateCensusAssistant(Individual $individual, $fact_id, $newged, $keep_chan) { |
|
| 257 | + $ca_title = Filter::post('ca_title'); |
|
| 258 | + $ca_place = Filter::post('ca_place'); |
|
| 259 | + $ca_citation = Filter::post('ca_citation'); |
|
| 260 | + $ca_individuals = Filter::postArray('ca_individuals'); |
|
| 261 | + $ca_notes = Filter::post('ca_notes'); |
|
| 262 | + $ca_census = Filter::post('ca_census', 'Fisharebest\\\\Webtrees\\\\Census\\\\CensusOf[A-Za-z0-9]+'); |
|
| 263 | + |
|
| 264 | + if ($ca_census !== '' && !empty($ca_individuals)) { |
|
| 265 | + $census = new $ca_census; |
|
| 266 | + |
|
| 267 | + $note_text = $this->createNoteText($census, $ca_title, $ca_place, $ca_citation, $ca_individuals, $ca_notes); |
|
| 268 | + $note_gedcom = '0 @new@ NOTE ' . str_replace("\n", "\n1 CONT ", $note_text); |
|
| 269 | + $note = $individual->getTree()->createRecord($note_gedcom); |
|
| 270 | + |
|
| 271 | + $newged .= "\n2 NOTE @" . $note->getXref() . '@'; |
|
| 272 | + |
|
| 273 | + // Add the census fact to the rest of the household |
|
| 274 | + foreach (array_keys($ca_individuals) as $xref) { |
|
| 275 | + if ($xref !== $individual->getXref()) { |
|
| 276 | + Individual::getInstance($xref, $individual->getTree()) |
|
| 277 | + ->updateFact($fact_id, $newged, !$keep_chan); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + return $newged; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * @param CensusInterface $census |
|
| 287 | + * @param string $ca_title |
|
| 288 | + * @param string $ca_place |
|
| 289 | + * @param string $ca_citation |
|
| 290 | + * @param string[][] $ca_individuals |
|
| 291 | + * @param string $ca_notes |
|
| 292 | + * |
|
| 293 | + * @return string |
|
| 294 | + */ |
|
| 295 | + private function createNoteText(CensusInterface $census, $ca_title, $ca_place, $ca_citation, $ca_individuals, $ca_notes) { |
|
| 296 | + $text = $ca_title . "\n" . $ca_citation . "\n" . $ca_place . "\n\n.start_formatted_area.\n\n"; |
|
| 297 | + |
|
| 298 | + foreach ($census->columns() as $n => $column) { |
|
| 299 | + if ($n > 0) { |
|
| 300 | + $text .= '|'; |
|
| 301 | + } |
|
| 302 | + $text .= '.b.' . $column->abbreviation(); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + foreach ($ca_individuals as $xref => $columns) { |
|
| 306 | + $text .= "\n" . implode('|', $columns); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $text . "\n.end_formatted_area.\n\n" . $ca_notes; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Find a media object. |
|
| 314 | + */ |
|
| 315 | + private static function mediaFind() { |
|
| 316 | + global $WT_TREE; |
|
| 317 | + |
|
| 318 | + $controller = new SimpleController; |
|
| 319 | + $filter = Filter::get('filter'); |
|
| 320 | + $multiple = Filter::getBool('multiple'); |
|
| 321 | + |
|
| 322 | + $controller |
|
| 323 | + ->setPageTitle(I18N::translate('Find an individual')) |
|
| 324 | + ->pageHeader(); |
|
| 325 | + |
|
| 326 | + ?> |
|
| 327 | 327 | <script> |
| 328 | 328 | function pasterow (id, name, gend, yob, age, bpl) { |
| 329 | 329 | window.opener.opener.insertRowToTable(id, name, '', gend, '', yob, age, 'Y', '', bpl); |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | if (thumb) { |
| 334 | 334 | window.opener.paste_id(id, name, thumb); |
| 335 | 335 | <?php if (!$multiple) { |
| 336 | - echo 'window.close();'; |
|
| 337 | - } ?> |
|
| 336 | + echo 'window.close();'; |
|
| 337 | + } ?> |
|
| 338 | 338 | } else { |
| 339 | 339 | // GEDFact_assistant ======================== |
| 340 | 340 | if (window.opener.document.getElementById('addlinkQueue')) { |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | window.opener.pastename(name); |
| 346 | 346 | } |
| 347 | 347 | <?php if (!$multiple) { |
| 348 | - echo 'window.close();'; |
|
| 349 | - } ?> |
|
| 348 | + echo 'window.close();'; |
|
| 349 | + } ?> |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
@@ -369,27 +369,27 @@ discard block |
||
| 369 | 369 | </script> |
| 370 | 370 | |
| 371 | 371 | <?php |
| 372 | - echo '<div>'; |
|
| 373 | - echo '<table class="list_table width90" border="0">'; |
|
| 374 | - echo '<tr><td style="padding: 10px;" class="facts_label03 width90">'; // start column for find text header |
|
| 375 | - echo $controller->getPageTitle(); |
|
| 376 | - echo '</td>'; |
|
| 377 | - echo '</tr>'; |
|
| 378 | - echo '</table>'; |
|
| 379 | - echo '<br>'; |
|
| 380 | - echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; |
|
| 381 | - echo '<br>'; |
|
| 382 | - |
|
| 383 | - $filter = trim($filter); |
|
| 384 | - $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); |
|
| 385 | - echo '<table class="tabs_table width90"><tr>'; |
|
| 386 | - $myindilist = FunctionsDb::searchIndividualNames($filter_array, [$WT_TREE]); |
|
| 387 | - if ($myindilist) { |
|
| 388 | - echo '<td class="list_value_wrap"><ul>'; |
|
| 389 | - usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare'); |
|
| 390 | - foreach ($myindilist as $indi) { |
|
| 391 | - $nam = Filter::escapeHtml($indi->getFullName()); |
|
| 392 | - echo "<li><a href=\"#\" onclick=\"pasterow( |
|
| 372 | + echo '<div>'; |
|
| 373 | + echo '<table class="list_table width90" border="0">'; |
|
| 374 | + echo '<tr><td style="padding: 10px;" class="facts_label03 width90">'; // start column for find text header |
|
| 375 | + echo $controller->getPageTitle(); |
|
| 376 | + echo '</td>'; |
|
| 377 | + echo '</tr>'; |
|
| 378 | + echo '</table>'; |
|
| 379 | + echo '<br>'; |
|
| 380 | + echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; |
|
| 381 | + echo '<br>'; |
|
| 382 | + |
|
| 383 | + $filter = trim($filter); |
|
| 384 | + $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); |
|
| 385 | + echo '<table class="tabs_table width90"><tr>'; |
|
| 386 | + $myindilist = FunctionsDb::searchIndividualNames($filter_array, [$WT_TREE]); |
|
| 387 | + if ($myindilist) { |
|
| 388 | + echo '<td class="list_value_wrap"><ul>'; |
|
| 389 | + usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare'); |
|
| 390 | + foreach ($myindilist as $indi) { |
|
| 391 | + $nam = Filter::escapeHtml($indi->getFullName()); |
|
| 392 | + echo "<li><a href=\"#\" onclick=\"pasterow( |
|
| 393 | 393 | '" . $indi->getXref() . "' , |
| 394 | 394 | '" . $nam . "' , |
| 395 | 395 | '" . $indi->getSex() . "' , |
@@ -398,44 +398,44 @@ discard block |
||
| 398 | 398 | '" . $indi->getBirthPlace() . "'); return false;\"> |
| 399 | 399 | <b>" . $indi->getFullName() . '</b> '; |
| 400 | 400 | |
| 401 | - $born = I18N::translate('Birth'); |
|
| 402 | - echo '</span><br><span class="list_item">', $born, ' ', $indi->getBirthYear(), ' ', $indi->getBirthPlace(), '</span></a></li>'; |
|
| 403 | - echo '<hr>'; |
|
| 404 | - } |
|
| 405 | - echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>'; |
|
| 406 | - } else { |
|
| 407 | - echo '<td class="list_value_wrap">'; |
|
| 408 | - echo I18N::translate('No results found.'); |
|
| 409 | - echo '</td></tr>'; |
|
| 410 | - } |
|
| 411 | - echo '</table>'; |
|
| 412 | - echo '</div>'; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Search for a media object. |
|
| 417 | - */ |
|
| 418 | - private static function mediaQuery() { |
|
| 419 | - global $WT_TREE; |
|
| 420 | - |
|
| 421 | - $iid2 = Filter::get('iid', WT_REGEX_XREF); |
|
| 422 | - |
|
| 423 | - $controller = new SimpleController; |
|
| 424 | - $controller |
|
| 425 | - ->setPageTitle(I18N::translate('Link to an existing media object')) |
|
| 426 | - ->pageHeader(); |
|
| 427 | - |
|
| 428 | - $record = GedcomRecord::getInstance($iid2, $WT_TREE); |
|
| 429 | - if ($record) { |
|
| 430 | - $headjs = ''; |
|
| 431 | - if ($record instanceof Family) { |
|
| 432 | - if ($record->getHusband()) { |
|
| 433 | - $headjs = $record->getHusband()->getXref(); |
|
| 434 | - } elseif ($record->getWife()) { |
|
| 435 | - $headjs = $record->getWife()->getXref(); |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - ?> |
|
| 401 | + $born = I18N::translate('Birth'); |
|
| 402 | + echo '</span><br><span class="list_item">', $born, ' ', $indi->getBirthYear(), ' ', $indi->getBirthPlace(), '</span></a></li>'; |
|
| 403 | + echo '<hr>'; |
|
| 404 | + } |
|
| 405 | + echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>'; |
|
| 406 | + } else { |
|
| 407 | + echo '<td class="list_value_wrap">'; |
|
| 408 | + echo I18N::translate('No results found.'); |
|
| 409 | + echo '</td></tr>'; |
|
| 410 | + } |
|
| 411 | + echo '</table>'; |
|
| 412 | + echo '</div>'; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Search for a media object. |
|
| 417 | + */ |
|
| 418 | + private static function mediaQuery() { |
|
| 419 | + global $WT_TREE; |
|
| 420 | + |
|
| 421 | + $iid2 = Filter::get('iid', WT_REGEX_XREF); |
|
| 422 | + |
|
| 423 | + $controller = new SimpleController; |
|
| 424 | + $controller |
|
| 425 | + ->setPageTitle(I18N::translate('Link to an existing media object')) |
|
| 426 | + ->pageHeader(); |
|
| 427 | + |
|
| 428 | + $record = GedcomRecord::getInstance($iid2, $WT_TREE); |
|
| 429 | + if ($record) { |
|
| 430 | + $headjs = ''; |
|
| 431 | + if ($record instanceof Family) { |
|
| 432 | + if ($record->getHusband()) { |
|
| 433 | + $headjs = $record->getHusband()->getXref(); |
|
| 434 | + } elseif ($record->getWife()) { |
|
| 435 | + $headjs = $record->getWife()->getXref(); |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + ?> |
|
| 439 | 439 | <script> |
| 440 | 440 | function insertId () { |
| 441 | 441 | if (window.opener.document.getElementById('addlinkQueue')) { |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | </script> |
| 448 | 448 | <?php |
| 449 | - } else { |
|
| 450 | - ?> |
|
| 449 | + } else { |
|
| 450 | + ?> |
|
| 451 | 451 | <script> |
| 452 | 452 | function insertId () { |
| 453 | 453 | window.opener.alert('<?= $iid2 ?> - <?= I18N::translate('Not a valid individual, family, or source ID') ?>'); |
@@ -455,142 +455,142 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | </script> |
| 457 | 457 | <?php |
| 458 | - } |
|
| 459 | - ?> |
|
| 458 | + } |
|
| 459 | + ?> |
|
| 460 | 460 | <script>window.onLoad = insertId();</script> |
| 461 | 461 | <?php |
| 462 | - } |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * Convert custom markup into HTML |
|
| 466 | - * |
|
| 467 | - * @param Note $note |
|
| 468 | - * |
|
| 469 | - * @return string |
|
| 470 | - */ |
|
| 471 | - public static function formatCensusNote(Note $note) { |
|
| 472 | - if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.+)\n(.+(?:\n.+)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) { |
|
| 473 | - // This looks like a census-assistant shared note |
|
| 474 | - $title = Filter::escapeHtml($match[1]); |
|
| 475 | - $preamble = Filter::escapeHtml($match[2]); |
|
| 476 | - $header = Filter::escapeHtml($match[3]); |
|
| 477 | - $data = Filter::escapeHtml($match[4]); |
|
| 478 | - $postamble = Filter::escapeHtml($match[5]); |
|
| 479 | - |
|
| 480 | - // Get the column headers for the census to which this note refers |
|
| 481 | - // requires the fact place & date to match the specific census |
|
| 482 | - // censusPlace() (Soundex match) and censusDate() functions |
|
| 483 | - $fmt_headers = []; |
|
| 484 | - /** @var GedcomRecord[] $linkedRecords */ |
|
| 485 | - $linkedRecords = array_merge($note->linkedIndividuals('NOTE'), $note->linkedFamilies('NOTE')); |
|
| 486 | - $firstRecord = array_shift($linkedRecords); |
|
| 487 | - if ($firstRecord) { |
|
| 488 | - $countryCode = ''; |
|
| 489 | - $date = ''; |
|
| 490 | - foreach ($firstRecord->getFacts('CENS') as $fact) { |
|
| 491 | - if (trim($fact->getAttribute('NOTE'), '@') === $note->getXref()) { |
|
| 492 | - $date = $fact->getAttribute('DATE'); |
|
| 493 | - $place = explode(',', strip_tags($fact->getPlace()->getFullName())); |
|
| 494 | - $countryCode = Soundex::daitchMokotoff(array_pop($place)); |
|
| 495 | - break; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - foreach (Census::allCensusPlaces() as $censusPlace) { |
|
| 500 | - if (Soundex::compare($countryCode, Soundex::daitchMokotoff($censusPlace->censusPlace()))) { |
|
| 501 | - foreach ($censusPlace->allCensusDates() as $census) { |
|
| 502 | - if ($census->censusDate() == $date) { |
|
| 503 | - foreach ($census->columns() as $column) { |
|
| 504 | - $abbrev = $column->abbreviation(); |
|
| 505 | - if ($abbrev) { |
|
| 506 | - $description = $column->title() ? $column->title() : I18N::translate('Description unavailable'); |
|
| 507 | - $fmt_headers[$abbrev] = '<span title="' . $description . '">' . $abbrev . '</span>'; |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - break 2; |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - // Substitute header labels and format as HTML |
|
| 517 | - $thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>'; |
|
| 518 | - $thead = str_replace('.b.', '', $thead); |
|
| 519 | - |
|
| 520 | - // Format data as HTML |
|
| 521 | - $tbody = ''; |
|
| 522 | - foreach (explode("\n", $data) as $row) { |
|
| 523 | - $tbody .= '<tr>'; |
|
| 524 | - foreach (explode('|', $row) as $column) { |
|
| 525 | - $tbody .= '<td>' . $column . '</td>'; |
|
| 526 | - } |
|
| 527 | - $tbody .= '</tr>'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return |
|
| 531 | - $title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link |
|
| 532 | - '<div class="markdown">' . |
|
| 533 | - '<p>' . $preamble . '</p>' . |
|
| 534 | - '<table>' . |
|
| 535 | - '<thead>' . $thead . '</thead>' . |
|
| 536 | - '<tbody>' . $tbody . '</tbody>' . |
|
| 537 | - '</table>' . |
|
| 538 | - '<p>' . $postamble . '</p>' . |
|
| 539 | - '</div>'; |
|
| 540 | - } else { |
|
| 541 | - // Not a census-assistant shared note - apply default formatting |
|
| 542 | - return Filter::formatText($note->getNote(), $note->getTree()); |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * Generate an HTML row of data for the census header |
|
| 548 | - * Add prefix cell (store XREF and drag/drop) |
|
| 549 | - * Add suffix cell (delete button) |
|
| 550 | - * |
|
| 551 | - * @param CensusInterface $census |
|
| 552 | - * |
|
| 553 | - * @return string |
|
| 554 | - */ |
|
| 555 | - public static function censusTableHeader(CensusInterface $census) { |
|
| 556 | - $html = ''; |
|
| 557 | - foreach ($census->columns() as $column) { |
|
| 558 | - $html .= '<th class="wt-census-assistant-field" title="' . $column->title() . '">' . $column->abbreviation() . '</th>'; |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - return '<tr class="wt-census-assistant-row"><th hidden></th>' . $html . '<th></th></tr>'; |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * Generate an HTML row of data for the census |
|
| 566 | - * Add prefix cell (store XREF and drag/drop) |
|
| 567 | - * Add suffix cell (delete button) |
|
| 568 | - * |
|
| 569 | - * @param CensusInterface $census |
|
| 570 | - * |
|
| 571 | - * @return string |
|
| 572 | - */ |
|
| 573 | - public static function censusTableEmptyRow(CensusInterface $census) { |
|
| 574 | - return '<tr class="wt-census-assistant-row"><td hidden></td>' . str_repeat('<td class="wt-census-assistant-field"><input type="text" class="form-control wt-census-assistant-form-control"></td>', count($census->columns())) . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>'; |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Generate an HTML row of data for the census |
|
| 579 | - * Add prefix cell (store XREF and drag/drop) |
|
| 580 | - * Add suffix cell (delete button) |
|
| 581 | - * |
|
| 582 | - * @param CensusInterface $census |
|
| 583 | - * @param Individual $individual |
|
| 584 | - * @param Individual $head |
|
| 585 | - * |
|
| 586 | - * @return string |
|
| 587 | - */ |
|
| 588 | - public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head) { |
|
| 589 | - $html = ''; |
|
| 590 | - foreach ($census->columns() as $column) { |
|
| 591 | - $html .= '<td class="wt-census-assistant-field"><input class="form-control wt-census-assistant-form-control" type="text" value="' . $column->generate($individual, $head) . '" name="ca_individuals[' . $individual->getXref() . '][]"></td>'; |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return '<tr class="wt-census-assistant-row"><td class="wt-census-assistant-field" hidden>' . $individual->getXref() . '</td>' . $html . '<td class="wt-census-assistant-field"><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>'; |
|
| 595 | - } |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * Convert custom markup into HTML |
|
| 466 | + * |
|
| 467 | + * @param Note $note |
|
| 468 | + * |
|
| 469 | + * @return string |
|
| 470 | + */ |
|
| 471 | + public static function formatCensusNote(Note $note) { |
|
| 472 | + if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.+)\n(.+(?:\n.+)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) { |
|
| 473 | + // This looks like a census-assistant shared note |
|
| 474 | + $title = Filter::escapeHtml($match[1]); |
|
| 475 | + $preamble = Filter::escapeHtml($match[2]); |
|
| 476 | + $header = Filter::escapeHtml($match[3]); |
|
| 477 | + $data = Filter::escapeHtml($match[4]); |
|
| 478 | + $postamble = Filter::escapeHtml($match[5]); |
|
| 479 | + |
|
| 480 | + // Get the column headers for the census to which this note refers |
|
| 481 | + // requires the fact place & date to match the specific census |
|
| 482 | + // censusPlace() (Soundex match) and censusDate() functions |
|
| 483 | + $fmt_headers = []; |
|
| 484 | + /** @var GedcomRecord[] $linkedRecords */ |
|
| 485 | + $linkedRecords = array_merge($note->linkedIndividuals('NOTE'), $note->linkedFamilies('NOTE')); |
|
| 486 | + $firstRecord = array_shift($linkedRecords); |
|
| 487 | + if ($firstRecord) { |
|
| 488 | + $countryCode = ''; |
|
| 489 | + $date = ''; |
|
| 490 | + foreach ($firstRecord->getFacts('CENS') as $fact) { |
|
| 491 | + if (trim($fact->getAttribute('NOTE'), '@') === $note->getXref()) { |
|
| 492 | + $date = $fact->getAttribute('DATE'); |
|
| 493 | + $place = explode(',', strip_tags($fact->getPlace()->getFullName())); |
|
| 494 | + $countryCode = Soundex::daitchMokotoff(array_pop($place)); |
|
| 495 | + break; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + foreach (Census::allCensusPlaces() as $censusPlace) { |
|
| 500 | + if (Soundex::compare($countryCode, Soundex::daitchMokotoff($censusPlace->censusPlace()))) { |
|
| 501 | + foreach ($censusPlace->allCensusDates() as $census) { |
|
| 502 | + if ($census->censusDate() == $date) { |
|
| 503 | + foreach ($census->columns() as $column) { |
|
| 504 | + $abbrev = $column->abbreviation(); |
|
| 505 | + if ($abbrev) { |
|
| 506 | + $description = $column->title() ? $column->title() : I18N::translate('Description unavailable'); |
|
| 507 | + $fmt_headers[$abbrev] = '<span title="' . $description . '">' . $abbrev . '</span>'; |
|
| 508 | + } |
|
| 509 | + } |
|
| 510 | + break 2; |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + // Substitute header labels and format as HTML |
|
| 517 | + $thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>'; |
|
| 518 | + $thead = str_replace('.b.', '', $thead); |
|
| 519 | + |
|
| 520 | + // Format data as HTML |
|
| 521 | + $tbody = ''; |
|
| 522 | + foreach (explode("\n", $data) as $row) { |
|
| 523 | + $tbody .= '<tr>'; |
|
| 524 | + foreach (explode('|', $row) as $column) { |
|
| 525 | + $tbody .= '<td>' . $column . '</td>'; |
|
| 526 | + } |
|
| 527 | + $tbody .= '</tr>'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return |
|
| 531 | + $title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link |
|
| 532 | + '<div class="markdown">' . |
|
| 533 | + '<p>' . $preamble . '</p>' . |
|
| 534 | + '<table>' . |
|
| 535 | + '<thead>' . $thead . '</thead>' . |
|
| 536 | + '<tbody>' . $tbody . '</tbody>' . |
|
| 537 | + '</table>' . |
|
| 538 | + '<p>' . $postamble . '</p>' . |
|
| 539 | + '</div>'; |
|
| 540 | + } else { |
|
| 541 | + // Not a census-assistant shared note - apply default formatting |
|
| 542 | + return Filter::formatText($note->getNote(), $note->getTree()); |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * Generate an HTML row of data for the census header |
|
| 548 | + * Add prefix cell (store XREF and drag/drop) |
|
| 549 | + * Add suffix cell (delete button) |
|
| 550 | + * |
|
| 551 | + * @param CensusInterface $census |
|
| 552 | + * |
|
| 553 | + * @return string |
|
| 554 | + */ |
|
| 555 | + public static function censusTableHeader(CensusInterface $census) { |
|
| 556 | + $html = ''; |
|
| 557 | + foreach ($census->columns() as $column) { |
|
| 558 | + $html .= '<th class="wt-census-assistant-field" title="' . $column->title() . '">' . $column->abbreviation() . '</th>'; |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + return '<tr class="wt-census-assistant-row"><th hidden></th>' . $html . '<th></th></tr>'; |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * Generate an HTML row of data for the census |
|
| 566 | + * Add prefix cell (store XREF and drag/drop) |
|
| 567 | + * Add suffix cell (delete button) |
|
| 568 | + * |
|
| 569 | + * @param CensusInterface $census |
|
| 570 | + * |
|
| 571 | + * @return string |
|
| 572 | + */ |
|
| 573 | + public static function censusTableEmptyRow(CensusInterface $census) { |
|
| 574 | + return '<tr class="wt-census-assistant-row"><td hidden></td>' . str_repeat('<td class="wt-census-assistant-field"><input type="text" class="form-control wt-census-assistant-form-control"></td>', count($census->columns())) . '<td><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>'; |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Generate an HTML row of data for the census |
|
| 579 | + * Add prefix cell (store XREF and drag/drop) |
|
| 580 | + * Add suffix cell (delete button) |
|
| 581 | + * |
|
| 582 | + * @param CensusInterface $census |
|
| 583 | + * @param Individual $individual |
|
| 584 | + * @param Individual $head |
|
| 585 | + * |
|
| 586 | + * @return string |
|
| 587 | + */ |
|
| 588 | + public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head) { |
|
| 589 | + $html = ''; |
|
| 590 | + foreach ($census->columns() as $column) { |
|
| 591 | + $html .= '<td class="wt-census-assistant-field"><input class="form-control wt-census-assistant-form-control" type="text" value="' . $column->generate($individual, $head) . '" name="ca_individuals[' . $individual->getXref() . '][]"></td>'; |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return '<tr class="wt-census-assistant-row"><td class="wt-census-assistant-field" hidden>' . $individual->getXref() . '</td>' . $html . '<td class="wt-census-assistant-field"><a class="icon-remove" href="#" title="' . I18N::translate('Remove') . '"></a></td></tr>'; |
|
| 595 | + } |
|
| 596 | 596 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | $years -= $years % 5; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - return (string)$years; |
|
| 43 | + return (string) $years; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | if ($marriage_date === null) { |
| 46 | 46 | return ''; |
| 47 | 47 | } else { |
| 48 | - return (string)Date::getAge($marriage_date, $this->date(), 0); |
|
| 48 | + return (string) Date::getAge($marriage_date, $this->date(), 0); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | if ($individual->getSex() === 'M') { |
| 36 | 36 | return ''; |
| 37 | 37 | } else { |
| 38 | - return (string)Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); |
|
| 38 | + return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -49,6 +49,6 @@ |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - return (string)$count; |
|
| 52 | + return (string) $count; |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -38,12 +38,12 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public function generate(Individual $individual, Individual $head = null) { |
| 40 | 40 | switch ($individual->getSex()) { |
| 41 | - case 'M': |
|
| 42 | - return $this->male; |
|
| 43 | - case 'F': |
|
| 44 | - return $this->female; |
|
| 45 | - default: |
|
| 46 | - return ''; |
|
| 41 | + case 'M': |
|
| 42 | + return $this->male; |
|
| 43 | + case 'F': |
|
| 44 | + return $this->female; |
|
| 45 | + default: |
|
| 46 | + return ''; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | if ($individual->getSex() === 'F') { |
| 36 | 36 | return ''; |
| 37 | 37 | } else { |
| 38 | - return (string)Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); |
|
| 38 | + return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -50,6 +50,6 @@ |
||
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - return (string)$count; |
|
| 53 | + return (string) $count; |
|
| 54 | 54 | } |
| 55 | 55 | } |
@@ -32,6 +32,6 @@ |
||
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | 34 | public function generate(Individual $individual, Individual $head = null) { |
| 35 | - return (string)Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); |
|
| 35 | + return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); |
|
| 36 | 36 | } |
| 37 | 37 | } |