function _webform_csv_data_select in Webform 6.3
Same name and namespace in other branches
- 5.2 components/select.inc \_webform_csv_data_select()
- 5 components/select.inc \_webform_csv_data_select()
- 6.2 components/select.inc \_webform_csv_data_select()
- 7.4 components/select.inc \_webform_csv_data_select()
- 7.3 components/select.inc \_webform_csv_data_select()
Implements _webform_csv_data_component().
File
- components/
select.inc, line 762 - Webform module multiple select component.
Code
function _webform_csv_data_select($component, $export_options, $value) {
$options = _webform_select_options($component, TRUE, FALSE);
$return = array();
if ($component['extra']['multiple']) {
foreach ($options as $key => $item) {
$index = array_search($key, (array) $value);
if ($index !== FALSE) {
if ($export_options['select_format'] == 'separate') {
$return[] = 'X';
}
else {
$return[] = $export_options['select_keys'] ? $key : $item;
}
unset($value[$index]);
}
elseif ($export_options['select_format'] == 'separate') {
$return[] = '';
}
}
// Any remaining items in the $value array will be user-added options.
if ($component['extra']['other_option']) {
$return[] = count($value) ? implode(',', $value) : '';
}
}
else {
$key = $value[0];
if ($export_options['select_keys']) {
$return = $key;
}
else {
$return = isset($options[$key]) ? $options[$key] : $key;
}
}
if ($component['extra']['multiple'] && $export_options['select_format'] == 'compact') {
$return = implode(',', (array) $return);
}
return $return;
}