Chart\InlinePie: locale-ignorant cast for floats

This has already been fixed with 92f454c3 and got broken again with be0c5d4b.
Time for a regression test I guess.

refs #6348
This commit is contained in:
Thomas Gelf 2014-06-25 22:13:19 +02:00
parent d44f89f287
commit 7112ed23f4
1 changed files with 9 additions and 1 deletions

View File

@ -383,12 +383,20 @@ EOD;
$template = str_replace('{borderColor}', $this->borderColor, $template);
$template = str_replace('{hideEmptyLabel}', $this->hideEmptyLabel ? 'true' : 'false', $template);
// Locale-ignorant string cast. Please. Do. NOT. Remove. This. Again.
// Problem is that implode respects locales when casting floats. This means
// that implode(',', array(1.1, 1.2)) would read '1,1,1,2'.
$data = array();
foreach ($this->data as $dat) {
$data[] = sprintf('%F', $dat);
}
// values
$formatted = array();
foreach ($this->data as $key => $value) {
$formatted[$key] = $this->formatValue($value);
}
$template = str_replace('{data}', htmlspecialchars(implode(',', $this->data)), $template);
$template = str_replace('{data}', htmlspecialchars(implode(',', $data)), $template);
$template = str_replace('{formatted}', htmlspecialchars(implode('|', $formatted)), $template);
$template = str_replace('{labels}', htmlspecialchars($this->createLabelString()), $template);
$template = str_replace('{tooltipFormat}', $this->tooltipFormat, $template);