You are here

function theme_webform_edit_file_extensions in Webform 7.3

Same name and namespace in other branches
  1. 6.3 components/file.inc \theme_webform_edit_file_extensions()
  2. 7.4 components/file.inc \theme_webform_edit_file_extensions()

Output the list of allowed extensions as checkboxes.

1 theme call to theme_webform_edit_file_extensions()
_webform_edit_file in components/file.inc
Implements _webform_edit_component().

File

components/file.inc, line 263
Webform module file component.

Code

function theme_webform_edit_file_extensions($variables) {
  $element = $variables['element'];

  // Format the components into a table.
  $rows = array();
  foreach (element_children($element['types']) as $filtergroup) {
    $row = array();
    $first_row = count($rows);
    if ($element['types'][$filtergroup]['#type'] == 'checkboxes') {
      $select_link = ' <a href="#" class="webform-select-link webform-select-link-' . $filtergroup . '">(' . t('select') . ')</a>';
      $row[] = $element['types'][$filtergroup]['#title'];
      $row[] = array(
        'data' => $select_link,
        'width' => 40,
      );
      $row[] = array(
        'data' => drupal_render_children($element['types'][$filtergroup]),
        'class' => array(
          'webform-file-extensions',
          'webform-select-group-' . $filtergroup,
        ),
      );
      $rows[] = array(
        'data' => $row,
      );
      unset($element['types'][$filtergroup]);
    }
  }

  // Add the row for additional types.
  $row = array();
  $title = $element['addextensions']['#title'];
  $element['addextensions']['#title'] = NULL;
  $row[] = array(
    'data' => $title,
    'colspan' => 2,
  );
  $row[] = drupal_render($element['addextensions']);
  $rows[] = $row;
  $header = array(
    array(
      'data' => t('Category'),
      'colspan' => '2',
    ),
    array(
      'data' => t('Types'),
    ),
  );

  // Create the table inside the form.
  $element['types']['table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => array(
      'class' => array(
        'webform-file-extensions',
      ),
    ),
  );
  return drupal_render_children($element);
}