. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsPrintLists; define('WT_SCRIPT_NAME', 'placelist.php'); require './includes/session.php'; $controller = new PageController; $action = Filter::get('action', 'find|show', 'find'); $display = Filter::get('display', 'hierarchy|list', 'hierarchy'); $parent = Filter::getArray('parent'); $level = count($parent); if ($display == 'hierarchy') { if ($level) { $controller->setPageTitle(I18N::translate('Place hierarchy') . ' - ' . Filter::escapeHtml(end($parent)) . ''); } else { $controller->setPageTitle(I18N::translate('Place hierarchy')); } } else { $controller->setPageTitle(I18N::translate('Place list')); } $controller->pageHeader(); echo '
'; switch ($display) { case 'list': echo '

', $controller->getPageTitle(), '

'; $list_places = Place::allPlaces($WT_TREE); $num_places = count($list_places); if ($num_places == 0) { echo '', I18N::translate('No results found.'), '
'; } else { echo ''; echo ''; echo '
'; echo I18N::translate('Place list'); echo '
    '; } if ($n == (int) (($num_places / 3) * 2)) { echo '
    '; } } elseif ($n == (int) ($num_places / 2)) { echo '
    '; } } echo '
'; } echo '

', I18N::translate('Show places in hierarchy'), '

'; break; case 'hierarchy': $gm_module = Module::getModuleByName('googlemap'); // Find this place and its ID $place = new Place(implode(', ', array_reverse($parent)), $WT_TREE); $place_id = $place->getPlaceId(); $child_places = $place->getChildPlaces(); $numfound = count($child_places); //-- if the number of places found is 0 then automatically redirect to search page if ($numfound == 0) { $action = 'show'; } echo '

', $controller->getPageTitle(); // Breadcrumbs if ($place_id) { $parent_place = $place->getParentPlace(); while ($parent_place->getPlaceId()) { echo ', ', $parent_place->getPlaceName(), ''; $parent_place = $parent_place->getParentPlace(); } echo ', ', I18N::translate('Top level'), ''; } echo '

'; if ($gm_module && $gm_module->getSetting('GM_PLACE_HIERARCHY')) { $linklevels = ''; $placelevels = ''; $place_names = array(); for ($j = 0; $j < $level; $j++) { $linklevels .= '&parent[' . $j . ']=' . rawurlencode($parent[$j]); if ($parent[$j] == '') { $placelevels = ', ' . I18N::translate('unknown') . $placelevels; } else { $placelevels = ', ' . $parent[$j] . $placelevels; } } $gm_module->createMap($placelevels); } elseif (Module::getModuleByName('places_assistant')) { // Places Assistant is a custom/add-on module that was once part of the core code. \PlacesAssistantModule::display_map($level, $parent); } // -- echo the array foreach ($child_places as $n => $child_place) { if ($n == 0) { echo ''; if ($action == 'find' && $place_id) { echo ''; } echo '
20) { echo 'colspan="3"'; } elseif ($numfound > 4) { echo 'colspan="2"'; } echo '> '; if ($place_id) { echo /* I18N: %s is a country or region */ I18N::translate('Places in %s', $place->getPlaceName()); } else { echo I18N::translate('Place hierarchy'); } echo '
    '; } echo '
  • ', $child_place->getPlaceName(), '
  • '; if ($gm_module && $gm_module->getSetting('GM_PLACE_HIERARCHY')) { list($tmp) = explode(', ', $child_place->getGedcomName(), 2); $place_names[$n] = $tmp; } $n++; if ($numfound > 20) { if ($n == (int) ($numfound / 3)) { echo '
    '; } if ($n == (int) (($numfound / 3) * 2)) { echo '
    '; } } elseif ($numfound > 4 && $n == (int) ($numfound / 2)) { echo '
    '; } } if ($child_places) { echo '
20) { echo 'colspan="3"'; } elseif ($numfound > 4) { echo 'colspan="2"'; } echo '>'; echo I18N::translate('View all records found in this place'); echo '
20) { echo 'colspan="3"'; } elseif ($numfound > 4) { echo 'colspan="2"'; } echo ' style="text-align: center;">'; echo '', $place->getPlaceName(), ''; echo '
'; } echo ''; if ($place_id && $action == 'show') { // -- array of names $myindilist = array(); $myfamlist = array(); $positions = Database::prepare("SELECT DISTINCT pl_gid FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?") ->execute(array($place_id, $WT_TREE->getTreeId())) ->fetchOneColumn(); foreach ($positions as $position) { $record = GedcomRecord::getInstance($position, $WT_TREE); if ($record && $record->canShow()) { if ($record instanceof Individual) { $myindilist[] = $record; } if ($record instanceof Family) { $myfamlist[] = $record; } } } echo '
'; //-- display results $controller ->addInlineJavascript('jQuery("#places-tabs").tabs();') ->addInlineJavascript('jQuery("#places-tabs").css("visibility", "visible");') ->addInlineJavascript('jQuery(".loading-image").css("display", "none");'); echo '
 
'; echo '
'; if ($myindilist) { echo '
', FunctionsPrintLists::individualTable($myindilist), '
'; } if ($myfamlist) { echo '
', FunctionsPrintLists::familyTable($myfamlist), '
'; } if (!$myindilist && !$myfamlist) { echo '
', FunctionsPrintLists::individualTable(array()), '
'; } echo '
'; //
} echo '

', I18N::translate('Show all places in a list'), '

'; if ($gm_module && $gm_module->getSetting('GM_PLACE_HIERARCHY')) { echo ''; $gm_module->mapScripts($numfound, $level, $parent, $linklevels, $placelevels, $place_names); } break; } echo '
'; //