Browse Source

Merge 01b4f07359 into 53db3bdb0d

pull/498/merge
lltodoll 4 years ago
committed by GitHub
parent
commit
ae24508b8c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 2464 additions and 13 deletions
  1. +1
    -1
      content/data/configList.json
  2. +5
    -0
      lang/de_DE.ini
  3. +6
    -1
      lang/en_US.ini
  4. +6
    -1
      lang/es_ES.ini
  5. +5
    -0
      lang/fr_FR.ini
  6. +6
    -1
      lang/hu_HU.ini
  7. +5
    -0
      lang/id_ID.ini
  8. +6
    -1
      lang/it_IT.ini
  9. +5
    -0
      lang/ko_KO.ini
  10. +5
    -0
      lang/ms_MY.ini
  11. +7
    -2
      lang/nl_NL.ini
  12. +6
    -1
      lang/pl_PL.ini
  13. +6
    -1
      lang/pt_BR.ini
  14. +6
    -1
      lang/ru_RU.ini
  15. +6
    -1
      lang/sv_SE.ini
  16. +6
    -1
      lang/tr_TR.ini
  17. +6
    -1
      lang/zh_TW.ini
  18. +48
    -0
      system/admin/views/config-widget.html.php
  19. +116
    -0
      system/includes/functions.php
  20. +2201
    -0
      system/plugins/matomo/MatomoTracker.php
  21. +1
    -0
      themes/blog/layout.html.php
  22. +1
    -0
      themes/clean/layout.html.php
  23. +1
    -0
      themes/logs/layout.html.php
  24. +1
    -0
      themes/readable/layout.html.php
  25. +1
    -0
      themes/twentyfifteen/layout.html.php
  26. +1
    -0
      themes/twentysixteen/layout.html.php

+ 1
- 1
content/data/configList.json View File

@ -1 +1 @@
["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","views.root","views.layout"]
["site.url", "timezone", "date.format", "language", "blog.title", "blog.tagline", "blog.description", "blog.copyright", "permalink.type", "static.frontpage", "blog.enable", "social.twitter", "social.facebook", "breadcrumb.home", "comment.system", "fb.appid", "fb.num", "fb.color", "disqus.shortname", "google.wmt.id", "google.analytics.id", "google.gtag.id", "google.reCaptcha", "google.reCaptcha.public", "google.reCaptcha.private", "posts.perpage", "category.perpage", "tag.perpage", "archive.perpage", "search.perpage", "profile.perpage", "type.perpage", "json.count", "category.info", "related.count", "recent.count", "popular.count", "teaser.type", "read.more", "teaser.char", "description.char", "rss.count", "rss.char", "views.counter", "sitemap.priority.base", "sitemap.priority.post", "sitemap.priority.static", "sitemap.priority.category", "sitemap.priority.tag", "sitemap.priority.archiveDay", "sitemap.priority.archiveMonth", "sitemap.priority.archiveYear", "sitemap.priority.author", "sitemap.priority.type", "prerelease", "cache.expiration", "cache.off", "generation.time", "cache.timestamp", "views.root", "views.layout", "matomo.id", "matomo.url", "matomo.token", "matomo.tracking"]

+ 5
- 0
lang/de_DE.ini View File

@ -248,3 +248,8 @@ Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope" Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Seiten ID"
Matomo_Tracking="Tracking Methode"

+ 6
- 1
lang/en_US.ini View File

@ -247,4 +247,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/es_ES.ini View File

@ -246,4 +246,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 5
- 0
lang/fr_FR.ini View File

@ -248,3 +248,8 @@ Github_pre_release="Pré-release Github"
Pre_release="Pré-release" Pre_release="Pré-release"
Yes_Im_in="Oui, je suis prêt" Yes_Im_in="Oui, je suis prêt"
Nope="Non !" Nope="Non !"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/hu_HU.ini View File

@ -247,4 +247,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 5
- 0
lang/id_ID.ini View File

@ -248,3 +248,8 @@ Github_pre_release="Pra-rilis Github"
Pre_release="Pra-rilis" Pre_release="Pra-rilis"
Yes_Im_in="Ya, saya ikut" Yes_Im_in="Ya, saya ikut"
Nope="Nggak" Nope="Nggak"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/it_IT.ini View File

