Skip to content

Commit 8eb83b9

Browse files
Merge branch 'fuerthwiki-statistik' into master_origin
# Conflicts: # i18n/de.json
2 parents f0e86c1 + 78144eb commit 8eb83b9

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

extension.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"author": [
44
"John Lewis",
55
"Southparkfan",
6-
"Universal Omega"
6+
"Universal Omega",
7+
"Mark Muzenhardt"
78
],
89
"url": "https://github.com/miraheze/MatomoAnalytics",
910
"version": "1.1.3",
@@ -30,10 +31,12 @@
3031
"MatomoAnalyticsOOUIForm": "includes/MatomoAnalyticsOOUIForm.php",
3132
"MatomoAnalyticsViewer": "includes/MatomoAnalyticsViewer.php",
3233
"MatomoAnalyticsWiki": "includes/MatomoAnalyticsWiki.php",
33-
"SpecialAnalytics": "includes/SpecialAnalytics.php"
34+
"SpecialAnalytics": "includes/SpecialAnalytics.php",
35+
"SpecialPageAnalytics": "includes/SpecialAnalytics.php"
3436
},
3537
"SpecialPages": {
36-
"Analytics": "SpecialAnalytics"
38+
"Analytics": "SpecialAnalytics",
39+
"PageAnalytics": "SpecialPageAnalytics"
3740
},
3841
"Hooks": {
3942
"CreateWikiCreation": [
@@ -50,7 +53,8 @@
5053
],
5154
"SkinAfterBottomScripts": [
5255
"MatomoAnalyticsHooks::matomoScript"
53-
]
56+
],
57+
"SkinAddFooterLinks": "MatomoAnalyticsHooks::onSkinAddFooterLinks"
5458
},
5559
"ResourceModules": {
5660
"ext.matomoanalytics.oouiform": {

includes/MatomoAnalyticsHooks.php

+23
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,27 @@ public static function matomoScript( $skin, &$text ) {
9191

9292
return true;
9393
}
94+
95+
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks ) {
96+
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'matomoanalytics' );
97+
$mAId = MatomoAnalytics::getSiteID( $config->get( 'DBname' ) );
98+
$id = strval( $mAId );
99+
$serverurl = $config->get( 'MatomoAnalyticsServerURL' );
100+
$title = $skin->getRelevantTitle();
101+
$urltitle = $title->getPrefixedURL();
102+
103+
if ( $key === 'places' ) {
104+
$footerlinks['statistics'] = Html::rawElement( 'a', [ 'href' => "{$serverurl}
105+
?module=API
106+
&method=ImageGraph.get&idSite={$id}
107+
&segment=pageUrl=\${$urltitle}
108+
&apiModule=VisitsSummary
109+
&apiAction=get
110+
&token_auth=anonymous
111+
&graphType=evolution
112+
&period=day
113+
&date=previous90" ], 'Statistik' );
114+
// verticalBar could also be used as graphType
115+
}
116+
}
94117
}

includes/SpecialAnalytics.php

+31
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,34 @@ public function execute( $par ) {
2525
$htmlForm->show();
2626
}
2727
}
28+
29+
class SpecialPageAnalytics extends SpecialPage {
30+
public function __construct() {
31+
parent::__construct( 'PageAnalytics' );
32+
}
33+
34+
public function execute( $par ) {
35+
$this->setHeaders();
36+
$this->outputHeader();
37+
38+
$out = $this->getOutput();
39+
$out->addWikiMsg( 'matomoanalytics-header' );
40+
$out->addModules( 'ext.matomoanalytics.oouiform' );
41+
42+
$analyticsViewer = new MatomoAnalyticsViewer();
43+
$htmlForm = $analyticsViewer->getForm( $this->getContext() );
44+
$sectionTitles = $htmlForm->getFormSections();
45+
46+
$sectTabs = [];
47+
foreach ( $sectionTitles as $key ) {
48+
$sectTabs[] = [
49+
'name' => $key,
50+
'label' => $htmlForm->getLegend( $key )
51+
];
52+
}
53+
54+
$out->addJsConfigVars( 'wgMatomoAnalyticsOOUIFormTabs', $sectTabs );
55+
56+
$htmlForm->show();
57+
}
58+
}

0 commit comments

Comments
 (0)