/** * Check if a fact has a date and is sourced * Values: * - 0, if no date is found for the fact * - -1, if the date is not precise * - -2, if the date is precise, but no source is found * - 1, if the date is precise, and a source is found * - 2, if the date is precise, a source exists, and is supported by a certificate (requires _ACT usage) * - 3, if the date is precise, a source exists, and the certificate supporting the fact is within an acceptable range of date * * @return int Level of sources */ public function isSourced() { $isSourced = 0; $date = $this->fact->getDate(); if ($date->isOK()) { $isSourced = -1; if ($date->qual1 == '' && $date->minimumJulianDay() == $date->maximumJulianDay()) { $isSourced = -2; $citations = $this->fact->getCitations(); foreach ($citations as $citation) { $isSourced = max($isSourced, 1); if (preg_match('/3 _ACT (.*)/', $citation)) { $isSourced = max($isSourced, 2); preg_match_all("/4 DATE (.*)/", $citation, $datessource, PREG_SET_ORDER); foreach ($datessource as $daterec) { $datesource = new Date($daterec[1]); if (abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN) { $isSourced = max($isSourced, 3); //If this level increases, do not forget to change the constant MAX_IS_SOURCED_LEVEL } } } } } } return $isSourced; }
/** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual|null $head * * @return string */ public function generate(Individual $individual, Individual $head = null) { if ($individual->getSex() === 'F') { return ''; } else { return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); } }
/** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual|null $head * * @return string */ public function generate(Individual $individual, Individual $head = null) { if ($individual->getSex() === 'M') { return ''; } else { $years = Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0); if ($years > 15) { $years -= $years % 5; } return (string) $years; } }
/** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual|null $head * * @return string */ public function generate(Individual $individual, Individual $head = null) { if ($individual->getBirthDate()->isOK()) { foreach ($individual->getSpouseFamilies() as $family) { foreach ($family->getFacts('MARR', true) as $fact) { if ($fact->getDate()->isOK()) { return Date::getAge($individual->getBirthDate(), $fact->getDate(), 0); } } } } return ''; }
/** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual|null $head * * @return string */ public function generate(Individual $individual, Individual $head = null) { if ($individual->getSex() !== 'F') { return ''; } $count = 0; foreach ($individual->getSpouseFamilies() as $family) { foreach ($family->getChildren() as $child) { if ($child->getBirthDate()->isOK() && Date::compare($child->getBirthDate(), $this->date()) < 0 && $child->getBirthDate() != $child->getDeathDate() && (!$child->getDeathDate()->isOK() || Date::compare($child->getDeathDate(), $this->date()) > 0)) { $count++; } } } return (string) $count; }
/** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual|null $head * * @return string */ public function generate(Individual $individual, Individual $head = null) { $marriage_date = null; foreach ($individual->getSpouseFamilies() as $family) { foreach ($family->getFacts('MARR', true) as $fact) { if ($fact->getDate()->isOK() && Date::compare($fact->getDate(), $this->date()) <= 0) { $marriage_date = $fact->getDate(); } } } if ($marriage_date === null) { return ''; } else { return (string) Date::getAge($marriage_date, $this->date(), 0); } }
/** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual|null $head * * @return string */ public function generate(Individual $individual, Individual $head = null) { $place = $individual->getBirthPlace(); // Did we emigrate or naturalise? foreach ($individual->getFacts('IMMI|EMIG|NATU', true) as $fact) { if (Date::compare($fact->getDate(), $this->date()) <= 0) { $place = $fact->getPlace()->getGedcomName(); } } $place = explode(', ', $place); $place = end($place); if ($place === 'England' || $place === 'Scotland' || $place === 'Wales') { return 'British'; } else { return $place; } }
/** * What was an individual's likely name on a given date, allowing * for marriages and married names. * * @param Individual $individual * @param Date $census_date * * @return string[] */ protected function nameAtCensusDate(Individual $individual, Date $census_date) { $names = $individual->getAllNames(); $name = $names[0]; foreach ($individual->getSpouseFamilies() as $family) { foreach ($family->getFacts('MARR') as $marriage) { if ($marriage->getDate()->isOK() && Date::compare($marriage->getDate(), $census_date) < 0) { $spouse = $family->getSpouse($individual); foreach ($names as $individual_name) { foreach ($spouse->getAllNames() as $spouse_name) { if ($individual_name['type'] === '_MARNM' && $individual_name['surn'] === $spouse_name['surn']) { return $individual_name; } } } } } } return $name; }
/** * {@inhericDoc} * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() */ protected function renderContent() { if ($this->data->get('has_sosa', false)) { $table_id = $this->data->get('table_id'); ?> <div id="sosa-indi-list" class="sosa-list"> <table id="<?php echo $table_id; ?> "> <thead> <tr> <th colspan="22"> <div class="btn-toolbar"> <div class="btn-group"> <button class="ui-state-default" data-filter-column="18" data-filter-value="M" title="<?php echo I18N::translate('Show only males.'); ?> " type="button" ><?php echo Individual::sexImage('M', 'large'); ?> </button> <button class="ui-state-default" data-filter-column="18" data-filter-value="F" title="<?php echo I18N::translate('Show only females.'); ?> " type="button" > <?php echo Individual::sexImage('F', 'large'); ?> </button> <button class="ui-state-default" data-filter-column="18" data-filter-value="U" title="<?php echo I18N::translate('Show only individuals for whom the gender is not known.'); ?> " type="button" > <?php echo Individual::sexImage('U', 'large'); ?> </button> </div> <div class="btn-group"> <button class="ui-state-default" data-filter-column="20" data-filter-value="N" title="<?php echo I18N::translate('Show individuals who are alive or couples where both partners are alive.'); ?> " type="button" > <?php echo I18N::translate('Alive'); ?> </button> <button class="ui-state-default" data-filter-column="20" data-filter-value="Y" title="<?php echo I18N::translate('Show individuals who are dead or couples where both partners are deceased.'); ?> " type="button" > <?php echo I18N::translate('Dead'); ?> </button> <button class="ui-state-default" data-filter-column="20" data-filter-value="YES" title="<?php echo I18N::translate('Show individuals who died more than 100 years ago.'); ?> " type="button" ><?php echo GedcomTag::getLabel('DEAT'); ?> >100 </button> <button class="ui-state-default" data-filter-column="20" data-filter-value="Y100" title="<?php echo I18N::translate('Show individuals who died within the last 100 years.'); ?> " type="button" ><?php echo GedcomTag::getLabel('DEAT'); ?> <=100 </button> </div> <div class="btn-group"> <button class="ui-state-default" data-filter-column="19" data-filter-value="YES" title="<?php echo I18N::translate('Show individuals born more than 100 years ago.'); ?> " type="button" ><?php echo GedcomTag::getLabel('BIRT'); ?> >100 </button> <button class="ui-state-default" data-filter-column="19" data-filter-value="Y100" title="<?php echo I18N::translate('Show individuals born within the last 100 years.'); ?> " type="button" ><?php echo GedcomTag::getLabel('BIRT'); ?> <=100 </button> </div> <div class="btn-group"> <button class="ui-state-default" data-filter-column="21" data-filter-value="R" title="<?php echo I18N::translate('Show “roots” couples or individuals. These individuals may also be called “patriarchs”. They are individuals who have no parents recorded in the database.'); ?> " type="button" > <?php echo I18N::translate('Roots'); ?> </button> <button class="ui-state-default" data-filter-column="21" data-filter-value="L" title="<?php echo I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.'); ?> " type="button" > <?php echo I18N::translate('Leaves'); ?> </button> </div> </div> </th> </tr> <tr> <th><?php echo I18N::translate('Sosa'); ?> </th> <th><?php echo GedcomTag::getLabel('INDI'); ?> </th> <th><?php echo GedcomTag::getLabel('GIVN'); ?> </th> <th><?php echo GedcomTag::getLabel('SURN'); ?> </th> <th>GIVN</th> <th>SURN</th> <th><?php echo GedcomTag::getLabel('BIRT'); ?> </th> <th>SORT_BIRT</th> <th><?php echo GedcomTag::getLabel('PLAC'); ?> </th> <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { ?> <th><i class="icon-source" title="<?php echo I18N::translate('Sourced birth'); ?> " border="0"></i></th> <th>SORT_BIRTSC</th> <?php } else { ?> <th></th> <th></th> <?php } ?> <th><?php echo GedcomTag::getLabel('DEAT'); ?> </th> <th>SORT_DEAT</th> <th><?php echo GedcomTag::getLabel('AGE'); ?> </th> <th>AGE</th> <th><?php echo GedcomTag::getLabel('PLAC'); ?> </th> <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { ?> <th><i class="icon-source" title="<?php echo I18N::translate('Sourced death'); ?> " border="0"></i></th> <th>SORT_DEATSC</th> <?php } else { ?> <th></th> <th></th> <?php } ?> <th>SEX</th> <th>BIRT</th> <th>DEAT</th> <th>TREE</th> </tr> </thead> <tbody> <?php foreach ($this->data->get('sosa_list') as $sosa => $person) { /** @var \Fisharebest\Webtrees\Individual $person */ if ($person->isPendingAddtion()) { $class = ' class="new"'; } elseif ($person->isPendingDeletion()) { $class = ' class="old"'; } else { $class = ''; } $dperson = new \MyArtJaub\Webtrees\Individual($person); ?> <tr <?php echo $class; ?> > <td class="transparent"><?php echo $sosa; ?> </td> <td class="transparent"><?php echo $person->getXref(); ?> </td> <td colspan="2"> <?php foreach ($person->getAllNames() as $num => $name) { if ($name['type'] == 'NAME') { $title = ''; } else { $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $person)) . '"'; } if ($num == $person->getPrimaryName()) { $class = ' class="name2"'; $sex_image = $person->getSexImage(); list($surn, $givn) = explode(',', $name['sort']); } else { $class = ''; $sex_image = ''; } ?> <a <?php echo $title . ' ' . $class; ?> href="<?php echo $person->getHtmlUrl(); ?> "> <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> </a> <?php echo $sex_image . FunctionsPrint::formatSosaNumbers($dperson->getSosaNumbers(), 1, 'smaller'); ?> <br/> <?php } echo $person->getPrimaryParentsNames('parents details1', 'none'); ?> </td> <td style="display:none;"></td> <td> <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> </td> <td> <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> </td> <td> <?php if ($birth_dates = $person->getAllBirthDates()) { foreach ($birth_dates as $num => $birth_date) { if ($num) { ?> <br/><?php } ?> <?php echo $birth_date->display(true); } } else { $birth_date = new Date(''); if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) { $birth_date = $person->getEstimatedBirthDate(); echo $birth_date->display(true); } else { echo ' '; } $birth_dates[0] = new Date(''); } ?> </td> <td><?php echo $birth_date->julianDay(); ?> </td> <td> <?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); if ($n) { ?> <br><?php } ?> <a href="'<?php echo $tmp->getURL(); ?> " title="<?php echo strip_tags($tmp->getFullName()); ?> "> <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?> </a> <?php } ?> </td> <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { $isBSourced = $dperson->isBirthSourced(); ?> <td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium'); ?> </td> <td><?php echo $isBSourced; ?> </td> <?php } else { ?> <td> </td> <td></td> <?php } ?> <td> <?php if ($death_dates = $person->getAllDeathDates()) { foreach ($death_dates as $num => $death_date) { if ($num) { ?> <br/><?php } ?> <?php echo $death_date->display(true); } } else { $death_date = $person->getEstimatedDeathDate(); if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES') && $death_date->minimumJulianDay() < WT_CLIENT_JD) { echo $death_date->display(true); } elseif ($person->isDead()) { echo I18N::translate('yes'); $death_date = new Date(''); } else { echo ' '; $death_date = new Date(''); } $death_dates[0] = new Date(''); } ?> </td> <td><?php echo $death_date->julianDay(); ?> </td> <td><?php echo Date::getAge($birth_dates[0], $death_dates[0], 2); ?> </td> <td><?php echo Date::getAge($birth_dates[0], $death_dates[0], 1); ?> </td> <td> <?php foreach ($person->getAllDeathPlaces() as $n => $death_place) { $tmp = new Place($death_place, $person->getTree()); if ($n) { ?> <br><?php } ?> <a href="'<?php echo $tmp->getURL(); ?> " title="<?php echo strip_tags($tmp->getFullName()); ?> "> <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?> </a> <?php } ?> </td> <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { $isDSourced = $dperson->isDeathSourced(); ?> <td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isDSourced, 'DEAT', 1, 'medium'); ?> </td> <td><?php echo $isDSourced; ?> </td> <?php } else { ?> <td> </td> <td></td> <?php } ?> <td><?php echo $person->getSex(); ?> </td> <td> <?php if (!$person->canShow() || Date::compare($birth_date, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } else { echo 'YES'; } ?> </td> <td> <?php if (Date::compare($death_dates[0], new Date(date('Y') - 100)) > 0) { echo 'Y100'; } elseif ($death_dates[0]->minimumJulianDay() || $person->isDead()) { echo 'YES'; } else { echo 'N'; } ?> </td> <td> <?php if (!$person->getChildFamilies()) { echo 'R'; } elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) { echo 'L'; } else { echo ' '; } ?> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <th class="ui-state-default" colspan="22"> <div class="center"> <?php echo I18N::translate('Number of Sosa ancestors: %1$s known / %2$s theoretical (%3$s)', I18N::number($this->data->get('sosa_count')), I18N::number($this->data->get('sosa_theo')), I18N::percentage($this->data->get('sosa_ratio'), 2)); ?> <?php if ($this->data->get('sosa_hidden') > 0) { echo '[' . I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))) . ']'; } ?> </div> </th> </tr> <tr> <th colspan="22"> <div class="btn-toolbar"> <div class="btn-group"> <button type="button" class="ui-state-default btn-toggle-parents"> <?php echo I18N::translate('Show parents'); ?> </button> <button id="btn-toggle-statistics-<?php echo $table_id; ?> " type="button" class="ui-state-default btn-toggle-statistics"> <?php echo I18N::translate('Show statistics charts'); ?> </button> </div> </div> </th> </tr> </tfoot> </table> <div id="indi_list_table-charts_<?php echo $table_id; ?> " style="display:none"> <table class="list-charts"> <tr> <td><?php echo $this->data->get('chart_births'); ?> </td> <td><?php echo $this->data->get('chart_deaths'); ?> </td> </tr> <tr> <td colspan="2"><?php echo $this->data->get('chart_ages'); ?> </td> </tr> </table> </div> </div> <?php } }
/** * Compare two dates, so they can be sorted. * * return <0 if $a<$b * return >0 if $b>$a * return 0 if dates same/overlap * BEF/AFT sort as the day before/after * * @param Date $a * @param Date $b * * @return int */ public static function compare(Date $a, Date $b) { // Get min/max JD for each date. switch ($a->qual1) { case 'BEF': $amin = $a->minimumJulianDay() - 1; $amax = $amin; break; case 'AFT': $amax = $a->maximumJulianDay() + 1; $amin = $amax; break; default: $amin = $a->minimumJulianDay(); $amax = $a->maximumJulianDay(); break; } switch ($b->qual1) { case 'BEF': $bmin = $b->minimumJulianDay() - 1; $bmax = $bmin; break; case 'AFT': $bmax = $b->maximumJulianDay() + 1; $bmin = $bmax; break; default: $bmin = $b->minimumJulianDay(); $bmax = $b->maximumJulianDay(); break; } if ($amax < $bmin) { return -1; } elseif ($amin > $bmax && $bmax > 0) { return 1; } elseif ($amin < $bmin && $amax <= $bmax) { return -1; } elseif ($amin > $bmin && $amax >= $bmax && $bmax > 0) { return 1; } else { return 0; } }
/** * Render the Ajax response for the sortable table of Sosa family * @param AjaxController $controller */ protected function renderFamSosaListIndi(AjaxController $controller) { global $WT_TREE; $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); $this->view_bag->set('has_sosa', false); if (count($listFamSosa) > 0) { $this->view_bag->set('has_sosa', true); $table_id = 'table-sosa-fam-' . Uuid::uuid4(); $this->view_bag->set('table_id', $table_id); $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript(' jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; jQuery("#' . $table_id . '").dataTable( { dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', ' . I18N::datatablesI18N(array(16, 32, 64, 128, -1)) . ', jQueryUI: true, autoWidth: false, processing: true, retrieve: true, columns: [ /* 0-Sosa */ { dataSort: 1, class: "center"}, /* 1-SOSA */ { type: "num", visible: false }, /* 2-Husb Givn */ { dataSort: 4}, /* 3-Husb Surn */ { dataSort: 5}, /* 4-GIVN,SURN */ { type: "unicode", visible: false}, /* 5-SURN,GIVN */ { type: "unicode", visible: false}, /* 6-Husb Age */ { dataSort: 7, class: "center"}, /* 7-AGE */ { type: "num", visible: false}, /* 8-Wife Givn */ { dataSort: 10}, /* 9-Wife Surn */ { dataSort: 11}, /* 10-GIVN,SURN */ { type: "unicode", visible: false}, /* 11-SURN,GIVN */ { type: "unicode", visible: false}, /* 12-Wife Age */ { dataSort: 13, class: "center"}, /* 13-AGE */ { type: "num", visible: false}, /* 14-Marr Date */ { dataSort: 15, class: "center"}, /* 15-MARR:DATE */ { visible: false}, /* 16-Marr Plac */ { type: "unicode", class: "center"}, /* 17-Marr Sour */ { dataSort : 18, class: "center", visible: ' . (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME) ? 'true' : 'false') . ' }, /* 18-Sort Sour */ { visible: false}, /* 19-Children */ { dataSort: 20, class: "center"}, /* 20-NCHI */ { type: "num", visible: false}, /* 21-MARR */ { visible: false}, /* 22-DEAT */ { visible: false}, /* 23-TREE */ { visible: false} ], sorting: [[0, "asc"]], displayLength: 16, pagingType: "full_numbers" }); jQuery("#' . $table_id . '") /* Hide/show parents */ .on("click", ".btn-toggle-parents", function() { jQuery(this).toggleClass("ui-state-active"); jQuery(".parents", jQuery(this).closest("table").DataTable().rows().nodes()).slideToggle(); }) /* Hide/show statistics */ .on("click", ".btn-toggle-statistics", function() { jQuery(this).toggleClass("ui-state-active"); jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle(); }) /* Filter buttons in table header */ .on("click", "button[data-filter-column]", function() { var btn = $(this); // De-activate the other buttons in this button group btn.siblings().removeClass("ui-state-active"); // Apply (or clear) this filter var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); if (btn.hasClass("ui-state-active")) { btn.removeClass("ui-state-active"); col.search("").draw(); } else { btn.addClass("ui-state-active"); col.search(btn.data("filter-value")).draw(); } }); jQuery("#sosa-fam-list").css("visibility", "visible"); jQuery("#btn-toggle-statistics-' . $table_id . '").click(); '); $stats = new Stats($WT_TREE); $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; //-- init chart data $marr_by_age = array(); for ($age = 0; $age <= $max_age; $age++) { $marr_by_age[$age] = ''; } $birt_by_decade = array(); $marr_by_decade = array(); for ($year = 1550; $year < 2030; $year += 10) { $birt_by_decade[$year] = ''; $marr_by_decade[$year] = ''; } foreach ($listFamSosa as $sosa => $fid) { $sfamily = Family::getInstance($fid, $WT_TREE); if (!$sfamily || !$sfamily->canShow()) { unset($sfamily[$sosa]); continue; } $mdate = $sfamily->getMarriageDate(); if (($husb = $sfamily->getHusband()) && ($hdate = $husb->getBirthDate()) && $hdate->isOK() && $mdate->isOK()) { if (FunctionsPrint::isDateWithinChartsRange($hdate)) { $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); } $hage = Date::getAge($hdate, $mdate, 0); if ($hage >= 0 && $hage <= $max_age) { $marr_by_age[$hage] .= $husb->getSex(); } } if (($wife = $sfamily->getWife()) && ($wdate = $wife->getBirthDate()) && $wdate->isOK() && $mdate->isOK()) { if (FunctionsPrint::isDateWithinChartsRange($wdate)) { $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); } $wage = Date::getAge($wdate, $mdate, 0); if ($wage >= 0 && $wage <= $max_age) { $marr_by_age[$wage] .= $wife->getSex(); } } if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); } $listFamSosa[$sosa] = $sfamily; } $this->view_bag->set('sosa_list', $listFamSosa); $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); } ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); }
/** * Extract all the dates from the given record and insert them into the database. * * @param string $xref * @param int $ged_id * @param string $gedrec */ public static function updateDates($xref, $ged_id, $gedrec) { if (strpos($gedrec, '2 DATE ') && preg_match_all("/\n1 (\\w+).*(?:\n[2-9].*)*(?:\n2 DATE (.+))(?:\n[2-9].*)*/", $gedrec, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $fact = $match[1]; if (($fact == 'FACT' || $fact == 'EVEN') && preg_match("/\n2 TYPE ([A-Z]{3,5})/", $match[0], $tmatch)) { $fact = $tmatch[1]; } $date = new Date($match[2]); Database::prepare("INSERT INTO `##dates` (d_day,d_month,d_mon,d_year,d_julianday1,d_julianday2,d_fact,d_gid,d_file,d_type) VALUES (?,?,?,?,?,?,?,?,?,?)")->execute(array($date->minimumDate()->d, $date->minimumDate()->format('%O'), $date->minimumDate()->m, $date->minimumDate()->y, $date->minimumDate()->minJD, $date->minimumDate()->maxJD, $fact, $xref, $ged_id, $date->minimumDate()->format('%@'))); if ($date->minimumDate() !== $date->maximumDate()) { Database::prepare("INSERT INTO `##dates` (d_day,d_month,d_mon,d_year,d_julianday1,d_julianday2,d_fact,d_gid,d_file,d_type) VALUES (?,?,?,?,?,?,?,?,?,?)")->execute(array($date->maximumDate()->d, $date->maximumDate()->format('%O'), $date->maximumDate()->m, $date->maximumDate()->y, $date->maximumDate()->minJD, $date->maximumDate()->maxJD, $fact, $xref, $ged_id, $date->maximumDate()->format('%@'))); } } } }
/** * {@inhericDoc} * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() */ protected function renderContent() { if ($this->data->get('has_sosa', false)) { $table_id = $this->data->get('table_id'); ?> <div id="sosa-fam-list" class="sosa-list"> <table id="<?php echo $table_id; ?> "> <thead> <tr> <th colspan="24"> <div class="btn-toolbar"> <div class="btn-group"> <button type="button" data-filter-column="22" data-filter-value="N" class="ui-state-default" title="<?php echo I18N::translate('Show individuals who are alive or couples where both partners are alive.'); ?> " > <?php echo I18N::translate('Both alive'); ?> </button> <button type="button" data-filter-column="22" data-filter-value="W" class="ui-state-default" title="<?php echo I18N::translate('Show couples where only the female partner is deceased.'); ?> " > <?php echo I18N::translate('Widower'); ?> </button> <button type="button" data-filter-column="22" data-filter-value="H" class="ui-state-default" title="<?php echo I18N::translate('Show couples where only the male partner is deceased.'); ?> " > <?php echo I18N::translate('Widow'); ?> </button> <button type="button" data-filter-column="22" data-filter-value="Y" class="ui-state-default" title="<?php echo I18N::translate('Show individuals who are dead or couples where both partners are deceased.'); ?> " > <?php echo I18N::translate('Both dead'); ?> </button> </div> <div class="btn-group"> <button type="button" data-filter-column="23" data-filter-value="R" class="ui-state-default" title="<?php echo I18N::translate('Show “roots” couples or individuals. These individuals may also be called “patriarchs”. They are individuals who have no parents recorded in the database.'); ?> " > <?php echo I18N::translate('Roots'); ?> </button> <button type="button" data-filter-column="23" data-filter-value="L" class="ui-state-default" title="<?php echo I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.'); ?> " > <?php echo I18N::translate('Leaves'); ?> </button> </div> <div class="btn-group"> <button type="button" data-filter-column="21" data-filter-value="U" class="ui-state-default" title="<?php echo I18N::translate('Show couples with an unknown marriage date.'); ?> " > <?php echo GedcomTag::getLabel('MARR'); ?> </button> <button type="button" data-filter-column="21" data-filter-value="YES" class="ui-state-default" title="<?php echo I18N::translate('Show couples who married more than 100 years ago.'); ?> " > <?php echo GedcomTag::getLabel('MARR'); ?> >100 </button> <button type="button" data-filter-column="21" data-filter-value="Y100" class="ui-state-default" title="<?php echo I18N::translate('Show couples who married within the last 100 years.'); ?> " > <?php echo GedcomTag::getLabel('MARR'); ?> <=100 </button> <button type="button" data-filter-column="21" data-filter-value="D" class="ui-state-default" title="<?php echo I18N::translate('Show divorced couples.'); ?> " > <?php echo GedcomTag::getLabel('DIV'); ?> </button> <button type="button" data-filter-column="21" data-filter-value="M" class="ui-state-default" title="<?php echo I18N::translate('Show couples where either partner married more than once.'); ?> " > <?php echo I18N::translate('Multiple marriages'); ?> </button> </div> </div> </th> </tr> <tr> <th><?php echo I18N::translate('Sosa'); ?> </th> <th>SOSA</th> <th><?php echo GedcomTag::getLabel('GIVN'); ?> </th> <th><?php echo GedcomTag::getLabel('SURN'); ?> </th> <th>HUSB:GIVN_SURN</th> <th>HUSB:SURN_GIVN</th> <th><?php echo GedcomTag::getLabel('AGE'); ?> </th> <th>AGE</th> <th><?php echo GedcomTag::getLabel('GIVN'); ?> </th> <th><?php echo GedcomTag::getLabel('SURN'); ?> </th> <th>WIFE:GIVN_SURN</th> <th>WIFE:SURN_GIVN</th> <th><?php echo GedcomTag::getLabel('AGE'); ?> </th> <th>AGE</th> <th><?php echo GedcomTag::getLabel('MARR'); ?> </th> <th>MARR:DATE</th> <th><?php echo GedcomTag::getLabel('PLAC'); ?> </th>'; <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { ?> <th><i class="icon-source" title="<?php echo I18N::translate('Sourced marriage'); ?> " border="0"></i></th> <th>SORT_MARRSC</th> <?php } else { ?> <th> </th> <th></th> <?php } ?> <th><i class="icon-children" title="<?php echo I18N::translate('Children'); ?> "></i></th> <th>NCHI</th> <th>MARR</th> <th>DEAT</th> <th>TREE</th> </tr> </thead> <tbody> <?php foreach ($this->data->get('sosa_list') as $sosa => $family) { /** @var \Fisharebest\Webtrees\Family $person */ //PERSO Create decorator for Family $dfamily = new Family($family); $husb = $family->getHusband(); if (is_null($husb)) { $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree()); } $dhusb = new \MyArtJaub\Webtrees\Individual($husb); $wife = $family->getWife(); if (is_null($wife)) { $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree()); } $dwife = new \MyArtJaub\Webtrees\Individual($wife); $mdate = $family->getMarriageDate(); if ($family->isPendingAddtion()) { $class = ' class="new"'; } elseif ($family->isPendingDeletion()) { $class = ' class="old"'; } else { $class = ''; } ?> <tr <?php echo $class; ?> > <td class="transparent"><?php echo I18N::translate('%1$d/%2$d', $sosa, ($sosa + 1) % 10); ?> </td> <td class="transparent"><?php echo $sosa; ?> </td> <!-- HUSBAND --> <td colspan="2"> <?php foreach ($husb->getAllNames() as $num => $name) { if ($name['type'] == 'NAME') { $title = ''; } else { $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $husb)) . '"'; } if ($num == $husb->getPrimaryName()) { $class = ' class="name2"'; $sex_image = $husb->getSexImage(); list($surn, $givn) = explode(',', $name['sort']); } else { $class = ''; $sex_image = ''; } ?> <a <?php echo $title . ' ' . $class; ?> href="<?php echo $husb->getHtmlUrl(); ?> "> <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> </a> <?php echo $sex_image . FunctionsPrint::formatSosaNumbers($dhusb->getSosaNumbers(), 1, 'smaller'); ?> <br/> <?php } echo $husb->getPrimaryParentsNames('parents details1', 'none'); ?> </td> <!-- Dummy column to match colspan in header --> <td style="display:none;"></td> <td> <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> </td> <td> <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> </td> <?php $hdate = $husb->getBirthDate(); ?> <td><?php Date::getAge($hdate, $mdate, 2); ?> </td> <td><?php Date::getAge($hdate, $mdate, 1); ?> </td> <!-- WIFE --> <td colspan="2"> <?php foreach ($wife->getAllNames() as $num => $name) { if ($name['type'] == 'NAME') { $title = ''; } else { $title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $wife)) . '"'; } if ($num == $wife->getPrimaryName()) { $class = ' class="name2"'; $sex_image = $wife->getSexImage(); list($surn, $givn) = explode(',', $name['sort']); } else { $class = ''; $sex_image = ''; } ?> <a <?php echo $title . ' ' . $class; ?> href="<?php echo $wife->getHtmlUrl(); ?> "> <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> </a> <?php echo $sex_image . FunctionsPrint::formatSosaNumbers($dwife->getSosaNumbers(), 1, 'smaller'); ?> <br/> <?php } echo $wife->getPrimaryParentsNames('parents details1', 'none'); ?> </td> <!-- Dummy column to match colspan in header --> <td style="display:none;"></td> <td> <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> </td> <td> <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> </td> <?php $wdate = $wife->getBirthDate(); ?> <td><?php Date::getAge($wdate, $mdate, 2); ?> </td> <td><?php Date::getAge($wdate, $mdate, 1); ?> </td> <td><?php if ($marriage_dates = $family->getAllMarriageDates()) { foreach ($marriage_dates as $n => $marriage_date) { if ($n) { echo '<br>'; } ?> <div><?php echo $marriage_date->display(true); ?> </div> <?php } } elseif ($family->getFacts('_NMR')) { echo I18N::translate('no'); } elseif ($family->getFacts('MARR')) { echo I18N::translate('yes'); } else { echo ' '; } ?> </td> <td><?php echo $marriage_dates ? $marriage_date->julianDay() : 0; ?> </td> <td><?php foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { $tmp = new Place($marriage_place, $family->getTree()); if ($n) { ?> <br><?php } ?> <a href="'<?php echo $tmp->getURL(); ?> " title="<?php echo strip_tags($tmp->getFullName()); ?> "> <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?> </a> <?php } ?> </td> <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { $isMSourced = $dfamily->isMarriageSourced(); ?> <td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isMSourced, 'MARR', 1, 'medium'); ?> </td> <td><?php echo $isMSourced; ?> </td> <?php } else { ?> <td> </td> <td></td> <?php } ?> <?php $nchi = $family->getNumberOfChildren(); ?> <td><?php echo I18N::number($nchi); ?> </td> <td><?php echo $nchi; ?> </td> <td><?php if (!$mdate->isOK()) { echo 'U'; } else { if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } else { echo 'YES'; } } if ($family->getFacts(WT_EVENTS_DIV)) { echo 'D'; } if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) { echo 'M'; } ?> </td> <td><?php if ($husb->isDead() && $wife->isDead()) { echo 'Y'; } if ($husb->isDead() && !$wife->isDead()) { if ($wife->getSex() == 'F') { echo 'H'; } if ($wife->getSex() == 'M') { echo 'W'; } // male partners } if (!$husb->isDead() && $wife->isDead()) { if ($husb->getSex() == 'M') { echo 'W'; } if ($husb->getSex() == 'F') { echo 'H'; } // female partners } if (!$husb->isDead() && !$wife->isDead()) { echo 'N'; } ?> </td> <td><?php if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } else { echo ' '; } ?> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <th colspan="24"> <div class="btn-toolbar"> <div class="btn-group"> <button type="button" class="ui-state-default btn-toggle-parents"> <?php echo I18N::translate('Show parents'); ?> </button> <button id="btn-toggle-statistics-<?php echo $table_id; ?> " type="button" class="ui-state-default btn-toggle-statistics"> <?php echo I18N::translate('Show statistics charts'); ?> </button> </div> </div> </th> </tr> </tfoot> </table> <div id="fam_list_table-charts_<?php echo $table_id; ?> " style="display:none"> <table class="list-charts"> <tr> <td><?php echo $this->data->get('chart_births'); ?> </td> <td><?php echo $this->data->get('chart_marriages'); ?> </td> </tr> <tr> <td colspan="2"><?php echo $this->data->get('chart_ages'); ?> </td> </tr> </table> </div> </div> <?php } else { ?> <p class="warning"><?php echo I18N::translate('No family has been found for generation %d', $this->data->get('generation')); ?> </p> <?php } }
$gedrec .= FunctionsEdit::addNewFact($match); } } $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); if (Filter::postBool('SOUR_INDI')) { $gedrec = FunctionsEdit::handleUpdates($gedrec); } else { $gedrec = FunctionsEdit::updateRest($gedrec); } // Create the new child $new_child = $family->getTree()->createRecord($gedrec); // Insert new child at the right place $done = false; foreach ($family->getFacts('CHIL') as $fact) { $old_child = $fact->getTarget(); if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { // Insert before this child $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); $done = true; break; } } if (!$done) { // Append child at end $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); } if (Filter::post('goto') === 'new') { $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");'); } else { $controller->addInlineJavascript('closePopupAndReloadParent();'); }
/** * Events * * @param string $type * @param string $direction * @param string $facts * * @return string */ private function eventQuery($type, $direction, $facts) { $eventTypes = array('BIRT' => I18N::translate('birth'), 'DEAT' => I18N::translate('death'), 'MARR' => I18N::translate('marriage'), 'ADOP' => I18N::translate('adoption'), 'BURI' => I18N::translate('burial'), 'CENS' => I18N::translate('census added')); $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')"; if ($direction != 'ASC') { $direction = 'DESC'; } $rows = $this->runSql('' . ' SELECT SQL_CACHE' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " `##dates`" . ' WHERE' . " d_file={$this->tree->getTreeId()} AND" . " d_gid<>'HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1<>0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type LIMIT 1"); if (!isset($rows[0])) { return ''; } $row = $rows[0]; $record = GedcomRecord::getInstance($row['id'], $this->tree); switch ($type) { default: case 'full': if ($record->canShow()) { $result = $record->formatList('span', false, $record->getFullName()); } else { $result = I18N::translate('This information is private and cannot be shown.'); } break; case 'year': $date = new Date($row['type'] . ' ' . $row['year']); $result = $date->display(); break; case 'type': if (isset($eventTypes[$row['fact']])) { $result = $eventTypes[$row['fact']]; } else { $result = GedcomTag::getLabel($row['fact']); } break; case 'name': $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>"; break; case 'place': $fact = $record->getFirstFact($row['fact']); if ($fact) { $result = FunctionsPrint::formatFactPlace($fact, true, true, true); } else { $result = I18N::translate('Private'); } break; } return $result; }
use Fisharebest\Webtrees\Census\CensusInterface; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Module\CensusAssistantModule; /** @var SimpleController $controller */ global $controller; /** @var Tree $WT_TREE */ global $WT_TREE; $xref = Filter::get('xref', WT_REGEX_XREF); $census = Filter::get('census'); $head = Individual::getInstance($xref, $WT_TREE); check_record_access($head); $controller->restrictAccess(class_exists($census)); /** @var CensusInterface */ $census = new $census(); $controller->restrictAccess($census instanceof CensusInterface); $date = new Date($census->censusDate()); $year = strip_tags($date->display(false, '%Y', false)); $headImg = '<i class="icon-button_head"></i>'; $controller->setPageTitle(I18N::translate('Create a new shared note using assistant'))->addInlineJavascript('jQuery("head").append(\'<link rel="stylesheet" href="' . WT_STATIC_URL . WT_MODULES_DIR . 'GEDFact_assistant/census/style.css" type="text/css">\');' . 'jQuery("#tblSample").on("click", ".icon-remove", function() { jQuery(this).closest("tr").remove(); });')->pageHeader(); ?> <h2> <?php echo $controller->getPageTitle(); ?> </h2> <form method="post" action="edit_interface.php" onsubmit="updateCensusText();"> <input type="hidden" name="action" value="addnoteaction_assisted"> <input type="hidden" name="noteid" value="newnote"> <input id="pid_array" type="hidden" name="pid_array" value="none">
/** * Static Helper functions to sort events * * @param Fact $a Fact one * @param Fact $b Fact two * * @return int */ public static function compareDate(Fact $a, Fact $b) { if ($a->getDate()->isOK() && $b->getDate()->isOK()) { // If both events have dates, compare by date $ret = Date::compare($a->getDate(), $b->getDate()); if ($ret == 0) { // If dates are the same, compare by fact type $ret = self::compareType($a, $b); // If the fact type is also the same, retain the initial order if ($ret == 0) { $ret = $a->sortOrder - $b->sortOrder; } } return $ret; } else { // One or both events have no date - retain the initial order return $a->sortOrder - $b->sortOrder; } }
/** * Perform the search */ private function advancedSearch() { global $WT_TREE; $this->myindilist = array(); $fct = count($this->fields); if (!array_filter($this->values)) { return; } // Dynamic SQL query, plus bind variables $sql = 'SELECT DISTINCT ind.i_id AS xref, ind.i_gedcom AS gedcom FROM `##individuals` ind'; $bind = array(); // Join the following tables $father_name = false; $mother_name = false; $spouse_family = false; $indi_name = false; $indi_date = false; $fam_date = false; $indi_plac = false; $fam_plac = false; foreach ($this->fields as $n => $field) { if ($this->values[$n]) { if (substr($field, 0, 14) == 'FAMC:HUSB:NAME') { $father_name = true; } elseif (substr($field, 0, 14) == 'FAMC:WIFE:NAME') { $mother_name = true; } elseif (substr($field, 0, 4) == 'NAME') { $indi_name = true; } elseif (strpos($field, ':DATE') !== false) { if (substr($field, 0, 4) == 'FAMS') { $fam_date = true; $spouse_family = true; } else { $indi_date = true; } } elseif (strpos($field, ':PLAC') !== false) { if (substr($field, 0, 4) == 'FAMS') { $fam_plac = true; $spouse_family = true; } else { $indi_plac = true; } } elseif ($field == 'FAMS:NOTE') { $spouse_family = true; } } } if ($father_name || $mother_name) { $sql .= " JOIN `##link` l_1 ON (l_1.l_file=ind.i_file AND l_1.l_from=ind.i_id AND l_1.l_type='FAMC')"; } if ($father_name) { $sql .= " JOIN `##link` l_2 ON (l_2.l_file=ind.i_file AND l_2.l_from=l_1.l_to AND l_2.l_type='HUSB')"; $sql .= " JOIN `##name` f_n ON (f_n.n_file=ind.i_file AND f_n.n_id =l_2.l_to)"; } if ($mother_name) { $sql .= " JOIN `##link` l_3 ON (l_3.l_file=ind.i_file AND l_3.l_from=l_1.l_to AND l_3.l_type='WIFE')"; $sql .= " JOIN `##name` m_n ON (m_n.n_file=ind.i_file AND m_n.n_id =l_3.l_to)"; } if ($spouse_family) { $sql .= " JOIN `##link` l_4 ON (l_4.l_file=ind.i_file AND l_4.l_from=ind.i_id AND l_4.l_type='FAMS')"; $sql .= " JOIN `##families` fam ON (fam.f_file=ind.i_file AND fam.f_id =l_4.l_to)"; } if ($indi_name) { $sql .= " JOIN `##name` i_n ON (i_n.n_file=ind.i_file AND i_n.n_id=ind.i_id)"; } if ($indi_date) { $sql .= " JOIN `##dates` i_d ON (i_d.d_file=ind.i_file AND i_d.d_gid=ind.i_id)"; } if ($fam_date) { $sql .= " JOIN `##dates` f_d ON (f_d.d_file=ind.i_file AND f_d.d_gid=fam.f_id)"; } if ($indi_plac) { $sql .= " JOIN `##placelinks` i_pl ON (i_pl.pl_file=ind.i_file AND i_pl.pl_gid =ind.i_id)"; $sql .= " JOIN (" . "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file" . " FROM `##places` AS p1" . " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" . " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" . " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" . " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" . " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" . " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" . " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" . " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" . ") AS i_p ON (i_p.file =ind.i_file AND i_pl.pl_p_id= i_p.id)"; } if ($fam_plac) { $sql .= " JOIN `##placelinks` f_pl ON (f_pl.pl_file=ind.i_file AND f_pl.pl_gid =fam.f_id)"; $sql .= " JOIN (" . "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file" . " FROM `##places` AS p1" . " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" . " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" . " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" . " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" . " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" . " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" . " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" . " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" . ") AS f_p ON (f_p.file =ind.i_file AND f_pl.pl_p_id= f_p.id)"; } // Add the where clause $sql .= " WHERE ind.i_file=?"; $bind[] = $WT_TREE->getTreeId(); for ($i = 0; $i < $fct; $i++) { $field = $this->fields[$i]; $value = $this->values[$i]; if ($value === '') { continue; } $parts = preg_split("/:/", $field . '::::'); if ($parts[0] == 'NAME') { // NAME:* switch ($parts[1]) { case 'GIVN': switch ($parts[2]) { case 'EXACT': $sql .= " AND i_n.n_givn=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND i_n.n_givn LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = Soundex::russell($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_givn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = Soundex::daitchMokotoff($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_givn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; } break; case 'SURN': switch ($parts[2]) { case 'EXACT': $sql .= " AND i_n.n_surname=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND i_n.n_surname LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND i_n.n_surname LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = Soundex::russell($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_surn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= " AND (" . implode(' OR ', $sdx) . ")"; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = Soundex::daitchMokotoff($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_surn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= " AND (" . implode(' OR ', $sdx) . ")"; break; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } } break; case 'NICK': case '_MARNM': case '_HEB': case '_AKA': $sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')"; $bind[] = $parts[1]; $bind[] = $value; break; } } elseif ($parts[1] == 'DATE') { // *:DATE $date = new Date($value); if ($date->isOK()) { $jd1 = $date->minimumJulianDay(); $jd2 = $date->maximumJulianDay(); if (!empty($this->plusminus[$i])) { $adjd = $this->plusminus[$i] * 365; $jd1 -= $adjd; $jd2 += $adjd; } $sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?"; $bind[] = $parts[0]; $bind[] = $jd1; $bind[] = $jd2; } } elseif ($parts[0] == 'FAMS' && $parts[2] == 'DATE') { // FAMS:*:DATE $date = new Date($value); if ($date->isOK()) { $jd1 = $date->minimumJulianDay(); $jd2 = $date->maximumJulianDay(); if (!empty($this->plusminus[$i])) { $adjd = $this->plusminus[$i] * 365; $jd1 -= $adjd; $jd2 += $adjd; } $sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?"; $bind[] = $parts[1]; $bind[] = $jd1; $bind[] = $jd2; } } elseif ($parts[1] == 'PLAC') { // *:PLAC // SQL can only link a place to a person/family, not to an event. $sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } elseif ($parts[0] == 'FAMS' && $parts[2] == 'PLAC') { // FAMS:*:PLAC // SQL can only link a place to a person/family, not to an event. $sql .= " AND f_p.place LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } elseif ($parts[0] == 'FAMC' && $parts[2] == 'NAME') { $table = $parts[1] == 'HUSB' ? 'f_n' : 'm_n'; // NAME:* switch ($parts[3]) { case 'GIVN': switch ($parts[4]) { case 'EXACT': $sql .= " AND {$table}.n_givn=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND {$table}.n_givn LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND {$table}.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = Soundex::russell($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_givn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = Soundex::daitchMokotoff($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_givn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; break; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } } break; case 'SURN': switch ($parts[4]) { case 'EXACT': $sql .= " AND {$table}.n_surname=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND {$table}.n_surname LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND {$table}.n_surname LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = Soundex::russell($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_surn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = Soundex::daitchMokotoff($value); if ($sdx !== null) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_surn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; } break; } } elseif ($parts[0] == 'FAMS') { // e.g. searches for occupation, religion, note, etc. $sql .= " AND fam.f_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)"; $bind[] = $parts[1]; $bind[] = $value; } else { // e.g. searches for occupation, religion, note, etc. $sql .= " AND ind.i_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)"; $bind[] = $parts[0]; $bind[] = $value; } } $rows = Database::prepare($sql)->execute($bind)->fetchAll(); foreach ($rows as $row) { $person = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); // Check for XXXX:PLAC fields, which were only partially matched by SQL foreach ($this->fields as $n => $field) { if ($this->values[$n] && preg_match('/^(' . WT_REGEX_TAG . '):PLAC$/', $field, $match)) { if (!preg_match('/\\n1 ' . $match[1] . '(\\n[2-9].*)*\\n2 PLAC .*' . preg_quote($this->values[$n], '/') . '/i', $person->getGedcom())) { continue 2; } } } $this->myindilist[] = $person; } }
use Fisharebest\Webtrees\Census\CensusInterface; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Module\CensusAssistantModule; /** @var SimpleController $controller */ global $controller; /** @var Tree $WT_TREE */ global $WT_TREE; $xref = Filter::get('xref', WT_REGEX_XREF); $census = Filter::get('census'); $head = Individual::getInstance($xref, $WT_TREE); check_record_access($head); $controller->restrictAccess(class_exists($census)); /** @var CensusInterface */ $census = new $census(); $controller->restrictAccess($census instanceof CensusInterface); $date = new Date($census->censusDate()); $year = $date->minimumDate()->format('%Y'); $headImg = '<i class="icon-button_head"></i>'; $controller->setPageTitle(I18N::translate('Create a shared note using the census assistant'))->addInlineJavascript('jQuery("head").append(\'<link rel="stylesheet" href="' . WT_STATIC_URL . WT_MODULES_DIR . 'GEDFact_assistant/census/style.css" type="text/css">\');' . 'jQuery("#tblSample").on("click", ".icon-remove", function() { jQuery(this).closest("tr").remove(); });')->pageHeader(); ?> <h2> <?php echo $controller->getPageTitle(); ?> </h2> <form method="post" action="edit_interface.php" onsubmit="updateCensusText();"> <input type="hidden" name="action" value="addnoteaction_assisted"> <input id="pid_array" type="hidden" name="pid_array" value="none"> <input type="hidden" name="NOTE" id="NOTE">
/** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsEdit; define('WT_SCRIPT_NAME', 'admin_trees_config.php'); require './includes/session.php'; $controller = new PageController(); $controller->restrictAccess(Auth::isManager($WT_TREE)); $calendars = array('none' => I18N::translate('No calendar conversion')) + Date::calendarNames(); $french_calendar_start = new Date('22 SEP 1792'); $french_calendar_end = new Date('31 DEC 1805'); $gregorian_calendar_start = new Date('15 OCT 1582'); $hide_show = array(0 => I18N::translate('hide'), 1 => I18N::translate('show')); $surname_list_styles = array('style1' => I18N::translate('list'), 'style2' => I18N::translate('table'), 'style3' => I18N::translate('tag cloud')); $layouts = array(0 => I18N::translate('Portrait'), 1 => I18N::translate('Landscape')); $one_to_nine = array(); for ($n = 1; $n <= 9; ++$n) { $one_to_nine[$n] = I18N::number($n); } $formats = array('' => I18N::translate('none'), 'markdown' => I18N::translate('markdown')); $source_types = array(0 => I18N::translate('none'), 1 => I18N::translate('facts'), 2 => I18N::translate('records')); $no_yes = array(0 => I18N::translate('no'), 1 => I18N::translate('yes')); $PRIVACY_CONSTANTS = array('none' => I18N::translate('Show to visitors'), 'privacy' => I18N::translate('Show to members'), 'confidential' => I18N::translate('Show to managers'), 'hidden' => I18N::translate('Hide from everyone')); $privacy = array(Auth::PRIV_PRIVATE => I18N::translate('Show to visitors'), Auth::PRIV_USER => I18N::translate('Show to members'), Auth::PRIV_NONE => I18N::translate('Show to managers'), Auth::PRIV_HIDE => I18N::translate('Hide from everyone')); $tags = array_unique(array_merge(explode(',', $WT_TREE->getPreference('INDI_FACTS_ADD')), explode(',', $WT_TREE->getPreference('INDI_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('FAM_FACTS_ADD')), explode(',', $WT_TREE->getPreference('FAM_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('NOTE_FACTS_ADD')), explode(',', $WT_TREE->getPreference('NOTE_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('SOUR_FACTS_ADD')), explode(',', $WT_TREE->getPreference('SOUR_FACTS_UNIQUE')), explode(',', $WT_TREE->getPreference('REPO_FACTS_ADD')), explode(',', $WT_TREE->getPreference('REPO_FACTS_UNIQUE')), array('SOUR', 'REPO', 'OBJE', '_PRIM', 'NOTE', 'SUBM', 'SUBN', '_UID', 'CHAN'))); $all_tags = array(); foreach ($tags as $tag) {
/** * Get any historical events. * * @param Individual $person * * @return Fact[] */ private static function historicalFacts(Individual $person) { $SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS'); $facts = array(); if ($SHOW_RELATIVES_EVENTS) { // Only include events between birth and death $birt_date = $person->getEstimatedBirthDate(); $deat_date = $person->getEstimatedDeathDate(); if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) { $histo = array(); require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php'; foreach ($histo as $hist) { // Earlier versions of the WIKI encouraged people to use HTML entities, // rather than UTF8 encoding. $hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8'); $fact = new Fact($hist, $person, 'histo'); $sdate = $fact->getDate(); if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) { $facts[] = $fact; } } } } return $facts; }
/** * Function getCalendarOptionList * * @return string */ public function getCalendarOptionList() { $html = ''; foreach (Date::calendarNames() as $calendar => $name) { $selected = $this->calendar === $calendar ? 'selected' : ''; $html .= sprintf('<option dir="auto" value="%s" %s>%s</option>', $calendar, $selected, $name); } return $html; }
/** * Print a fact for an individual. * * @param Fact $event */ public function printTimeFact(Fact $event) { global $basexoffset, $baseyoffset, $factcount, $placements; $desc = $event->getValue(); // check if this is a family fact $gdate = $event->getDate(); $date = $gdate->minimumDate(); $date = $date->convertToCalendar('gregorian'); $year = $date->y; $month = max(1, $date->m); $day = max(1, $date->d); $xoffset = $basexoffset + 22; $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale; $yoffset = $yoffset + $month / 12 * $this->scale; $yoffset = $yoffset + $day / 30 * ($this->scale / 12); $yoffset = (int) $yoffset; $place = (int) ($yoffset / $this->bheight); $i = 1; $j = 0; $tyoffset = 0; while (isset($placements[$place])) { if ($i === $j) { $tyoffset = $this->bheight * $i; $i++; } else { $tyoffset = -1 * $this->bheight * $j; $j++; } $place = (int) (($yoffset + $tyoffset) / $this->bheight); } $yoffset += $tyoffset; $xoffset += abs($tyoffset); $placements[$place] = $yoffset; echo "<div id=\"fact{$factcount}\" style=\"position:absolute; " . (I18N::direction() === 'ltr' ? 'left: ' . $xoffset : 'right: ' . $xoffset) . 'px; top:' . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">"; echo '<table cellspacing="0" cellpadding="0" border="0" style="cursor: hand;"><tr><td>'; echo '<img src="' . Theme::theme()->parameter('image-hline') . '" name="boxline' . $factcount . '" id="boxline' . $factcount . '" height="3" width="10" style="padding-'; if (I18N::direction() === 'ltr') { echo 'left: 3px;">'; } else { echo 'right: 3px;">'; } $col = array_search($event->getParent(), $this->people); if ($col === false) { // Marriage event - use the color of the husband $col = array_search($event->getParent()->getHusband(), $this->people); } if ($col === false) { // Marriage event - use the color of the wife $col = array_search($event->getParent()->getWife(), $this->people); } $col = $col % 6; echo '</td><td class="person' . $col . '">'; if (count($this->people) > 6) { // We only have six colours, so show naes if more than this number echo $event->getParent()->getFullName() . ' — '; } $record = $event->getParent(); echo $event->getLabel(); echo ' — '; if ($record instanceof Individual) { echo FunctionsPrint::formatFactDate($event, $record, false, false); } elseif ($record instanceof Family) { echo $gdate->display(); if ($record->getHusband() && $record->getHusband()->getBirthDate()->isOK()) { $ageh = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getHusband()->getBirthDate(), $gdate)); } else { $ageh = null; } if ($record->getWife() && $record->getWife()->getBirthDate()->isOK()) { $agew = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getWife()->getBirthDate(), $gdate)); } else { $agew = null; } if ($ageh && $agew) { echo '<span class="age"> ', I18N::translate('Husband’s age'), ' ', $ageh, ' ', I18N::translate('Wife’s age'), ' ', $agew, '</span>'; } elseif ($ageh) { echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>'; } elseif ($agew) { echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>'; } } echo ' ' . Filter::escapeHtml($desc); if (!$event->getPlace()->isEmpty()) { echo ' — ' . $event->getPlace()->getShortName(); } // Print spouses names for family events if ($event->getParent() instanceof Family) { echo ' — <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>'; } echo '</td></tr></table>'; echo '</div>'; if (I18N::direction() === 'ltr') { $img = 'image-dline2'; $ypos = '0%'; } else { $img = 'image-dline'; $ypos = '100%'; } $dyoffset = $yoffset - $tyoffset + $this->bheight / 3; if ($tyoffset < 0) { $dyoffset = $yoffset + $this->bheight / 3; if (I18N::direction() === 'ltr') { $img = 'image-dline'; $ypos = '100%'; } else { $img = 'image-dline2'; $ypos = '0%'; } } // Print the diagonal line echo '<div id="dbox' . $factcount . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left: ' . ($basexoffset + 25) : 'right: ' . ($basexoffset + 25)) . 'px; top:' . $dyoffset . 'px; font-size: 8pt; height: ' . abs($tyoffset) . 'px; width: ' . abs($tyoffset) . 'px;'; echo ' background-image: url(\'' . Theme::theme()->parameter($img) . '\');'; echo ' background-position: 0% ' . $ypos . ';">'; echo '</div>'; }
if ($controller->record->canShow()) { // Highlight image or silhouette echo '<div id="indi_mainimage">', $controller->record->displayImage(), '</div>'; echo '<div id="header_accordion1">'; // contain accordions for names echo '<h3 class="name_one ', $controller->getPersonStyle($controller->record), '"><span>', $controller->record->getFullName(), '</span>'; // First name accordion header $bdate = $controller->record->getBirthDate(); $ddate = $controller->record->getDeathDate(); echo '<span class="header_age">'; if ($bdate->isOK() && !$controller->record->isDead()) { // If living display age echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate), true), $controller->record, 'span'); } elseif ($bdate->isOK() && $ddate->isOK()) { // If dead, show age at death echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, $ddate), false), $controller->record, 'span'); } echo '</span>'; // Display summary birth/death info. echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>'; // Display gender icon foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'SEX') { $controller->printSexRecord($fact); } } echo '</h3>'; // close first name accordion header // Display name details foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'NAME') {
/** * Calculate whether this individual is living or dead. * If not known to be dead, then assume living. * * @return bool */ public function isDead() { $MAX_ALIVE_AGE = $this->tree->getPreference('MAX_ALIVE_AGE'); // "1 DEAT Y" or "1 DEAT/2 DATE" or "1 DEAT/2 PLAC" if (preg_match('/\\n1 (?:' . WT_EVENTS_DEAT . ')(?: Y|(?:\\n[2-9].+)*\\n2 (DATE|PLAC) )/', $this->gedcom)) { return true; } // If any event occured more than $MAX_ALIVE_AGE years ago, then assume the individual is dead if (preg_match_all('/\\n2 DATE (.+)/', $this->gedcom, $date_matches)) { foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * $MAX_ALIVE_AGE) { return true; } } // The individual has one or more dated events. All are less than $MAX_ALIVE_AGE years ago. // If one of these is a birth, the individual must be alive. if (preg_match('/\\n1 BIRT(?:\\n[2-9].+)*\\n2 DATE /', $this->gedcom)) { return false; } } // If we found no conclusive dates then check the dates of close relatives. // Check parents (birth and adopted) foreach ($this->getChildFamilies(Auth::PRIV_HIDE) as $family) { foreach ($family->getSpouses(Auth::PRIV_HIDE) as $parent) { // Assume parents are no more than 45 years older than their children preg_match_all('/\\n2 DATE (.+)/', $parent->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 45)) { return true; } } } } // Check spouses foreach ($this->getSpouseFamilies(Auth::PRIV_HIDE) as $family) { preg_match_all('/\\n2 DATE (.+)/', $family->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); // Assume marriage occurs after age of 10 if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 10)) { return true; } } // Check spouse dates $spouse = $family->getSpouse($this); if ($spouse) { preg_match_all('/\\n2 DATE (.+)/', $spouse->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); // Assume max age difference between spouses of 40 years if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 40)) { return true; } } } // Check child dates foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) { preg_match_all('/\\n2 DATE (.+)/', $child->gedcom, $date_matches); // Assume children born after age of 15 foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 15)) { return true; } } // Check grandchildren foreach ($child->getSpouseFamilies(Auth::PRIV_HIDE) as $child_family) { foreach ($child_family->getChildren(Auth::PRIV_HIDE) as $grandchild) { preg_match_all('/\\n2 DATE (.+)/', $grandchild->gedcom, $date_matches); // Assume grandchildren born after age of 30 foreach ($date_matches[1] as $date_match) { $date = new Date($date_match); if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 30)) { return true; } } } } } } return false; }
/** * Print SOUR structure * This function prints the input array of SOUR sub-records built by the * getSourceStructure() function. * * @param string[] $textSOUR * * @return string */ public static function printSourceStructure($textSOUR) { global $WT_TREE; $html = ''; if ($textSOUR['PAGE']) { $html .= GedcomTag::getLabelValue('PAGE', Filter::expandUrls($textSOUR['PAGE'])); } if ($textSOUR['EVEN']) { $html .= GedcomTag::getLabelValue('EVEN', Filter::escapeHtml($textSOUR['EVEN'])); if ($textSOUR['ROLE']) { $html .= GedcomTag::getLabelValue('ROLE', Filter::escapeHtml($textSOUR['ROLE'])); } } if ($textSOUR['DATE'] || count($textSOUR['TEXT'])) { if ($textSOUR['DATE']) { $date = new Date($textSOUR['DATE']); $html .= GedcomTag::getLabelValue('DATA:DATE', $date->display()); } foreach ($textSOUR['TEXT'] as $text) { $html .= GedcomTag::getLabelValue('TEXT', Filter::formatText($text, $WT_TREE)); } } if ($textSOUR['QUAY'] != '') { $html .= GedcomTag::getLabelValue('QUAY', GedcomCodeQuay::getValue($textSOUR['QUAY'])); } return '<div class="indent">' . $html . '</div>'; }
/** * Print a new fact box on details pages * * @param string $id the id of the person, family, source etc the fact will be added to * @param array $usedfacts an array of facts already used in this record * @param string $type the type of record INDI, FAM, SOUR etc */ public static function printAddNewFact($id, $usedfacts, $type) { global $WT_TREE; // -- Add from clipboard if (is_array(Session::get('clipboard'))) { $newRow = true; foreach (array_reverse(Session::get('clipboard'), true) as $fact_id => $fact) { if ($fact["type"] == $type || $fact["type"] == 'all') { if ($newRow) { $newRow = false; echo '<tr><td class="descriptionbox">'; echo I18N::translate('Add from clipboard'), '</td>'; echo '<td class="optionbox wrap"><form method="get" name="newFromClipboard" action="?" onsubmit="return false;">'; echo '<select id="newClipboardFact">'; } echo '<option value="', Filter::escapeHtml($fact_id), '">', GedcomTag::getLabel($fact['fact']); // TODO use the event class to store/parse the clipboard events if (preg_match('/^2 DATE (.+)/m', $fact['factrec'], $match)) { $tmp = new Date($match[1]); echo '; ', $tmp->minimumDate()->format('%Y'); } if (preg_match('/^2 PLAC ([^,\\n]+)/m', $fact['factrec'], $match)) { echo '; ', $match[1]; } echo '</option>'; } } if (!$newRow) { echo '</select>'; echo ' <input type="button" value="', I18N::translate('Add'), "\" onclick=\"return paste_fact('{$id}', '#newClipboardFact');\"> "; echo '</form></td></tr>', "\n"; } } // -- Add from pick list switch ($type) { case "INDI": $addfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('INDI_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "FAM": $addfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('FAM_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "SOUR": $addfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('SOUR_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "NOTE": $addfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('NOTE_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "REPO": $addfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", $WT_TREE->getPreference('REPO_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; default: return; } $addfacts = array_merge(self::checkFactUnique($uniquefacts, $usedfacts, $type), $addfacts); $quickfacts = array_intersect($quickfacts, $addfacts); $translated_addfacts = array(); foreach ($addfacts as $addfact) { $translated_addfacts[$addfact] = GedcomTag::getLabel($addfact); } uasort($translated_addfacts, function ($x, $y) { return I18N::strcasecmp(I18N::translate($x), I18N::translate($y)); }); echo '<tr><td class="descriptionbox">'; echo I18N::translate('Fact or event'); echo '</td>'; echo '<td class="optionbox wrap">'; echo '<form method="get" name="newfactform" action="?" onsubmit="return false;">'; echo '<select id="newfact" name="newfact">'; echo '<option value="" disabled selected>' . I18N::translate('<select>') . '</option>'; foreach ($translated_addfacts as $fact => $fact_name) { echo '<option value="', $fact, '">', $fact_name, '</option>'; } if ($type == 'INDI' || $type == 'FAM') { echo '<option value="FACT">', I18N::translate('Custom fact'), '</option>'; echo '<option value="EVEN">', I18N::translate('Custom event'), '</option>'; } echo '</select>'; echo '<input type="button" value="', I18N::translate('Add'), '" onclick="add_record(\'' . $id . '\', \'newfact\');">'; echo '<span class="quickfacts">'; foreach ($quickfacts as $fact) { echo '<a href="#" onclick="add_new_record(\'' . $id . '\', \'' . $fact . '\');return false;">', GedcomTag::getLabel($fact), '</a>'; } echo '</span></form>'; echo '</td></tr>'; }
/** * Print the lifespan of this person * * @param type $person * @param type $is_spouse * @return string */ private function printLifespan($person, $is_spouse = false) { $html = ''; $birthdate = $person->getBirthDate(); $deathdate = $person->getDeathdate(); $ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($birthdate, $deathdate), false); $birthdata = false; if ($birthdate->isOK() || $person->getBirthPlace() != '') { $birthdata = true; $bapm = $person->getFirstFact('BAPM'); $chr = $person->getFirstFact('CHR'); $birt = $person->getFirstFact('BIRT'); if ($birt) { $html .= $this->printBirthText($person, 'BIRT', $is_spouse); $html .= $this->printDate($birt); } else { if ($bapm || $chr) { $html .= $this->printBirthText($person, 'BAPM', $is_spouse); $html .= $bapm ? $this->printDate($bapm) : $this->printDate($chr); } } if ($person->getBirthPlace() != '') { $html .= $this->printPlace($person->getBirthPlace(), $person->getTree()); } } $deathdata = false; if ($deathdate->isOK() || $person->getDeathPlace() != '') { $deathdata = true; if ($birthdata) { $html .= ' ' . I18N::translate('and '); $person->getSex() == 'F' ? $html .= I18N::translateContext('FEMALE', 'died') : ($html .= I18N::translateContext('MALE', 'died')); } else { $person->getSex() == 'F' ? $html .= '. ' . I18N::translate('She died') : ($html .= '. ' . I18N::translate('He died')); } $deat = $person->getFirstFact('DEAT'); if ($deat) { $html .= $this->printDate($deat); } if ($person->getDeathPlace() != '') { $html .= $this->printPlace($person->getDeathPlace(), $person->getTree()); } if ($birthdate->isOK() && $deathdate->isOK() && $this->isDateDMY($birt) && $this->isDateDMY($deat)) { if (Date::getAge($birthdate, $deathdate, 0) < 2) { $html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath); } else { $html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath); } } } return $html; }
for ($d = $start_d; $d <= $end_d; ++$d) { if (($d + $cal_date->minJD - $week_start) % $days_in_week === 1) { echo '<tr>'; } echo '<td class="optionbox wrap">'; if ($d < 1 || $d > $days_in_month) { if (count($cal_facts[0]) > 0) { echo '<span class="cal_day">', I18N::translate('Day not set'), '</span><br style="clear: both;">'; echo '<div class="details1" style="height: 180px; overflow: auto;">'; echo calendar_list_text($cal_facts[0], '', '', false); echo '</div>'; $cal_facts[0] = array(); } } else { // Format the day number using the calendar $tmp = new Date($cal_date->format("%@ {$d} %O %E")); $d_fmt = $tmp->minimumDate()->format('%j'); if ($d === $today->d && $cal_date->m === $today->m) { echo '<span class="cal_day current_day">', $d_fmt, '</span>'; } else { echo '<span class="cal_day">', $d_fmt, '</span>'; } // Show a converted date foreach (explode('_and_', $CALENDAR_FORMAT) as $convcal) { switch ($convcal) { case 'french': $alt_date = new FrenchDate($cal_date->minJD + $d - 1); break; case 'gregorian': $alt_date = new GregorianDate($cal_date->minJD + $d - 1); break;
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $controller, $WT_TREE; $days = $this->getBlockSetting($block_id, 'days', '7'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $calendar = $this->getBlockSetting($block_id, 'calendar', 'jewish'); $block = $this->getBlockSetting($block_id, 'block', '1'); foreach (array('days', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } $startjd = WT_CLIENT_JD; $endjd = WT_CLIENT_JD + $days - 1; $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; } else { $title = ''; } $title .= $this->getTitle(); $content = ''; // The standard anniversary rules cover most of the Yahrzeit rules, we just // need to handle a few special cases. // Fetch normal anniversaries... $yahrzeits = array(); for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) { foreach (FunctionsDb::getAnniversaryEvents($jd, 'DEAT _YART', $WT_TREE) as $fact) { // Exact hebrew dates only $date = $fact->getDate(); if ($date->minimumDate() instanceof JewishDate && $date->minimumJulianDay() === $date->maximumJulianDay()) { $fact->jd = $jd; $yahrzeits[] = $fact; } } } // ...then adjust dates $jewish_calendar = new JewishCalendar(); foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->getTag() === 'DEAT') { $today = new JewishDate($yahrzeit->jd); $hd = $yahrzeit->getDate()->minimumDate(); $hd1 = new JewishDate($hd); $hd1->y += 1; $hd1->setJdFromYmd(); // Special rules. See http://www.hebcal.com/help/anniv.html // Everything else is taken care of by our standard anniversary rules. if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->daysInMonth() < 30) { // 30 CSH - Last day in CSH $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 3, 1) - 1; } elseif ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->daysInMonth() < 30) { // 30 KSL - Last day in KSL $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 4, 1) - 1; } elseif ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->daysInMonth() < 30 && !$today->isLeapYear()) { // 30 ADR - Last day in SHV $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 6, 1) - 1; } } } switch ($infoStyle) { case 'list': foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) { $ind = $yahrzeit->getParent(); $content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage(); $content .= "<div class=\"indent\">"; $content .= $yahrzeit->getDate()->display(true); $content .= ', ' . I18N::translate('%s year anniversary', $yahrzeit->anniv); $content .= "</div>"; } } break; case 'table': default: $table_id = Uuid::uuid4(); // table requires a unique ID $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript(' jQuery("#' . $table_id . '").dataTable({ dom: \'t\', ' . I18N::datatablesI18N() . ', autoWidth: false, paginate: false, lengthChange: false, filter: false, info: true, jQueryUI: true, sorting: [[5,"asc"]], columns: [ /* 0-name */ { dataSort: 1 }, /* 1-NAME */ { visible: false }, /* 2-date */ { dataSort: 3 }, /* 3-DATE */ { visible: false }, /* 4-Aniv */ { class: "center"}, /* 5-yart */ { dataSort: 6 }, /* 6-YART */ { visible: false } ] }); jQuery("#' . $table_id . '").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); $content = ''; $content .= '<div class="loading-image"> </div>'; $content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">'; $content .= '<thead><tr>'; $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>'; $content .= '<th>' . GedcomTag::getLabel('NAME') . '</th>'; $content .= '<th>' . GedcomTag::getLabel('DEAT') . '</th>'; $content .= '<th>DEAT</th>'; $content .= '<th><i class="icon-reminder" title="' . I18N::translate('Anniversary') . '"></i></th>'; $content .= '<th>' . GedcomTag::getLabel('_YART') . '</th>'; $content .= '<th>_YART</th>'; $content .= '</tr></thead><tbody>'; foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) { $content .= '<tr>'; $ind = $yahrzeit->getParent(); // Individual name(s) $name = $ind->getFullName(); $url = $ind->getHtmlUrl(); $content .= '<td>'; $content .= '<a href="' . $url . '">' . $name . '</a>'; $content .= $ind->getSexImage(); $addname = $ind->getAddName(); if ($addname) { $content .= '<br><a href="' . $url . '">' . $addname . '</a>'; } $content .= '</td>'; $content .= '<td>' . $ind->getSortName() . '</td>'; // death/yahrzeit event date $content .= '<td>' . $yahrzeit->getDate()->display() . '</td>'; $content .= '<td>' . $yahrzeit->getDate()->julianDay() . '</td>'; // sortable date // Anniversary $content .= '<td>' . $yahrzeit->anniv . '</td>'; // upcomming yahrzeit dates switch ($calendar) { case 'gregorian': $today = new GregorianDate($yahrzeit->jd); break; case 'jewish': default: $today = new JewishDate($yahrzeit->jd); break; } $td = new Date($today->format('%@ %A %O %E')); $content .= '<td>' . $td->display() . '</td>'; $content .= '<td>' . $td->julianDay() . '</td>'; // sortable date $content .= '</tr>'; } } $content .= '</tbody></table>'; break; } if ($template) { if ($block) { $class .= ' small_inner_block'; } return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }