function _webform_csv_data_select in Webform 7.4
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.3 components/select.inc \_webform_csv_data_select()
- 6.2 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 826 - Webform module multiple select component.
Code
function _webform_csv_data_select($component, $export_options, $value) {
$options = _webform_select_options($component, TRUE);
$return = array();
if ($component['extra']['multiple']) {
foreach ($options as $key => $item) {
// Strict search is needed to avoid a key of 0 from matching an empty
// value.
$index = array_search((string) $key, (array) $value, TRUE);
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;
}