| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\ProfessionalServices; |
|
|
| use Piwik\Plugin; |
| use Piwik\Config; |
| use Piwik\Url; |
|
|
| |
| |
| |
| |
| |
| |
| |
| class Advertising |
| { |
| public const CAMPAIGN_NAME_PROFESSIONAL_SERVICES = 'App_ProfessionalServices'; |
|
|
| |
| |
| |
| private $pluginManager; |
|
|
| |
| |
| |
| private $config; |
|
|
| public function __construct(Plugin\Manager $pluginManager, Config $config) |
| { |
| $this->pluginManager = $pluginManager; |
| $this->config = $config; |
| } |
|
|
| |
| |
| |
| |
| public function areAdsForProfessionalServicesEnabled() |
| { |
| return self::isAdsEnabledInConfig($this->config->General); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function getPromoUrlForProfessionalServices($campaignMedium, $campaignContent = '') |
| { |
| return Url::addCampaignParametersToMatomoLink( |
| 'https://matomo.org/support-plans/', |
| self::CAMPAIGN_NAME_PROFESSIONAL_SERVICES, |
| null, |
| $campaignMedium |
| ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public function addPromoCampaignParametersToUrl($url, $campaignName, $campaignMedium, $campaignContent = '', $campaignSource = null) |
| { |
| if (empty($url)) { |
| return ''; |
| } |
|
|
| return Url::addCampaignParametersToMatomoLink($url, $campaignName, $campaignSource, $campaignMedium . |
| ($campaignContent !== '' ? '.' . $campaignContent : '')); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| private function getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent = '') |
| { |
| $campaignName = sprintf('pk_campaign=%s&pk_medium=%s&pk_source=Matomo_App', $campaignName, $campaignMedium); |
|
|
| if (!empty($campaignContent)) { |
| $campaignName .= '&pk_content=' . $campaignContent; |
| } |
|
|
| return $campaignName; |
| } |
|
|
| |
| |
| |
| |
| public static function isAdsEnabledInConfig($configGeneralSection) |
| { |
| $oldSettingValue = false; |
| if (isset($configGeneralSection['piwik_pro_ads_enabled'])) { |
| $oldSettingValue = @$configGeneralSection['piwik_pro_ads_enabled']; |
| } |
| $newSettingValue = @$configGeneralSection['piwik_professional_support_ads_enabled']; |
| return (bool) ($newSettingValue || $oldSettingValue); |
| } |
| } |
|
|