function theme_vbo_export_content_csv in VBO export 8
Same name and namespace in other branches
- 8.2 includes/vbo_export.theme.inc \theme_vbo_export_content_csv()
Csv content builder function.
1 string reference to 'theme_vbo_export_content_csv'
- vbo_export_theme in ./
vbo_export.module - Implements hook_theme().
File
- includes/
vbo_export.theme.inc, line 11 - Theme implementation for csv output.
Code
function theme_vbo_export_content_csv($variables) {
// Sanitize data.
foreach ($variables['header'] as $key => $item) {
$variables['header'][$key] = strtr($item, array(
$variables['separator'] => ' ',
));
}
$content_replacements = array(
'\\r\\n' => ' ',
'\\n\\r' => ' ',
'\\r' => ' ',
'\\n' => ' ',
'\\t' => ' ',
$variables['separator'] => ' ',
);
foreach ($variables['rows'] as $row_key => $row) {
foreach ($row as $cell_key => $cell) {
$variables['rows'][$row_key][$cell_key] = strtr($cell, $content_replacements);
}
}
// Generate output.
$csv_rows = array();
$csv_rows[] = implode(';', $variables['header']);
foreach ($variables['rows'] as $row) {
$csv_rows[] = implode(';', $row);
}
$csv_string = implode(PHP_EOL, $csv_rows);
if (!empty($variables['strip_tags'])) {
$csv_string = strip_tags($csv_string);
}
return $csv_string;
}