diff --git a/core/Metrics.php b/core/Metrics.php index 03f486653c0c02cdc3a0d243fdd8f02cd2e7c4db..b576ea7c9fa3ac117e73dba59b71dbc7d0060623 100644 --- a/core/Metrics.php +++ b/core/Metrics.php @@ -323,7 +323,7 @@ class Metrics static public function getDefaultMetricsDocumentation() { - $documentation = array( + $translations = array( 'nb_visits' => 'General_ColumnNbVisitsDocumentation', 'nb_uniq_visitors' => 'General_ColumnNbUniqVisitorsDocumentation', 'nb_actions' => 'General_ColumnNbActionsDocumentation', @@ -336,7 +336,14 @@ class Metrics 'exit_rate' => 'General_ColumnExitRateDocumentation' ); - return array_map(array('\\Piwik\\Piwik','translate'), $documentation); + /** + * Use this event to register translations for metrics documentation processed by your plugin. + * + * @param string[] $translations The array mapping of column_name => Plugin_TranslationForColumnDocumentation + */ + Piwik::postEvent('Metrics.getDefaultMetricDocumentationTranslations', array(&$translations)); + + return array_map(array('\\Piwik\\Piwik','translate'), $translations); } public static function getPercentVisitColumn() diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php index bf6035a2890dabfa5a667d92ed29e3cae198c55e..b7a288740ebdb5e0aa76a3f75d243960bea5c337 100644 --- a/core/Plugin/Report.php +++ b/core/Plugin/Report.php @@ -152,33 +152,35 @@ class Report 'category' => $this->category, 'name' => $this->name, 'module' => $this->module, - 'action' => $this->action, - 'metrics' => $this->getMetrics(), - 'metricsDocumentation' => $this->getMetricsDocumentation(), - 'processedMetrics' => $this->processedMetrics, - 'order' => $this->order + 'action' => $this->action ); - if (!empty($this->documentation)) { - $report['documentation'] = $this->documentation; + if (!empty($this->dimension)) { + $report['dimension'] = $this->dimension->getName(); } - if (null !== $this->constantRowsCount) { - $report['constantRowsCount'] = $this->constantRowsCount; + if (!empty($this->documentation)) { + $report['documentation'] = $this->documentation; } if (null !== $this->isSubtableReport) { $report['isSubtableReport'] = $this->isSubtableReport; } - if (!empty($this->dimension)) { - $report['dimension'] = $this->dimension->getName(); - } + $report['metrics' ] = $this->getMetrics(); + $report['metricsDocumentation'] = $this->getMetricsDocumentation(); + $report['processedMetrics' ] = $this->processedMetrics; if (!empty($this->actionToLoadSubTables)) { $report['actionToLoadSubTables'] = $this->actionToLoadSubTables; } + if (null !== $this->constantRowsCount) { + $report['constantRowsCount'] = $this->constantRowsCount; + } + + $report['order'] = $this->order; + return $report; } diff --git a/plugins/Events/Events.php b/plugins/Events/Events.php index 32012c57daf5894ceab3e57fd68458069e5a6c5e..60e4de33795d3ff07e698157411a87433a34bc93 100644 --- a/plugins/Events/Events.php +++ b/plugins/Events/Events.php @@ -19,7 +19,8 @@ class Events extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations' + 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations', + 'Metrics.getDefaultMetricDocumentationTranslations' => 'addMetricDocumentationTranslations' ); } @@ -28,6 +29,11 @@ class Events extends \Piwik\Plugin $translations = array_merge($translations, $this->getMetricTranslations()); } + public function addMetricDocumentationTranslations(&$translations) + { + $translations = array_merge($translations, $this->getMetricDocumentation()); + } + public function getMetricDocumentation() { $documentation = array(