From 55ca66fe6d22984343b5c12c803909780e3646d3 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 13 Nov 2024 14:14:48 +0100 Subject: [PATCH] Add column renderer for currencies --- .../renderer/CurrencyColumnRenderer.class.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php diff --git a/wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php b/wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php new file mode 100644 index 0000000000..6c07c28cd0 --- /dev/null +++ b/wcfsetup/install/files/lib/system/gridView/renderer/CurrencyColumnRenderer.class.php @@ -0,0 +1,38 @@ + + * @since 6.2 + */ +class CurrencyColumnRenderer extends AbstractColumnRenderer +{ + public function __construct( + private readonly string $currency, + ) {} + + #[\Override] + public function render(mixed $value, mixed $context = null): string + { + return \number_format( + \round($value, 2), + 2, + WCF::getLanguage()->get('wcf.global.decimalPoint'), + WCF::getLanguage()->get('wcf.global.thousandsSeparator') + ) . ' ' . StringUtil::encodeHTML($this->currency); + } + + #[\Override] + public function getClasses(): string + { + return 'gridView__column--digits'; + } +} -- 2.20.1