You are here

function theme_ip_geoloc_plugin_style_differentiator_color_table in IP Geolocation Views & Maps 8

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

Return HTML for differentiator to color associations table.

Parameters

array $variables: An associative array containing $variables['form']: a render element representing the form.

1 theme call to theme_ip_geoloc_plugin_style_differentiator_color_table()
ip_geoloc_plugin_style_bulk_of_form in src/Plugin/views/style/ip_geoloc_plugin_style.inc
The bulk of the plugin style form.

File

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

Code

function theme_ip_geoloc_plugin_style_differentiator_color_table(array $variables) {

  // Use the first form child to find out the name of the differentiator.
  $form = $variables['form'];
  $form_children = element_children($form);
  if (empty($form_children)) {
    return '';
  }
  $key = reset($form_children);
  foreach ($form[$key] as $attribute_name => $element) {
    if (drupal_substr($attribute_name, 0, 1) != '#' && $attribute_name != 'color') {
      $differentiator = $attribute_name;
      break;
    }
  }
  if (empty($differentiator)) {
    return '';
  }
  $instances = ip_geoloc_get_field_instances($differentiator);
  $instance = reset($instances);
  $differentiator_label = isset($instance) ? $instance['label'] : $differentiator;
  $headers = [
    t('%differentiator value', [
      '%differentiator' => $differentiator_label,
    ]),
    t('Associated marker image'),
    t('Special char'),
    t('Special char CSS class'),
  ];
  $rows = [];
  foreach ($form_children as $key) {
    $row = [
      'data' => [],
      'class' => [],
    ];
    $row['data'][] = drupal_render($form[$key][$differentiator]);
    $row['data'][] = drupal_render($form[$key]['color']);
    $row['data'][] = drupal_render($form[$key]['special char']);
    $row['data'][] = drupal_render($form[$key]['special char class']);
    $rows[] = $row;
  }
  $output = theme('table', [
    'header' => $headers,
    'rows' => $rows,
    'attributes' => [
      'id' => 'differentiator-color-table',
    ],
  ]);
  $output .= drupal_render_children($form);
  return $output;
}