-
Notifications
You must be signed in to change notification settings - Fork 1
/
Helpers.php
74 lines (60 loc) · 2.06 KB
/
Helpers.php
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
<?php
namespace Piwik\Plugins\SimpleABTesting;
use Piwik\Common;
use Piwik\Url;
use Piwik\Site;
trait Helpers
{
private function getCustomUrl($period = null, $date = null, $category = null, $subcategory = null)
{
$baseUrl = Url::getCurrentUrlWithoutFileName();
$idSite = Common::getRequestVar('idSite', 1, 'int');
$period = $period ?? Common::getRequestVar('period');
$date = $date ?? Common::getRequestVar('date');
$category = $category ?? 'SimpleABTesting_Tests';
$subcategory = $subcategory ?? 'General_Overview';
$params = [
'module' => 'CoreHome',
'action' => 'index',
'idSite' => $idSite,
'period' => $period,
'date' => $date,
];
return $baseUrl . 'index.php?' . http_build_query($params) . '#' . http_build_query($params) . '&category=' . $category .'&subcategory=' . $subcategory;
}
private function getCustomDimensionsUrl()
{
$baseUrl = Url::getCurrentUrlWithoutFileName();
$idSite = Common::getRequestVar('idSite', 1, 'int');
$params = [
'module' => 'CustomDimensions',
'action' => 'manage',
'idSite' => $idSite,
'period' => 'day',
'date' => 'today'
];
return $baseUrl . 'index.php?' . http_build_query($params);
}
private function getHost($url)
{
$url = str_replace("https://", "", $url);
$url = str_replace("http://", "", $url);
return $url;
}
private function getDomain($url)
{
$url = $this->getHost($url);
$url = str_replace("www.", "", $url);
return $url;
}
/**
* Method that gets the domain, extracted from the main url, by id
* @param int $idSite
* @return string The domain
*/
private function getSiteDomainFromId($idSite)
{
$site = new Site($idSite);
return str_replace("www.", "", str_replace("https://", "", str_replace("http://", "", $site->getMainUrl())));
}
}