Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2014-11-13 12:45:05 +0300
committerdiosmosis <benaka@piwik.pro>2014-11-13 12:45:05 +0300
commite596b71231113941b43809e0adc9af608e797645 (patch)
treebbe492d166839be95976eed16c965786d9084f42 /core/Plugin/Visualization.php
parentd07d24c59780587c58727a5295951a2dfcb8fc58 (diff)
Move goal translations and metric docs to metric classes from Goals visualization. Allow these values as defaults for translations in visualizations, and fix a bug in GoalsTable where sort was improperly applied if no data was in the data table. Also include in-memory caching for Goals.getGoals API method.
Diffstat (limited to 'core/Plugin/Visualization.php')
-rw-r--r--core/Plugin/Visualization.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php
index 0ea725e9f2..74cd2950fd 100644
--- a/core/Plugin/Visualization.php
+++ b/core/Plugin/Visualization.php
@@ -170,6 +170,7 @@ class Visualization extends ViewDataTable
$requestPropertiesAfterLoadDataTable = $this->requestConfig->getProperties();
$this->applyFilters();
+ $this->addVisualizationInfoFromMetricMetadata();
$this->afterAllFiltersAreApplied();
$this->beforeRender();
@@ -307,6 +308,28 @@ class Visualization extends ViewDataTable
}
}
+ private function addVisualizationInfoFromMetricMetadata()
+ {
+ $report = Report::factory($this->requestConfig->getApiModuleToRequest(), $this->requestConfig->getApiMethodToRequest());
+ $dataTable = $this->dataTable instanceof DataTable\Map ? $this->dataTable->getFirstRow() : $this->dataTable;
+
+ $processedMetrics = Report::getProcessedMetricsFor($dataTable, $report);
+
+ // TODO: instead of iterating & calling translate everywhere, maybe we can get all translated names in one place.
+ // may be difficult, though, since translated metrics are specific to the report.
+ foreach ($processedMetrics as $metric) {
+ $name = $metric->getName();
+
+ if (empty($this->config->translations[$name])) {
+ $this->config->translations[$name] = $metric->getTranslatedName();
+ }
+
+ if (empty($this->config->metrics_documentation[$name])) {
+ $this->config->metrics_documentation[$name] = $metric->getDocumentation();
+ }
+ }
+ }
+
private function applyFilters()
{
$postProcessor = $this->makeDataTablePostProcessor();
@@ -343,6 +366,8 @@ class Visualization extends ViewDataTable
if (!$this->requestConfig->areQueuedFiltersDisabled()) {
$this->dataTable->applyQueuedFilters();
}
+
+ $postProcessor->applyProcessedMetricsFormatting($this->dataTable);
}
private function removeEmptyColumnsFromDisplay()