You are here

function _ip_geoloc_plugin_style_add_label_and_styling in IP Geolocation Views & Maps 8

Same name and namespace in other branches
  1. 7 views/ip_geoloc_plugin_style.inc \_ip_geoloc_plugin_style_add_label_and_styling()

Style field value, label and wrapper around both, where requested.

Note: the "Add default classes" tickbox, options['element_default_classes'], is NOT supported to avoid the balloons having excessive bulky markup.

Parameters

string $field: The field.

string $field_content: The content of the field.

Return value

string $field_content wrapped in HTML with CSS classes

2 calls to _ip_geoloc_plugin_style_add_label_and_styling()
ip_geoloc_plugin_style_render_fields in src/Plugin/views/style/ip_geoloc_plugin_style.inc
Perform token replacement, convert timestamps to date strings etc.
_ip_geoloc_plugin_style_decorate in src/Plugin/views/style/ip_geoloc_plugin_style.inc
Call to decoration functions for marker.

File

src/Plugin/views/style/ip_geoloc_plugin_style.inc, line 1070
ip_geoloc_plugin_style.inc

Code

function _ip_geoloc_plugin_style_add_label_and_styling($field, $field_content) {
  if ($field_content_type = $field
    ->element_type(TRUE, TRUE)) {
    $element = '<' . $field_content_type;
    if ($field_content_class = $field
      ->element_classes(NULL)) {
      $element .= ' class="' . $field_content_class . '"';
    }
    $element .= '>';
    $close_element = '</' . $field_content_type . '>';
    $field_content = $element . $field_content . $close_element;
  }
  $label = $field
    ->label();
  if ($label && $field->options['element_label_colon']) {
    $label .= ': ';
  }
  $label_and_field_content = $label . $field_content;
  if ($label_type = $field
    ->element_label_type(TRUE, TRUE)) {
    $element = '<' . $label_type;
    if ($label_class = $field
      ->element_label_classes(NULL)) {
      $element .= ' class="' . $label_class . '"';
    }
    $element .= '>';
    $close_element = '</' . $label_type . '>';
    $label_and_field_content = $element . $label . $close_element . $field_content;
  }
  if ($wrapper_type = $field
    ->element_wrapper_type(TRUE, TRUE)) {
    $element = '<' . $wrapper_type;
    if ($wrapper_class = $field
      ->element_wrapper_classes(NULL)) {
      $element .= ' class="' . $wrapper_class . '"';
    }
    $element .= '>';
    $close_element = '</' . $wrapper_type . '>';
    return $element . $label_and_field_content . $close_element;
  }
  return $label_and_field_content;
}