You are here

function theme_webform_component_select in Webform 7.4

Same name and namespace in other branches
  1. 6.3 includes/webform.components.inc \theme_webform_component_select()
  2. 7.3 includes/webform.components.inc \theme_webform_component_select()

Theme the contents of a Webform component select element.

File

includes/webform.components.inc, line 1134
Webform module component handling.

Code

function theme_webform_component_select($variables) {
  $element = $variables['element'];
  $rows = array();
  $header = array();
  if (!isset($element['#all_checkbox']) || $element['#all_checkbox']) {
    $header = array(
      array(
        'class' => array(
          'select-all',
        ),
        'data' => ' ' . t('Include all components'),
      ),
    );
  }
  foreach (element_children($element) as $key) {
    if ($key != 'suffix') {
      $rows[] = array(
        theme('indentation', array(
          'size' => $element[$key]['#indent'],
        )) . drupal_render($element[$key]),
      );
    }
  }
  $element['#type'] = 'fieldset';
  $element['#value'] = NULL;
  $element['#attributes']['class'] = array(
    'webform-component-select-table',
  );
  if (!isset($element['#collapsible']) || $element['#collapsible']) {
    $element['#attributes']['class'][] = 'collapsible';
  }
  if (!isset($element['#collapsed']) || $element['#collapsed']) {
    $element['#attributes']['class'][] = 'collapsed';
  }
  if (empty($rows)) {
    $element['#children'] = t('No available components.');
  }
  else {
    $element['#children'] = '<div class="webform-component-select-wrapper">' . theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'sticky' => FALSE,
    )) . '</div>';
  }
  if (isset($element['suffix'])) {
    $element['#children'] .= '<div class="webform-component-select-suffix">' . drupal_render($element['suffix']) . '</div>';
  }
  return theme('fieldset', array(
    'element' => $element,
  ));
}