protected function FlatTextExporter::collapseRow in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/aklump/loft_data_grids/src/AKlump/LoftDataGrids/FlatTextExporter.php \AKlump\LoftDataGrids\FlatTextExporter::collapseRow()
Collapse a row
Overrides CSVExporter::collapseRow
2 calls to FlatTextExporter::collapseRow()
- FlatTextExporter::compile in vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ FlatTextExporter.php - Build $this->output in prep for export/save
- MarkdownTableExporter::compile in vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ MarkdownTableExporter.php - Build $this->output in prep for export/save
File
- vendor/
aklump/ loft_data_grids/ src/ AKlump/ LoftDataGrids/ FlatTextExporter.php, line 98
Class
- FlatTextExporter
- Class FlatTextExporter
Namespace
AKlump\LoftDataGridsCode
protected function collapseRow($row) {
$output = '';
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
foreach ($row as $key => $value) {
if ($key == 'data') {
$cells = $value;
}
}
}
else {
$cells = $row;
}
$output = array();
if (count($cells)) {
foreach ($cells as $cell) {
//compress a complex cell
if (is_array($cell)) {
$cell = isset($cell['data']) ? $cell['data'] : '';
}
if (!$this->format->html) {
$cell = strip_tags($cell);
}
// Escape chars that conflice with delimiters
if (!empty($this->format->escape)) {
$escapeables = array(
$this->format->left,
$this->format->right,
);
$escapeables = array_filter(array_unique($escapeables));
foreach ($escapeables as $find) {
$cell = str_replace($find, $this->format->escape . $find, $cell);
}
}
// A cell cannot contain line breaks so we replace them
$cell = preg_replace('/\\r\\n|\\r|\\n/', '; ', $cell);
$output[] = $this->format->left . $cell . $this->format->right;
}
}
$output = $this->format->bol . implode($this->format->sep, $output) . $this->format->eol;
return $output;
}