업데이트 README.md, .github/README.en.md
[liberty-mw-skin.git] / LibertyHooks.php
blob41bae20ae68412fcce6fb2bbe0b81d69ef2ff5e6
1 <?php //phpcs:ignore
2 class LibertyHooks extends Hooks{
3 /**
4 * @since 1.17.0
5 * @param OutputPage $out
6 * @param Skin $sk
7 * @param array &$bodyAttrs
8 */
9 public static function onOutputPageBodyAttributes( OutputPage $out, Skin $sk, &$bodyAttrs ) {
10 if ( $sk->getSkinName() === 'liberty' ) {
11 $bodyAttrs['class'] .= ' Liberty width-size';
15 /**
16 * Preference
17 * @param User $user user
18 * @param Preferences &$preferences preferences
20 public static function onGetPreferences( $user, &$preferences ) {
21 global $wgLibertyAdSetting, $wgLibertyAdGroup;
22 $service = MediaWiki\MediaWikiServices::getInstance();
23 $usergroupemanager = $service->getUserGroupManager();
24 $userGroups = $usergroupemanager->getUserGroups( $user );
25 $permissionManager = $service->getPermissionManager();
27 $preferences['liberty-layout-width'] = [
28 'type' => 'select',
29 'label-message' => 'liberty-pref-layout-width',
30 'section' => 'liberty/layout',
31 'options' => [
32 wfMessage( 'liberty-layout-select-1000' )->text() => '1000px',
33 wfMessage( 'liberty-layout-select-1100' )->text() => '1100px',
34 wfMessage( 'liberty-layout-select-1200' )->text() => null,
35 wfMessage( 'liberty-layout-select-1300' )->text() => '1300px',
36 wfMessage( 'liberty-layout-select-1400' )->text() => '1400px',
37 wfMessage( 'liberty-layout-select-1500' )->text() => '1500px',
38 wfMessage( 'liberty-layout-select-1600' )->text() => '1600px',
40 'help-message' => 'liberty-pref-layout-width-help',
41 'default' => null
44 $preferences['liberty-layout-navfix'] = [
45 'type' => 'toggle',
46 'label-message' => 'liberty-pref-layout-navfix',
47 'section' => 'liberty/layout',
50 $preferences['liberty-layout-sidebar'] = [
51 'type' => 'toggle',
52 'label-message' => 'liberty-pref-layout-sidebar',
53 'section' => 'liberty/layout',
56 $preferences['liberty-layout-controlbar'] = [
57 'type' => 'toggle',
58 'label-message' => 'liberty-pref-layout-controlbar',
59 'section' => 'liberty/layout',
62 if ( isset( $wgLibertyAdSetting['client'] ) && $wgLibertyAdSetting['client'] &&
63 isset( $wgLibertyAdGroup ) && $wgLibertyAdGroup == 'differ' ) {
64 if ( isset( $wgLibertyAdSetting['belowarticle'] ) && $wgLibertyAdSetting['belowarticle']
65 && $permissionManager->userHasRight( $user, 'blockads-belowarticle' ) ) {
66 $preferences['liberty-ads-morearticle'] = [
67 'type' => 'toggle',
68 'label-message' => 'liberty-pref-ads-belowarticle',
69 'section' => 'liberty/ads',
73 if ( isset( $wgLibertyAdSetting['header'] ) && $wgLibertyAdSetting['header'] &&
74 $permissionManager->userHasRight( $user, 'blockads-header' ) ) {
75 $preferences['liberty-ads-header'] = [
76 'type' => 'toggle',
77 'label-message' => 'liberty-pref-ads-header',
78 'section' => 'liberty/ads',
82 if ( isset( $wgLibertyAdSetting['right'] ) && $wgLibertyAdSetting['right'] &&
83 $permissionManager->userHasRight( $user, 'blockads-right' ) ) {
84 $preferences['liberty-ads-rightads'] = [
85 'type' => 'toggle',
86 'label-message' => 'liberty-pref-ads-right',
87 'section' => 'liberty/ads',
91 if ( isset( $wgLibertyAdSetting['bottom'] ) && $wgLibertyAdSetting['bottom'] &&
92 $permissionManager->userHasRight( $user, 'blockads-bottom' ) ) {
93 $preferences['liberty-ads-bottom'] = [
94 'type' => 'toggle',
95 'label-message' => 'liberty-pref-ads-bottom',
96 'section' => 'liberty/ads',
101 $preferences['liberty-color-main'] = [
102 'type' => 'text',
103 'label-message' => 'liberty-pref-color-main',
104 'section' => 'liberty/color',
105 'help-message' => 'liberty-pref-color-main-help'
108 $preferences['liberty-color-second'] = [
109 'type' => 'text',
110 'label-message' => 'liberty-pref-color-second',
111 'section' => 'liberty/color',
112 'help-message' => 'liberty-pref-color-second-help'
115 $preferences['liberty-font'] = [
116 'type' => 'selectorother',
117 'label-message' => 'liberty-pref-fonts',
118 'section' => 'liberty/font',
119 'options' => [
120 wfMessage( 'liberty-font-name-default' )->text() => null,
121 wfMessage( 'liberty-font-name-noto-sans-kr' )->text() => 'Noto Sans KR',
122 wfMessage( 'liberty-font-name-noto-serif-kr' )->text() => 'Noto Serif KR',
123 wfMessage( 'liberty-font-name-spoqa-han-sans' )->text() => 'Spoqa Han Sans',
124 wfMessage( 'liberty-font-name-nanum-gothic' )->text() => 'Nanum Gothic',
125 wfMessage( 'liberty-font-name-nanum-myeongjo' )->text() => 'Nanum Myeongjo',
126 wfMessage( 'liberty-font-name-dokdo' )->text() => 'Dokdo',
127 wfMessage( 'liberty-font-name-gaegu' )->text() => 'Gaegu',
128 wfMessage( 'liberty-font-name-hankc' )->text() => 'Hankc',
129 wfMessage( 'liberty-font-name-youth' )->text() => 'Youth',
130 wfMessage( 'liberty-font-name-malgun-gothic' )->text() => 'Malgun Gothic'
132 'help-message' => 'liberty-pref-fonts-help',
133 'default' => null,
136 $preferences['liberty-dark'] = [
137 'type' => 'select',
138 'label-message' => 'liberty-pref-dark',
139 'section' => 'liberty/color',
140 'options' => [
141 wfMessage( 'liberty-dark-default' )->text() => null,
142 wfMessage( 'liberty-dark-dark' )->text() => 'dark',
143 wfMessage( 'liberty-dark-light' )->text() => 'light'
145 'help-message' => 'liberty-pref-dark-help',
146 'default' => null