function theme_node_gallery_content_multiple_values in Node Gallery 7
Same name and namespace in other branches
- 6.3 theme/theme.inc \theme_node_gallery_content_multiple_values()
Theme function for multiple content values.
File
- theme/
theme.inc, line 98 - Node gallery theme functions
Code
function theme_node_gallery_content_multiple_values($variables) {
$element = $variables['element'];
$nid = $element['#parents'][1];
$field_name = $element['#field_name'];
$field = content_fields($field_name);
$output = '';
if ($field['multiple'] >= 1) {
$table_id = $element['#field_name'] . '_values-' . $nid;
$order_class = $element['#field_name'] . '-delta-order';
$required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';
$header = array(
array(
'data' => t('!title: !required', array(
'!title' => $element['#title'],
'!required' => $required,
)),
'colspan' => 2,
),
t('Order'),
);
$rows = array();
// Sort items according to '_weight' (needed when the form comes back after
// preview or failed validation).
$items = array();
foreach (element_children($element) as $key) {
if ($key !== $element['#field_name'] . '_add_more-' . $nid) {
$items[] =& $element[$key];
}
}
usort($items, '_content_sort_items_value_helper');
// Add the items as table rows.
foreach ($items as $key => $item) {
$item['_weight']['#attributes']['class'] = $order_class;
$delta_element = drupal_render($item['_weight']);
$cells = array(
array(
'data' => '',
'class' => 'content-multiple-drag',
),
drupal_render($item),
array(
'data' => $delta_element,
'class' => 'delta-order',
),
);
$rows[] = array(
'data' => $cells,
'class' => 'draggable',
);
}
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => $table_id,
'class' => 'content-multiple-table',
),
));
$output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
$output .= drupal_render($element[$element['#field_name'] . '_add_more-' . $nid]);
drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
}
else {
foreach (element_children($element) as $key) {
$output .= drupal_render_children($element[$key]);
}
}
return $output;
}