contrib modules updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
Module: Matomo Analytics
|
||||
Author: Alexander Hass <http://drupal.org/user/85918>
|
||||
Author: Alexander Hass <https://drupal.org/user/85918>
|
||||
|
||||
|
||||
Description
|
||||
@@ -46,7 +46,7 @@ user with 'Administer Matomo' permission.
|
||||
Like the blocks visibility settings in Drupal core, there is a choice for
|
||||
"Add if the following PHP code returns TRUE." Sample PHP snippets that can be
|
||||
used in this textarea can be found on the handbook page "Overview-approach to
|
||||
block visibility" at http://drupal.org/node/64135.
|
||||
block visibility" at https://drupal.org/node/64135.
|
||||
|
||||
Custom variables
|
||||
=================
|
||||
@@ -65,7 +65,7 @@ Value: [current-user:matomo-role-ids]
|
||||
Scope: Visitor
|
||||
|
||||
More details about custom variables can be found in the Matomo API documentation
|
||||
at http://matomo.org/docs/javascript-tracking/#toc-custom-variables.
|
||||
at https://matomo.org/docs/javascript-tracking/#toc-custom-variables.
|
||||
|
||||
|
||||
Advanced Settings
|
||||
@@ -80,7 +80,7 @@ file locally.
|
||||
|
||||
Known issues
|
||||
============
|
||||
Drupal requirements (http://drupal.org/requirements) tell you to configure
|
||||
Drupal requirements (https://drupal.org/requirements) tell you to configure
|
||||
PHP with "session.save_handler = user", but your Matomo installation may
|
||||
not work with this configuration and gives you a server error 500.
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://www.drupal.org/project/issues/matomo",
|
||||
"source": "http://git.drupal.org/project/matomo.git"
|
||||
"source": "https://git.drupal.org/project/matomo.git"
|
||||
},
|
||||
"license": "GPL-2.0+",
|
||||
"require": {}
|
||||
"require": {
|
||||
"drupal/core": "~8.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ description: "Adds Matomo javascript tracking code to all your site's pages."
|
||||
package: Statistics
|
||||
# core: 8.x
|
||||
configure: matomo.admin_settings_form
|
||||
dependencies:
|
||||
- drupal:system (>= 8.5)
|
||||
test_dependencies:
|
||||
- php:php
|
||||
- token:token
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-07-13
|
||||
version: '8.x-1.7'
|
||||
# Information added by Drupal.org packaging script on 2019-02-08
|
||||
version: '8.x-1.9'
|
||||
core: '8.x'
|
||||
project: 'matomo'
|
||||
datestamp: 1531470224
|
||||
datestamp: 1549615102
|
||||
|
||||
@@ -17,7 +17,8 @@ function matomo_install() {
|
||||
$role->grantPermission('opt-in or out of matomo tracking');
|
||||
$success = $role->save();
|
||||
if ($success) {
|
||||
drupal_set_message(t('Module %module granted %permission permission to authenticated users.', ['%module' => 'Matomo Analytics', '%permission' => t('Opt-in or out of tracking')]), 'status');
|
||||
$messenger = \Drupal::messenger();
|
||||
$messenger->addMessage(t('Module %module granted %permission permission to authenticated users.', ['%module' => 'Matomo Analytics', '%permission' => t('Opt-in or out of tracking')]), 'status');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Adds the required Javascript to all your Drupal pages to allow tracking by
|
||||
* the Matomo statistics package.
|
||||
*
|
||||
* @author: Alexander Hass <http://drupal.org/user/85918>
|
||||
* @author: Alexander Hass <https://drupal.org/user/85918>
|
||||
*/
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
@@ -19,22 +19,18 @@ use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\matomo\MatomoInterface;
|
||||
use Drupal\node\NodeInterface;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Drupal\matomo\Component\Render\MatomoJavaScriptSnippet;
|
||||
|
||||
/**
|
||||
* Define the default file extension list that should be tracked as download.
|
||||
*/
|
||||
define('MATOMO_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip');
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function matomo_help($route_name, RouteMatchInterface $route_match) {
|
||||
switch ($route_name) {
|
||||
case 'matomo.admin_settings_form':
|
||||
return t('<a href=":pk_url">Matomo Analytics</a> is an open source (GPL license) web analytics software. It gives interesting reports on your website visitors, your popular pages, the search engines keywords they used, the language they speak... and so much more. Matomo aims to be an open source alternative to Google Analytics.', [':pk_url' => 'http://www.matomo.org/']);
|
||||
return t('<a href=":pk_url">Matomo Analytics</a> is an open source (GPL license) web analytics software. It gives interesting reports on your website visitors, your popular pages, the search engines keywords they used, the language they speak... and so much more. Matomo aims to be an open source alternative to Google Analytics.', [':pk_url' => 'https://www.matomo.org/']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +110,7 @@ function matomo_page_attachments(array &$page) {
|
||||
'error' => t('Error message'),
|
||||
];
|
||||
|
||||
foreach (drupal_get_messages(NULL, FALSE) as $type => $messages) {
|
||||
foreach (\Drupal::messenger()->all(NULL, FALSE) as $type => $messages) {
|
||||
// Track only the selected message types.
|
||||
if (in_array($type, $message_types)) {
|
||||
foreach ($messages as $message) {
|
||||
@@ -198,7 +194,7 @@ function matomo_page_attachments(array &$page) {
|
||||
$codesnippet_after = $config->get('codesnippet.after');
|
||||
|
||||
// Build tracker code.
|
||||
// @see http://matomo.org/docs/javascript-tracking/#toc-asynchronous-tracking
|
||||
// @see https://matomo.org/docs/javascript-tracking/#toc-asynchronous-tracking
|
||||
$script = 'var _paq = _paq || [];';
|
||||
$script .= '(function(){';
|
||||
$script .= 'var u=(("https:" == document.location.protocol) ? "' . UrlHelper::filterBadProtocol($url_https) . '" : "' . UrlHelper::filterBadProtocol($url_http) . '");';
|
||||
@@ -220,7 +216,7 @@ function matomo_page_attachments(array &$page) {
|
||||
}
|
||||
|
||||
// Custom file download extensions.
|
||||
if ($config->get('track.files') && !($config->get('track.files_extensions') == MATOMO_TRACKFILES_EXTENSIONS)) {
|
||||
if ($config->get('track.files') && !($config->get('track.files_extensions') == MatomoInterface::MATOMO_TRACKFILES_EXTENSIONS)) {
|
||||
$script .= '_paq.push(["setDownloadExtensions", ' . Json::encode($config->get('track.files_extensions')) . ']);';
|
||||
}
|
||||
|
||||
@@ -279,7 +275,7 @@ function matomo_page_attachments(array &$page) {
|
||||
];
|
||||
// Disable the download & outlink tracking for specific CSS classes.
|
||||
// Custom code snippets with 'setIgnoreClasses' will override the value.
|
||||
// @see http://developer.matomo.org/api-reference/tracking-javascript#disable-the-download-amp-outlink-tracking-for-specific-css-classes
|
||||
// @see https://developer.matomo.org/api-reference/tracking-javascript#disable-the-download-amp-outlink-tracking-for-specific-css-classes
|
||||
$script .= '_paq.push(["setIgnoreClasses", ' . Json::encode($ignore_classes) . ']);';
|
||||
|
||||
// Enable download & outlink link tracking.
|
||||
@@ -441,11 +437,12 @@ function matomo_user_profile_form_submit($form, FormStateInterface $form_state)
|
||||
*/
|
||||
function matomo_cron() {
|
||||
$config = \Drupal::config('matomo.settings');
|
||||
$request_time = \Drupal::time()->getRequestTime();
|
||||
|
||||
// Regenerate the piwik.js every day.
|
||||
if (REQUEST_TIME - \Drupal::state()->get('matomo.last_cache') >= 86400 && $config->get('cache')) {
|
||||
if ($request_time - \Drupal::state()->get('matomo.last_cache') >= 86400 && $config->get('cache')) {
|
||||
_matomo_cache($config->get('url_http') . 'piwik.js', TRUE);
|
||||
\Drupal::state()->set('matomo.last_cache', REQUEST_TIME);
|
||||
\Drupal::state()->set('matomo.last_cache', $request_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,37 @@ namespace Drupal\matomo\Form;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Extension\ModuleHandler;
|
||||
use Drupal\Core\Form\ConfigFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\matomo\MatomoInterface;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Client;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Configure Matomo settings for this site.
|
||||
*/
|
||||
class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
|
||||
protected $moduleHandler;
|
||||
|
||||
protected $currentUser;
|
||||
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $currentUser, ModuleHandler $moduleHandler, Client $httpClient) {
|
||||
parent::__construct($config_factory);
|
||||
$this->currentUser = $currentUser;
|
||||
$this->moduleHandler = $moduleHandler;
|
||||
$this->httpClient = $httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -117,7 +139,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
];
|
||||
|
||||
// Page specific visibility configurations.
|
||||
$account = \Drupal::currentUser();
|
||||
$account = $this->currentUser;
|
||||
$php_access = $account->hasPermission('use php for matomo tracking visibility');
|
||||
$visibility_request_path_pages = $config->get('visibility.request_path_pages');
|
||||
|
||||
@@ -140,7 +162,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
];
|
||||
$description = $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", ['%blog' => '/blog', '%blog-wildcard' => '/blog/*', '%front' => '<front>']);
|
||||
|
||||
if (\Drupal::moduleHandler()->moduleExists('php') && $php_access) {
|
||||
if ($this->moduleHandler->moduleExists('php') && $php_access) {
|
||||
$options[] = $this->t('Pages on which this PHP code returns <code>TRUE</code> (experts only)');
|
||||
$title = $this->t('Pages or PHP code');
|
||||
$description .= ' ' . $this->t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', ['%php' => '<?php ?>']);
|
||||
@@ -207,13 +229,13 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
1 => $this->t('Tracking on by default, users with %permission permission can opt out', $t_permission),
|
||||
2 => $this->t('Tracking off by default, users with %permission permission can opt in', $t_permission),
|
||||
],
|
||||
'#default_value' => !empty($visibility_user_account_mode) ? $visibility_user_account_mode : 1,
|
||||
'#default_value' => !empty($visibility_user_account_mode) ? $visibility_user_account_mode : 0,
|
||||
];
|
||||
$form['tracking']['user_visibility_settings']['matomo_trackuserid'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Track User ID'),
|
||||
'#default_value' => $config->get('track.userid'),
|
||||
'#description' => $this->t('User ID enables the analysis of groups of sessions, across devices, using a unique, persistent, and non-personally identifiable ID string representing a user. <a href=":url">Learn more about the benefits of using User ID</a>.', [':url' => 'http://matomo.org/docs/user-id/']),
|
||||
'#description' => $this->t('User ID enables the analysis of groups of sessions, across devices, using a unique, persistent, and non-personally identifiable ID string representing a user. <a href=":url">Learn more about the benefits of using User ID</a>.', [':url' => 'https://matomo.org/docs/user-id/']),
|
||||
];
|
||||
|
||||
// Link specific configurations.
|
||||
@@ -237,7 +259,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $config->get('track.files_extensions'),
|
||||
'#description' => $this->t('A file extension list separated by the | character that will be tracked as download when clicked. Regular expressions are supported. For example: @extensions', ['@extensions' => MATOMO_TRACKFILES_EXTENSIONS]),
|
||||
'#description' => $this->t('A file extension list separated by the | character that will be tracked as download when clicked. Regular expressions are supported. For example: @extensions', ['@extensions' => MatomoInterface::MATOMO_TRACKFILES_EXTENSIONS]),
|
||||
'#maxlength' => 500,
|
||||
'#states' => [
|
||||
'enabled' => [
|
||||
@@ -251,7 +273,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
];
|
||||
|
||||
$colorbox_dependencies = '<div class="admin-requirements">';
|
||||
$colorbox_dependencies .= $this->t('Requires: @module-list', ['@module-list' => (\Drupal::moduleHandler()->moduleExists('colorbox') ? $this->t('@module (<span class="admin-enabled">enabled</span>)', ['@module' => 'Colorbox']) : $this->t('@module (<span class="admin-missing">disabled</span>)', ['@module' => 'Colorbox']))]);
|
||||
$colorbox_dependencies .= $this->t('Requires: @module-list', ['@module-list' => ($this->moduleHandler->moduleExists('colorbox') ? $this->t('@module (<span class="admin-enabled">enabled</span>)', ['@module' => 'Colorbox']) : $this->t('@module (<span class="admin-missing">disabled</span>)', ['@module' => 'Colorbox']))]);
|
||||
$colorbox_dependencies .= '</div>';
|
||||
|
||||
$form['tracking']['linktracking']['matomo_trackcolorbox'] = [
|
||||
@@ -259,7 +281,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
'#title' => $this->t('Track content in colorbox modal dialogs'),
|
||||
'#description' => $this->t('Enable to track the content shown in colorbox modal windows.') . $colorbox_dependencies,
|
||||
'#default_value' => $config->get('track.colorbox'),
|
||||
'#disabled' => (\Drupal::moduleHandler()->moduleExists('colorbox') ? FALSE : TRUE),
|
||||
'#disabled' => ($this->moduleHandler->moduleExists('colorbox') ? FALSE : TRUE),
|
||||
];
|
||||
|
||||
// Message specific configurations.
|
||||
@@ -288,7 +310,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
];
|
||||
|
||||
$site_search_dependencies = '<div class="admin-requirements">';
|
||||
$site_search_dependencies .= $this->t('Requires: @module-list', ['@module-list' => (\Drupal::moduleHandler()->moduleExists('search') ? $this->t('@module (<span class="admin-enabled">enabled</span>)', ['@module' => 'Search']) : $this->t('@module (<span class="admin-missing">disabled</span>)', ['@module' => 'Search']))]);
|
||||
$site_search_dependencies .= $this->t('Requires: @module-list', ['@module-list' => ($this->moduleHandler->moduleExists('search') ? $this->t('@module (<span class="admin-enabled">enabled</span>)', ['@module' => 'Search']) : $this->t('@module (<span class="admin-missing">disabled</span>)', ['@module' => 'Search']))]);
|
||||
$site_search_dependencies .= '</div>';
|
||||
|
||||
$form['tracking']['search']['matomo_site_search'] = [
|
||||
@@ -296,7 +318,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
'#title' => $this->t('Track internal search'),
|
||||
'#description' => $this->t('If checked, internal search keywords are tracked.') . $site_search_dependencies,
|
||||
'#default_value' => $config->get('track.site_search'),
|
||||
'#disabled' => (\Drupal::moduleHandler()->moduleExists('search') ? FALSE : TRUE),
|
||||
'#disabled' => ($this->moduleHandler->moduleExists('search') ? FALSE : TRUE),
|
||||
];
|
||||
|
||||
// Privacy specific configurations.
|
||||
@@ -308,7 +330,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
$form['tracking']['privacy']['matomo_privacy_donottrack'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Universal web tracking opt-out'),
|
||||
'#description' => $this->t('If enabled and your Matomo server receives the <a href="http://donottrack.us/">Do-Not-Track</a> header from the client browser, the Matomo server will not track the user. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision.'),
|
||||
'#description' => $this->t('If enabled and your Matomo server receives the <a href=":donottrack">Do-Not-Track</a> header from the client browser, the Matomo server will not track the user. Compliance with Do Not Track could be purely voluntary, enforced by industry self-regulation, or mandated by state or federal law. Please accept your visitors privacy. If they have opt-out from tracking and advertising, you should accept their personal decision.', [':donottrack' => 'https://www.eff.org/issues/do-not-track']),
|
||||
'#default_value' => $config->get('privacy.donottrack'),
|
||||
];
|
||||
|
||||
@@ -334,7 +356,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
|
||||
// Custom variables.
|
||||
$form['matomo_custom_var'] = [
|
||||
'#description' => $this->t('You can add Matomos <a href=":custom_var_documentation">Custom Variables</a> here. These will be added to every page that Matomo tracking code appears on. Custom variable names and values are limited to 200 characters in length. Keep the names and values as short as possible and expect long values to get trimmed. You may use tokens in custom variable names and values. Global and user tokens are always available; on node pages, node tokens are also available.', [':custom_var_documentation' => 'http://matomo.org/docs/custom-variables/']),
|
||||
'#description' => $this->t('You can add Matomos <a href=":custom_var_documentation">Custom Variables</a> here. These will be added to every page that Matomo tracking code appears on. Custom variable names and values are limited to 200 characters in length. Keep the names and values as short as possible and expect long values to get trimmed. You may use tokens in custom variable names and values. Global and user tokens are always available; on node pages, node tokens are also available.', [':custom_var_documentation' => 'https://matomo.org/docs/custom-variables/']),
|
||||
'#title' => $this->t('Custom variables'),
|
||||
'#tree' => TRUE,
|
||||
'#type' => 'details',
|
||||
@@ -382,7 +404,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
'#element_validate' => [[get_class($this), 'tokenElementValidate']],
|
||||
'#token_types' => ['node'],
|
||||
];
|
||||
if (\Drupal::moduleHandler()->moduleExists('token')) {
|
||||
if ($this->moduleHandler->moduleExists('token')) {
|
||||
$form['matomo_custom_var']['slots'][$i]['value']['#element_validate'][] = 'token_element_validate';
|
||||
}
|
||||
$form['matomo_custom_var']['slots'][$i]['scope'] = [
|
||||
@@ -402,7 +424,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
'#type' => 'item',
|
||||
'#description' => $this->t("You can supplement Matomos' basic IP address tracking of visitors by segmenting users based on custom variables. Make sure you will not associate (or permit any third party to associate) any data gathered from your websites (or such third parties' websites) with any personally identifying information from any source as part of your use (or such third parties' use) of the Matomo' service."),
|
||||
];
|
||||
if (\Drupal::moduleHandler()->moduleExists('token')) {
|
||||
if ($this->moduleHandler->moduleExists('token')) {
|
||||
$form['matomo_custom_var']['matomo_custom_var_token_tree'] = [
|
||||
'#theme' => 'token_tree_link',
|
||||
'#token_types' => ['node'],
|
||||
@@ -424,7 +446,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
];
|
||||
|
||||
// Allow for tracking of the originating node when viewing translation sets.
|
||||
if (\Drupal::moduleHandler()->moduleExists('content_translation')) {
|
||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||
$form['advanced']['matomo_translation_set'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Track translation sets as one unit'),
|
||||
@@ -439,7 +461,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Custom JavaScript code'),
|
||||
'#open' => TRUE,
|
||||
'#description' => $this->t('You can add custom Matomo <a href=":snippets">code snippets</a> here. These will be added to every page that Matomo appears on. <strong>Do not include the <script> tags</strong>, and always end your code with a semicolon (;).', [':snippets' => 'http://matomo.org/docs/javascript-tracking/']),
|
||||
'#description' => $this->t('You can add custom Matomo <a href=":snippets">code snippets</a> here. These will be added to every page that Matomo appears on. <strong>Do not include the <script> tags</strong>, and always end your code with a semicolon (;).', [':snippets' => 'https://matomo.org/docs/javascript-tracking/']),
|
||||
];
|
||||
$form['advanced']['codesnippet']['matomo_codesnippet_before'] = [
|
||||
'#type' => 'textarea',
|
||||
@@ -496,7 +518,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
|
||||
$url = $form_state->getValue('matomo_url_http') . 'piwik.php';
|
||||
try {
|
||||
$result = \Drupal::httpClient()->get($url);
|
||||
$result = $this->httpClient->get($url);
|
||||
if ($result->getStatusCode() != 200 && $form_state->getValue('matomo_url_skiperror') == FALSE) {
|
||||
$form_state->setErrorByName('matomo_url_http', $this->t('The validation of "@url" failed with error "@error" (HTTP code @code).', [
|
||||
'@url' => UrlHelper::filterBadProtocol($url),
|
||||
@@ -517,7 +539,7 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
if (!empty($matomo_url_https)) {
|
||||
$url = $matomo_url_https . 'piwik.php';
|
||||
try {
|
||||
$result = \Drupal::httpClient()->get($url);
|
||||
$result = $this->httpClient->get($url);
|
||||
if ($result->getStatusCode() != 200 && $form_state->getValue('matomo_url_skiperror') == FALSE) {
|
||||
$form_state->setErrorByName('matomo_url_https', $this->t('The validation of "@url" failed with error "@error" (HTTP code @code).', [
|
||||
'@url' => UrlHelper::filterBadProtocol($url),
|
||||
@@ -714,4 +736,17 @@ class MatomoAdminSettingsForm extends ConfigFormBase {
|
||||
return preg_match('/' . implode('|', array_map('preg_quote', $token_blacklist)) . '/i', $token_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
// Load the service required to construct this class.
|
||||
$container->get('config.factory'),
|
||||
$container->get('current_user'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('http_client')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\matomo;
|
||||
|
||||
/**
|
||||
* Provides an interface.
|
||||
*/
|
||||
interface MatomoInterface {
|
||||
|
||||
/**
|
||||
* Define the default file extension list that should be tracked as download.
|
||||
*/
|
||||
const MATOMO_TRACKFILES_EXTENSIONS = '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip';
|
||||
|
||||
}
|
||||
@@ -63,7 +63,6 @@ class MatomoSearchTest extends WebTestBase {
|
||||
$search['keys'] = $this->randomMachineName(8);
|
||||
|
||||
// Create a node to search for.
|
||||
// Create a node.
|
||||
$edit = [];
|
||||
$edit['title[0][value]'] = 'This is a test title';
|
||||
$edit['body[0][value]'] = 'This test content contains ' . $search['keys'] . ' string.';
|
||||
|
||||
@@ -57,7 +57,11 @@ class MatomoStatusMessagesTest extends WebTestBase {
|
||||
$this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message with html tags and link."]);', '[testMatomoStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
|
||||
|
||||
// Enable logging of status, warnings and errors.
|
||||
$this->config('matomo.settings')->set('track.messages', ['status' => 'status', 'warning' => 'warning', 'error' => 'error'])->save();
|
||||
$this->config('matomo.settings')->set('track.messages', [
|
||||
'status' => 'status',
|
||||
'warning' => 'warning',
|
||||
'error' => 'error',
|
||||
])->save();
|
||||
|
||||
$this->drupalGet('matomo-test/drupal-messenger-add-message');
|
||||
$this->assertRaw('_paq.push(["trackEvent", "Messages", "Status message", "Example status message."]);', '[testMatomoStatusMessages]: Example status message is enabled for tracking.');
|
||||
|
||||
+3
-3
@@ -4,8 +4,8 @@ description: 'Support module for Matomo testing.'
|
||||
package: Testing
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-07-13
|
||||
version: '8.x-1.7'
|
||||
# Information added by Drupal.org packaging script on 2019-02-08
|
||||
version: '8.x-1.9'
|
||||
core: '8.x'
|
||||
project: 'matomo'
|
||||
datestamp: 1531470224
|
||||
datestamp: 1549615102
|
||||
|
||||
+4
-4
@@ -17,10 +17,10 @@ class MatomoTestController extends ControllerBase {
|
||||
*/
|
||||
public function drupalAddMessageTest() {
|
||||
// Set some messages.
|
||||
drupal_set_message($this->t('Example status message.'), 'status');
|
||||
drupal_set_message($this->t('Example warning message.'), 'warning');
|
||||
drupal_set_message($this->t('Example error message.'), 'error');
|
||||
drupal_set_message($this->t('Example error <em>message</em> with html tags and <a href="http://example.com/">link</a>.'), 'error');
|
||||
$this->messenger()->addMessage($this->t('Example status message.'), 'status');
|
||||
$this->messenger()->addMessage($this->t('Example warning message.'), 'warning');
|
||||
$this->messenger()->addMessage($this->t('Example error message.'), 'error');
|
||||
$this->messenger()->addMessage($this->t('Example error <em>message</em> with html tags and <a href="https://example.com/">link</a>.'), 'error');
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user