18c2e8227SGreg Roach<?php 28c2e8227SGreg Roach/** 38c2e8227SGreg Roach * webtrees: online genealogy 48c2e8227SGreg Roach * Copyright (C) 2015 webtrees development team 58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 88c2e8227SGreg Roach * (at your option) any later version. 98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 128c2e8227SGreg Roach * GNU General Public License for more details. 138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 158c2e8227SGreg Roach */ 1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module; 1776692c8bSGreg Roach 18ad51e0bbSGreg Roachuse Fisharebest\Webtrees\Census\CensusInterface; 190e62c4b8SGreg Roachuse Fisharebest\Webtrees\Controller\SimpleController; 204c00bbb9SGreg Roachuse Fisharebest\Webtrees\Date; 210e62c4b8SGreg Roachuse Fisharebest\Webtrees\Family; 220e62c4b8SGreg Roachuse Fisharebest\Webtrees\Filter; 23ad51e0bbSGreg Roachuse Fisharebest\Webtrees\Functions\Functions; 243d7a8a4cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsDb; 250e62c4b8SGreg Roachuse Fisharebest\Webtrees\GedcomRecord; 260e62c4b8SGreg Roachuse Fisharebest\Webtrees\GedcomTag; 270e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 2899f222b3SGreg Roachuse Fisharebest\Webtrees\Individual; 29ad51e0bbSGreg Roachuse Fisharebest\Webtrees\Menu; 300e62c4b8SGreg Roachuse Fisharebest\Webtrees\Note; 318c2e8227SGreg Roach 328c2e8227SGreg Roach/** 338c2e8227SGreg Roach * Class CensusAssistantModule 348c2e8227SGreg Roach */ 3515834aaeSGreg Roachclass CensusAssistantModule extends AbstractModule { 368c2e8227SGreg Roach /** {@inheritdoc} */ 378c2e8227SGreg Roach public function getTitle() { 388c2e8227SGreg Roach return /* I18N: Name of a module */ I18N::translate('Census assistant'); 398c2e8227SGreg Roach } 408c2e8227SGreg Roach 418c2e8227SGreg Roach /** {@inheritdoc} */ 428c2e8227SGreg Roach public function getDescription() { 438c2e8227SGreg Roach return /* I18N: Description of the “Census assistant” module */ I18N::translate('An alternative way to enter census transcripts and link them to individuals.'); 448c2e8227SGreg Roach } 458c2e8227SGreg Roach 4676692c8bSGreg Roach /** 4776692c8bSGreg Roach * This is a general purpose hook, allowing modules to respond to routes 4876692c8bSGreg Roach * of the form module.php?mod=FOO&mod_action=BAR 4976692c8bSGreg Roach * 5076692c8bSGreg Roach * @param string $mod_action 5176692c8bSGreg Roach */ 528c2e8227SGreg Roach public function modAction($mod_action) { 538c2e8227SGreg Roach switch ($mod_action) { 5440990b78SGreg Roach case 'census_find': 5540990b78SGreg Roach self::censusFind(); 568c2e8227SGreg Roach break; 5740990b78SGreg Roach case 'media_find': 58764a01d9SGreg Roach self::mediaFind(); 598c2e8227SGreg Roach break; 608c2e8227SGreg Roach case 'media_query_3a': 61764a01d9SGreg Roach self::mediaQuery(); 628c2e8227SGreg Roach break; 638c2e8227SGreg Roach default: 648c2e8227SGreg Roach http_response_code(404); 658c2e8227SGreg Roach } 668c2e8227SGreg Roach } 678c2e8227SGreg Roach 688c2e8227SGreg Roach /** 6976692c8bSGreg Roach * Find an individual. 708c2e8227SGreg Roach */ 7140990b78SGreg Roach private static function censusFind() { 7240990b78SGreg Roach global $WT_TREE; 7340990b78SGreg Roach 7440990b78SGreg Roach $controller = new SimpleController; 7540990b78SGreg Roach $filter = Filter::get('filter'); 7640990b78SGreg Roach $action = Filter::get('action'); 77ad51e0bbSGreg Roach $census = Filter::get('census'); 78ad51e0bbSGreg Roach $census = new $census; 7940990b78SGreg Roach 8040990b78SGreg Roach $controller 81ad51e0bbSGreg Roach ->restrictAccess($census instanceof CensusInterface) 8240990b78SGreg Roach ->setPageTitle(I18N::translate('Find an individual')) 8340990b78SGreg Roach ->pageHeader(); 8440990b78SGreg Roach 85ad51e0bbSGreg Roach echo '<table class="list_table width90" border="0">'; 86ad51e0bbSGreg Roach echo '<tr><td style="padding: 10px;" valign="top" class="facts_label03 width90">'; 8740990b78SGreg Roach echo I18N::translate('Find an individual'); 88ad51e0bbSGreg Roach echo '</td>'; 89ad51e0bbSGreg Roach echo '</table>'; 90ad51e0bbSGreg Roach echo '<br>'; 9140990b78SGreg Roach 92ad51e0bbSGreg Roach if ($action == 'filter') { 9340990b78SGreg Roach $filter = trim($filter); 9440990b78SGreg Roach $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); 9540990b78SGreg Roach 9640990b78SGreg Roach // Output Individual for GEDFact Assistant ====================== 97ad51e0bbSGreg Roach echo '<table class="list_table width90">'; 983d7a8a4cSGreg Roach $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE)); 9940990b78SGreg Roach if ($myindilist) { 100ad51e0bbSGreg Roach echo '<tr><td class="list_value_wrap"><ul>'; 10140990b78SGreg Roach usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare'); 10240990b78SGreg Roach foreach ($myindilist as $indi) { 103ad51e0bbSGreg Roach echo '<li>'; 104*0b18a98dSGreg Roach echo '<a href="#" onclick="window.opener.appendCensusRow(\'' . Filter::escapeJs(self::censusTableRow($census, $indi, null)) . '\'); window.close();">'; 105ad51e0bbSGreg Roach echo '<b>' . $indi->getFullName() . '</b>'; 106ad51e0bbSGreg Roach echo '</a>'; 107ad51e0bbSGreg Roach echo $indi->formatFirstMajorFact(WT_EVENTS_BIRT, 1); 108ad51e0bbSGreg Roach echo $indi->formatFirstMajorFact(WT_EVENTS_DEAT, 1); 109ad51e0bbSGreg Roach echo '<hr>'; 110ad51e0bbSGreg Roach echo '</li>'; 11140990b78SGreg Roach } 11240990b78SGreg Roach echo '</ul></td></tr>'; 11340990b78SGreg Roach } else { 114ad51e0bbSGreg Roach echo '<tr><td class="list_value_wrap">'; 11540990b78SGreg Roach echo I18N::translate('No results found.'); 116ad51e0bbSGreg Roach echo '</td></tr>'; 11740990b78SGreg Roach } 118ad51e0bbSGreg Roach echo '<tr><td>'; 11940990b78SGreg Roach echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; 120ad51e0bbSGreg Roach echo '</td></tr>'; 121ad51e0bbSGreg Roach echo '</table>'; 122ad51e0bbSGreg Roach } 12340990b78SGreg Roach } 12440990b78SGreg Roach 12540990b78SGreg Roach /** 12676692c8bSGreg Roach * Find a media object. 12740990b78SGreg Roach */ 128764a01d9SGreg Roach private static function mediaFind() { 1298c2e8227SGreg Roach global $WT_TREE; 1308c2e8227SGreg Roach 1318c2e8227SGreg Roach $controller = new SimpleController; 1328c2e8227SGreg Roach $filter = Filter::get('filter'); 1338c2e8227SGreg Roach $multiple = Filter::getBool('multiple'); 1348c2e8227SGreg Roach 1358c2e8227SGreg Roach $controller 1368c2e8227SGreg Roach ->setPageTitle(I18N::translate('Find an individual')) 1378c2e8227SGreg Roach ->pageHeader(); 1388c2e8227SGreg Roach 1398c2e8227SGreg Roach ?> 14099f222b3SGreg Roach <script> 1418c2e8227SGreg Roach function pasterow(id, name, gend, yob, age, bpl) { 1428c2e8227SGreg Roach window.opener.opener.insertRowToTable(id, name, '', gend, '', yob, age, 'Y', '', bpl); 1438c2e8227SGreg Roach } 1448c2e8227SGreg Roach 1458c2e8227SGreg Roach function pasteid(id, name, thumb) { 1468c2e8227SGreg Roach if (thumb) { 1478c2e8227SGreg Roach window.opener.paste_id(id, name, thumb); 14899f222b3SGreg Roach <?php if (!$multiple) { echo "window.close();"; } ?> 1498c2e8227SGreg Roach } else { 1508c2e8227SGreg Roach // GEDFact_assistant ======================== 1518c2e8227SGreg Roach if (window.opener.document.getElementById('addlinkQueue')) { 1528c2e8227SGreg Roach window.opener.insertRowToTable(id, name); 1538c2e8227SGreg Roach } 1548c2e8227SGreg Roach window.opener.paste_id(id); 1558c2e8227SGreg Roach if (window.opener.pastename) { 1568c2e8227SGreg Roach window.opener.pastename(name); 1578c2e8227SGreg Roach } 15899f222b3SGreg Roach <?php if (!$multiple) { echo "window.close();"; } ?> 1598c2e8227SGreg Roach } 1608c2e8227SGreg Roach } 1618c2e8227SGreg Roach function checknames(frm) { 1628c2e8227SGreg Roach if (document.forms[0].subclick) { 1638c2e8227SGreg Roach button = document.forms[0].subclick.value; 1648c2e8227SGreg Roach } else { 1658c2e8227SGreg Roach button = ""; 1668c2e8227SGreg Roach } 167ad51e0bbSGreg Roach if (frm.filter.value.length < 2 && button !== "all") { 16877e70a22SGreg Roach alert("<?php echo I18N::translate('Please enter more than one character.'); ?>"); 1698c2e8227SGreg Roach frm.filter.focus(); 1708c2e8227SGreg Roach return false; 1718c2e8227SGreg Roach } 1728c2e8227SGreg Roach if (button=="all") { 1738c2e8227SGreg Roach frm.filter.value = ""; 1748c2e8227SGreg Roach } 1758c2e8227SGreg Roach return true; 1768c2e8227SGreg Roach } 17799f222b3SGreg Roach </script> 1788c2e8227SGreg Roach 17999f222b3SGreg Roach <?php 1808c2e8227SGreg Roach echo "<div align=\"center\">"; 1818c2e8227SGreg Roach echo "<table class=\"list_table width90\" border=\"0\">"; 1828c2e8227SGreg Roach echo "<tr><td style=\"padding: 10px;\" valign=\"top\" class=\"facts_label03 width90\">"; // start column for find text header 1838c2e8227SGreg Roach echo $controller->getPageTitle(); 1848c2e8227SGreg Roach echo "</td>"; 1858c2e8227SGreg Roach echo "</tr>"; 1868c2e8227SGreg Roach echo "</table>"; 1878c2e8227SGreg Roach echo "<br>"; 1888c2e8227SGreg Roach echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; 1898c2e8227SGreg Roach echo "<br>"; 1908c2e8227SGreg Roach 1918c2e8227SGreg Roach $filter = trim($filter); 1928c2e8227SGreg Roach $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); 1938c2e8227SGreg Roach echo "<table class=\"tabs_table width90\"><tr>"; 1943d7a8a4cSGreg Roach $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE)); 1958c2e8227SGreg Roach if ($myindilist) { 1968c2e8227SGreg Roach echo "<td class=\"list_value_wrap\"><ul>"; 1970e62c4b8SGreg Roach usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare'); 1988c2e8227SGreg Roach foreach ($myindilist as $indi) { 1998c2e8227SGreg Roach $nam = Filter::escapeHtml($indi->getFullName()); 2008c2e8227SGreg Roach echo "<li><a href=\"#\" onclick=\"pasterow( 2018c2e8227SGreg Roach '" . $indi->getXref() . "' , 2028c2e8227SGreg Roach '" . $nam . "' , 2038c2e8227SGreg Roach '" . $indi->getSex() . "' , 2048c2e8227SGreg Roach '" . $indi->getbirthyear() . "' , 2058c2e8227SGreg Roach '" . (1901 - $indi->getbirthyear()) . "' , 2068c2e8227SGreg Roach '" . $indi->getbirthplace() . "'); return false;\"> 2078c2e8227SGreg Roach <b>" . $indi->getFullName() . "</b> "; 2088c2e8227SGreg Roach 209764a01d9SGreg Roach $born = GedcomTag::getLabel('BIRT'); 2108c2e8227SGreg Roach echo "</span><br><span class=\"list_item\">", $born, " ", $indi->getbirthyear(), " ", $indi->getbirthplace(), "</span></a></li>"; 2118c2e8227SGreg Roach echo "<hr>"; 2128c2e8227SGreg Roach } 2138c2e8227SGreg Roach echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>'; 2148c2e8227SGreg Roach } else { 2158c2e8227SGreg Roach echo "<td class=\"list_value_wrap\">"; 2168c2e8227SGreg Roach echo I18N::translate('No results found.'); 2178c2e8227SGreg Roach echo "</td></tr>"; 2188c2e8227SGreg Roach } 2198c2e8227SGreg Roach echo "</table>"; 2208c2e8227SGreg Roach echo '</div>'; 2218c2e8227SGreg Roach } 2228c2e8227SGreg Roach 2238c2e8227SGreg Roach /** 22476692c8bSGreg Roach * Search for a media object. 2258c2e8227SGreg Roach */ 226764a01d9SGreg Roach private static function mediaQuery() { 22724ec66ceSGreg Roach global $WT_TREE; 22824ec66ceSGreg Roach 2298c2e8227SGreg Roach $iid2 = Filter::get('iid', WT_REGEX_XREF); 2308c2e8227SGreg Roach 2318c2e8227SGreg Roach $controller = new SimpleController; 2328c2e8227SGreg Roach $controller 2338c2e8227SGreg Roach ->setPageTitle(I18N::translate('Link to an existing media object')) 2348c2e8227SGreg Roach ->pageHeader(); 2358c2e8227SGreg Roach 23624ec66ceSGreg Roach $record = GedcomRecord::getInstance($iid2, $WT_TREE); 2378c2e8227SGreg Roach if ($record) { 2388c2e8227SGreg Roach $headjs = ''; 2398c2e8227SGreg Roach if ($record instanceof Family) { 2408c2e8227SGreg Roach if ($record->getHusband()) { 2418c2e8227SGreg Roach $headjs = $record->getHusband()->getXref(); 2428c2e8227SGreg Roach } elseif ($record->getWife()) { 2438c2e8227SGreg Roach $headjs = $record->getWife()->getXref(); 2448c2e8227SGreg Roach } 2458c2e8227SGreg Roach } 2468c2e8227SGreg Roach ?> 2478c2e8227SGreg Roach <script> 2488c2e8227SGreg Roach function insertId() { 2498c2e8227SGreg Roach if (window.opener.document.getElementById('addlinkQueue')) { 2508c2e8227SGreg Roach // alert('Please move this alert window and examine the contents of the pop-up window, then click OK') 2518c2e8227SGreg Roach window.opener.insertRowToTable('<?php echo $record->getXref(); ?>', '<?php echo htmlSpecialChars($record->getFullName()); ?>', '<?php echo $headjs; ?>'); 2528c2e8227SGreg Roach window.close(); 2538c2e8227SGreg Roach } 2548c2e8227SGreg Roach } 2558c2e8227SGreg Roach </script> 2568c2e8227SGreg Roach <?php 2578c2e8227SGreg Roach } else { 2588c2e8227SGreg Roach ?> 2598c2e8227SGreg Roach <script> 2608c2e8227SGreg Roach function insertId() { 26177e70a22SGreg Roach window.opener.alert('<?php echo $iid2; ?> - <?php echo I18N::translate('Not a valid individual, family, or source ID'); ?>'); 2628c2e8227SGreg Roach window.close(); 2638c2e8227SGreg Roach } 2648c2e8227SGreg Roach </script> 2658c2e8227SGreg Roach <?php 2668c2e8227SGreg Roach } 2678c2e8227SGreg Roach ?> 2688c2e8227SGreg Roach <script>window.onLoad = insertId();</script> 2698c2e8227SGreg Roach <?php 2708c2e8227SGreg Roach } 2718c2e8227SGreg Roach 2728c2e8227SGreg Roach /** 2738c2e8227SGreg Roach * Convert custom markup into HTML 2748c2e8227SGreg Roach * 2758c2e8227SGreg Roach * @param Note $note 2768c2e8227SGreg Roach * 2778c2e8227SGreg Roach * @return string 2788c2e8227SGreg Roach */ 2798c2e8227SGreg Roach public static function formatCensusNote(Note $note) { 2808c2e8227SGreg Roach global $WT_TREE; 2818c2e8227SGreg Roach 2828c2e8227SGreg Roach $headers = array( 2838c2e8227SGreg Roach 'AgM' => 'Age at first marriage', 2848c2e8227SGreg Roach 'Age' => 'Age at last birthday', 2858c2e8227SGreg Roach 'Assets' => 'Assets = Owned,Rented - Value,Rent - Radio - Farm', 2868c2e8227SGreg Roach 'BIC' => 'Born in County', 2878c2e8227SGreg Roach 'BOE' => 'Born outside England', 2888c2e8227SGreg Roach 'BP' => 'Birthplace - (Chapman format)', 2898c2e8227SGreg Roach 'Birthplace' => 'Birthplace (Full format)', 2908c2e8227SGreg Roach 'Bmth' => 'Month of birth - If born within Census year', 2918c2e8227SGreg Roach 'ChB' => 'Children born alive', 2928c2e8227SGreg Roach 'ChD' => 'Children who have died', 2938c2e8227SGreg Roach 'ChL' => 'Children still living', 2948c2e8227SGreg Roach 'DOB' => 'Date of birth', 2958c2e8227SGreg Roach 'Edu' => 'Education - At School, Can Read, Can Write', // or "Cannot Read, Cannot Write" ?? 2968c2e8227SGreg Roach 'EmD' => 'Employed?', 2978c2e8227SGreg Roach 'EmN' => 'Unemployed?', 2988c2e8227SGreg Roach 'EmR' => 'Employer?', 2998c2e8227SGreg Roach 'Employ' => 'Employment', 3008c2e8227SGreg Roach 'Eng?' => 'English spoken?', 3018c2e8227SGreg Roach 'EngL' => 'English spoken?, if not, Native Language', 3028c2e8227SGreg Roach 'FBP' => 'Father’s Birthplace - (Chapman format)', 3038c2e8227SGreg Roach 'Health' => 'Health - 1.Blind, 2.Deaf & Dumb, 3.Idiotic, 4.Insane, 5.Disabled etc', 3048c2e8227SGreg Roach 'Home' => 'Home Ownership - Owned/Rented-Free/Mortgaged-Farm/House-Farm Schedule number', 3058c2e8227SGreg Roach 'Industry' => 'Industry', 3068c2e8227SGreg Roach 'Infirm' => 'Infirmities - 1. Deaf & Dumb, 2. Blind, 3. Lunatic, 4. Imbecile/feeble-minded', 3078c2e8227SGreg Roach 'Lang' => 'If Foreign Born - Native Language', 3088c2e8227SGreg Roach 'MBP' => 'Mother’s Birthplace - (Chapman format)', 3098c2e8227SGreg Roach 'MC' => 'Marital Condition - Married, Single, Unmarried, Widowed or Divorced', 3108c2e8227SGreg Roach 'Mmth' => 'Month of marriage - If married during Census Year', 3118c2e8227SGreg Roach 'MnsE' => 'Months employed during Census Year', 3128c2e8227SGreg Roach 'MnsU' => 'Months unemployed during Census Year', 3138c2e8227SGreg Roach 'N/A' => 'If Foreign Born - Naturalized, Alien', 3148c2e8227SGreg Roach 'NL' => 'If Foreign Born - Native Language', 3158c2e8227SGreg Roach 'Name' => 'Full Name or Married name if married', 3168c2e8227SGreg Roach 'Occupation' => 'Occupation', 3178c2e8227SGreg Roach 'Par' => 'Parentage - Father if foreign born, Mother if foreign born', 3188c2e8227SGreg Roach 'Race' => 'Race or Color - Black, White, Mulatto, Asian, Indian, Chinese etc', 3198c2e8227SGreg Roach 'Relation' => 'Relationship to Head of Household', 3208c2e8227SGreg Roach 'Sex' => 'Male or Female', 3218c2e8227SGreg Roach 'Situ' => 'Situation - Disease, Infirmity, Convict, Pauper etc', 3228c2e8227SGreg Roach 'Ten' => 'Tenure - Owned/Rented, (if owned)Free/Morgaged', 3238c2e8227SGreg Roach 'Vet' => 'War Veteran?', 3248c2e8227SGreg Roach 'WH' => 'Working at Home?', 3258c2e8227SGreg Roach 'War' => 'War or Expedition', 3268c2e8227SGreg Roach 'WksU' => 'Weeks unemployed during Census Year', 3278c2e8227SGreg Roach 'YOI' => 'If Foreign Born - Year of immigration', 3288c2e8227SGreg Roach 'YON' => 'If Foreign Born - Year of naturalization', 3298c2e8227SGreg Roach 'YUS' => 'If Foreign Born - Years in the USA', 3308c2e8227SGreg Roach 'YrsM' => 'Years Married, or Y if married in Census Year', 3318c2e8227SGreg Roach ); 3328c2e8227SGreg Roach 3338c2e8227SGreg Roach if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.*)((?:\n.*)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) { 3348c2e8227SGreg Roach // This looks like a census-assistant shared note 3358c2e8227SGreg Roach $title = Filter::escapeHtml($match[1]); 3368c2e8227SGreg Roach $preamble = Filter::escapeHtml($match[2]); 3378c2e8227SGreg Roach $header = Filter::escapeHtml($match[3]); 3388c2e8227SGreg Roach $data = Filter::escapeHtml($match[4]); 3398c2e8227SGreg Roach $postamble = Filter::escapeHtml($match[5]); 3408c2e8227SGreg Roach 3418c2e8227SGreg Roach $fmt_headers = array(); 3428c2e8227SGreg Roach foreach ($headers as $key => $value) { 343ad51e0bbSGreg Roach $fmt_headers[$key] = '<span title="' . Filter::escapeHtml($value) . '">' . $key . '</span>'; 3448c2e8227SGreg Roach } 3458c2e8227SGreg Roach 3468c2e8227SGreg Roach // Substitue header labels and format as HTML 3478c2e8227SGreg Roach $thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>'; 348ad51e0bbSGreg Roach $thead = str_replace('.b.', '', $thead); 3498c2e8227SGreg Roach 3508c2e8227SGreg Roach // Format data as HTML 3518c2e8227SGreg Roach $tbody = ''; 3528c2e8227SGreg Roach foreach (explode("\n", $data) as $row) { 3538c2e8227SGreg Roach $tbody .= '<tr>'; 3548c2e8227SGreg Roach foreach (explode('|', $row) as $column) { 3558c2e8227SGreg Roach $tbody .= '<td>' . $column . '</td>'; 3568c2e8227SGreg Roach } 3578c2e8227SGreg Roach $tbody .= '</tr>'; 3588c2e8227SGreg Roach } 3598c2e8227SGreg Roach 3608c2e8227SGreg Roach return 3618c2e8227SGreg Roach $title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link 3628c2e8227SGreg Roach '<p>' . $preamble . '</p>' . 3638c2e8227SGreg Roach '<table class="table-census-assistant">' . 3648c2e8227SGreg Roach '<thead>' . $thead . '</thead>' . 3658c2e8227SGreg Roach '<tbody>' . $tbody . '</tbody>' . 3668c2e8227SGreg Roach '</table>' . 3678c2e8227SGreg Roach '<p>' . $postamble . '</p>'; 3688c2e8227SGreg Roach } else { 3698c2e8227SGreg Roach // Not a census-assistant shared note - apply default formatting 3708c2e8227SGreg Roach return Filter::formatText($note->getNote(), $WT_TREE); 3718c2e8227SGreg Roach } 3728c2e8227SGreg Roach } 37399f222b3SGreg Roach 37499f222b3SGreg Roach /** 375ad51e0bbSGreg Roach * Generate an HTML row of data for the census header 37699f222b3SGreg Roach * 377ad51e0bbSGreg Roach * @param CensusInterface $census 37899f222b3SGreg Roach * 379ad51e0bbSGreg Roach * @return string 38099f222b3SGreg Roach */ 381ad51e0bbSGreg Roach public static function censusTableHeader(CensusInterface $census) { 382ad51e0bbSGreg Roach $html = '<th></th>'; // hidden column - used to save data 383ad51e0bbSGreg Roach foreach ($census->columns() as $column) { 384ad51e0bbSGreg Roach $html .= '<th title="' . $column->title() . '">' . $column->abbreviation() . '</th>'; 38599f222b3SGreg Roach } 38699f222b3SGreg Roach 387ad51e0bbSGreg Roach return '<tr>' . $html . '</tr>'; 388ad51e0bbSGreg Roach } 38999f222b3SGreg Roach 390ad51e0bbSGreg Roach /** 391ad51e0bbSGreg Roach * Generate an HTML row of data for the census 392ad51e0bbSGreg Roach * 393ad51e0bbSGreg Roach * @param CensusInterface $census 394ad51e0bbSGreg Roach * 395ad51e0bbSGreg Roach * @return string 396ad51e0bbSGreg Roach */ 397ad51e0bbSGreg Roach public static function censusTableEmptyRow(CensusInterface $census) { 398ad51e0bbSGreg Roach return '<tr><td></td>' . str_repeat('<td><input type="text"></td>', count($census->columns())) . '</tr>'; 399ad51e0bbSGreg Roach } 40099f222b3SGreg Roach 401ad51e0bbSGreg Roach /** 402ad51e0bbSGreg Roach * Generate an HTML row of data for the census 403ad51e0bbSGreg Roach * 404ad51e0bbSGreg Roach * @param CensusInterface $census 405ad51e0bbSGreg Roach * @param Individual $individual 406ad51e0bbSGreg Roach * @param Individual|null $head 407ad51e0bbSGreg Roach * 408ad51e0bbSGreg Roach * @return string 409ad51e0bbSGreg Roach */ 410ad51e0bbSGreg Roach public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head = null) { 411ad51e0bbSGreg Roach $html = '<td>' . $individual->getXref() . '</td>'; 412ad51e0bbSGreg Roach foreach ($census->columns() as $column) { 413ad51e0bbSGreg Roach $html .= '<td><input type="text" value="' . $column->generate($individual, $head) . '"></td>'; 414ad51e0bbSGreg Roach } 415ad51e0bbSGreg Roach 416ad51e0bbSGreg Roach return '<tr>' . $html . '</tr>'; 417ad51e0bbSGreg Roach } 418ad51e0bbSGreg Roach 419ad51e0bbSGreg Roach /** 420ad51e0bbSGreg Roach * Create a family on the census navigator. 421ad51e0bbSGreg Roach * 422ad51e0bbSGreg Roach * @param CensusInterface $census 423ad51e0bbSGreg Roach * @param Family $family 424ad51e0bbSGreg Roach * @param Individual $head 425ad51e0bbSGreg Roach * 426ad51e0bbSGreg Roach * @return string 427ad51e0bbSGreg Roach */ 428ad51e0bbSGreg Roach public static function censusNavigatorFamily(CensusInterface $census, Family $family, Individual $head) { 429ad51e0bbSGreg Roach $headImg2 = '<i class="icon-button_head" title="' . I18N::translate('Click to choose individual as head of family.') . '"></i>'; 430ad51e0bbSGreg Roach 431ad51e0bbSGreg Roach foreach ($family->getSpouses() as $spouse) { 432ad51e0bbSGreg Roach $menu = new Menu(Functions::getCloseRelationshipName($head, $spouse)); 433ad51e0bbSGreg Roach foreach ($spouse->getChildFamilies() as $grandparents) { 434ad51e0bbSGreg Roach foreach ($grandparents->getSpouses() as $grandparent) { 435ad51e0bbSGreg Roach $submenu = new Menu( 436ad51e0bbSGreg Roach Functions::getCloseRelationshipName($head, $grandparent) . ' - ' . $grandparent->getFullName(), 437ad51e0bbSGreg Roach '#', 438ad51e0bbSGreg Roach '', 439*0b18a98dSGreg Roach array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $grandparent, $head)) . '");') 440ad51e0bbSGreg Roach ); 441ad51e0bbSGreg Roach $submenu->addClass('submenuitem', ''); 442ad51e0bbSGreg Roach $menu->addSubmenu($submenu); 443ad51e0bbSGreg Roach $menu->addClass('', 'submenu'); 44499f222b3SGreg Roach } 44599f222b3SGreg Roach } 44699f222b3SGreg Roach 447ad51e0bbSGreg Roach ?> 448ad51e0bbSGreg Roach <tr> 449ad51e0bbSGreg Roach <td class="optionbox"> 450ad51e0bbSGreg Roach <?php echo $menu->getMenu(); ?> 451ad51e0bbSGreg Roach </td> 452ad51e0bbSGreg Roach <td class="facts_value nowrap"> 453*0b18a98dSGreg Roach <a href="#" onclick="return appendCensusRow('<?php echo Filter::escapeJs(self::censusTableRow($census, $spouse, $head)); ?>');"> 454ad51e0bbSGreg Roach <?php echo $spouse->getFullName(); ?> 455ad51e0bbSGreg Roach </a> 456ad51e0bbSGreg Roach </td> 457ad51e0bbSGreg Roach <td align="left" class="facts_value"> 458ad51e0bbSGreg Roach <a href="edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=<?php echo $spouse->getXref(); ?>&gedcom=<?php echo $spouse->getTree()->getNameUrl(); ?>&census=<?php echo get_class($census); ?>"> 459ad51e0bbSGreg Roach <?php echo $headImg2; ?> 460ad51e0bbSGreg Roach </a> 461ad51e0bbSGreg Roach </td> 462ad51e0bbSGreg Roach </tr> 463ad51e0bbSGreg Roach <?php 46499f222b3SGreg Roach } 465ad51e0bbSGreg Roach 466ad51e0bbSGreg Roach foreach ($family->getChildren() as $child) { 467ad51e0bbSGreg Roach $menu = new Menu(Functions::getCloseRelationshipName($head, $child)); 468ad51e0bbSGreg Roach foreach ($child->getSpouseFamilies() as $spouse_family) { 469ad51e0bbSGreg Roach foreach ($spouse_family->getSpouses() as $spouse_family_spouse) { 470ad51e0bbSGreg Roach if ($spouse_family_spouse != $child) { 471ad51e0bbSGreg Roach $submenu = new Menu( 472ad51e0bbSGreg Roach Functions::getCloseRelationshipName($head, $spouse_family_spouse) . ' - ' . $spouse_family_spouse->getFullName(), 473ad51e0bbSGreg Roach '#', 474ad51e0bbSGreg Roach '', 475*0b18a98dSGreg Roach array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_spouse, $head)) . '");') 476ad51e0bbSGreg Roach ); 477ad51e0bbSGreg Roach $submenu->addClass('submenuitem', ''); 478ad51e0bbSGreg Roach $menu->addSubmenu($submenu); 479ad51e0bbSGreg Roach $menu->addClass('', 'submenu'); 480ad51e0bbSGreg Roach } 481ad51e0bbSGreg Roach } 482ad51e0bbSGreg Roach foreach ($spouse_family->getChildren() as $spouse_family_child) { 483ad51e0bbSGreg Roach $submenu = new Menu( 484ad51e0bbSGreg Roach Functions::getCloseRelationshipName($head, $spouse_family_child) . ' - ' . $spouse_family_child->getFullName(), 485ad51e0bbSGreg Roach '#', 486ad51e0bbSGreg Roach '', 487*0b18a98dSGreg Roach array('onclick' => 'return appendCensusRow("' . Filter::escapeJs(self::censusTableRow($census, $spouse_family_child, $head)) . '");') 488ad51e0bbSGreg Roach ); 489ad51e0bbSGreg Roach $submenu->addClass('submenuitem', ''); 490ad51e0bbSGreg Roach $menu->addSubmenu($submenu); 491ad51e0bbSGreg Roach $menu->addClass('', 'submenu'); 49299f222b3SGreg Roach } 49399f222b3SGreg Roach } 49499f222b3SGreg Roach 495ad51e0bbSGreg Roach ?> 496ad51e0bbSGreg Roach <tr> 497ad51e0bbSGreg Roach <td class="optionbox"> 498ad51e0bbSGreg Roach <?php echo $menu->getMenu(); ?> 499ad51e0bbSGreg Roach </td> 500ad51e0bbSGreg Roach <td class="facts_value"> 501*0b18a98dSGreg Roach <a href="#" onclick="return appendCensusRow('<?php echo Filter::escapeJs(self::censusTableRow($census, $child, $head)); ?>');"> 502ad51e0bbSGreg Roach <?php echo $child->getFullName(); ?> 503ad51e0bbSGreg Roach </a> 504ad51e0bbSGreg Roach </td> 505ad51e0bbSGreg Roach <td class="facts_value"> 506ad51e0bbSGreg Roach <a href="edit_interface.php?action=addnewnote_assisted&noteid=newnote&xref=<?php echo $child->getXref(); ?>&gedcom=<?php echo $child->getTree()->getNameUrl(); ?>&census=<?php echo get_class($census); ?>"> 507ad51e0bbSGreg Roach <?php echo $headImg2; ?> 508ad51e0bbSGreg Roach </a> 509ad51e0bbSGreg Roach </td> 510ad51e0bbSGreg Roach </tr> 511ad51e0bbSGreg Roach <?php 51299f222b3SGreg Roach } 513ad51e0bbSGreg Roach echo '<tr><td><br></td></tr>'; 51499f222b3SGreg Roach } 5158c2e8227SGreg Roach} 516