summaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-01-25 14:59:31 +0000
committerGreg Roach <fisharebest@webtrees.net>2019-01-25 19:09:59 +0000
commit37eb8894d5d4381f3fd9b791a53a32f0012b32ec (patch)
tree383982de09bcf286033b61de69829608866fafeb /resources
parentf0393844a7bf8df7dfbdb5cceafe26a558c04601 (diff)
downloadwebtrees-37eb8894d5d4381f3fd9b791a53a32f0012b32ec.tar.gz
webtrees-37eb8894d5d4381f3fd9b791a53a32f0012b32ec.tar.bz2
webtrees-37eb8894d5d4381f3fd9b791a53a32f0012b32ec.zip
Convert tracking and analytics functions into modules
Diffstat (limited to 'resources')
-rw-r--r--resources/views/admin/analytics/bing-webmaster-form.phtml12
-rw-r--r--resources/views/admin/analytics/bing-webmaster-snippet.phtml1
-rw-r--r--resources/views/admin/analytics/edit.phtml35
-rw-r--r--resources/views/admin/analytics/google-analytics-form.phtml11
-rw-r--r--resources/views/admin/analytics/google-analytics-snippet.phtml7
-rw-r--r--resources/views/admin/analytics/google-webmaster-form.phtml12
-rw-r--r--resources/views/admin/analytics/google-webmaster-snippet.phtml1
-rw-r--r--resources/views/admin/analytics/index.phtml36
-rw-r--r--resources/views/admin/analytics/matomo-analytics-form.phtml21
-rw-r--r--resources/views/admin/analytics/matomo-analytics-snippet.phtml12
-rw-r--r--resources/views/admin/analytics/statcounter-form.phtml20
-rw-r--r--resources/views/admin/analytics/statcounter-snippet.phtml9
-rw-r--r--resources/views/admin/control-panel.phtml4
-rw-r--r--resources/views/admin/site-analytics.phtml136
-rw-r--r--resources/views/icons/help.phtml2
-rw-r--r--resources/views/icons/information.phtml1
-rw-r--r--resources/views/layouts/default.phtml4
17 files changed, 184 insertions, 140 deletions
diff --git a/resources/views/admin/analytics/bing-webmaster-form.phtml b/resources/views/admin/analytics/bing-webmaster-form.phtml
new file mode 100644
index 0000000000..e483ede59a
--- /dev/null
+++ b/resources/views/admin/analytics/bing-webmaster-form.phtml
@@ -0,0 +1,12 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<div class="row form-group">
+ <label for="BING_WEBMASTER_ID" class="col-sm-3 col-form-label">
+ <?= I18N::translate('Site verification code') ?>
+ </label>
+
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="BING_WEBMASTER_ID" name="BING_WEBMASTER_ID" value="<?= e($BING_WEBMASTER_ID ?? '') ?>" maxlength="255" pattern="[0-9a-zA-Z+=/_:.!-]*">
+ </div>
+</div>
+
diff --git a/resources/views/admin/analytics/bing-webmaster-snippet.phtml b/resources/views/admin/analytics/bing-webmaster-snippet.phtml
new file mode 100644
index 0000000000..f78fb17c81
--- /dev/null
+++ b/resources/views/admin/analytics/bing-webmaster-snippet.phtml
@@ -0,0 +1 @@
+<meta name="msvalidate.01" content="<?= e($BING_WEBMASTER_ID ?? '') ?>">
diff --git a/resources/views/admin/analytics/edit.phtml b/resources/views/admin/analytics/edit.phtml
new file mode 100644
index 0000000000..ce9879b5c1
--- /dev/null
+++ b/resources/views/admin/analytics/edit.phtml
@@ -0,0 +1,35 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('analytics') => I18N::translate('Tracking and analytics'), $title]]) ?>
+
+<h1><?= $title ?></h1>
+
+<form method="post" class="form-horizontal">
+ <?= csrf_field() ?>
+ <?= $form_fields ?>
+
+ <div class="row form-group">
+ <div class="col-sm-3">
+ <?= I18N::translate('Preview') ?>
+ </div>
+
+ <div class="col-sm-9">
+ <pre><code><?= e($preview) ?></code></pre>
+ </div>
+ </div>
+
+
+ <div class="row form-group">
+ <div class="offset-sm-3 col-sm-9">
+ <button type="submit" class="btn btn-primary">
+ <?= view('icons/save') ?>
+ <?= I18N::translate('save') ?>
+ </button>
+
+ <a href="<?= e(route('analytics')) ?>" class="btn btn-secondary">
+ <?= view('icons/cancel') ?>
+ <?= I18N::translate('cancel') ?>
+ </a>
+ </div>
+ </div>
+</form>
diff --git a/resources/views/admin/analytics/google-analytics-form.phtml b/resources/views/admin/analytics/google-analytics-form.phtml
new file mode 100644
index 0000000000..a246214c5c
--- /dev/null
+++ b/resources/views/admin/analytics/google-analytics-form.phtml
@@ -0,0 +1,11 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<div class="row form-group">
+ <label for="GOOGLE_ANALYTICS_ID" class="col-sm-3 col-form-label">
+ <?= /* I18N: A configuration setting */ I18N::translate('Site identification code') ?>
+ <span class="sr-only">Google Analytics</span>
+ </label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="GOOGLE_ANALYTICS_ID" name="GOOGLE_ANALYTICS_ID" value="<?= e($GOOGLE_ANALYTICS_ID ?? '') ?>" placeholder="UA-12345-6" maxlength="255" pattern="UA-[0-9]+-[0-9]+">
+ </div>
+</div>
diff --git a/resources/views/admin/analytics/google-analytics-snippet.phtml b/resources/views/admin/analytics/google-analytics-snippet.phtml
new file mode 100644
index 0000000000..e55b77b528
--- /dev/null
+++ b/resources/views/admin/analytics/google-analytics-snippet.phtml
@@ -0,0 +1,7 @@
+<script async src="https://www.google-analytics.com/analytics.js"></script>
+<script>
+ window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};
+ ga.l=+new Date;
+ ga("create", "<?= e($GOOGLE_ANALYTICS_ID ?? '') ?>", "auto");
+ ga("send", "pageview", <?= json_encode($dimensions) ?>);
+</script>
diff --git a/resources/views/admin/analytics/google-webmaster-form.phtml b/resources/views/admin/analytics/google-webmaster-form.phtml
new file mode 100644
index 0000000000..4e3a7bd731
--- /dev/null
+++ b/resources/views/admin/analytics/google-webmaster-form.phtml
@@ -0,0 +1,12 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<div class="row form-group">
+ <label for="GOOGLE_WEBMASTER_ID" class="col-sm-3 col-form-label">
+ <?= /* I18N: A configuration setting */ I18N::translate('Site verification code') ?>
+ <span class="sr-only">Google Webmaster Tools</span>
+ </label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="GOOGLE_WEBMASTER_ID" name="GOOGLE_WEBMASTER_ID" value="<?= e($GOOGLE_WEBMASTER_ID ?? '') ?>" maxlength="255" pattern="[0-9a-zA-Z+=/_:.!-]*">
+ </div>
+</div>
+
diff --git a/resources/views/admin/analytics/google-webmaster-snippet.phtml b/resources/views/admin/analytics/google-webmaster-snippet.phtml
new file mode 100644
index 0000000000..8728d9ada4
--- /dev/null
+++ b/resources/views/admin/analytics/google-webmaster-snippet.phtml
@@ -0,0 +1 @@
+<meta name="google-site-verification" content="<?= e($GOOGLE_WEBMASTER_ID ?? '') ?>">
diff --git a/resources/views/admin/analytics/index.phtml b/resources/views/admin/analytics/index.phtml
new file mode 100644
index 0000000000..1e31c27075
--- /dev/null
+++ b/resources/views/admin/analytics/index.phtml
@@ -0,0 +1,36 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+<?php use Fisharebest\Webtrees\Site; ?>
+
+<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), $title]]) ?>
+
+<h1><?= $title ?></h1>
+
+<p>
+ <?= I18N::translate('If you use one of the following tracking and analytics services, webtrees can add the tracking codes automatically.') ?>
+</p>
+
+<p>
+ <?= I18N::translate('Tracking and analytics are not added to the control panel.') ?>
+</p>
+
+<p>
+ <?= I18N::translate('Site verification codes do not work when webtrees is installed in a subfolder.') ?>
+</p>
+
+<?php foreach ($modules as $module) : ?>
+ <h2>
+ <?= e($module->title()) ?>
+ </h2>
+
+ <p>
+ <a class="btn btn-link" href="<?= e(route('analytics-edit', ['module' => $module->name()])) ?>">
+ <?= view('icons/preferences') ?>
+ <?= I18N::translate('Preferences') ?>
+ </a>
+
+ <a class="btn btn-link" href="<?= e($module->analyticsHomePageUrl()) ?>">
+ <?= view('icons/information') ?>
+ <?= e($module->analyticsHomePageUrl()) ?>
+ </a>
+ </p>
+<?php endforeach ?>
diff --git a/resources/views/admin/analytics/matomo-analytics-form.phtml b/resources/views/admin/analytics/matomo-analytics-form.phtml
new file mode 100644
index 0000000000..dcd4edfe92
--- /dev/null
+++ b/resources/views/admin/analytics/matomo-analytics-form.phtml
@@ -0,0 +1,21 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<div class="row form-group">
+ <label for="PIWIK_SITE_ID" class="col-sm-3 col-form-label">
+ <?= /* I18N: A configuration setting */ I18N::translate('Site identification code') ?>
+ </label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="PIWIK_SITE_ID" name="PIWIK_SITE_ID" value="<?= e($PIWIK_SITE_ID ?? '') ?>" maxlength="255" pattern="[0-9]+">
+ </div>
+</div>
+
+<!-- PIWIK_URL -->
+<div class="row form-group">
+ <label for="PIWIK_URL" class="col-sm-3 col-form-label">
+ <?= /* I18N: A configuration setting */ I18N::translate('URL') ?>
+ </label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="PIWIK_URL" name="PIWIK_URL" value="<?= e($PIWIK_URL ?? '') ?>" placeholder="//example.com/piwik/" maxlength="255">
+ </div>
+</div>
+
diff --git a/resources/views/admin/analytics/matomo-analytics-snippet.phtml b/resources/views/admin/analytics/matomo-analytics-snippet.phtml
new file mode 100644
index 0000000000..c81a17f402
--- /dev/null
+++ b/resources/views/admin/analytics/matomo-analytics-snippet.phtml
@@ -0,0 +1,12 @@
+<script type="text/javascript">
+ var _paq = window._paq || [];
+ _paq.push(['trackPageView']);
+ _paq.push(['enableLinkTracking']);
+ (function() {
+ var u=<?= json_encode($PIWIK_URL ?? '') ?>;
+ _paq.push(['setTrackerUrl', u+'piwik.php']);
+ _paq.push(['setSiteId', <?= json_encode($PIWIK_SITE_ID ?? '') ?>]);
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+ g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
+ })();
+</script>
diff --git a/resources/views/admin/analytics/statcounter-form.phtml b/resources/views/admin/analytics/statcounter-form.phtml
new file mode 100644
index 0000000000..23a38294b0
--- /dev/null
+++ b/resources/views/admin/analytics/statcounter-form.phtml
@@ -0,0 +1,20 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<div class="row form-group">
+ <label for="STATCOUNTER_PROJECT_ID" class="col-sm-3 col-form-label">
+ <?= /* I18N: A configuration setting */ I18N::translate('Site identification code') ?>
+ </label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="STATCOUNTER_PROJECT_ID" name="STATCOUNTER_PROJECT_ID" value="<?= e($STATCOUNTER_PROJECT_ID ?? '') ?>" maxlength="255" pattern="[0-9]+">
+ </div>
+</div>
+
+<!-- STATCOUNTER_SECURITY_ID -->
+<div class="row form-group">
+ <label for="STATCOUNTER_SECURITY_ID" class="col-sm-3 col-form-label">
+ <?= /* I18N: A configuration setting */ I18N::translate('Security code') ?>
+ </label>
+ <div class="col-sm-9">
+ <input type="text" class="form-control" id="STATCOUNTER_SECURITY_ID" name="STATCOUNTER_SECURITY_ID" value="<?= e($STATCOUNTER_SECURITY_ID ?? '') ?>" maxlength="255" pattern="[0-9a-zA-Z]+">
+ </div>
+</div>
diff --git a/resources/views/admin/analytics/statcounter-snippet.phtml b/resources/views/admin/analytics/statcounter-snippet.phtml
new file mode 100644
index 0000000000..13dfa49009
--- /dev/null
+++ b/resources/views/admin/analytics/statcounter-snippet.phtml
@@ -0,0 +1,9 @@
+<script>
+ var sc_project=<?= json_encode((int) ($STATCOUNTER_PROJECT_ID ?? '')) ?>;
+ var sc_invisible=1;
+ var sc_security=<?= json_encode($STATCOUNTER_SECURITY_ID ?? '') ?>;
+ var sc_https=1;
+ var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
+ document.write("<sc"+"ript type='text/javascript' async src='" + scJsHost + "statcounter.com/counter/counter_xhtml.js'></"+"script>");
+</script>
+
diff --git a/resources/views/admin/control-panel.phtml b/resources/views/admin/control-panel.phtml
index 6f2277a342..b575b41729 100644
--- a/resources/views/admin/control-panel.phtml
+++ b/resources/views/admin/control-panel.phtml
@@ -64,8 +64,8 @@
</a>
</li>
<li>
- <span class="fa-li"><?= view('icons/preferences') ?></span>
- <a href="<?= e(route('admin-site-analytics')) ?>">
+ <span class="fa-li"><?= view('icons/wizard') ?></span>
+ <a href="<?= e(route('analytics')) ?>">
<?= I18N::translate('Tracking and analytics') ?>
</a>
</li>
diff --git a/resources/views/admin/site-analytics.phtml b/resources/views/admin/site-analytics.phtml
deleted file mode 100644
index 3a6b4ab472..0000000000
--- a/resources/views/admin/site-analytics.phtml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php use Fisharebest\Webtrees\I18N; ?>
-<?php use Fisharebest\Webtrees\Site; ?>
-
-<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), $title]]) ?>
-
-<h1><?= $title ?></h1>
-
-<form method="post" class="form-horizontal">
- <?= csrf_field() ?>
-
- <p>
- <?= I18N::translate('If you use one of the following tracking and analytics services, webtrees can add the tracking codes automatically.') ?>
- </p>
-
- <h2><a href="https://www.bing.com/toolbox/webmaster/">Bing Webmaster Tools</a></h2>
-
- <!-- BING_WEBMASTER_ID -->
- <div class="row form-group">
- <label for="BING_WEBMASTER_ID" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('Site verification code') ?>
- <span class="sr-only">Google Webmaster Tools</span>
- </label>
- <div class="col-sm-9">
- <input
- type="text" class="form-control"
- id="BING_WEBMASTER_ID" name="BING_WEBMASTER_ID" <?= dirname(parse_url(WT_BASE_URL, PHP_URL_PATH)) === '/' ? '' : 'disabled' ?>
- value="<?= e(Site::getPreference('BING_WEBMASTER_ID')) ?>"
- maxlength="255" pattern="[0-9a-zA-Z+=/_:.!-]*"
- >
- <p class="small text-muted">
- <?= /* I18N: Help text for the "Site verification code for Google Webmaster Tools" site configuration setting */ I18N::translate('Site verification codes do not work when webtrees is installed in a subfolder.') ?>
- </p>
- </div>
- </div>
-
- <h2><a href="https://www.google.com/webmasters/">Google Webmaster Tools</a></h2>
-
- <!-- GOOGLE_WEBMASTER_ID -->
- <div class="row form-group">
- <label for="GOOGLE_WEBMASTER_ID" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('Site verification code') ?>
- <span class="sr-only">Google Webmaster Tools</span>
- </label>
- <div class="col-sm-9">
- <input
- type="text" class="form-control"
- id="GOOGLE_WEBMASTER_ID" name="GOOGLE_WEBMASTER_ID" <?= dirname(parse_url(WT_BASE_URL, PHP_URL_PATH)) === '/' ? '' : 'disabled' ?>
- value="<?= e(Site::getPreference('GOOGLE_WEBMASTER_ID')) ?>"
- maxlength="255" pattern="[0-9a-zA-Z+=/_:.!-]*"
- >
- <p class="small text-muted">
- <?= /* I18N: Help text for the "Site verification code for Google Webmaster Tools" site configuration setting */ I18N::translate('Site verification codes do not work when webtrees is installed in a subfolder.') ?>
- </p>
- </div>
- </div>
-
- <h2><a href="https://www.google.com/analytics/">Google Analytics</a></h2>
-
- <!-- GOOGLE_ANALYTICS_ID -->
- <div class="row form-group">
- <label for="GOOGLE_ANALYTICS_ID" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('Site identification code') ?>
- <span class="sr-only">Google Analytics</span>
- </label>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="GOOGLE_ANALYTICS_ID" name="GOOGLE_ANALYTICS_ID" value="<?= e(Site::getPreference('GOOGLE_ANALYTICS_ID')) ?>" placeholder="UA-12345-6" maxlength="255" pattern="UA-[0-9]+-[0-9]+">
- <p class="small text-muted">
- <?= I18N::translate('Tracking and analytics are not added to the control panel.') ?>
- </p>
- </div>
- </div>
-
- <h2><a href="https://piwik.org/">Piwik</a></h2>
-
- <!-- PIWIK_SITE_ID -->
- <div class="row form-group">
- <label for="PIWIK_SITE_ID" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('Site identification code') ?>
- </label>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="PIWIK_SITE_ID" name="PIWIK_SITE_ID" value="<?= e(Site::getPreference('PIWIK_SITE_ID')) ?>" maxlength="255" pattern="[0-9]+">
- </div>
- </div>
-
- <!-- PIWIK_URL -->
- <div class="row form-group">
- <label for="PIWIK_URL" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('URL') ?>
- </label>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="PIWIK_URL" name="PIWIK_URL" value="<?= e(Site::getPreference('PIWIK_URL')) ?>" placeholder="example.com/piwik" maxlength="255">
- <p class="small text-muted">
- <?= I18N::translate('Tracking and analytics are not added to the control panel.') ?>
- </p>
- </div>
- </div>
-
- <h2><a href="https://statcounter.com/">StatCounter</a></h2>
-
- <!-- STATCOUNTER_PROJECT_ID -->
- <div class="row form-group">
- <label for="STATCOUNTER_PROJECT_ID" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('Site identification code') ?>
- </label>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="STATCOUNTER_PROJECT_ID" name="STATCOUNTER_PROJECT_ID" value="<?= e(Site::getPreference('STATCOUNTER_PROJECT_ID')) ?>" maxlength="255" pattern="[0-9]+">
- </div>
- </div>
-
- <!-- STATCOUNTER_SECURITY_ID -->
- <div class="row form-group">
- <label for="STATCOUNTER_SECURITY_ID" class="col-sm-3 col-form-label">
- <?= /* I18N: A configuration setting */ I18N::translate('Security code') ?>
- </label>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="STATCOUNTER_SECURITY_ID" name="STATCOUNTER_SECURITY_ID" value="<?= e(Site::getPreference('STATCOUNTER_SECURITY_ID')) ?>" maxlength="255" pattern="[0-9a-zA-Z]+">
- <p class="small text-muted">
- <?= I18N::translate('Tracking and analytics are not added to the control panel.') ?>
- </p>
- </div>
- </div>
-
- <div class="row form-group">
- <div class="offset-sm-3 col-sm-9">
- <button type="submit" class="btn btn-primary">
- <?= view('icons/save') ?>
- <?= I18N::translate('save') ?>
- </button>
-
- <a href="<?= e(route('admin-control-panel')) ?>" class="btn btn-secondary">
- <?= view('icons/cancel') ?>
- <?= I18N::translate('cancel') ?>
- </a>
- </div>
- </div>
-</form>
diff --git a/resources/views/icons/help.phtml b/resources/views/icons/help.phtml
index 3d2e8cd1ca..cab0e99de6 100644
--- a/resources/views/icons/help.phtml
+++ b/resources/views/icons/help.phtml
@@ -1 +1 @@
-<i class="fas fa-info-circle fa-fw wt-icon-help" aria-hidden="true"></i>
+<i class="fas fa-question-circle fa-fw wt-icon-help" aria-hidden="true"></i>
diff --git a/resources/views/icons/information.phtml b/resources/views/icons/information.phtml
new file mode 100644
index 0000000000..9152155dc8
--- /dev/null
+++ b/resources/views/icons/information.phtml
@@ -0,0 +1 @@
+<i class="fas fa-info-circle fa-fw wt-icon-information" aria-hidden="true"></i>
diff --git a/resources/views/layouts/default.phtml b/resources/views/layouts/default.phtml
index e4c018135c..236c6f3358 100644
--- a/resources/views/layouts/default.phtml
+++ b/resources/views/layouts/default.phtml
@@ -2,6 +2,8 @@
<?php use Fisharebest\Webtrees\DebugBar; ?>
<?php use Fisharebest\Webtrees\FlashMessages; ?>
<?php use Fisharebest\Webtrees\I18N; ?>
+<?php use Fisharebest\Webtrees\Module; ?>
+<?php use Fisharebest\Webtrees\Module\ModuleAnalyticsInterface; ?>
<?php use Fisharebest\Webtrees\Theme; ?>
<?php use Fisharebest\Webtrees\View; ?>
<?php use Fisharebest\Webtrees\Webtrees; ?>
@@ -41,7 +43,7 @@
<?= View::stack('styles') ?>
- <?= Theme::theme()->analytics() ?>
+ <?= Module::findByInterface(ModuleAnalyticsInterface::class)->filter(function (ModuleAnalyticsInterface $module): bool { return $module->analyticsCanShow(); })->map(function (ModuleAnalyticsInterface $module): string { return $module->analyticsSnippet($module->analyticsParameters()); })->implode('') ?>
<?= DebugBar::renderHead() ?>
</head>