|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://dukt.net/analytics/ |
|
4
|
|
|
* @copyright Copyright (c) 2022, Dukt |
|
5
|
|
|
* @license https://github.com/dukt/analytics/blob/master/LICENSE.md |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace dukt\analytics\controllers; |
|
9
|
|
|
|
|
10
|
|
|
use Craft; |
|
11
|
|
|
use craft\helpers\Json; |
|
12
|
|
|
use craft\web\Controller; |
|
13
|
|
|
use craft\web\View; |
|
14
|
|
|
use dukt\analytics\Plugin as Analytics; |
|
15
|
|
|
use dukt\analytics\web\assets\tests\TestsAsset; |
|
16
|
|
|
use yii\web\Response; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class TestsController |
|
20
|
|
|
* |
|
21
|
|
|
* @package dukt\analytics\controllers |
|
22
|
|
|
*/ |
|
23
|
|
|
class TestsController extends Controller |
|
24
|
|
|
{ |
|
25
|
|
|
// Public Methods |
|
26
|
|
|
// ========================================================================= |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Columns |
|
30
|
|
|
* |
|
31
|
|
|
* @param array $variables |
|
32
|
|
|
* |
|
33
|
|
|
* @return Response |
|
34
|
|
|
*/ |
|
35
|
|
|
public function actionColumns(array $variables = []) |
|
36
|
|
|
{ |
|
37
|
|
|
$variables['columns'] = Analytics::$plugin->metadata->getColumns(); |
|
38
|
|
|
|
|
39
|
|
|
return $this->renderTemplate('analytics/tests/_columns', $variables); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Column Groups |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $variables |
|
46
|
|
|
* |
|
47
|
|
|
* @return Response |
|
48
|
|
|
*/ |
|
49
|
|
|
public function actionColumnGroups(array $variables = []) |
|
50
|
|
|
{ |
|
51
|
|
|
$variables['columnGroups'] = Analytics::$plugin->metadata->getColumnGroups(); |
|
52
|
|
|
|
|
53
|
|
|
return $this->renderTemplate('analytics/tests/_columnGroups', $variables); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Data Types |
|
58
|
|
|
* |
|
59
|
|
|
* @param array $variables |
|
60
|
|
|
* |
|
61
|
|
|
* @return Response |
|
62
|
|
|
*/ |
|
63
|
|
|
public function actionDataTypes(array $variables = []) |
|
64
|
|
|
{ |
|
65
|
|
|
$variables['googleAnalyticsDataTypes'] = Analytics::$plugin->metadata->getGoogleAnalyticsDataTypes(); |
|
66
|
|
|
$variables['dataTypes'] = Analytics::$plugin->metadata->getDataTypes(); |
|
67
|
|
|
|
|
68
|
|
|
return $this->renderTemplate('analytics/tests/_dataTypes', $variables); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Formatting |
|
73
|
|
|
* |
|
74
|
|
|
* @param array $variables |
|
75
|
|
|
* |
|
76
|
|
|
* @return Response |
|
77
|
|
|
*/ |
|
78
|
|
|
public function actionFormatting(array $variables = []) |
|
79
|
|
|
{ |
|
80
|
|
|
$currencyDefinition = Analytics::$plugin->getAnalytics()->getCurrencyDefinition(); |
|
81
|
|
|
|
|
82
|
|
|
$js = 'AnalyticsCurrencyDefinition = '.Json::encode($currencyDefinition).';'; |
|
83
|
|
|
|
|
84
|
|
|
Craft::$app->getView()->registerJs($js, View::POS_BEGIN); |
|
85
|
|
|
|
|
86
|
|
|
return $this->renderTemplate('analytics/tests/_formatting', $variables); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Report Widgets |
|
91
|
|
|
* |
|
92
|
|
|
* @param array $variables |
|
93
|
|
|
* |
|
94
|
|
|
* @return Response |
|
95
|
|
|
*/ |
|
96
|
|
|
public function actionReportWidgets(array $variables = []) |
|
97
|
|
|
{ |
|
98
|
|
|
Craft::$app->getView()->registerAssetBundle(TestsAsset::class); |
|
99
|
|
|
|
|
100
|
|
|
return $this->renderTemplate('analytics/tests/_reportWidgets', $variables); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Template Variables |
|
105
|
|
|
* |
|
106
|
|
|
* @param array $variables |
|
107
|
|
|
* |
|
108
|
|
|
* @return Response |
|
109
|
|
|
*/ |
|
110
|
|
|
public function actionTemplateVariables(array $variables = []) |
|
111
|
|
|
{ |
|
112
|
|
|
Craft::$app->getView()->registerAssetBundle(TestsAsset::class); |
|
113
|
|
|
|
|
114
|
|
|
return $this->renderTemplate('analytics/tests/_templateVariables', $variables); |
|
115
|
|
|
} |
|
116
|
|
|
} |