You are here

function theme_feeds_ui_mapping_form in Feeds 6

Same name and namespace in other branches
  1. 8.2 feeds_ui/feeds_ui.admin.inc \theme_feeds_ui_mapping_form()
  2. 7.2 feeds_ui/feeds_ui.admin.inc \theme_feeds_ui_mapping_form()
  3. 7 feeds_ui/feeds_ui.admin.inc \theme_feeds_ui_mapping_form()

Theme function for feeds_ui_mapping_form().

File

feeds_ui/feeds_ui.admin.inc, line 776
Contains all page callbacks, forms and theming functions for Feeds administrative pages.

Code

function theme_feeds_ui_mapping_form($form) {

  // Build the actual mapping table.
  $header = array(
    t('Source'),
    t('Target'),
    t('Unique target'),
    ' ',
  );
  $rows = array();
  if (is_array($form['#mappings'])) {
    foreach ($form['#mappings'] as $i => $mapping) {

      // Some parsers do not define source options.
      $source = isset($form['source']['#options'][$mapping['source']]) ? $form['source']['#options'][$mapping['source']] : $mapping['source'];
      $rows[] = array(
        check_plain($source),
        check_plain($form['target']['#options'][$mapping['target']]),
        drupal_render($form['unique_flags'][$i]),
        drupal_render($form['remove_flags'][$i]),
      );
    }
  }
  if (!count($rows)) {
    $rows[] = array(
      array(
        'colspan' => 4,
        'data' => t('No mappings defined.'),
      ),
    );
  }
  $rows[] = array(
    drupal_render($form['source']),
    drupal_render($form['target']),
    '',
    drupal_render($form['add']),
  );
  $output = '<div class="help feeds-admin-ui""' . drupal_render($form['help']) . '</div>';
  $output .= theme('table', $header, $rows);

  // Build the help table that explains available sources.
  $legend = '';
  $rows = array();
  foreach (element_children($form['legendset']['legend']['sources']) as $k) {
    $rows[] = array(
      check_plain(drupal_render($form['legendset']['legend']['sources'][$k]['name'])),
      check_plain(drupal_render($form['legendset']['legend']['sources'][$k]['description'])),
    );
  }
  if (count($rows)) {
    $legend .= '<h4>' . t('Sources') . '</h4>';
    $legend .= theme('table', array(
      t('Name'),
      t('Description'),
    ), $rows);
  }

  // Build the help table that explains available targets.
  $rows = array();
  foreach (element_children($form['legendset']['legend']['targets']) as $k) {
    $rows[] = array(
      check_plain(drupal_render($form['legendset']['legend']['targets'][$k]['name'])),
      check_plain(drupal_render($form['legendset']['legend']['targets'][$k]['description'])),
    );
  }
  $legend .= '<h4>' . t('Targets') . '</h4>';
  $legend .= theme('table', array(
    t('Name'),
    t('Description'),
  ), $rows);

  // Stick tables into collapsible fieldset.
  $form['legendset']['legend'] = array(
    '#value' => '<div>' . $legend . '</div>',
  );
  $output .= drupal_render($form['legendset']);
  $output .= drupal_render($form);
  return $output;
}