function theme_webform_results_table in Webform 7.3
Same name and namespace in other branches
- 5.2 webform_report.inc \theme_webform_results_table()
- 5 webform_report.inc \theme_webform_results_table()
- 6.3 includes/webform.report.inc \theme_webform_results_table()
- 6.2 webform_report.inc \theme_webform_results_table()
- 7.4 includes/webform.report.inc \theme_webform_results_table()
Theme the results table displaying all the submissions for a particular node.
Parameters
$node: The node whose results are being displayed.
$components: An associative array of the components for this webform.
$submissions: An array of all submissions for this webform.
$total_count: The total number of submissions to this webform.
$pager_count: The number of results to be shown per page.
1 theme call to theme_webform_results_table()
- webform_results_table in includes/
webform.report.inc - Create a table containing all submitted values for a webform node.
File
- includes/
webform.report.inc, line 216 - This file includes helper functions for creating reports for webform.module.
Code
function theme_webform_results_table($variables) {
drupal_add_library('webform', 'admin');
$node = $variables['node'];
$components = $variables['components'];
$submissions = $variables['submissions'];
$total_count = $variables['total_count'];
$pager_count = $variables['pager_count'];
$header = array();
$rows = array();
$cell = array();
// This header has to be generated separately so we can add the SQL necessary.
// to sort the results.
$header = theme('webform_results_table_header', array(
'node' => $node,
));
// Generate a row for each submission.
foreach ($submissions as $sid => $submission) {
$cell[] = l($sid, 'node/' . $node->nid . '/submission/' . $sid);
$cell[] = format_date($submission->submitted, 'short');
$cell[] = theme('username', array(
'account' => $submission,
));
$cell[] = $submission->remote_addr;
$component_headers = array();
// Generate a cell for each component.
foreach ($node->webform['components'] as $component) {
$data = isset($submission->data[$component['cid']]['value']) ? $submission->data[$component['cid']]['value'] : NULL;
$submission_output = webform_component_invoke($component['type'], 'table', $component, $data);
if ($submission_output !== NULL) {
$component_headers[] = check_plain($component['name']);
$cell[] = $submission_output;
}
}
$rows[] = $cell;
unset($cell);
}
if (!empty($component_headers)) {
$header = array_merge($header, $component_headers);
}
if (count($rows) == 0) {
$rows[] = array(
array(
'data' => t('There are no submissions for this form. <a href="!url">View this form</a>.', array(
'!url' => url('node/' . $node->nid),
)),
'colspan' => 4,
),
);
}
$output = '';
$output .= theme('webform_results_per_page', array(
'total_count' => $total_count,
'pager_count' => $pager_count,
));
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
return $output;
}