@ -247,4 +247,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 5
- 0
lang/ko_KO.ini View File

@ -248,3 +248,8 @@ Github_pre_release = "Github에서의 시험판"
Pre_release = "사전 출시" Pre_release = "사전 출시"
Yes_Im_in = "그래, 난에있어" Yes_Im_in = "그래, 난에있어"
Nope = "아니" Nope = "아니"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 5
- 0
lang/ms_MY.ini View File

@ -248,3 +248,8 @@ Github_pre_release = "Github pra keluaran"
Pre_release = "Pra-release" Pre_release = "Pra-release"
Yes_Im_in = "Ya saya setuju" Yes_Im_in = "Ya saya setuju"
Nope = "Nope" Nope = "Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 7
- 2
lang/nl_NL.ini View File

@ -207,7 +207,7 @@ post_your_post_slug="/bericht/uw-bericht-slug"
Meta_description_character="Meta beschrijving" Meta_description_character="Meta beschrijving"
Breadcrumb_home_text="Breadcrumb home tekst" Breadcrumb_home_text="Breadcrumb home tekst"
Sitemap="Sitemap" Sitemap="Sitemap"
Valid_values_range_from_0_to_1.0._See="Geldige waarden variëren van 0,0 tot 1,0. Zie"
Valid_values_range_from_0_to_1.0._See="Geldige waarden variëren van 0,0 tot 1,0. Zie"
hint_Use_CtrlCMDF_to_search_for_your_config_key_or_value="<u>hint:</u> Use <code>Ctrl</code>/<code>CMD</code> + <code>F</code> to search for your config key or value." hint_Use_CtrlCMDF_to_search_for_your_config_key_or_value="<u>hint:</u> Use <code>Ctrl</code>/<code>CMD</code> + <code>F</code> to search for your config key or value."
pro_tips_You_can_creating_custom_config_key_and_print_out_your_config_key_value_anywhere_in_your_template="<u>pro tips:</u> You can creating custom config key and print out your config key value anywhere in your template." pro_tips_You_can_creating_custom_config_key_and_print_out_your_config_key_value_anywhere_in_your_template="<u>pro tips:</u> You can creating custom config key and print out your config key value anywhere in your template."
your_key="your.key" your_key="your.key"
@ -247,4 +247,9 @@ Page_generation_time="Generatietijd pagina"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Ja, ik doe mee" Yes_Im_in="Ja, ik doe mee"
Nope="Nietes"
Nope="Nietes"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/pl_PL.ini View File

@ -248,4 +248,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/pt_BR.ini View File

@ -247,4 +247,9 @@ Page_generation_time="Tempo de geração da página"
Github_pre_release="Pré-lançamento do Github" Github_pre_release="Pré-lançamento do Github"
Pre_release="Pré-lançamento" Pre_release="Pré-lançamento"
Yes_Im_in="Sim, estou dentro" Yes_Im_in="Sim, estou dentro"
Nope="Não"
Nope="Não"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/ru_RU.ini View File

@ -248,4 +248,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/sv_SE.ini View File

@ -265,4 +265,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/tr_TR.ini View File

@ -247,4 +247,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 6
- 1
lang/zh_TW.ini View File

@ -247,4 +247,9 @@ Page_generation_time="Page generation time"
Github_pre_release="Github pre-release" Github_pre_release="Github pre-release"
Pre_release="Pre-release" Pre_release="Pre-release"
Yes_Im_in="Yes I'm in" Yes_Im_in="Yes I'm in"
Nope="Nope"
Nope="Nope"
Matomo="Matomo"
Matomo_URL="Server"
Matomo_Token="Token"
Matomo_ID="Page ID"
Matomo_Tracking="Tracking Method"

+ 48
- 0
system/admin/views/config-widget.html.php View File

