From 7112ed23f46219a4e60bc64dfea0f9c1c54c9ffa Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 25 Jun 2014 22:13:19 +0200 Subject: [PATCH] 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 --- library/Icinga/Web/Widget/Chart/InlinePie.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index e19310d49..bac2aa595 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -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);