function _webform_display_array in Webform Matrix Component 6
Same name and namespace in other branches
- 7.4 components/matrix.inc \_webform_display_array()
 - 7.2 components/matrix.inc \_webform_display_array()
 - 7.3 components/matrix.inc \_webform_display_array()
 
This is return display array
Parameters
array $sub_elements matrix node compoenent:
array $value_array matrix submission result:
Return value
$display_array display result
3 calls to _webform_display_array()
- _webform_csv_data_matrix in components/
matrix.inc  - Implements _webform_csv_data_component().
 - _webform_display_matrix in components/
matrix.inc  - Implements _webform_display_component().
 - _webform_table_matrix in components/
matrix.inc  - Implements _webform_table_component().
 
File
- components/
matrix.inc, line 824  - Webform module matrix component.
 
Code
function _webform_display_array($sub_elements, $value_array, &$headers = array()) {
  $col = 1;
  foreach ($sub_elements as $sub_element) {
    $headers[] = check_plain($sub_element['title']);
    if ($sub_element['type'] == 'textfield') {
      foreach ($value_array as $key => $value_row) {
        if (!empty($value_row[$col])) {
          $display_array[$key][$col] = check_plain($value_row[$col]);
        }
        else {
          $display_array[$key][$col] = "";
        }
      }
    }
    elseif ($sub_element['type'] == 'select') {
      $option_array = _webform_matrix_component_select_option_from_text($sub_element['option']);
      foreach ($value_array as $key => $value_row) {
        if (isset($value_row[$col])) {
          //Check for multiple
          $is_multiple = @$sub_element['multiple'];
          if (is_array($value_row[$col])) {
            $select_values_options = array();
            foreach ($value_row[$col] as $select_values) {
              if (array_key_exists($select_values, $option_array)) {
                $select_values_options[] = $option_array[$select_values];
              }
            }
            if (!empty($select_values_options)) {
              $display_array[$key][$col] = implode(',', $select_values_options);
            }
            else {
              $display_array[$key][$col] = '_none';
            }
          }
          else {
            //Previous functionality
            if (array_key_exists($value_row[$col], $option_array)) {
              $display_array[$key][$col] = $option_array[$value_row[$col]];
            }
            else {
              $display_array[$key][$col] = $value_row[$col];
            }
          }
        }
        else {
          $display_array[$key][$col] = '_none';
        }
      }
    }
    elseif ($sub_element['type'] == 'date') {
      foreach ($value_array as $key => $value_row) {
        if ($value_array[$key][$col]['year'] && $value_array[$key][$col]['month'] && $value_array[$key][$col]['day']) {
          $timestamp = webform_strtotime($value_array[$key][$col]['month'] . '/' . $value_array[$key][$col]['day'] . '/' . $value_array[$key][$col]['year']);
          $format = webform_date_format('short');
          $display_array[$key][$col] = format_date($timestamp, 'custom', $format, 'UTC');
        }
        else {
          $display_array[$key][$col] = "";
        }
      }
    }
    else {
      foreach ($value_array as $key => $value_row) {
        $display_array[$key][$col] = $sub_element['label_name'];
      }
    }
    $col++;
  }
  return $display_array;
}