Added simple currency modifier
authorMarcel Werk <burntime@woltlab.com>
Tue, 20 Aug 2013 16:46:58 +0000 (18:46 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 20 Aug 2013 16:46:58 +0000 (18:46 +0200)
wcfsetup/install/files/lib/system/template/plugin/CurrencyModifierTemplatePlugin.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/template/plugin/CurrencyModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/CurrencyModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..f35997a
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\WCF;
+
+/**
+ * Formats a currency value.
+ * 
+ * Usage:
+ *     {$float|currency}
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class CurrencyModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               return number_format(round($tagArgs[0], 2), 2, WCF::getLanguage()->get('wcf.global.decimalPoint'), WCF::getLanguage()->get('wcf.global.thousandsSeparator'));
+       }
+}