From 4793bc774656c59df6a48eed239f72718570ac35 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Wed, 20 Nov 2013 03:40:08 +0000 Subject: refs #1816 do not create metrics for ratio, instead add total values to tableMetadata and generate ratio in view --- core/Twig.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/Twig.php') diff --git a/core/Twig.php b/core/Twig.php index 01282ef35d..69a6501d90 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -65,6 +65,7 @@ class Twig $this->addFilter_money(); $this->addFilter_truncate(); $this->addFilter_notificiation(); + $this->addFilter_percentage(); $this->twig->addFilter(new Twig_SimpleFilter('implode', 'implode')); $this->twig->addFilter(new Twig_SimpleFilter('ucwords', 'ucwords')); @@ -187,6 +188,14 @@ class Twig $this->twig->addFilter($notificationFunction); } + protected function addFilter_percentage() + { + $percentage = new Twig_SimpleFilter('percentage', function ($string, $totalValue, $precision = 1) { + return Piwik::getPercentageSafe($string, $totalValue, $precision) . '%'; + }); + $this->twig->addFilter($percentage); + } + protected function addFilter_truncate() { $truncateFilter = new Twig_SimpleFilter('truncate', function ($string, $size) { -- cgit v1.2.3