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
|
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
* @package Transitions
*/
namespace Piwik\Plugins\Transitions;
use Piwik\View;
/**
* @package Transitions
*/
class Controller extends \Piwik\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_PageviewsInline',
'loopsInline' => 'Transitions_LoopsInline',
'fromPreviousPages' => 'Transitions_FromPreviousPages',
'fromPreviousPagesInline' => 'Transitions_FromPreviousPagesInline',
'fromPreviousSiteSearches' => 'Transitions_FromPreviousSiteSearches',
'fromPreviousSiteSearchesInline' => 'Transitions_FromPreviousSiteSearchesInline',
'fromSearchEngines' => 'Transitions_FromSearchEngines',
'fromSearchEnginesInline' => 'Transitions_FromSearchEnginesInline',
'fromWebsites' => 'Transitions_FromWebsites',
'fromWebsitesInline' => 'Transitions_FromWebsitesInline',
'fromCampaigns' => 'Transitions_FromCampaigns',
'fromCampaignsInline' => 'Transitions_FromCampaignsInline',
'directEntries' => 'Transitions_DirectEntries',
'directEntriesInline' => 'Referers_TypeDirectEntries',
'toFollowingPages' => 'Transitions_ToFollowingPages',
'toFollowingPagesInline' => 'Transitions_ToFollowingPagesInline',
'toFollowingSiteSearches' => 'Transitions_ToFollowingSiteSearches',
'toFollowingSiteSearchesInline' => 'Transitions_ToFollowingSiteSearchesInline',
'downloads' => 'General_Downloads',
'downloadsInline' => 'VisitsSummary_NbDownloadsDescription',
'outlinks' => 'General_Outlinks',
'outlinksInline' => 'VisitsSummary_NbOutlinksDescription',
'exits' => 'General_ColumnExits',
'exitsInline' => 'Transitions_ExitsInline',
'bouncesInline' => 'Transitions_BouncesInline'
);
/**
* Translations that are added to JS
* (object Piwik_Transitions_Translations)
*/
private static $jsTranslations = array(
'XOfY' => 'Transitions_XOutOfYVisits',
'XOfAllPageviews' => 'Transitions_XOfAllPageviews',
'NoDataForAction' => 'Transitions_NoDataForAction',
'NoDataForActionDetails' => 'Transitions_NoDataForActionDetails',
'NoDataForActionBack' => '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();
echo $view->render();
}
public function getTranslations()
{
$translations = self::$metricTranslations + self::$jsTranslations;
foreach ($translations as &$message) {
$message = Piwik_Translate($message);
}
return $translations;
}
}
|