function theme_hierarchical_select_dropbox_table in Hierarchical Select 6.3
Same name and namespace in other branches
- 5.3 hierarchical_select.module \theme_hierarchical_select_dropbox_table()
- 7.3 includes/theme.inc \theme_hierarchical_select_dropbox_table()
Forms API theming callback for the dropbox. Renders the dropbox as a table.
Parameters
$element: An element for which the #theme property was set to this function.
Return value
A themed HTML string.
File
- includes/
theme.inc, line 197 - All theme functions for the Hierarchical Select module.
Code
function theme_hierarchical_select_dropbox_table($element) {
$output = '';
$class = 'dropbox';
if (form_get_error($element) === '') {
$class .= ' error';
}
$title = $element['title']['#value'];
$separator = $element['separator']['#value'];
$is_empty = $element['is_empty']['#value'];
$separator_html = '<span class="hierarchical-select-item-separator">' . $separator . '</span>';
$output .= '<div class="' . $class . '">';
$output .= '<table>';
$output .= '<caption class="dropbox-title">' . $title . '</caption>';
$output .= '<tbody>';
if (!$is_empty) {
// Each lineage in the dropbox corresponds to an entry in the dropbox table.
$lineage_count = count(element_children($element['lineages']));
for ($x = 0; $x < $lineage_count; $x++) {
$db_entry = $element['lineages'][$x];
$zebra = $db_entry['#zebra'];
$first = $db_entry['#first'];
$last = $db_entry['#last'];
// The deepest level is the number of child levels minus one. This "one"
// is the element for the "Remove" checkbox.
$deepest_level = count(element_children($db_entry)) - 1;
$output .= '<tr class="dropbox-entry ' . $first . ' ' . $last . ' ' . $zebra . '">';
$output .= '<td>';
// Each item in a lineage is separated by the separator string.
for ($depth = 0; $depth < $deepest_level; $depth++) {
$output .= drupal_render($db_entry[$depth]);
if ($depth < $deepest_level - 1) {
$output .= $separator_html;
}
}
$output .= '</td>';
$output .= '<td class="dropbox-remove">' . drupal_render($db_entry['remove']) . '</td>';
$output .= '</tr>';
}
}
else {
$output .= '<tr class="dropbox-entry first last dropbox-is-empty"><td>';
$output .= t('Nothing has been selected.');
$output .= '</td></tr>';
}
$output .= '</tbody>';
$output .= '</table>';
$output .= '</div>';
return $output;
}