0) { // id of existing region was passed $id = intval($subtarget['id']); $action = "edit"; try { // object can be loaded $region = Factory::getObjectByID($id); } catch (Exception $e) { // object cannot be loaded => abort echo $errormessage; die(); } if (is_object($region)) { //$region = new Region($content_vars['region']); $region = Factory::getObjectByID($id); $content_vars['fieldidentifier'] = $id; $content_vars['name'] = $region->getName(); $content_vars['short_name'] = $region->getShortName(); $content_vars['regiontypename'] = $region->getRegiontypeName(); $content_vars['data'] = $region->getDisplayData(); // the plain values $plainvalues = $region->getValues(); #var_dump($content_vars['data']); //$content_vars['data'] = $region->getVisibleData(); > this is more worse that the other one... $content_vars['population'] = $plainvalues['population']; $content_vars['area'] = $plainvalues['area']; $content_vars['center'] = $plainvalues['center']; $content_vars['identifier_openstreetmap'] = $plainvalues['identifier_openstreetmap']; $content_vars['zoomlevel'] = $plainvalues['zoomlevel']; #$content_vars['boundary'] = 'boundary'; $content_vars['links'] = $content_vars['data']['links']; #if one result then current region is ITSELF! $content_vars['parentregions'] = $region->getParentRegions(); // get possible subregions $possible_subregions = $region->getChildRegiontypes(FALSE); } } if (intval($subtarget['parentid']) > 0) { // the parentid of a new region (if a NEW region is created) try { $content_vars['parentid'] = intval($subtarget['parentid']); $action = "add"; //$region = new Region($content_vars['region']); $parentregion = Factory::getObjectByID(intval($subtarget['parentid'])); $content_vars['parentname'] = $parentregion->getName(); $content_vars['allowed_childregion_ids'] = $parentregion->getChildRegiontypesID(FALSE); $content_vars['fieldidentifier'] = 0; $content_vars['name'] = ''; if (count($content_vars['allowed_childregion_ids']) == 0) { // no allowed child regions given; use city as failover (should not happe) $content_vars['regiontypeid'] = 7; // 7=city } else { // allowed child regions given; take first entry (such as "district" for a city) $content_vars['regiontypeid'] = $content_vars['allowed_childregion_ids'][0]; // 7=city } $content_vars['population'] = ''; $content_vars['area'] = ''; $content_vars['zoomlevel'] = '7'; $content_vars['center'] = ''; #$content_vars['boundary'] = ''; } catch (Exception $e) { echo $errormessage; die(); } } if ($action === "add" || $action === "edit") { // allowed action } else { // something strange happened; do not show form $showform = false; } } ?>