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

Widgets.php « Goals « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bdfa47a924fb9499dc8adba46e67802bf89c7d18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */
namespace Piwik\Plugins\Goals;

use Piwik\WidgetsList;
use Piwik\Common;
use Piwik\Site;
use Piwik\Piwik;

class Widgets extends \Piwik\Plugin\Widgets
{
    public function configure(WidgetsList $widgetsList)
    {
        $idSite = Common::getRequestVar('idSite', null, 'int');

        $site  = new Site($idSite);
        if ($site->isEcommerceEnabled()) {
            $this->addEcommerceWidgets($widgetsList);
        }

        $this->addGoalsWidgets($widgetsList, $idSite);
    }

    private function addEcommerceWidgets(WidgetsList $widgetsList)
    {
        $goals = new Goals();

        $widgetsList->add('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER));
        $widgetsList->add('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog');
        foreach ($goals->getEcommerceReports() as $widget) {
            $widgetsList->add('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]);
        }
    }

    private function addGoalsWidgets(WidgetsList $widgetsList, $idSite)
    {
        $widgetsList->add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview');

        $goals = API::getInstance()->getGoals($idSite);
        if (count($goals) > 0) {
            foreach ($goals as $goal) {
                $widgetsList->add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal']));
            }
        }
    }

}