function theme_feeds_tamper_ui_list_form in Feeds Tamper 6
Same name and namespace in other branches
- 7 feeds_tamper_ui/feeds_tamper_ui.admin.inc \theme_feeds_tamper_ui_list_form()
File
- feeds_tamper_ui/
feeds_tamper_ui.admin.inc, line 150 - Forms and their accompanying validation and submit functions for Feeds Tamper UI.
Code
function theme_feeds_tamper_ui_list_form($form) {
// Shortcut to save typing and screen space.
$map =& $form['mappings'];
$mappings = element_children($map);
$header_normal = array(
t('Description'),
t('Weight'),
t('Plugin'),
t('Status'),
t('Operations'),
t('Enabled'),
);
// Remove weight column for empty tables. It looks nicer.
$header_empty = $header_normal;
unset($header_empty[1]);
if (empty($mappings)) {
// Can't use drupal_set_message here.
$link = FEEDS_TAMPER_UI_FEEDS_BASE . '/edit/' . $form['#importer']->id . '/mapping';
$link = l(t('mappings'), $link);
$output = '<div class="messages warning">';
$message = 'There are no !mappings defined for this importer.';
$output .= t($message, array(
'!mappings' => $link,
));
$output .= '</div>';
return $output;
}
foreach ($mappings as $key => $i) {
$table_rows = $disabled_rows = array();
// We used to use the source name in the table id, but it just needs to be
// unique, so use the key to avoid problems.
$table_id = 'feeds-tamper-' . $key . '-table';
// Plugin instances for a particluar source.
$instances = element_children($map[$i]['table']);
if (empty($instances)) {
$header = $header_empty;
$help_text = t('No plugins defined.');
$table_rows = array(
'data' => array(
array(
'data' => $help_text,
'colspan' => 5,
),
),
);
}
else {
$header = $header_normal;
foreach ($instances as $id) {
$enabled = !empty($map[$i]['table'][$id]['enabled']['#default_value']);
// Assemble enabled plugin rows.
if ($enabled) {
$this_row = array();
// Add description column.
$this_row[] = $map[$i]['table'][$id]['#description'];
// Add weight column, it will be hidden if javascript is enabled.
$this_row[] = drupal_render($map[$i]['table'][$id]['weight']);
// The name of the plugin, as defined in a PLUGIN.inc.
$this_row[] = $map[$i]['table'][$id]['#name'];
// One of Normal, Default, Overridden.
$this_row[] = $map[$i]['table'][$id]['#status'];
// Operations to perform on a plugin instance.
$this_row[] = $map[$i]['table'][$id]['#edit'];
// Enabled checkbox.
$this_row[] = drupal_render($map[$i]['table'][$id]['enabled']);
// Add draggable class for sortable table.
$table_rows[] = array(
'data' => $this_row,
'class' => 'draggable',
);
}
else {
// Assemble disabled plugin rows.
$this_row = array();
// Add description column.
$this_row[] = $map[$i]['table'][$id]['#description'];
// Add weight column, it will be hidden if javascript is enabled.
$this_row[] = drupal_render($map[$i]['table'][$id]['weight']);
// The name of the plugin, as defined in a PLUGIN.inc.
$this_row[] = $map[$i]['table'][$id]['#name'];
// One of Normal, Default, Overridden.
$this_row[] = $map[$i]['table'][$id]['#status'];
// Operations to perform on a plugin instance. It's disabled, so make
// it just text.
$this_row[] = strip_tags($map[$i]['table'][$id]['#edit']);
// Enabled checkbox.
$this_row[] = drupal_render($map[$i]['table'][$id]['enabled']);
// Add disabled class to differentiate.
$disabled_rows[] = array(
'data' => $this_row,
'class' => 'disabled',
);
}
}
// Only add tabledrag if there were plugins for that source.
drupal_add_tabledrag($table_id, 'order', 'sibling', 'weight');
}
// Combine enabled and disabled rows.
$table_rows = array_merge($table_rows, $disabled_rows);
// "Add plugin" link is the last row.
$table_rows[] = array(
'data' => array(
array(
'data' => $map[$i]['#add_link'],
'colspan' => 7,
),
),
'class' => 'feeds-tamper-add',
);
// Table caption, in the form of source_name -> target_name1, target_name2
$caption = $map[$i]['#title']['source'] . ' -> ' . implode(', ', $map[$i]['#title']['targets']);
$table = theme_table($header, $table_rows, array(
'id' => $table_id,
), $caption);
//$table['#attributes']['id'] = $table_id;
//$table['#attached']['css'][] = drupal_get_path('module', 'feeds_tamper_ui') . '/feeds_tamper_ui.css';
$map[$i]['table'] = array(
'#value' => $table,
);
$map[$i]['#prefix'] = '<div class="feeds-tamper-table">';
$map[$i]['#suffix'] = '</div>';
}
return drupal_render($form);
}