function _webform_display_array in Webform Matrix Component 7.2
Same name and namespace in other branches
- 6 components/matrix.inc \_webform_display_array()
- 7.4 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 710 - 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])) {
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];
}
}
}
}
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;
}