@ -150,6 +150,53 @@
<small><em><?php echo i18n('For_google_site_verification_meta');?></em></small> <small><em><?php echo i18n('For_google_site_verification_meta');?></em></small>
</div> </div>
</div> </div>
<br>
<h4><?php echo i18n('Matomo');?></h4>
<hr>
<div class="form-group row">
<label for="matamo.url" class="col-sm-2 col-form-label"><?php echo i18n('Matomo_URL');?></label>
<div class="col-sm-10">
<input type="text" name="-config-matomo.url" class="form-control" id="matomo.url" value="<?php echo valueMaker(config('matomo.url'));?>" placeholder="https://matomo.org/">
</div>
</div>
<div class="form-group row">
<label for="matomo.token" class="col-sm-2 col-form-label"><?php echo i18n('Matomo_Token');?></label>
<div class="col-sm-10">
<input type="text" name="-config-matomo.token" class="form-control" id="matomo.token" value="<?php echo valueMaker(config('matomo.token'));?>" placeholder="1234567890">
</div>
</div>
<div class="form-group row">
<label for="matomo.id" class="col-sm-2 col-form-label"><?php echo i18n('Matomo_ID');?></label>
<div class="col-sm-10">
<input type="text" name="-config-matomo.id" class="form-control" id="matomo.id" value="<?php echo valueMaker(config('matomo.id'));?>" placeholder="1">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('Matomo_Tracking');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-matomo.tracking" id="matomo.tracking1" value="disable" <?php if (config('matomo.tracking') === 'disable'):?>checked<?php endif;?>>
<label class="form-check-label" for="matomo.tracking1">
<?php echo i18n('Disabled');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-matomo.tracking" id="matomo.tracking2" value="javascript" <?php if (config('matomo.tracking') === 'javascript'):?>checked<?php endif;?>>
<label class="form-check-label" for="matomo.tracking2">
Javascript
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-matomo.tracking" id="matomo.tracking3" value="php" <?php if (config('matomo.tracking') === 'php'):?>checked<?php endif;?>>
<label class="form-check-label" for="matomo.tracking3">
PHP
</label>
</div>
</div>
</div>
</div>
<br> <br>
<h4><?php echo i18n('Social_Media');?></h4> <h4><?php echo i18n('Social_Media');?></h4>
<hr> <hr>
@ -170,4 +217,5 @@
<button type="submit" class="btn btn-primary"><?php echo i18n('Save_Config');?></button> <button type="submit" class="btn btn-primary"><?php echo i18n('Save_Config');?></button>
</div> </div>
</div> </div>
</form> </form>

+ 116
- 0
system/includes/functions.php View File

@ -5,6 +5,7 @@ use \Michelf\MarkdownExtra;
use \Suin\RSSWriter\Feed; use \Suin\RSSWriter\Feed;
use \Suin\RSSWriter\Channel; use \Suin\RSSWriter\Channel;
use \Suin\RSSWriter\Item; use \Suin\RSSWriter\Item;
use function Composer\Autoload\includeFile;
// Get blog post path. Unsorted. Mostly used on widget. // Get blog post path. Unsorted. Mostly used on widget.
function get_post_unsorted() function get_post_unsorted()
@ -2021,6 +2022,121 @@ EOF;
} }
} }
// Matomo
function matomo($title)
{
$matomoURL = config('matomo.url');
$matomoToken = config('matomo.token');
$matomoID = config('matomo.id');
$matomoTracking = config('matomo.tracking');
if($matomoTracking == 'disable')
{
return;
}
if(empty($matomoURL) || empty($matomoTracking) || empty($matomoID))
{
error_log("Please set all Matomo configuration values", 0);
return;
}
if($matomoTracking == 'javascript')
{
$jsURL = $matomoURL;
$imageURL = $matomoURL;
// remove http | https
if (startsWith($matomoURL, 'https'))
{
$jsURL = replace_first_str('https', '', $matomoURL);
}
else if (startsWith($matomoURL, 'http'))
{
$jsURL = replace_first_str('http', '', $matomoURL);
}
if(!endsWith($matomoURL, '/'))
{
$jsURL = $jsURL . '/';
$imageURL = $imageURL . "/";
}
$script = <<<EOF
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{$jsURL}";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{$matomoID}']);
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+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="{$imageURL}matomo.php?idsite={$matomoID}&amp;rec=1" style="border:0;" alt="" /></p></noscript>
EOF;
return $script;
}
else if($matomoTracking == 'php')
{
$url = $matomoURL;
if(empty($matomoToken))
{
error_log("Please set Matomo Token for PHP Tracking Method", 0);
return;
}
require_once ('system/plugins/matomo/MatomoTracker.php');
MatomoTracker::$URL = $url;
// Matomo object
$matomoTracker = new MatomoTracker((int) $matomoID, $url);
// TODO: async request without waiting?!
$matomoTracker->setRequestTimeout(10);
// Set authentication token
$matomoTracker->setTokenAuth($matomoToken);
// Track page view
$matomoTracker->doTrackPageView($title);
}
}
function startsWith($haystack, $needle, $case = true)
{
if ($case)
{
return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0);
}
return (strcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0);
}
function endsWith($haystack, $needle, $case = true)
{
if ($case)
{
return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0);
}
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0);
}
function replace_first_str($search_str, $replacement_str, $src_str)
{
return (false !== ($pos = strpos($src_str, $search_str))) ? substr_replace($src_str, $replacement_str, $pos, strlen($search_str)) : $src_str;
}
function slashUrl($url) { function slashUrl($url) {
return rtrim($url, '/') . '/'; return rtrim($url, '/') . '/';
} }


