You are here

function theme_webform_results_table in Webform 5

Same name and namespace in other branches
  1. 5.2 webform_report.inc \theme_webform_results_table()
  2. 6.3 includes/webform.report.inc \theme_webform_results_table()
  3. 6.2 webform_report.inc \theme_webform_results_table()
  4. 7.4 includes/webform.report.inc \theme_webform_results_table()
  5. 7.3 includes/webform.report.inc \theme_webform_results_table()

Theme the results table displaying all the submissions for a particular node.

Parameters

$nid: The nid of 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.

1 theme call to theme_webform_results_table()
_webform_results_table in ./webform_report.inc
Create a table containing all submitted values for a webform node.

File

./webform_report.inc, line 117

Code

function theme_webform_results_table($nid, $components, $submissions) {
  $header = array();
  $rows = array();
  $cell = array();
  $node = node_load($nid);

  // This header has to be generated seperately so we can add the SQL necessary.
  // to sort the results.
  $header = theme('webform_results_table_header', $nid);

  // Generate a row for each submission.
  foreach ($submissions as $sid => $submission) {
    $cell[] = l($sid, 'node/' . $nid, NULL, "sid=" . $sid);
    $cell[] = format_date($submission->submitted, "small");
    $cell[] = theme('username', $submission);
    $cell[] = $submission->remote_addr;
    $component_headers = array();

    // Generate a cell for each component.
    foreach ($node->webformcomponents as $component) {
      $table_function = "_webform_table_data_" . $component['type'];
      if (function_exists($table_function)) {
        $submission_output = $table_function($submission->data[$component['cid']], $component);
        if ($submission_output !== NULL) {
          $component_headers[] = $component['name'];
          $cell[] = $submission_output;
        }
      }
    }
    $rows[] = $cell;
    unset($cell);
  }
  if (!empty($component_headers)) {
    $header = array_merge($header, $component_headers);
  }
  return theme('table', $header, $rows);
}