You are here

function theme_webform_results_download_range in Webform 7.3

Same name and namespace in other branches
  1. 6.3 includes/webform.report.inc \theme_webform_results_download_range()
  2. 7.4 includes/webform.report.inc \theme_webform_results_download_range()

Theme the output of the export range fieldset.

1 theme call to theme_webform_results_download_range()
webform_results_download_form in includes/webform.report.inc
Form to configure the download of CSV files.

File

includes/webform.report.inc, line 570
This file includes helper functions for creating reports for webform.module.

Code

function theme_webform_results_download_range($variables) {
  drupal_add_library('webform', 'admin');
  $element = $variables['element'];
  $download_info = $element['#webform_download_info'];

  // Set description for total of all submissions.
  $element['range_type']['all']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['all']['#description'] = '(' . t('@count total', array(
    '@count' => $download_info['total'],
  )) . ')';

  // Set description for "New submissions since last download".
  $format = webform_date_format('short');
  $requested_date = format_date($download_info['requested'], 'custom', $format);
  $element['range_type']['new']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['new']['#description'] = '(' . t('@count new since @date', array(
    '@count' => $download_info['new'],
    '@date' => $requested_date,
  )) . ')';

  // Disable option if there are no new submissions.
  if ($download_info['new'] == 0) {
    $element['range_type']['new']['#attributes']['disabled'] = 'disabled';
  }

  // Render latest x submissions option.
  $element['latest']['#attributes']['class'][] = 'webform-set-active';
  $element['range_type']['latest']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['latest']['#inline_element'] = t('Only the latest !number submissions', array(
    '!number' => drupal_render($element['latest']),
  ));
  $element['range_type']['latest']['#title'] = NULL;

  // Render Start-End submissions option.
  $element['start']['#attributes']['class'][] = 'webform-set-active';
  $element['end']['#attributes']['class'][] = 'webform-set-active';
  $element['range_type']['range']['#theme_wrappers'] = array(
    'webform_inline_radio',
  );
  $element['range_type']['range']['#inline_element'] = t('All submissions starting from: !start and optionally to: !end', array(
    '!start' => drupal_render($element['start']),
    '!end' => drupal_render($element['end']),
  ));
  $element['range_type']['range']['#title'] = NULL;
  $last_sid = $download_info['sid'] ? $download_info['sid'] : drupal_placeholder(t('none'));
  $element['range_type']['range']['#description'] = '(' . t('Use submission IDs for the range. Last downloaded end SID: !sid.', array(
    '!sid' => $last_sid,
  )) . ')';
  return drupal_render_children($element);
}