You are here

function ip_geoloc_region_autocomplete in IP Geolocation Views & Maps 7

Autocompletes the partial region received.

Parameters

string $partial_region:

3 string references to 'ip_geoloc_region_autocomplete'
ip_geoloc_block_set_my_location in ./ip_geoloc_blocks.inc
ip_geoloc_menu in ./ip_geoloc.module
Implements hook_menu().
_ip_geoloc_set_my_location_add_region in ./ip_geoloc_blocks.inc

File

./ip_geoloc.module, line 197
IPGV&M is a mapping engine for Views that contain locations of entities and/or visitors. Google Maps, Leaflet and OpenLayers2 maps are all supported. and available through this module. Using a number of optional sources IPGV&M also retrieves…

Code

function ip_geoloc_region_autocomplete($partial_region = '') {
  $matches = array();
  if (strlen($partial_region) >= 2) {
    $geo_vocabulary_id = variable_get('ip_geoloc_geo_vocabulary_id', 0);
    foreach (taxonomy_get_tree($geo_vocabulary_id) as $term) {
      $term_name = check_plain($term->name);

      // We define a "match" as any 2 consecutive chars, case-insensitive.
      $is_match = stripos($term_name, $partial_region) !== FALSE;
      if ($is_match) {
        $matches[$term_name] = $term_name;
      }
    }
  }
  drupal_json_output($matches);
}