File size: 1,856 Bytes
e852054 | 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 | <?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\AnonymousPiwikUsageMeasurement\Tracker;
use Piwik\Common;
use Piwik\Plugins\AnonymousPiwikUsageMeasurement\SystemSettings;
use Piwik\SettingsPiwik;
use Piwik\Tests\Framework\Fixture;
/**
* Defines Settings for AnonymousPiwikUsageMeasurement.
*/
class Targets
{
/**
* @var SystemSettings
*/
private $settings;
public function __construct(SystemSettings $settings)
{
$this->settings = $settings;
}
public function getTargets()
{
$targets = array();
$ownSiteId = $this->settings->ownPiwikSiteId->getValue();
if ($ownSiteId) {
$piwikUrl = SettingsPiwik::getPiwikUrl();
if (!Common::stringEndsWith($piwikUrl, '/')) {
$piwikUrl .= '/';
}
$targets[] = array(
'url' => $piwikUrl . 'matomo.php',
'idSite' => (int) $ownSiteId,
'useAnonymization' => $this->settings->anonymizeSelfPiwik->getValue()
);
}
$customUrl = $this->settings->customPiwikSiteUrl->getValue();
$customSiteId = $this->settings->customPiwikSiteId->getValue();
if ($customUrl && $customSiteId) {
$targets[] = array(
'url' => $customUrl,
'idSite' => (int) $customSiteId,
'useAnonymization' => $this->settings->anonymizeCustomPiwik->getValue()
);
}
if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE && Common::isPhpCliMode()) {
foreach ($targets as &$target) {
$target['token_auth'] = Fixture::getTokenAuth();
}
}
return $targets;
}
}
|