You are here

function theme_webform_edit_file_extensions in Webform 6.3

Same name and namespace in other branches
  1. 7.4 components/file.inc \theme_webform_edit_file_extensions()
  2. 7.3 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 227
Webform module file component.

Code

function theme_webform_edit_file_extensions($element) {
  drupal_add_js(drupal_get_path('module', 'webform') . '/js/webform-admin.js');
  drupal_add_css(drupal_get_path('module', 'webform') . '/css/webform-admin.css');

  // 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'];
      $element['types'][$filtergroup]['#title'] = NULL;
      $row[] = array(
        'data' => $select_link,
        'width' => 40,
      );
      $row[] = array(
        'data' => drupal_render($element['types'][$filtergroup]),
        'class' => '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.
  $table = theme('table', $header, $rows, array(
    'class' => 'webform-file-extensions',
  ));
  $element['types']['table'] = array(
    '#value' => theme('form_element', $element, $table),
  );
  return drupal_render($element);
}