/** * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents * @return string HTML code */ private function htmlAncestorDispersionG3() { $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); $size = '700x300'; $color_motmot = 'ffd1dc'; $color_motfat = 'b998a0'; $color_fatfat = '577292'; $color_fatmot = '84beff'; $color_shared = '777777'; $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha; $chd = $this->arrayToExtendedEncoding(array(4095 * Functions::safeDivision($total_fatfat, $total), 4095 * Functions::safeDivision($total_fatmot, $total), 4095 * Functions::safeDivision($total_sha, $total), 4095 * Functions::safeDivision($total_motfat, $total), 4095 * Functions::safeDivision($total_motmot, $total))); $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); $chl = \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; }
/** * 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(); }
/** * GeoAnalysis@dataTabs */ public function dataTabs() { global $WT_TREE; $controller = new JsonController(); $ga_id = Filter::getInteger('ga_id'); $ga = $this->provider->getGeoAnalysis($ga_id); $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); $controller->restrictAccess($ga && $sosa_provider->isSetup())->pageHeader(); $jsonArray = array(); list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); $flags = array(); if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { $mapProvider = new GoogleMapsProvider(); foreach ($placesDispGeneral['places'] as $place => $count) { $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); } } $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); $controller->encode($jsonArray); }
/** * Get the list of Sosa numbers for this individual * This list is cached. * * @uses \MyArtJaub\Webtrees\Functions\ModuleManager * @return array List of Sosa numbers */ public function getSosaNumbers() { if ($this->sosa === null) { $provider = new SosaProvider($this->gedcomrecord->getTree()); $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); } return $this->sosa; }