-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSkinLakeus.php
80 lines (71 loc) · 2.59 KB
/
SkinLakeus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace MediaWiki\Skins\Lakeus;
use MediaWiki\SiteStats\SiteStats;
use SkinMustache;
class SkinLakeus extends SkinMustache {
/**
* Extends the getTemplateData function to add a template key 'html-myskin-hello-world'
* which can be rendered in skin.mustache using {{{html-myskin-hello-world}}}
*
* @return array
*/
public function getTemplateData(): array {
$data = parent::getTemplateData();
// this is a Config object
$config = $this->getConfig();
$data['html-articlecount'] = SiteStats::articles();
// trying to overwrite
$data['msg-lakeus-articlecount'] = $this->msg( 'lakeus-articlecount' )
->numParams( SiteStats::articles() )->parse();
$show_repository_link = $config->get( 'LakeusShowRepositoryLink' );
if ( $show_repository_link ) {
$data['html-repository-link'] = '<a href="https://github.com/lakejason0/mediawiki-skins-Lakeus">' .
$this->msg( 'lakeus-footermessage' )->escaped() . '</a>';
$data['is-repository-link-shown'] = true;
}
$data['is-notice-with-border'] = $config->get( 'LakeusSiteNoticeHasBorder' );
$data['is-portlet-animated'] = $config->get( 'LakeusShouldAnimatePortlets' );
$data['is-sticky-toc-shown'] = $config->get( 'LakeusShowStickyTOC' );
$page_tools_key = array_search(
'p-tb',
array_column( $data['data-portlets-sidebar']['array-portlets-rest'], 'id' )
);
$data['data-portlets']['data-page-tools'] =
$data['data-portlets-sidebar']['array-portlets-rest'][$page_tools_key];
unset( $data['data-portlets-sidebar']['array-portlets-rest'][$page_tools_key] );
$data['data-portlets-sidebar']['array-portlets-rest'] = array_values(
$data['data-portlets-sidebar']['array-portlets-rest']
);
$dropdown_portlet_keys = [
'data-user-menu',
'data-actions',
'data-page-tools',
'data-variants',
'data-languages',
];
foreach ( $dropdown_portlet_keys as $portlet_key ) {
if ( isset( $data['data-portlets'][$portlet_key] ) ) {
$data['data-portlets'][$portlet_key]['class'] = str_replace(
'mw-portlet mw-portlet-',
'mw-portlet mw-portlet-dropdown mw-portlet-',
$data['data-portlets'][$portlet_key]['class']
);
}
}
if ( empty( $data['data-toc']['array-sections'] ) ) {
unset( $data['data-toc'] );
}
$custom_indicators = $config->get( 'LakeusCustomIndicators' );
$id_tracker = [];
foreach ( $data['array-indicators'] as $item ) {
$id_tracker[$item['id']] = true;
}
foreach ( $custom_indicators as $indicator ) {
if ( !isset( $id_tracker[ $indicator['id'] ] ) ) {
$data['array-indicators'][] = $indicator;
$id_tracker[ $indicator['id'] ] = true;
}
}
return $data;
}
}