You are here

function theme_webform_analysis_component_basic in Webform 7.4

Render an individual component's analysis data in a table.

Parameters

$variables: An array of theming variables for this theme function. Included keys:

  • $component: The component whose analysis is being rendered.
  • $data: An array of array containing the analysis data. Contains the keys:
    • table_header: If this table has more than a single column, an array of header labels.
    • table_rows: If this component has a table that should be rendered, an array of values

Return value

string The rendered table.

2 theme calls to theme_webform_analysis_component_basic()
webform_results_analysis in includes/webform.report.inc
Provides a simple analysis of all submissions to a webform.
webform_results_analysis in includes/webform.report.inc
Provides a simple analysis of all submissions to a webform.

File

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

Code

function theme_webform_analysis_component_basic($variables) {
  $data = $variables['data'];

  // Ensure defaults.
  $data += array(
    'table_header' => NULL,
    'table_rows' => array(),
    'other_data' => array(),
  );

  // Combine the "other data" into the table rows by default.
  if (is_array($data['other_data'])) {
    foreach ($data['other_data'] as $other_data) {
      if (is_array($other_data)) {
        $data['table_rows'][] = $other_data;
      }
      else {
        $data['table_rows'][] = array(
          array(
            'colspan' => 2,
            'data' => $other_data,
          ),
        );
      }
    }
  }
  elseif (strlen($data['other_data'])) {
    $data['table_rows'][] = array(
      'colspan' => 2,
      'data' => $data['other_data'],
    );
  }
  return theme('table', array(
    'header' => $data['table_header'],
    'rows' => $data['table_rows'],
    'sticky' => FALSE,
    'attributes' => array(
      'class' => array(
        'webform-analysis-table',
      ),
    ),
  ));
}