public function FeedsCSVParser::getTemplate in Feeds 8.2
File
- lib/
Drupal/ feeds/ Plugin/ feeds/ parser/ FeedsCSVParser.php, line 224 - Contains the FeedsCSVParser class.
Class
- FeedsCSVParser
- Defines a CSV feed parser.
Namespace
Drupal\feeds\Plugin\feeds\parserCode
public function getTemplate() {
$mappings = feeds_importer($this->id)->processor->config['mappings'];
$sources = $uniques = array();
foreach ($mappings as $mapping) {
if (!empty($mapping['unique'])) {
$uniques[] = check_plain($mapping['source']);
}
else {
$sources[] = check_plain($mapping['source']);
}
}
$sep = ',';
$columns = array();
foreach (array_merge($uniques, $sources) as $col) {
if (strpos($col, $sep) !== FALSE) {
$col = '"' . str_replace('"', '""', $col) . '"';
}
$columns[] = $col;
}
drupal_add_http_header('Cache-Control', 'max-age=60, must-revalidate');
drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $this->id . '_template.csv"');
drupal_add_http_header('Content-type', 'text/csv; charset=utf-8');
print implode($sep, $columns);
return;
}