public function ip_geoloc_plugin_style_leaflet::get_region_field_depth in IP Geolocation Views & Maps 7
1 call to ip_geoloc_plugin_style_leaflet::get_region_field_depth()
File
- views/
ip_geoloc_plugin_style_leaflet.inc, line 1585
Class
Code
public function get_region_field_depth($region_field) {
if (empty($region_field['type'])) {
// Dodgy business. Return 1 and hope for the best.
return 1;
}
if ($region_field['type'] === 'addressfield') {
return 4;
}
if (empty($region_field['settings']['allowed_values'])) {
return 1;
}
// Possibly a taxonomy or list.
$depth = 0;
foreach ($region_field['settings']['allowed_values'] as $tree) {
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
foreach ($terms as $term) {
$depth = max($term->depth, $depth);
}
break;
}
}
}
return $depth + 1;
}