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

Controller.php « Transitions « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a8a85e011564c4c2e4e75159543901ebe6c8dc36 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */
namespace Piwik\Plugins\Transitions;

use Piwik\Piwik;
use Piwik\View;

/**
 */
class Controller extends \Piwik\Plugin\Controller
{
    /**
     * Since the metric translations are taken from different plugins,
     * it makes the rest of the code easier to read and maintain when we
     * use this indirection to map between the metrics and the actual
     * translation keys.
     */
    private static $metricTranslations = array(
        'pageviewsInline'                => 'Transitions_NumPageviews',
        'loopsInline'                    => 'Transitions_LoopsInline',
        'fromPreviousPages'              => 'Transitions_FromPreviousPages',
        'fromPreviousPagesInline'        => 'Transitions_FromPreviousPagesInline',
        'fromPreviousSiteSearches'       => 'Transitions_FromPreviousSiteSearches',
        'fromPreviousSiteSearchesInline' => 'Transitions_FromPreviousSiteSearchesInline',
        'fromSearchEngines'              => 'Transitions_FromSearchEngines',
        'fromSearchEnginesInline'        => 'Referrers_TypeSearchEngines',
        'fromSocialNetworks'             => 'Transitions_FromSocialNetworks',
        'fromSocialNetworksInline'       => 'Referrers_TypeSocialNetworks',
        'fromWebsites'                   => 'Transitions_FromWebsites',
        'fromWebsitesInline'             => 'Referrers_TypeWebsites',
        'fromCampaigns'                  => 'Transitions_FromCampaigns',
        'fromCampaignsInline'            => 'Referrers_TypeCampaigns',
        'directEntries'                  => 'Transitions_DirectEntries',
        'directEntriesInline'            => 'Referrers_TypeDirectEntries',
        'toFollowingPages'               => 'Transitions_ToFollowingPages',
        'toFollowingPagesInline'         => 'Transitions_ToFollowingPagesInline',
        'toFollowingSiteSearches'        => 'Transitions_ToFollowingSiteSearches',
        'toFollowingSiteSearchesInline'  => 'Transitions_ToFollowingSiteSearchesInline',
        'downloads'                      => 'General_Downloads',
        'downloadsInline'                => 'Transitions_NumDownloads',
        'outlinks'                       => 'General_Outlinks',
        'outlinksInline'                 => 'Transitions_NumOutlinks',
        'exits'                          => 'General_ColumnExits',
        'exitsInline'                    => 'Transitions_ExitsInline',
        'bouncesInline'                  => 'Transitions_BouncesInline'
    );

    /**
     * Translations that are added to JS
     */
    private static $jsTranslations = array(
        'XOfY'                   => 'Transitions_XOutOfYVisits',
        'XOfAllPageviews'        => 'Transitions_XOfAllPageviews',
        'NoDataForAction'        => 'Transitions_NoDataForAction',
        'NoDataForActionDetails' => 'Transitions_NoDataForActionDetails',
        'NoDataForActionBack'    => 'Transitions_ErrorBack',
        'PeriodNotAllowed'       => 'Transitions_PeriodNotAllowed',
        'PeriodNotAllowedDetails'=> 'Transitions_PeriodNotAllowedDetails',
        'PeriodNotAllowedBack'   => 'Transitions_ErrorBack',
        'ShareOfAllPageviews'    => 'Transitions_ShareOfAllPageviews',
        'DateRange'              => 'General_DateRange'
    );

    public static function getTranslation($key)
    {
        return Piwik::translate(self::$metricTranslations[$key]);
    }

    /**
     * The main method of the plugin.
     * It is triggered from the Transitions data table action.
     */
    public function renderPopover()
    {
        $view = new View('@Transitions/renderPopover');
        $view->translations = $this->getTranslations();
        return $view->render();
    }

    public function getTranslations()
    {
        $translations = self::$metricTranslations + self::$jsTranslations;
        foreach ($translations as &$message) {
            $message = Piwik::translate($message);
        }
        return $translations;
    }
}