private function adminPlaces() { require WT_ROOT . 'includes/functions/functions_edit.php'; $action = WT_Filter::get('action'); $parent = WT_Filter::get('parent'); $inactive = WT_Filter::getBool('inactive'); $deleteRecord = WT_Filter::get('deleteRecord'); if (!isset($parent)) { $parent = 0; } $controller = new WT_Controller_Page(); $controller->restrictAccess(Auth::isAdmin()); if ($action == 'ExportFile' && Auth::isAdmin()) { Zend_Session::writeClose(); $tmp = $this->placeIdToHierarchy($parent); $maxLevel = $this->getHighestLevel(); if ($maxLevel > 8) { $maxLevel = 8; } $tmp[0] = 'places'; $outputFileName = preg_replace('/[:;\\/\\\\(\\)\\{\\}\\[\\] $]/', '_', implode('-', $tmp)) . '.csv'; header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $outputFileName . '"'); echo '"', WT_I18N::translate('Level'), '";"', WT_I18N::translate('Country'), '";'; if ($maxLevel > 0) { echo '"', WT_I18N::translate('State'), '";'; } if ($maxLevel > 1) { echo '"', WT_I18N::translate('County'), '";'; } if ($maxLevel > 2) { echo '"', WT_I18N::translate('City'), '";'; } if ($maxLevel > 3) { echo '"', WT_I18N::translate('Place'), '";'; } if ($maxLevel > 4) { echo '"', WT_I18N::translate('Place'), '";'; } if ($maxLevel > 5) { echo '"', WT_I18N::translate('Place'), '";'; } if ($maxLevel > 6) { echo '"', WT_I18N::translate('Place'), '";'; } if ($maxLevel > 7) { echo '"', WT_I18N::translate('Place'), '";'; } echo '"', WT_I18N::translate('Longitude'), '";"', WT_I18N::translate('Latitude'), '";'; echo '"', WT_I18N::translate('Zoom level'), '";"', WT_I18N::translate('Icon'), '";', WT_EOL; $this->outputLevel($parent); exit; } $controller->setPageTitle(WT_I18N::translate('Google Maps™'))->pageHeader(); ?> <table id="gm_config"> <tr> <th> <a href="module.php?mod=googlemap&mod_action=admin_config"> <?php echo WT_I18N::translate('Google Maps™ preferences'); ?> </a> </th> <th> <a class="current" href="module.php?mod=googlemap&mod_action=admin_places"> <?php echo WT_I18N::translate('Geographic data'); ?> </a> </th> <th> <a href="module.php?mod=googlemap&mod_action=admin_placecheck"> <?php echo WT_I18N::translate('Place check'); ?> </a> </th> </tr> </table> <?php if ($action == 'ImportGedcom') { $placelist = array(); $j = 0; $gedcom_records = WT_DB::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_file=? UNION ALL SELECT f_gedcom FROM `##families` WHERE f_file=?")->execute(array(WT_GED_ID, WT_GED_ID))->fetchOneColumn(); foreach ($gedcom_records as $gedrec) { $i = 1; $placerec = get_sub_record(2, '2 PLAC', $gedrec, $i); while (!empty($placerec)) { if (preg_match("/2 PLAC (.+)/", $placerec, $match)) { $placelist[$j] = array(); $placelist[$j]['place'] = trim($match[1]); if (preg_match("/4 LATI (.*)/", $placerec, $match)) { $placelist[$j]['lati'] = trim($match[1]); if ($placelist[$j]['lati'][0] != 'N' && $placelist[$j]['lati'][0] != 'S') { if ($placelist[$j]['lati'] < 0) { $placelist[$j]['lati'][0] = 'S'; } else { $placelist[$j]['lati'] = 'N' . $placelist[$j]['lati']; } } } else { $placelist[$j]['lati'] = NULL; } if (preg_match("/4 LONG (.*)/", $placerec, $match)) { $placelist[$j]['long'] = trim($match[1]); if ($placelist[$j]['long'][0] != 'E' && $placelist[$j]['long'][0] != 'W') { if ($placelist[$j]['long'] < 0) { $placelist[$j]['long'][0] = 'W'; } else { $placelist[$j]['long'] = 'E' . $placelist[$j]['long']; } } } else { $placelist[$j]['long'] = NULL; } $j = $j + 1; } $i = $i + 1; $placerec = get_sub_record(2, '2 PLAC', $gedrec, $i); } } asort($placelist); $prevPlace = ''; $prevLati = ''; $prevLong = ''; $placelistUniq = array(); $j = 0; foreach ($placelist as $k => $place) { if ($place['place'] != $prevPlace) { $placelistUniq[$j] = array(); $placelistUniq[$j]['place'] = $place['place']; $placelistUniq[$j]['lati'] = $place['lati']; $placelistUniq[$j]['long'] = $place['long']; $j = $j + 1; } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) { if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) { $placelistUniq[$j - 1]['lati'] = $place['lati']; $placelistUniq[$j - 1]['long'] = $place['long']; } elseif ($place['lati'] != '0' || $place['long'] != '0') { echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>'; } } $prevPlace = $place['place']; $prevLati = $place['lati']; $prevLong = $place['long']; } $highestIndex = $this->getHighestIndex(); $default_zoom_level = array(4, 7, 10, 12); foreach ($placelistUniq as $k => $place) { $parent = preg_split('/ *, */', $place['place']); $parent = array_reverse($parent); $parent_id = 0; for ($i = 0; $i < count($parent); $i++) { if (!isset($default_zoom_level[$i])) { $default_zoom_level[$i] = $default_zoom_level[$i - 1]; } $escparent = $parent[$i]; if ($escparent == '') { $escparent = 'Unknown'; } $row = WT_DB::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ?")->execute(array($i, $parent_id, $escparent))->fetchOneRow(); if ($i < count($parent) - 1) { // Create higher-level places, if necessary if (empty($row)) { $highestIndex++; WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom) VALUES (?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $default_zoom_level[$i])); echo WT_Filter::escapeHtml($escparent), '<br>'; $parent_id = $highestIndex; } else { $parent_id = $row->pl_id; } } else { // Create lowest-level place, if necessary if (empty($row->pl_id)) { $highestIndex++; WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom) VALUES (?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $default_zoom_level[$i])); echo WT_Filter::escapeHtml($escparent), '<br>'; } else { if (empty($row->pl_long) && empty($row->pl_lati) && $place['lati'] != '0' && $place['long'] != '0') { WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $row->pl_id)); echo WT_Filter::escapeHtml($escparent), '<br>'; } } } } } $parent = 0; } if ($action == 'ImportFile') { $placefiles = array(); $this->findFiles(WT_MODULES_DIR . 'googlemap/extra'); sort($placefiles); ?> <form method="post" enctype="multipart/form-data" id="importfile" name="importfile" action="module.php?mod=googlemap&mod_action=admin_places&action=ImportFile2"> <table class="gm_plac_edit"> <tr> <th><?php echo WT_I18N::translate('File containing places (CSV)'); ?> </th> <td><input type="file" name="placesfile" size="50"></td> </tr> <?php if (count($placefiles) > 0) { ?> <tr> <th><?php echo WT_I18N::translate('Server file containing places (CSV)'), help_link('PLIF_LOCALFILE', 'googlemap'); ?> </th> <td> <select name="localfile"> <option></option> <?php foreach ($placefiles as $p => $placefile) { ?> <option value="<?php echo WT_Filter::escapeHtml($placefile); ?> "><?php if (substr($placefile, 0, 1) == "/") { echo substr($placefile, 1); } else { echo $placefile; } ?> </option> <?php } ?> </select> </td> </tr> <?php } ?> <tr> <th><?php echo WT_I18N::translate('Delete all existing geographic data before importing the file.'); ?> </th> <td><input type="checkbox" name="cleardatabase"></td> </tr> <tr> <th><?php echo WT_I18N::translate('Do not create new locations, just import coordinates for existing locations.'); ?> </th> <td><input type="checkbox" name="updateonly"></td> </tr> <tr> <th><?php echo WT_I18N::translate('Overwrite existing coordinates.'); ?> </th> <td><input type="checkbox" name="overwritedata"></td> </tr> </table> <input id="savebutton" type="submit" value="<?php echo WT_I18N::translate('Continue adding'); ?> "><br> </form> <?php exit; } if ($action == 'ImportFile2') { $country_names = array(); foreach (WT_Stats::iso3166() as $key => $value) { $country_names[$key] = WT_I18N::translate($key); } if (isset($_POST['cleardatabase'])) { WT_DB::exec("DELETE FROM `##placelocation` WHERE 1=1"); } if (!empty($_FILES['placesfile']['tmp_name'])) { $lines = file($_FILES['placesfile']['tmp_name']); } elseif (!empty($_REQUEST['localfile'])) { $lines = file(WT_MODULES_DIR . 'googlemap/extra' . $_REQUEST['localfile']); } // Strip BYTE-ORDER-MARK, if present if (!empty($lines[0]) && substr($lines[0], 0, 3) == WT_UTF8_BOM) { $lines[0] = substr($lines[0], 3); } asort($lines); $highestIndex = $this->getHighestIndex(); $placelist = array(); $j = 0; $maxLevel = 0; foreach ($lines as $p => $placerec) { $fieldrec = explode(';', $placerec); if ($fieldrec[0] > $maxLevel) { $maxLevel = $fieldrec[0]; } } $fields = count($fieldrec); $set_icon = true; if (!is_dir(WT_MODULES_DIR . 'googlemap/places/flags/')) { $set_icon = false; } foreach ($lines as $p => $placerec) { $fieldrec = explode(';', $placerec); if (is_numeric($fieldrec[0]) && $fieldrec[0] <= $maxLevel) { $placelist[$j] = array(); $placelist[$j]['place'] = ''; for ($ii = $fields - 4; $ii > 1; $ii--) { if ($fieldrec[0] > $ii - 2) { $placelist[$j]['place'] .= $fieldrec[$ii] . ','; } } foreach ($country_names as $countrycode => $countryname) { if ($countrycode == strtoupper($fieldrec[1])) { $fieldrec[1] = $countryname; break; } } $placelist[$j]['place'] .= $fieldrec[1]; $placelist[$j]['long'] = $fieldrec[$fields - 4]; $placelist[$j]['lati'] = $fieldrec[$fields - 3]; $placelist[$j]['zoom'] = $fieldrec[$fields - 2]; if ($set_icon) { $placelist[$j]['icon'] = trim($fieldrec[$fields - 1]); } else { $placelist[$j]['icon'] = ''; } $j = $j + 1; } } $prevPlace = ''; $prevLati = ''; $prevLong = ''; $placelistUniq = array(); $j = 0; foreach ($placelist as $k => $place) { if ($place['place'] != $prevPlace) { $placelistUniq[$j] = array(); $placelistUniq[$j]['place'] = $place['place']; $placelistUniq[$j]['lati'] = $place['lati']; $placelistUniq[$j]['long'] = $place['long']; $placelistUniq[$j]['zoom'] = $place['zoom']; $placelistUniq[$j]['icon'] = $place['icon']; $j = $j + 1; } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) { if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) { $placelistUniq[$j - 1]['lati'] = $place['lati']; $placelistUniq[$j - 1]['long'] = $place['long']; $placelistUniq[$j - 1]['zoom'] = $place['zoom']; $placelistUniq[$j - 1]['icon'] = $place['icon']; } elseif ($place['lati'] != '0' || $place['long'] != '0') { echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>'; } } $prevPlace = $place['place']; $prevLati = $place['lati']; $prevLong = $place['long']; } $default_zoom_level = array(); $default_zoom_level[0] = 4; $default_zoom_level[1] = 7; $default_zoom_level[2] = 10; $default_zoom_level[3] = 12; foreach ($placelistUniq as $k => $place) { $parent = explode(',', $place['place']); $parent = array_reverse($parent); $parent_id = 0; for ($i = 0; $i < count($parent); $i++) { $escparent = $parent[$i]; if ($escparent == '') { $escparent = 'Unknown'; } $row = WT_DB::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom, pl_icon FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place")->execute(array($i, $parent_id, $escparent))->fetchOneRow(); if (empty($row)) { // this name does not yet exist: create entry if (!isset($_POST['updateonly'])) { $highestIndex = $highestIndex + 1; if ($i + 1 == count($parent)) { $zoomlevel = $place['zoom']; } elseif (isset($default_zoom_level[$i])) { $zoomlevel = $default_zoom_level[$i]; } else { $zoomlevel = $this->getSetting('GM_MAX_ZOOM'); } if ($place['lati'] == '0' || $place['long'] == '0' || $i + 1 < count($parent)) { WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $zoomlevel, $place['icon'])); } else { //delete leading zero $pl_lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $place['lati']); $pl_long = str_replace(array('E', 'W', ','), array('', '-', '.'), $place['long']); if ($pl_lati >= 0) { $place['lati'] = 'N' . abs($pl_lati); } elseif ($pl_lati < 0) { $place['lati'] = 'S' . abs($pl_lati); } if ($pl_long >= 0) { $place['long'] = 'E' . abs($pl_long); } elseif ($pl_long < 0) { $place['long'] = 'W' . abs($pl_long); } WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $zoomlevel, $place['icon'])); } $parent_id = $highestIndex; } } else { $parent_id = $row->pl_id; if (isset($_POST['overwritedata']) && $i + 1 == count($parent)) { WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=?, pl_zoom=?, pl_icon=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $place['zoom'], $place['icon'], $parent_id)); } else { if (($row->pl_long == '0' || $row->pl_long == null) && ($row->pl_lati == '0' || $row->pl_lati == null)) { WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $parent_id)); } if (empty($row->pl_icon) && !empty($place['icon'])) { WT_DB::prepare("UPDATE `##placelocation` SET pl_icon=? WHERE pl_id=?")->execute(array($place['icon'], $parent_id)); } } } } } $parent = 0; } if ($action == 'DeleteRecord') { $exists = WT_DB::prepare("SELECT 1 FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($deleteRecord))->fetchOne(); if (!$exists) { WT_DB::prepare("DELETE FROM `##placelocation` WHERE pl_id=?")->execute(array($deleteRecord)); } else { echo '<table class="facts_table"><tr><td>', WT_I18N::translate('Location not removed: this location contains sub-locations'), '</td></tr></table>'; } } ?> <script> function updateList(inactive) { window.location.href='<?php if (strstr($_SERVER['REQUEST_URI'], '&inactive', true)) { $uri = strstr($_SERVER['REQUEST_URI'], '&inactive', true); } else { $uri = $_SERVER['REQUEST_URI']; } echo $uri, '&inactive='; ?> '+inactive; } function edit_place_location(placeid) { window.open('module.php?mod=googlemap&mod_action=places_edit&action=update&placeid='+placeid, '_blank', gmap_window_specs); return false; } function add_place_location(placeid) { window.open('module.php?mod=googlemap&mod_action=places_edit&action=add&placeid='+placeid, '_blank', gmap_window_specs); return false; } function delete_place(placeid) { var answer=confirm('<?php echo WT_I18N::translate('Remove this location?'); ?> '); if (answer == true) { window.location = '<?php echo $_SERVER['REQUEST_URI']; ?> &action=DeleteRecord&deleteRecord=' + placeid; } } </script> <?php echo '<div id="gm_breadcrumb">'; $where_am_i = $this->placeIdToHierarchy($parent); foreach (array_reverse($where_am_i, true) as $id => $place) { if ($id == $parent) { if ($place != 'Unknown') { echo WT_Filter::escapeHtml($place); } else { echo WT_I18N::translate('unknown'); } } else { echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $id, '&inactive=', $inactive, '">'; if ($place != 'Unknown') { echo WT_Filter::escapeHtml($place), '</a>'; } else { echo WT_I18N::translate('unknown'), '</a>'; } } echo ' - '; } echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=0&inactive=', $inactive, '">', WT_I18N::translate('Top level'), '</a></div>'; echo '<form name="active" method="post" action="module.php?mod=googlemap&mod_action=admin_places&parent=', $parent, '&inactive=', $inactive, '"><div id="gm_active">'; echo '<label for="inactive">', WT_I18N::translate('Show inactive places'), '</label>'; echo '<input type="checkbox" name="inactive" id="inactive"'; if ($inactive) { echo ' checked="checked"'; } echo ' onclick="updateList(this.checked)"'; echo '>', help_link('PLE_ACTIVE', 'googlemap'), '</div></form>'; $placelist = $this->getPlaceListLocation($parent, $inactive); echo '<div class="gm_plac_edit">'; echo '<table class="gm_plac_edit"><tr>'; echo '<th>', WT_Gedcom_Tag::getLabel('PLAC'), '</th>'; echo '<th>', WT_Gedcom_Tag::getLabel('LATI'), '</th>'; echo '<th>', WT_Gedcom_Tag::getLabel('LONG'), '</th>'; echo '<th>', WT_I18N::translate('Zoom level'), '</th>'; echo '<th>', WT_I18N::translate('Icon'), '</th>'; echo '<th>'; echo WT_I18N::translate('Edit'), '</th><th>', WT_I18N::translate('Delete'), '</th></tr>'; if (count($placelist) == 0) { echo '<tr><td colspan="7" class="accepted">', WT_I18N::translate('No places found'), '</td></tr>'; } foreach ($placelist as $place) { echo '<tr><td><a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $place['place_id'], '&inactive=', $inactive, '">'; if ($place['place'] != 'Unknown') { echo WT_Filter::escapeHtml($place['place']), '</a></td>'; } else { echo WT_I18N::translate('unknown'), '</a></td>'; } echo '<td>', $place['lati'], '</td>'; echo '<td>', $place['long'], '</td>'; echo '<td>', $place['zoom'], '</td>'; echo '<td>'; if ($place['icon'] == NULL || $place['icon'] == '') { if ($place['lati'] == NULL || $place['long'] == NULL || $place['lati'] == '0' && $place['long'] == '0') { echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_yellow.png">'; } else { echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_red.png">'; } } else { echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/', $place['icon'], '" width="25" height="15">'; } echo '</td>'; echo '<td class="narrow"><a href="#" onclick="edit_place_location(', $place['place_id'], ');return false;" class="icon-edit" title="', WT_I18N::translate('Edit'), '"></a></td>'; $noRows = WT_DB::prepare("SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($place['place_id']))->fetchOne(); if ($noRows == 0) { ?> <td><a href="#" onclick="delete_place(<?php echo $place['place_id']; ?> );return false;" class="icon-delete" title="<?php echo WT_I18N::translate('Remove'); ?> "></a></td> <?php } else { ?> <td><i class="icon-delete-grey"></i></td> <?php } ?> </tr> <?php } ?> </table> </div> <table id="gm_manage"> <tr> <td> <?php echo WT_I18N::translate('Add a new geographic location'); ?> </td> <td> <form action="?" onsubmit="add_place_location(this.parent_id.options[this.parent_id.selectedIndex].value); return false;"> <?php echo select_edit_control('parent_id', $where_am_i, WT_I18N::translate('Top level'), $parent); ?> <input type="submit" value="<?php echo WT_I18N::translate('Add'); ?> "> </form> </td> </tr> <tr> <td> <?php echo WT_I18N::translate('Import all places from a family tree'); ?> </td> <td> <form action="module.php" method="get"> <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="admin_places"> <input type="hidden" name="action" value="ImportGedcom"> <?php echo select_edit_control('ged', WT_Tree::getNameList(), null, WT_GEDCOM); ?> <input type="submit" value="<?php echo WT_I18N::translate('Import'); ?> "> </form> </td> </tr> <tr> <td> <?php echo WT_I18N::translate('Upload geographic data'); ?> </td> <td> <form action="module.php" method="get"> <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="admin_places"> <input type="hidden" name="action" value="ImportFile"> <input type="submit" value="<?php echo WT_I18N::translate('Upload'); ?> "> </form> </td> </tr> <tr> <td> <?php echo WT_I18N::translate('Download geographic data'); ?> </td> <td> <form action="module.php" method="get"> <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="admin_places"> <input type="hidden" name="action" value="ExportFile"> <?php echo select_edit_control('parent', $where_am_i, WT_I18N::translate('All'), WT_GED_ID); ?> <input type="submit" value="<?php echo WT_I18N::translate('Download'); ?> "> </form> </td> </tr> </table> <?php }
function format_fam_table($datalist) { global $GEDCOM, $SHOW_LAST_CHANGE, $SEARCH_SPIDER, $controller; $table_id = 'table-fam-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page $controller->addExternalJavascript(WT_JQUERY_DATATABLES_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("#' . $table_id . '").dataTable( { dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', ' . WT_I18N::datatablesI18N() . ', jQueryUI: true, autoWidth: false, processing: true, retrieve: true, columns: [ /* 0 husb givn */ {dataSort: 2}, /* 1 husb surn */ {dataSort: 3}, /* 2 GIVN,SURN */ {type: "unicode", visible: false}, /* 3 SURN,GIVN */ {type: "unicode", visible: false}, /* 4 age */ {dataSort: 5, class: "center"}, /* 5 AGE */ {type: "num", visible: false}, /* 6 wife givn */ {dataSort: 8}, /* 7 wife surn */ {dataSort: 9}, /* 8 GIVN,SURN */ {type: "unicode", visible: false}, /* 9 SURN,GIVN */ {type: "unicode", visible: false}, /* 10 age */ {dataSort: 11, class: "center"}, /* 11 AGE */ {type: "num", visible: false}, /* 12 marr date */ {dataSort: 13}, /* 13 MARR:DATE */ {visible: false}, /* 14 anniv */ {dataSort: 13, class: "center"}, /* 15 marr plac */ {type: "unicode"}, /* 16 children */ {dataSort: 17, class: "center"}, /* 17 NCHI */ {type: "num", visible: false}, /* 18 CHAN */ {dataSort: 19, visible: ' . ($SHOW_LAST_CHANGE ? 'true' : 'false') . '}, /* 19 CHAN_sort */ {visible: false}, /* 20 MARR */ {visible: false}, /* 21 DEAT */ {visible: false}, /* 22 TREE */ {visible: false} ], sorting: [[1, "asc"]], displayLength: 20, 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(".fam-list").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); $stats = new WT_Stats($GEDCOM); $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; //-- init chart data for ($age = 0; $age <= $max_age; $age++) { $marr_by_age[$age] = ''; } for ($year = 1550; $year < 2030; $year += 10) { $birt_by_decade[$year] = ''; $marr_by_decade[$year] = ''; } $html = ' <div class="loading-image"> </div> <div class="fam-list"> <table id="' . $table_id . '"> <thead> <tr> <th colspan="23"> <div class="btn-toolbar"> <div class="btn-group"> <button type="button" data-filter-column="21" data-filter-value="N" class="ui-state-default" title="' . WT_I18N::translate('Show individuals who are alive or couples where both partners are alive.') . '" > ' . WT_I18N::translate('Both alive') . ' </button> <button type="button" data-filter-column="21" data-filter-value="W" class="ui-state-default" title="' . WT_I18N::translate('Show couples where only the female partner is deceased.') . '" > ' . WT_I18N::translate('Widower') . ' </button> <button type="button" data-filter-column="21" data-filter-value="H" class="ui-state-default" title="' . WT_I18N::translate('Show couples where only the male partner is deceased.') . '" > ' . WT_I18N::translate('Widow') . ' </button> <button type="button" data-filter-column="21" data-filter-value="Y" class="ui-state-default" title="' . WT_I18N::translate('Show individuals who are dead or couples where both partners are deceased.') . '" > ' . WT_I18N::translate('Both dead') . ' </button> </div> <div class="btn-group"> <button type="button" data-filter-column="22" data-filter-value="R" class="ui-state-default" title="' . WT_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.') . '" > ' . WT_I18N::translate('Roots') . ' </button> <button type="button" data-filter-column="22" data-filter-value="L" class="ui-state-default" title="' . WT_I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') . '" > ' . WT_I18N::translate('Leaves') . ' </button> </div> <div class="btn-group"> <button type="button" data-filter-column="20" data-filter-value="U" class="ui-state-default" title="' . WT_I18N::translate('Show couples with an unknown marriage date.') . '" > ' . WT_Gedcom_Tag::getLabel('MARR') . ' </button> <button type="button" data-filter-column="20" data-filter-value="YES" class="ui-state-default" title="' . WT_I18N::translate('Show couples who married more than 100 years ago.') . '" > ' . WT_Gedcom_Tag::getLabel('MARR') . '>100 </button> <button type="button" data-filter-column="20" data-filter-value="Y100" class="ui-state-default" title="' . WT_I18N::translate('Show couples who married within the last 100 years.') . '" > ' . WT_Gedcom_Tag::getLabel('MARR') . '<=100 </button> <button type="button" data-filter-column="20" data-filter-value="D" class="ui-state-default" title="' . WT_I18N::translate('Show divorced couples.') . '" > ' . WT_Gedcom_Tag::getLabel('DIV') . ' </button> <button type="button" data-filter-column="20" data-filter-value="M" class="ui-state-default" title="' . WT_I18N::translate('Show couples where either partner married more than once.') . '" > ' . WT_I18N::translate('Multiple marriages') . ' </button> </div> </div> </th> </tr> <tr> <th>' . WT_Gedcom_Tag::getLabel('GIVN') . '</th> <th>' . WT_Gedcom_Tag::getLabel('SURN') . '</th> <th>HUSB:GIVN_SURN</th> <th>HUSB:SURN_GIVN</th> <th>' . WT_Gedcom_Tag::getLabel('AGE') . '</th> <th>AGE</th> <th>' . WT_Gedcom_Tag::getLabel('GIVN') . '</th> <th>' . WT_Gedcom_Tag::getLabel('SURN') . '</th> <th>WIFE:GIVN_SURN</th> <th>WIFE:SURN_GIVN</th> <th>' . WT_Gedcom_Tag::getLabel('AGE') . '</th> <th>AGE</th> <th>' . WT_Gedcom_Tag::getLabel('MARR') . '</th> <th>MARR:DATE</th> <th><i class="icon-reminder" title="' . WT_I18N::translate('Anniversary') . '"></i></th> <th>' . WT_Gedcom_Tag::getLabel('PLAC') . '</th> <th><i class="icon-children" title="' . WT_I18N::translate('Children') . '"></i></th> <th>NCHI</th> <th' . ($SHOW_LAST_CHANGE ? '' : '') . '>' . WT_Gedcom_Tag::getLabel('CHAN') . '</th> <th' . ($SHOW_LAST_CHANGE ? '' : '') . '>CHAN</th> <th>MARR</th> <th>DEAT</th> <th>TREE</th> </tr> </thead> <tfoot> <tr> <th colspan="23"> <div class="btn-toolbar"> <div class="btn-group"> <button type="button" class="ui-state-default btn-toggle-parents"> ' . WT_I18N::translate('Show parents') . ' </button> <button type="button" class="ui-state-default btn-toggle-statistics"> ' . WT_I18N::translate('Show statistics charts') . ' </button> </div> </div> </th> </tr> </tfoot> <tbody>'; $d100y = new WT_Date(date('Y') - 100); // 100 years ago foreach ($datalist as $family) { //-- Retrieve husband and wife $husb = $family->getHusband(); if (is_null($husb)) { $husb = new WT_Individual('H', '0 @H@ INDI', null, WT_GED_ID); } $wife = $family->getWife(); if (is_null($wife)) { $wife = new WT_Individual('W', '0 @W@ INDI', null, WT_GED_ID); } if (!$family->canShow()) { continue; } if ($family->isNew()) { $class = ' class="new"'; } elseif ($family->isOld()) { $class = ' class="old"'; } else { $class = ''; } $html .= '<tr' . $class . '>'; //-- Husband name(s) $html .= '<td colspan="2">'; foreach ($husb->getAllNames() as $num => $name) { if ($name['type'] == 'NAME') { $title = ''; } else { $title = 'title="' . strip_tags(WT_Gedcom_Tag::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 = ''; } // Only show married names if they are the name we are filtering by. if ($name['type'] != '_MARNM' || $num == $husb->getPrimaryName()) { $html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . highlight_search_hits($name['full']) . '</a>' . $sex_image . '<br>'; } } // Husband parents $html .= $husb->getPrimaryParentsNames('parents details1', 'none'); $html .= '</td>'; // Dummy column to match colspan in header $html .= '<td style="display:none;"></td>'; //-- Husb GIVN // Use "AAAA" as a separator (instead of ",") as Javascript.localeCompare() ignores // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it. // Similarly, @N.N. would sort as NN. $html .= '<td>' . WT_Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . WT_Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . '</td>'; $html .= '<td>' . WT_Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . WT_Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . '</td>'; $mdate = $family->getMarriageDate(); //-- Husband age $hdate = $husb->getBirthDate(); if ($hdate->isOK() && $mdate->isOK()) { if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) { $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); } $hage = WT_Date::getAge($hdate, $mdate, 0); if ($hage >= 0 && $hage <= $max_age) { $marr_by_age[$hage] .= $husb->getSex(); } } $html .= '<td>' . WT_Date::getAge($hdate, $mdate, 2) . '</td><td>' . WT_Date::getAge($hdate, $mdate, 1) . '</td>'; //-- Wife name(s) $html .= '<td colspan="2">'; foreach ($wife->getAllNames() as $num => $name) { if ($name['type'] == 'NAME') { $title = ''; } else { $title = 'title="' . strip_tags(WT_Gedcom_Tag::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 = ''; } // Only show married names if they are the name we are filtering by. if ($name['type'] != '_MARNM' || $num == $wife->getPrimaryName()) { $html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . highlight_search_hits($name['full']) . '</a>' . $sex_image . '<br>'; } } // Wife parents $html .= $wife->getPrimaryParentsNames('parents details1', 'none'); $html .= '</td>'; // Dummy column to match colspan in header $html .= '<td style="display:none;"></td>'; //-- Wife GIVN //-- Husb GIVN // Use "AAAA" as a separator (instead of ",") as Javascript.localeCompare() ignores // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it. // Similarly, @N.N. would sort as NN. $html .= '<td>' . WT_Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . WT_Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . '</td>'; $html .= '<td>' . WT_Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . WT_Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . '</td>'; $mdate = $family->getMarriageDate(); //-- Wife age $wdate = $wife->getBirthDate(); if ($wdate->isOK() && $mdate->isOK()) { if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) { $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); } $wage = WT_Date::getAge($wdate, $mdate, 0); if ($wage >= 0 && $wage <= $max_age) { $marr_by_age[$wage] .= $wife->getSex(); } } $html .= '<td>' . WT_Date::getAge($wdate, $mdate, 2) . '</td><td>' . WT_Date::getAge($wdate, $mdate, 1) . '</td>'; //-- Marriage date $html .= '<td>'; if ($marriage_dates = $family->getAllMarriageDates()) { foreach ($marriage_dates as $n => $marriage_date) { if ($n) { $html .= '<br>'; } $html .= '<div>' . $marriage_date->Display(!$SEARCH_SPIDER) . '</div>'; } if ($marriage_dates[0]->gregorianYear() >= 1550 && $marriage_dates[0]->gregorianYear() < 2030) { $marr_by_decade[(int) ($marriage_dates[0]->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); } } elseif ($family->getFacts('_NMR')) { $html .= WT_I18N::translate('no'); } elseif ($family->getFacts('MARR')) { $html .= WT_I18N::translate('yes'); } else { $html .= ' '; } $html .= '</td>'; //-- Event date (sortable)hidden by datatables code $html .= '<td>'; if ($marriage_dates) { $html .= $marriage_date->JD(); } else { $html .= 0; } $html .= '</td>'; //-- Marriage anniversary $html .= '<td>' . WT_Date::getAge($mdate, null, 2) . '</td>'; //-- Marriage place $html .= '<td>'; foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { $tmp = new WT_Place($marriage_place, WT_GED_ID); if ($n) { $html .= '<br>'; } if ($SEARCH_SPIDER) { $html .= $tmp->getShortName(); } else { $html .= '<a href="' . $tmp->getURL() . '" title="' . strip_tags($tmp->getFullName()) . '">'; $html .= highlight_search_hits($tmp->getShortName()) . '</a>'; } } $html .= '</td>'; //-- Number of children $nchi = $family->getNumberOfChildren(); $html .= '<td>' . WT_I18N::number($nchi) . '</td><td>' . $nchi . '</td>'; //-- Last change if ($SHOW_LAST_CHANGE) { $html .= '<td>' . $family->LastChangeTimestamp() . '</td>'; } else { $html .= '<td> </td>'; } //-- Last change hidden sort column if ($SHOW_LAST_CHANGE) { $html .= '<td>' . $family->LastChangeTimestamp(true) . '</td>'; } else { $html .= '<td> </td>'; } //-- Sorting by marriage date $html .= '<td>'; if (!$family->canShow() || !$mdate->isOK()) { $html .= 'U'; } else { if (WT_Date::Compare($mdate, $d100y) > 0) { $html .= 'Y100'; } else { $html .= 'YES'; } } if ($family->getFacts(WT_EVENTS_DIV)) { $html .= 'D'; } if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) { $html .= 'M'; } $html .= '</td>'; //-- Sorting alive/dead $html .= '<td>'; if ($husb->isDead() && $wife->isDead()) { $html .= 'Y'; } if ($husb->isDead() && !$wife->isDead()) { if ($wife->getSex() == 'F') { $html .= 'H'; } if ($wife->getSex() == 'M') { $html .= 'W'; } // male partners } if (!$husb->isDead() && $wife->isDead()) { if ($husb->getSex() == 'M') { $html .= 'W'; } if ($husb->getSex() == 'F') { $html .= 'H'; } // female partners } if (!$husb->isDead() && !$wife->isDead()) { $html .= 'N'; } $html .= '</td>'; //-- Roots or Leaves $html .= '<td>'; if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { $html .= 'R'; } elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { $html .= 'L'; } else { $html .= ' '; } $html .= '</td> </tr>'; } $html .= ' </tbody> </table> <div id="fam_list_table-charts_' . $table_id . '" style="display:none"> <table class="list-charts"> <tr> <td> ' . print_chart_by_decade($birt_by_decade, WT_I18N::translate('Decade of birth')) . ' </td> <td> ' . print_chart_by_decade($marr_by_decade, WT_I18N::translate('Decade of marriage')) . ' </td> </tr> <tr> <td colspan="2"> ' . print_chart_by_age($marr_by_age, WT_I18N::translate('Age in year of marriage')) . ' </td> </tr> </table> </div> </div>'; return $html; }
// it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA define('WT_SCRIPT_NAME', 'statisticsplot.php'); require './includes/session.php'; $controller = new WT_Controller_Ajax(); $stats = new WT_Stats($GEDCOM); // Month of birth function bimo() { global $z_as, $months, $zgrenzen, $stats, $n1; if ($z_as == 300) { $num = $stats->statsBirthQuery(false); foreach ($num as $values) { foreach ($months as $key => $month) { if ($month == $values['d_month']) { fill_ydata(0, $key, $values['total']); $n1 += $values['total']; } } } } else {
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $GEDCOM; // Only show this block for certain languages $languages = get_block_setting($block_id, 'languages'); if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) { return; } /* * Select GEDCOM */ $gedcom = get_block_setting($block_id, 'gedcom'); switch ($gedcom) { case '__current__': break; case '': break; case '__default__': $GEDCOM = WT_Site::getPreference('DEFAULT_GEDCOM'); if (!$GEDCOM) { foreach (WT_Tree::getAll() as $tree) { $GEDCOM = $tree->tree_name; break; } } break; default: $GEDCOM = $gedcom; break; } /* * Retrieve text, process embedded variables */ $title_tmp = get_block_setting($block_id, 'title'); $html = get_block_setting($block_id, 'html'); if (strpos($title_tmp, '#') !== false || strpos($html, '#') !== false) { $stats = new WT_Stats($GEDCOM); $title_tmp = $stats->embedTags($title_tmp); $html = $stats->embedTags($html); } /* * Restore Current GEDCOM */ $GEDCOM = WT_GEDCOM; /* * Start Of Output */ $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $title_tmp; $content = $html; if (get_block_setting($block_id, 'show_timestamp', false)) { $content .= '<br>' . format_timestamp(get_block_setting($block_id, 'timestamp', WT_TIMESTAMP)); } if ($template) { if (get_block_setting($block_id, 'block', false)) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $top10_block_present; $show_last_update = get_block_setting($block_id, 'show_last_update', true); $show_common_surnames = get_block_setting($block_id, 'show_common_surnames', true); $stat_indi = get_block_setting($block_id, 'stat_indi', true); $stat_fam = get_block_setting($block_id, 'stat_fam', true); $stat_sour = get_block_setting($block_id, 'stat_sour', true); $stat_media = get_block_setting($block_id, 'stat_media', true); $stat_repo = get_block_setting($block_id, 'stat_repo', true); $stat_surname = get_block_setting($block_id, 'stat_surname', true); $stat_events = get_block_setting($block_id, 'stat_events', true); $stat_users = get_block_setting($block_id, 'stat_users', true); $stat_first_birth = get_block_setting($block_id, 'stat_first_birth', true); $stat_last_birth = get_block_setting($block_id, 'stat_last_birth', true); $stat_first_death = get_block_setting($block_id, 'stat_first_death', true); $stat_last_death = get_block_setting($block_id, 'stat_last_death', true); $stat_long_life = get_block_setting($block_id, 'stat_long_life', true); $stat_avg_life = get_block_setting($block_id, 'stat_avg_life', true); $stat_most_chil = get_block_setting($block_id, 'stat_most_chil', true); $stat_avg_chil = get_block_setting($block_id, 'stat_avg_chil', true); $stat_link = get_block_setting($block_id, 'stat_link', true); $block = get_block_setting($block_id, 'block', false); if ($cfg) { foreach (array('show_common_surnames', 'stat_indi', 'stat_fam', 'stat_sour', 'stat_media', 'stat_surname', 'stat_events', 'stat_users', 'stat_first_birth', 'stat_last_birth', 'stat_first_death', 'stat_last_death', 'stat_long_life', 'stat_avg_life', 'stat_most_chil', 'stat_avg_chil', 'stat_link', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $this->getTitle(); $stats = new WT_Stats(WT_GEDCOM); $content = '<b>' . WT_TREE_TITLE . '</b><br>'; if ($show_last_update) { $content .= '<div>' . WT_I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</div>'; } $content .= '<table><tr><td class="width20"><table class="facts_table">'; if ($stat_indi) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Individuals') . '</td><td class="facts_value stats_value"><a href="' . "indilist.php?surname_sublist=no&ged=" . WT_GEDURL . '">' . $stats->totalIndividuals() . '</a></td></tr>'; $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Males') . '</td><td class="facts_value stats_value">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</td></tr>'; $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Females') . '</td><td class="facts_value stats_value">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</td></tr>'; } if ($stat_surname) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Total surnames') . '</td><td class="facts_value stats_value"><a href="indilist.php?show_all=yes&surname_sublist=yes&ged=' . WT_GEDURL . '">' . $stats->totalSurnames() . '</a></td></tr>'; } if ($stat_fam) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Families') . '</td><td class="facts_value stats_value"><a href="famlist.php?ged=' . WT_GEDURL . '">' . $stats->totalFamilies() . '</a></td></tr>'; } if ($stat_sour) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Sources') . '</td><td class="facts_value stats_value"><a href="sourcelist.php?ged=' . WT_GEDURL . '">' . $stats->totalSources() . '</a></td></tr>'; } if ($stat_media) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Media objects') . '</td><td class="facts_value stats_value"><a href="medialist.php?ged=' . WT_GEDURL . '">' . $stats->totalMedia() . '</a></td></tr>'; } if ($stat_repo) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Repositories') . '</td><td class="facts_value stats_value"><a href="repolist.php?ged=' . WT_GEDURL . '">' . $stats->totalRepositories() . '</a></td></tr>'; } if ($stat_events) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Total events') . '</td><td class="facts_value stats_value">' . $stats->totalEvents() . '</td></tr>'; } if ($stat_users) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Total users') . '</td><td class="facts_value stats_value">'; if (WT_USER_GEDCOM_ADMIN) { $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; } else { $content .= $stats->totalUsers(); } $content .= '</td></tr>'; } if (!$block) { $content .= '</table></td><td><table class="facts_table">'; } if ($stat_first_birth) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Earliest birth year') . '</td><td class="facts_value stats_value">' . $stats->firstBirthYear() . '</td>'; if (!$block) { $content .= '<td class="facts_value">' . $stats->firstBirth() . '</td>'; } $content .= '</tr>'; } if ($stat_last_birth) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Latest birth year') . '</td><td class="facts_value stats_value">' . $stats->lastBirthYear() . '</td>'; if (!$block) { $content .= '<td class="facts_value">' . $stats->lastBirth() . '</td>'; } $content .= '</tr>'; } if ($stat_first_death) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Earliest death year') . '</td><td class="facts_value stats_value">' . $stats->firstDeathYear() . '</td>'; if (!$block) { $content .= '<td class="facts_value">' . $stats->firstDeath() . '</td>'; } $content .= '</tr>'; } if ($stat_last_death) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Latest death year') . '</td><td class="facts_value stats_value">' . $stats->lastDeathYear() . ' </td>'; if (!$block) { $content .= '<td class="facts_value">' . $stats->lastDeath() . '</td>'; } $content .= '</tr>'; } if ($stat_long_life) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Individual who lived the longest') . '</td><td class="facts_value stats_value">' . $stats->LongestLifeAge() . '</td>'; if (!$block) { $content .= '<td class="facts_value">' . $stats->LongestLife() . '</td>'; } $content .= '</tr>'; } if ($stat_avg_life) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Average age at death') . '</td><td class="facts_value stats_value">' . $stats->averageLifespan() . '</td>'; if (!$block) { $content .= '<td class="facts_value">' . WT_I18N::translate('Males') . ': ' . $stats->averageLifespanMale(); $content .= ' ' . WT_I18N::translate('Females') . ': ' . $stats->averageLifespanFemale() . '</td>'; } $content .= '</tr>'; } if ($stat_most_chil && !$block) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Family with the most children') . '</td><td class="facts_value stats_value">' . $stats->largestFamilySize() . '</td>'; if (!$block) { $content .= '<td class="facts_value">' . $stats->largestFamily() . '</td>'; } $content .= '</tr>'; } if ($stat_avg_chil) { $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Average number of children per family') . '</td><td class="facts_value stats_value">' . $stats->averageChildren() . '</td>'; if (!$block) { $content .= '<td class="facts_value"> </td>'; } $content .= '</tr>'; } $content .= '</table></td></tr></table>'; if ($stat_link) { $content .= '<a href="statistics.php?ged=' . WT_GEDURL . '"><b>' . WT_I18N::translate('View statistics as graphs') . '</b></a><br>'; } // NOTE: Print the most common surnames if ($show_common_surnames) { $surnames = get_common_surnames(get_gedcom_setting(WT_GED_ID, 'COMMON_NAMES_THRESHOLD')); if (count($surnames) > 0) { $content .= '<p><b>' . WT_I18N::translate('Most common surnames') . '</b></p>'; $content .= '<div class="common_surnames">'; $i = 0; foreach ($surnames as $indexval => $surname) { if (stristr($surname['name'], '@N.N') === false) { if ($i > 0) { $content .= ', '; } $content .= '<a href="' . "indilist.php?ged=" . WT_GEDURL . "&surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>'; $i++; } } $content .= '</div>'; } } if ($template) { require WT_THEME_DIR . 'templates/block_main_temp.php'; } else { return $content; } }
</tr> </tbody> </table> </div> <h2><?php echo WT_I18N::translate('Family trees'); ?> </h2> <div id="trees"> <div id="tree_stats"> <?php foreach (WT_Tree::getAll() as $tree) { ?> <?php $stats = new WT_Stats($tree->tree_name); ?> <h3><?php echo $stats->gedcomTitle(); ?> </h3> <div> <table> <thead> <tr> <th><?php echo WT_I18N::translate('Records'); ?> </th> <th><?php echo WT_I18N::translate('Count');
private static function _centuryName($century) { if ($century < 0) { return str_replace(-$century, WT_Stats::_centuryName(-$century), WT_I18N::translate('%s BCE', WT_I18N::number(-$century))); } // The current chart engine (Google charts) can't handle <sup></sup> markup switch ($century) { case 21: return strip_tags(WT_I18N::translate_c('CENTURY', '21st')); case 20: return strip_tags(WT_I18N::translate_c('CENTURY', '20th')); case 19: return strip_tags(WT_I18N::translate_c('CENTURY', '19th')); case 18: return strip_tags(WT_I18N::translate_c('CENTURY', '18th')); case 17: return strip_tags(WT_I18N::translate_c('CENTURY', '17th')); case 16: return strip_tags(WT_I18N::translate_c('CENTURY', '16th')); case 15: return strip_tags(WT_I18N::translate_c('CENTURY', '15th')); case 14: return strip_tags(WT_I18N::translate_c('CENTURY', '14th')); case 13: return strip_tags(WT_I18N::translate_c('CENTURY', '13th')); case 12: return strip_tags(WT_I18N::translate_c('CENTURY', '12th')); case 11: return strip_tags(WT_I18N::translate_c('CENTURY', '11th')); case 10: return strip_tags(WT_I18N::translate_c('CENTURY', '10th')); case 9: return strip_tags(WT_I18N::translate_c('CENTURY', '9th')); case 8: return strip_tags(WT_I18N::translate_c('CENTURY', '8th')); case 7: return strip_tags(WT_I18N::translate_c('CENTURY', '7th')); case 6: return strip_tags(WT_I18N::translate_c('CENTURY', '6th')); case 5: return strip_tags(WT_I18N::translate_c('CENTURY', '5th')); case 4: return strip_tags(WT_I18N::translate_c('CENTURY', '4th')); case 3: return strip_tags(WT_I18N::translate_c('CENTURY', '3rd')); case 2: return strip_tags(WT_I18N::translate_c('CENTURY', '2nd')); case 1: return strip_tags(WT_I18N::translate_c('CENTURY', '1st')); default: return $century - 1 . '01-' . $century . '00'; } }
public function getBlock($block_id, $template = true, $cfg = null) { global $TEXT_DIRECTION, $ctype, $controller; $num = get_block_setting($block_id, 'num', 10); $infoStyle = get_block_setting($block_id, 'infoStyle', 'table'); $block = get_block_setting($block_id, 'block', false); if ($cfg) { foreach (array('num', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } $stats = new WT_Stats(WT_GEDCOM); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } if ($num == 1) { // I18N: i.e. most popular given name. $title .= WT_I18N::translate('Top given name'); } else { // I18N: Title for a list of the most common given names, %s is a number. Note that a separate translation exists when %s is 1 $title .= WT_I18N::plural('Top %s given name', 'Top %s given names', $num, WT_I18N::number($num)); } $content = '<div class="normal_inner_block">'; //Select List or Table switch ($infoStyle) { case "list": // Output style 1: Simple list style. Better suited to left side of page. if ($TEXT_DIRECTION == 'ltr') { $padding = 'padding-left: 15px'; } else { $padding = 'padding-right: 15px'; } $params = array(1, $num, 'rcount'); //List Female names $totals = $stats->commonGivenFemaleTotals($params); if ($totals) { $content .= '<b>' . WT_I18N::translate('Females') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; } //List Male names $totals = $stats->commonGivenMaleTotals($params); if ($totals) { $content .= '<b>' . WT_I18N::translate('Males') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; } break; case "table": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page $params = array(1, $num, 'rcount'); $content .= '<table style="margin:auto;"> <tr valign="top"> <td>' . $stats->commonGivenFemaleTable($params) . '</td> <td>' . $stats->commonGivenMaleTable($params) . '</td>'; $content .= '</tr></table>'; break; } $content .= "</div>"; if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } }
// Only load each tab once if (ui.tab.data("loaded")) { event.preventDefault(); return; } ui.jqXHR.success(function() { ui.tab.data("loaded", true); }); } }); ')->pageHeader(); echo '<div id="statistics-page"><h2>', WT_I18N::translate('Statistics'), '</h2>', '<div id="statistics_chart">', '<ul>', '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=0">', '<span id="stats-indi">', WT_I18N::translate('Individuals'), '</span></a></li>', '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=1">', '<span id="stats-fam">', WT_I18N::translate('Families'), '</span></a></li>', '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=2">', '<span id="stats-other">', WT_I18N::translate('Others'), '</span></a></li>', '<li><a href="statistics.php?ged=', WT_GEDURL, '&ajax=1&tab=3">', '<span id="stats-own">', WT_I18N::translate('Own charts'), '</span></a></li>', '</ul>', '<div id="loading-indicator" style="margin:auto;width:100%;"></div>', '</div>', '</div>', '<br><br>'; } else { $controller = new WT_Controller_Ajax(); $controller->pageHeader()->addInlineJavascript('autocomplete();')->addInlineJavascript('jQuery("#loading-indicator").removeClass("loading-image");'); $stats = new WT_Stats($GEDCOM); if ($tab == 0) { echo '<fieldset> <legend>', WT_I18N::translate('Total individuals: %s', $stats->totalIndividuals()), '</legend> <table class="facts_table"> <tr> <td class="facts_label">', WT_I18N::translate('Total males'), '</td> <td class="facts_label">', WT_I18N::translate('Total females'), '</td> <td class="facts_label">', WT_I18N::translate('Total living'), '</td> <td class="facts_label">', WT_I18N::translate('Total dead'), '</td> </tr> <tr> <td class="facts_value" align="center">', $stats->totalSexMales(), '</td> <td class="facts_value" align="center">', $stats->totalSexFemales(), '</td> <td class="facts_value" align="center">', $stats->totalLiving(), '</td> <td class="facts_value" align="center">', $stats->totalDeceased(), '</td>