Skip to content

Commit 7a75f34

Browse files
authored
Merge pull request #8 from indigoxela/rename-piwik-matomo
Issue #5: Renamed piwik.js/php to matomo.js/php
2 parents f6e257c + 872e6f9 commit 7a75f34

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

matomo.admin.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ function matomo_admin_settings_form_validate($form, &$form_state) {
470470
$matomo_url = $matomo_url . '/';
471471
$form_state['values']['url_http'] = $matomo_url;
472472
}
473-
$url = $matomo_url . 'piwik.php';
473+
$url = $matomo_url . 'matomo.php';
474474
$result = backdrop_http_request($url);
475475
if ($result->code != 200 && $form_state['values']['url_skiperror'] == FALSE) {
476476
form_set_error('url_http', t('The validation of "@url" failed with error "@error" (HTTP code @code).', array('@url' => check_url($url), '@error' => $result->error, '@code' => $result->code)));
@@ -482,7 +482,7 @@ function matomo_admin_settings_form_validate($form, &$form_state) {
482482
$matomo_url = $matomo_url . '/';
483483
$form_state['values']['url_https'] = $matomo_url;
484484
}
485-
$url = $matomo_url . 'piwik.php';
485+
$url = $matomo_url . 'matomo.php';
486486
$result = backdrop_http_request($url);
487487
if ($result->code != 200 && $form_state['values']['url_skiperror'] == FALSE) {
488488
form_set_error('url_https', t('The validation of "@url" failed with error "@error" (HTTP code @code).', array('@url' => check_url($url), '@error' => $result->error, '@code' => $result->code)));

matomo.module

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function matomo_preprocess_layout(&$variables) {
246246
$script .= '(function(){';
247247
$script .= 'var u=(("https:" == document.location.protocol) ? "' . check_url($url_https) . '" : "' . check_url($url_http) . '");';
248248
$script .= '_paq.push(["setSiteId", ' . backdrop_json_encode($config->get('site_id')) . ']);';
249-
$script .= '_paq.push(["setTrackerUrl", u+"piwik.php"]);';
249+
$script .= '_paq.push(["setTrackerUrl", u+"matomo.php"]);';
250250

251251
// Track logged in users across all devices.
252252
if ($config->get('trackuserid') && user_is_logged_in()) {
@@ -343,7 +343,7 @@ function matomo_preprocess_layout(&$variables) {
343343
$script .= 'g.async=true;';
344344

345345
// Should a local cached copy of the tracking code be used?
346-
if ($config->get('cache') && $url = _matomo_cache($url_http . 'piwik.js')) {
346+
if ($config->get('cache') && $url = _matomo_cache($url_http . 'matomo.js')) {
347347
// A dummy query-string is added to filenames, to gain control over
348348
// browser-caching. The string changes on every update or full cache
349349
// flush, forcing browsers to load a new copy of the files, as the
@@ -353,7 +353,7 @@ function matomo_preprocess_layout(&$variables) {
353353
$script .= 'g.src="' . $url . $query_string . '";';
354354
}
355355
else {
356-
$script .= 'g.src=u+"piwik.js";';
356+
$script .= 'g.src=u+"matomo.js";';
357357
}
358358

359359
$script .= 's.parentNode.insertBefore(g,s);';
@@ -456,9 +456,9 @@ function matomo_user_presave($account) {
456456
*/
457457
function matomo_cron() {
458458
$config = config('matomo.settings');
459-
// Regenerate the piwik.js every day.
459+
// Regenerate the matomo.js every day.
460460
if (REQUEST_TIME - $config->get('last_cache') >= 86400 && $config->get('cache', 0)) {
461-
_matomo_cache($config->get('url_http', '') . 'piwik.js', TRUE);
461+
_matomo_cache($config->get('url_http', '') . 'matomo.js', TRUE);
462462
$config->set('last_cache', REQUEST_TIME);
463463
$config->save();
464464
}

tests/matomo.test

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,30 @@ class MatomoBasicTest extends BackdropWebTestCase {
8484
// Check tracking code visibility.
8585
$this->backdropGet('');
8686
$this->assertRaw('/matomo/matomo.js', '[testMatomoPageVisibility]: Custom tracking script is displayed for authenticated users.');
87-
$this->assertRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is displayed for authenticated users.');
87+
$this->assertRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is displayed for authenticated users.');
8888

8989
// Test whether tracking code is not included on pages to omit.
9090
$this->backdropGet('admin');
91-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is not displayed on admin page.');
91+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is not displayed on admin page.');
9292
$this->backdropGet('admin/config/system/matomo');
9393
// Checking for tracking code URI here, as $ua_code is displayed in the form.
94-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is not displayed on admin subpage.');
94+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is not displayed on admin subpage.');
9595

9696
// Test whether tracking code display is properly flipped.
9797
$config->set('visibility_pages', 1);
9898
$config->save();
9999
$this->backdropGet('admin');
100-
$this->assertRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is displayed on admin page.');
100+
$this->assertRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is displayed on admin page.');
101101
$this->backdropGet('admin/config/system/matomo');
102102
// Checking for tracking code URI here, as $ua_code is displayed in the form.
103-
$this->assertRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is displayed on admin subpage.');
103+
$this->assertRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is displayed on admin subpage.');
104104
$this->backdropGet('');
105-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is NOT displayed on front page.');
105+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is NOT displayed on front page.');
106106

107107
// Test whether tracking code is not display for anonymous.
108108
$this->backdropLogout();
109109
$this->backdropGet('');
110-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is NOT displayed for anonymous.');
110+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoPageVisibility]: Tracking code is NOT displayed for anonymous.');
111111

112112
// Switch back to every page except the listed pages.
113113
$config->set('visibility_pages', 0);
@@ -142,7 +142,7 @@ class MatomoBasicTest extends BackdropWebTestCase {
142142
(function(){
143143
var u=(("https:" == document.location.protocol) ? "https://{$MATOMO_URL}" : "http://{$MATOMO_URL}");
144144
_paq.push(['setSiteId', {$IDSITE}]);
145-
_paq.push(['setTrackerUrl', u+'piwik.php']);
145+
_paq.push(['setTrackerUrl', u+'matomo.php']);
146146
_paq.push(['trackPageView']);
147147
var d=document,
148148
g=d.createElement('script'),
@@ -160,7 +160,7 @@ class MatomoBasicTest extends BackdropWebTestCase {
160160
$config->set('cache', 0);
161161
$config->save();
162162
$this->backdropGet('');
163-
$this->assertRaw('u+"piwik.php"', '[testMatomoTrackingCode]: Latest tracking code used.');
163+
$this->assertRaw('u+"matomo.php"', '[testMatomoTrackingCode]: Latest tracking code used.');
164164

165165
// Test if tracking of User ID is enabled.
166166
$config->set('trackuserid', 1);
@@ -464,16 +464,16 @@ class MatomoRolesTest extends BackdropWebTestCase {
464464

465465
// Check tracking code visibility.
466466
$this->backdropGet('');
467-
$this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for anonymous users on frontpage with default settings.');
467+
$this->assertRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for anonymous users on frontpage with default settings.');
468468
$this->backdropGet('admin');
469469
$this->assertRaw('"403/URL = "', '[testMatomoRoleVisibility]: 403 Forbidden tracking code is displayed for anonymous users in admin section with default settings.');
470470

471471
$this->backdropLogin($this->admin_user);
472472

473473
$this->backdropGet('');
474-
$this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for authenticated users on frontpage with default settings.');
474+
$this->assertRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for authenticated users on frontpage with default settings.');
475475
$this->backdropGet('admin');
476-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed for authenticated users in admin section with default settings.');
476+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed for authenticated users in admin section with default settings.');
477477

478478
// Test if the non-default settings are working as expected.
479479

@@ -483,11 +483,11 @@ class MatomoRolesTest extends BackdropWebTestCase {
483483
cache_flush('page');
484484

485485
$this->backdropGet('');
486-
$this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for authenticated users only on frontpage.');
486+
$this->assertRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for authenticated users only on frontpage.');
487487

488488
$this->backdropLogout();
489489
$this->backdropGet('');
490-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed for anonymous users on frontpage.');
490+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed for anonymous users on frontpage.');
491491

492492
// Add to every role except the selected ones.
493493
$config->set('visibility_roles', 1);
@@ -498,30 +498,30 @@ class MatomoRolesTest extends BackdropWebTestCase {
498498

499499
// Check tracking code visibility.
500500
$this->backdropGet('');
501-
$this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and displayed for anonymous users.');
501+
$this->assertRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and displayed for anonymous users.');
502502
$this->backdropGet('admin');
503503
$this->assertRaw('"403/URL = "', '[testMatomoRoleVisibility]: 403 Forbidden tracking code is shown for anonymous users if every role except the selected ones is selected.');
504504

505505
$this->backdropLogin($this->admin_user);
506506

507507
$this->backdropGet('');
508-
$this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and displayed on frontpage for authenticated users.');
508+
$this->assertRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and displayed on frontpage for authenticated users.');
509509
$this->backdropGet('admin');
510-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and NOT displayed in admin section for authenticated users.');
510+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and NOT displayed in admin section for authenticated users.');
511511

512512
// Disable tracking for authenticated users.
513513
$config->set('roles', array(BACKDROP_AUTHENTICATED_ROLE => BACKDROP_AUTHENTICATED_ROLE));
514514
$config->save();
515515
cache_flush('page');
516516

517517
$this->backdropGet('');
518-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed on frontpage for excluded authenticated users.');
518+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed on frontpage for excluded authenticated users.');
519519
$this->backdropGet('admin');
520-
$this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed in admin section for excluded authenticated users.');
520+
$this->assertNoRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed in admin section for excluded authenticated users.');
521521

522522
$this->backdropLogout();
523523
$this->backdropGet('');
524-
$this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed on frontpage for included anonymous users.');
524+
$this->assertRaw('u+"matomo.php"', '[testMatomoRoleVisibility]: Tracking code is displayed on frontpage for included anonymous users.');
525525
}
526526

527527
}
@@ -576,14 +576,14 @@ class MatomoRolesTest extends BackdropWebTestCase {
576576
// $config->set('pages', '<?php return TRUE; ?>');
577577
// $config->save();
578578
// $this->backdropGet('');
579-
// $this->assertRaw('u+"piwik.php"', '[testMatomoPhpFilter]: Tracking is displayed on frontpage page.');
579+
// $this->assertRaw('u+"matomo.php"', '[testMatomoPhpFilter]: Tracking is displayed on frontpage page.');
580580
// $this->backdropGet('admin');
581-
// $this->assertRaw('u+"piwik.php"', '[testMatomoPhpFilter]: Tracking is displayed on admin page.');
581+
// $this->assertRaw('u+"matomo.php"', '[testMatomoPhpFilter]: Tracking is displayed on admin page.');
582582
//
583583
// $config->set('pages', '<?php return FALSE; ?>');
584584
// $config->save();
585585
// $this->backdropGet('');
586-
// $this->assertNoRaw('u+"piwik.php"', '[testMatomoPhpFilter]: Tracking is not displayed on frontpage page.');
586+
// $this->assertNoRaw('u+"matomo.php"', '[testMatomoPhpFilter]: Tracking is not displayed on frontpage page.');
587587
//
588588
// // Test administration form.
589589
// $config->set('pages', '<?php return TRUE; ?>');

0 commit comments

Comments
 (0)