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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\SitesManager\SiteContentDetection;
use Piwik\Piwik;
use Piwik\SiteContentDetector;
abstract class SiteContentDetectionAbstract
{
public const TYPE_TRACKER = 1;
public const TYPE_CMS = 2;
public const TYPE_JS_FRAMEWORK = 3;
public const TYPE_CONSENT_MANAGER = 4;
public const TYPE_JS_CRASH_ANALYTICS = 5;
public const TYPE_OTHER = 99;
public function __construct()
{
}
/**
* Returns the ID of the current detection. Automatically built from the class name (without namespace)
*
*/
public static function getId(): string
{
$classParts = explode('\\', static::class);
return end($classParts);
}
/**
* Returns the Name of this detection (e.g. name of CMS, Framework, ...)
*
*/
abstract public static function getName(): string;
/**
* Returns the location of the icon of this detection
*
*/
public static function getIcon(): string
{
return '';
}
/**
* Returns the content type this detection provides
* May be one of TYPE_TRACKER, TYPE_CMS, TYPE_JS_FRAMEWORK, TYPE_CONSENT_MANAGER
*
*/
abstract public static function getContentType(): int;
/**
* Returns the URL to the instruction FAQ on how to integrate Matomo (if applicable)
*
*/
public static function getInstructionUrl(): ?string
{
return null;
}
/**
* Returns the priority the tab should be displayed with.
*
*/
public static function getPriority(): int
{
return 1000;
}
/**
* Returns if the current detection succeeded for the provided site content or not.
*
* @param array<string,string>|null $headers
*/
abstract public function isDetected(?string $data = null, ?array $headers = null): bool;
/**
* Returns the content that should be rendered into a new Tab on the no data page
*
*/
public function renderInstructionsTab(SiteContentDetector $detector): string
{
return '';
}
/**
* Returns the content that should be displayed in the Others tab on the no data page
*
*/
public function renderOthersInstruction(SiteContentDetector $detector): string
{
return '';
}
/**
* Returns if the method should be recommended. Returns true if the method was detected
*
*/
public function isRecommended(SiteContentDetector $detector): bool
{
return $detector->wasDetected(static::getId());
}
/**
* Returns details used to render the recommendation on no data screen
*
* @return array{title: string, text: string, button: string}
*/
public function getRecommendationDetails(SiteContentDetector $detector): array
{
return [
'title' => Piwik::translate('SitesManager_SiteWithoutDataInstallWithXRecommendation', [static::getName()]),
'text' => Piwik::translate('SitesManager_SiteWithoutDataRecommendationText', [static::getName()]),
'button' => Piwik::translate('SitesManager_SiteWithoutDataInstallWithX', [static::getName()]),
];
}
}
|