/** * Adds a vector to the map for a particular location, and zooms into it. */ function iform_map_zoom_to_location($locationId, $readAuth) { $getPopDataOpts = array('table' => 'location', 'extraParams' => $readAuth + array('id' => $locationId, 'view' => 'detail')); $response = data_entry_helper::get_population_data($getPopDataOpts); $geom = $response[0]['boundary_geom'] ? $response[0]['boundary_geom'] : $response[0]['centroid_geom']; iform_map_zoom_to_geom($geom, lang::get('{1} boundary', $response[0]['name'])); }
/** * Override get_form_html so we can store the remembered argument in a global, to make * it available to a hook function which exists outside the form. */ protected static function get_form_html($args, $auth, $attributes) { group_authorise_form($args, $auth['read']); // We always want an autocomplete formatter function for species lookups. The form implementation can // specify its own if required if (method_exists(self::$called_class, 'build_grid_autocomplete_function')) { call_user_func(array(self::$called_class, 'build_grid_autocomplete_function'), $args); } else { $opts = array('cacheLookup' => $args['cache_lookup'], 'speciesIncludeBothNames' => $args['species_include_both_names'], 'speciesIncludeTaxonGroup' => $args['species_include_taxon_group'], 'speciesIncludeIdDiff' => $args['species_include_id_diff']); data_entry_helper::build_species_autocomplete_item_function($opts); } global $remembered; $remembered = isset($args['remembered']) ? $args['remembered'] : ''; if (empty(data_entry_helper::$entity_to_load['sample:group_id']) && !empty($_GET['group_id'])) { data_entry_helper::$entity_to_load['sample:group_id'] = $_GET['group_id']; } if (!empty(data_entry_helper::$entity_to_load['sample:group_id'])) { self::$group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $auth['read'] + array('view' => 'detail', 'id' => data_entry_helper::$entity_to_load['sample:group_id']))); self::$group = self::$group[0]; $filterdef = json_decode(self::$group['filter_definition']); // does the group filter define a site or boundary for the recording? If so we need to show it and limit the map extent $locationIDToLoad = empty($filterdef->location_id) ? empty($filterdef->indexed_location_id) ? false : $filterdef->indexed_location_id : $filterdef->location_id; if ($locationIDToLoad) { $response = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $auth['read'] + array('id' => $locationIDToLoad, 'view' => 'detail'))); $geom = $response[0]['boundary_geom'] ? $response[0]['boundary_geom'] : $response[0]['centroid_geom']; iform_map_zoom_to_geom($geom, lang::get('Boundary of {1} for the {2} group', $response[0]['name'], self::$group['title']), true); self::hide_other_boundaries($args); } elseif (!empty($filterdef->searchArea)) { iform_map_zoom_to_geom($filterdef->searchArea, lang::get('Recording area for the {1} group', self::$group['title']), true); self::hide_other_boundaries($args); } if (!empty($filterDef->taxon_group_names)) { $args['taxon_filter'] = implode("\n", array_values((array) $filterdef->taxon_group_names)); $args['taxon_filter_field'] = 'taxon_group'; } // @todo Consider other types of species filter, e.g. family or species list? } return parent::get_form_html($args, $auth, $attributes); }