diff options
Diffstat (limited to 'plugins/Goals/Reports/Get.php')
-rw-r--r-- | plugins/Goals/Reports/Get.php | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php index d7180547f0..b6842b1722 100644 --- a/plugins/Goals/Reports/Get.php +++ b/plugins/Goals/Reports/Get.php @@ -40,10 +40,32 @@ class Get extends Base $this->parameters = null; } + private function getGoals() + { + $idSite = $this->getIdSite(); + $goals = API::getInstance()->getGoals($idSite); + return $goals; + } + + private function getGoal($goalId) + { + $goals = $this->getGoals(); + + if (!empty($goals[$goalId])) { + + return $goals[$goalId]; + } + } + public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { - $idSite = $this->getIdSite(); - $goals = API::getInstance()->getGoals($idSite); + $idSite = Common::getRequestVar('idSite', 0, 'int'); + + if (empty($idSite)) { + return; + } + + $goals = $this->getGoals(); $reports = Goals::getReportsWithGoalMetrics(); $page = new Pages($factory, $reports); @@ -77,12 +99,24 @@ class Get extends Base public function configureView(ViewDataTable $view) { + $idGoal = Common::getRequestVar('idGoal', 0, 'string'); + if ($view->isViewDataTableId(Sparklines::ID)) { /** @var Sparklines $view */ $idSite = $this->getIdSite(); $isEcommerceEnabled = $this->isEcommerceEnabled($idSite); - $idGoal = Common::getRequestVar('idGoal', 0, 'int'); + $onlySummary = Common::getRequestVar('only_summary', 0, 'int'); + + if ($onlySummary && !empty($idGoal)) { + // in Goals overview summary we show proper title for a goal + $goal = $this->getGoal($idGoal); + if (!empty($goal['name'])) { + $view->config->title = Piwik::translate('Goals_GoalX', "'" . $goal['name'] . "'"); + } + } else { + $view->config->title = ''; + } $numberFormatter = NumberFormatter::getInstance(); $view->config->filters[] = function (DataTable $table) use ($numberFormatter, $idSite) { @@ -138,8 +172,6 @@ class Get extends Base } } else { - $onlySummary = Common::getRequestVar('only_summary', 0, 'int'); - if ($onlySummary) { // in Goals Overview we list an overview for each goal.... $view->config->addTranslation('conversion_rate', Piwik::translate('Goals_ConversionRate')); @@ -150,6 +182,13 @@ class Get extends Base } } } else if ($view->isViewDataTableId(Evolution::ID)) { + $goal = $this->getGoal($idGoal); + if (!empty($goal['name'])) { + $view->config->title = Piwik::translate('Goals_GoalX', "'" . $goal['name'] . "'"); + } else { + $view->config->title = Piwik::translate('General_EvolutionOverPeriod'); + } + if (empty($view->config->columns_to_display)) { $view->config->columns_to_display = array('nb_conversions'); } |