Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glrvrl csv export separator #5815

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Form/Field/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,14 @@ public function render()
$this->setupDefaultOptions();

if (!empty($this->value)) {
$this->attribute('data-initial-preview', $this->preview());
$this->attribute('data-initial-caption', $this->initialCaption($this->value));

/*
* Dont show upload path/url for security reaseon
*/
if (!$this->hidePreview()) {
$this->attribute('data-initial-preview', $this->preview());
$this->attribute('data-initial-caption', $this->initialCaption($this->value));
}

$this->setupPreviewOptions();
/*
Expand Down
27 changes: 22 additions & 5 deletions src/Grid/Exporters/CsvExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ class CsvExporter extends AbstractExporter
*/
protected $columnUseOriginalValue;


protected $csvSeparator;

/**
* @param string $csvSeparator
*
* @return $this
*/
public function separator(string $csvSeparator = ';'): self
{
$this->csvSeparator = $csvSeparator;

return $this;
}



/**
* @param string $filename
*
Expand Down Expand Up @@ -173,12 +190,12 @@ public function export()

// Write title
if (empty($titles)) {
fputcsv($handle, $titles = $this->getVisiableTitles());
fputcsv($handle, $titles = $this->getVisiableTitles(), $this->csvSeparator);
}

// Write rows
foreach ($current as $index => $record) {
fputcsv($handle, $this->getVisiableFields($record, $original[$index]));
fputcsv($handle, $this->getVisiableFields($record, $original[$index]), $this->csvSeparator);
}
});
fclose($handle);
Expand All @@ -202,7 +219,7 @@ protected function getVisiableTitles()
$columnTitle = $this->titleCallbacks[$columnName]($columnTitle);
}

return [$columnName => $columnTitle];
return [$columnName => html_entity_decode(htmlspecialchars_decode($columnTitle))];
});

if ($this->onlyColumns) {
Expand Down Expand Up @@ -231,8 +248,8 @@ public function getVisiableFields(array $value, array $original): array
foreach ($this->visibleColumns as $column) {
$fields[] = $this->getColumnValue(
$column,
data_get($value, $column),
data_get($original, $column)
html_entity_decode(htmlspecialchars_decode(data_get($value, $column))),
html_entity_decode(htmlspecialchars_decode(data_get($original, $column)))
);
}

Expand Down