Home » Structures » Structures_DataGrid » Bug #7606
DataGrid Renderer CSV
Details
| Submitted | 2006-05-11 16:27 UTC |
|---|---|
| From | amarie at clever-age dot com |
| Assigned | wiesemann |
| Status | Closed |
| Package | Structures_DataGrid |
| PHP Version | 5.1.4 |
| OS | N/A |
| Roadmaps | (Not assigned) |
Comments
[2006-05-11 16:27 UTC] amarie at clever-age dot com
Description:
------------
1) When you change the delimiter to ";", the renderer don't put quotes if there are a ";" in the data.
2) When you put "setUseQuotes()" at true, the data are lost.
Test script:
---------------
Old code in the file Structures/DataGrid/Renderer/CSV.php at line 166 :
if ($this->useQuotes) {
$content = '"' . str_replace('"', '""', $content) . '"';
} else {
if (strstr($content, '"')) {
$content = '"' . str_replace('"', '""', $content) . '"';
} elseif (strstr($content, ',')) {
$content = '"' . $content . '"';
}
$csv .= $content;
}
FIX :
if ($this->useQuotes) {
$content = '"' . str_replace('"', '""', $content) . '"';
} else {
if (strstr($content, '"')) {
$content = '"' . str_replace('"', '""', $content) . '"';
} elseif (strstr($content, <b>$this->delimiter</b>)) {
$content = '"' . $content . '"';
}
}
<b>$csv .= $content;</b>
Actual result:
--------------
CSV result for bug 1 :
$renderer =& $datagrid->getRenderer();
$renderer->setDelimiter(';');
$datagrid->render();
result :
line 1; data whithout quotes; data; data
line 2; data whith quotes; da;ta; da;ta
insted of :
line 1; data whithout quotes; data; data
line 2; data whith quotes; "da;ta"; "da;ta"
CSV result for bug 2 :
$renderer =& $datagrid->getRenderer();
$renderer->setDelimiter(';');
$renderer->setUseQuotes(true);
$datagrid->render();
result :
; ; ;
; ; ;
insted of :
"line 1"; "data whithout quotes"; "data"; "data"
"line 2"; "data whith quotes"; "da;ta"; "da;ta"