+ 2201
- 0
system/plugins/matomo/MatomoTracker.php
File diff suppressed because it is too large
View File


+ 1
- 0
themes/blog/layout.html.php View File

@ -192,5 +192,6 @@
<script type="text/javascript" src="<?php echo site_url();?>themes/blog/js/jquery-latest.min.js"></script> <script type="text/javascript" src="<?php echo site_url();?>themes/blog/js/jquery-latest.min.js"></script>
<script type="text/javascript" src="<?php echo site_url();?>themes/blog/js/bootstrap.min.js"></script> <script type="text/javascript" src="<?php echo site_url();?>themes/blog/js/bootstrap.min.js"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?> <?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
<?php if (matomo($title)): ?><?php echo matomo($title) ?><?php endif; ?>
</body> </body>
</html> </html>

+ 1
- 0
themes/clean/layout.html.php View File

@ -45,5 +45,6 @@
<?php echo content() ?> <?php echo content() ?>
</section> </section>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?> <?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
<?php if (matomo($title)): ?><?php echo matomo($title) ?><?php endif; ?>
</body> </body>
</html> </html>

+ 1
- 0
themes/logs/layout.html.php View File

@ -93,5 +93,6 @@
</div> </div>
</div> </div>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?> <?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
<?php if (matomo($title)): ?><?php echo matomo($title) ?><?php endif; ?>
</body> </body>
</html> </html>

+ 1
- 0
themes/readable/layout.html.php View File

@ -58,5 +58,6 @@
</div> </div>
</div> </div>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?> <?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
<?php if (matomo($title)): ?><?php echo matomo($title) ?><?php endif; ?>
</body> </body>
</html> </html>

+ 1
- 0
themes/twentyfifteen/layout.html.php View File

@ -132,6 +132,7 @@
<script type="text/javascript" src="<?php echo site_url();?>themes/twentyfifteen/js/functions.js"></script> <script type="text/javascript" src="<?php echo site_url();?>themes/twentyfifteen/js/functions.js"></script>
<script type="text/javascript" src="<?php echo site_url();?>themes/twentyfifteen/js/skip-link-focus-fix.js"></script> <script type="text/javascript" src="<?php echo site_url();?>themes/twentyfifteen/js/skip-link-focus-fix.js"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?> <?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
<?php if (matomo($title)): ?><?php echo matomo($title) ?><?php endif; ?>
</body> </body>
</html> </html>

+ 1
- 0
themes/twentysixteen/layout.html.php View File

@ -157,5 +157,6 @@
</script> </script>
<script type="text/javascript" src="<?php echo site_url();?>themes/twentysixteen/js/functions.js"></script> <script type="text/javascript" src="<?php echo site_url();?>themes/twentysixteen/js/functions.js"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?> <?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
<?php if (matomo($title)): ?><?php echo matomo($title) ?><?php endif; ?>
</body> </body>
</html> </html>

Loading…
Cancel
Save