diff options
author | diosmosis <benaka@piwik.pro> | 2014-11-14 05:22:49 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-11-14 05:22:49 +0300 |
commit | 545d316d4dad434edfe5048807bfbe686f856259 (patch) | |
tree | 2f82ab2c064539c0624b7496ccfd41398dee75db /core/Plugin/Visualization.php | |
parent | f57473c98324fa6026c4e7776f30c104d81d0989 (diff) |
Make MetricsFormatter a class with instance methods and move Html related functionality to derived class. Use FOrmatter in Metric::format calls so Metrics do not have to be aware of context of formatting, and so Metric::format methods will have less code redundancy.
Diffstat (limited to 'core/Plugin/Visualization.php')
-rw-r--r-- | core/Plugin/Visualization.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php index 74cd2950fd..5674b189c9 100644 --- a/core/Plugin/Visualization.php +++ b/core/Plugin/Visualization.php @@ -14,7 +14,7 @@ use Piwik\Common; use Piwik\DataTable; use Piwik\Date; use Piwik\Log; -use Piwik\MetricsFormatter; +use Piwik\Metrics\Formatter\Html as HtmlFormatter; use Piwik\NoAccessException; use Piwik\Option; use Piwik\Period; @@ -144,6 +144,7 @@ class Visualization extends ViewDataTable private $templateVars = array(); private $reportLastUpdatedMessage = null; private $metadata = null; + protected $metricsFormatter = null; final public function __construct($controllerAction, $apiMethodToRequestDataTable, $params = array()) { @@ -153,6 +154,8 @@ class Visualization extends ViewDataTable throw new \Exception('You have not defined a constant named TEMPLATE_FILE in your visualization class.'); } + $this->metricsFormatter = new HtmlFormatter(); + parent::__construct($controllerAction, $apiMethodToRequestDataTable, $params); } @@ -367,7 +370,7 @@ class Visualization extends ViewDataTable $this->dataTable->applyQueuedFilters(); } - $postProcessor->applyProcessedMetricsFormatting($this->dataTable); + $postProcessor->applyProcessedMetricsFormatting($this->dataTable, $this->metricsFormatter); } private function removeEmptyColumnsFromDisplay() @@ -402,9 +405,8 @@ class Visualization extends ViewDataTable $today = mktime(0, 0, 0); if ($date->getTimestamp() > $today) { - $elapsedSeconds = time() - $date->getTimestamp(); - $timeAgo = MetricsFormatter::getPrettyTimeFromSeconds($elapsedSeconds); + $timeAgo = $this->metricsFormatter->getPrettyTimeFromSeconds($elapsedSeconds); return Piwik::translate('CoreHome_ReportGeneratedXAgo', $timeAgo); } |