You are here

function theme_feeds_ex_configuration_table in Feeds extensible parsers 8

Same name and namespace in other branches
  1. 7.2 feeds_ex.theme.inc \theme_feeds_ex_configuration_table()
  2. 7 feeds_ex.theme.inc \theme_feeds_ex_configuration_table()

Themes the parser configuration table.

1 theme call to theme_feeds_ex_configuration_table()
ParserBase::_buildConfigurationForm in src/Feeds/Parser/ParserBase.php
Builds configuration form for the parser settings.

File

./feeds_ex.theme.inc, line 13
Theme callbacks for feeds_ex.

Code

function theme_feeds_ex_configuration_table(array $variables) {
  $element = $variables['element'];
  $rows = [];

  // Render the context at the top. Context is optional.
  if (!empty($element['context'])) {
    $context_row = [];
    foreach (array_keys($element['#header']) as $column) {
      $context_row[] = \Drupal::service('renderer')
        ->render($element['context'][$column]);
    }
    $rows[] = $context_row;
  }

  // Render the sources.
  foreach (Element::children($element['sources']) as $source_key) {
    $source = $element['sources'][$source_key];
    $row = [];
    foreach (array_keys($element['#header']) as $column) {
      $row[] = \Drupal::service('renderer')
        ->render($element['sources'][$source_key][$column]);
    }
    $rows[] = [
      'data' => $row,
      'class' => [
        'draggable',
      ],
    ];
  }

  // Render the add row.
  $add_row = [];
  foreach (array_keys($element['#header']) as $column) {
    $add_row[] = [
      'data' => \Drupal::service('renderer')
        ->render($element['add'][$column]),
      'class' => [
        'feeds-ex-add-' . $column,
      ],
    ];
  }
  $rows[] = [
    'data' => $add_row,
    'class' => [
      'draggable',
    ],
  ];
  $output = _theme('table', [
    'header' => $element['#header'],
    'rows' => $rows,
    'attributes' => [
      'id' => $element['sources']['#id'],
    ],
  ]);
  $output .= render($element);
  return $output;
}