70 行
1.6 KiB
PHP
70 行
1.6 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\RNRSHook;
|
|
|
|
use MediaWiki\Preferences\Hook\GetPreferencesHook;
|
|
use OOUI\ButtonWidget;
|
|
use OOUI\HorizontalLayout;
|
|
use User;
|
|
|
|
/**
|
|
* Handler for GetPreferences hook
|
|
* Add hidden preference to keep dark mode turned on all pages
|
|
*
|
|
* @param User $user Current user
|
|
* @param array &$preferences
|
|
*/
|
|
class PreferencesHook implements GetPreferencesHook
|
|
{
|
|
/**
|
|
* @param User $user
|
|
* @param array &$preferences
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function onGetPreferences($user, &$preferences)
|
|
{
|
|
$manageButton = new ButtonWidget([
|
|
'href' => wfMessage('rnrshook-url')->text(),
|
|
'label' => wfMessage('rnrshook-ui-manage')->text()
|
|
]);
|
|
|
|
$control = new HorizontalLayout([
|
|
'items' => [$manageButton]
|
|
]);
|
|
|
|
$RNRSPrefs = [];
|
|
|
|
$RNRSPrefs['rnrshook-module'] = [
|
|
'type' => 'info',
|
|
'raw' => true,
|
|
'default' => (string)$control,
|
|
'label-message' => 'rnrshook-prefs-label',
|
|
'help-message' => 'rnrshook-prefs-label-desc',
|
|
'section' => 'personal/info',
|
|
];
|
|
|
|
$RNRSPrefs['rnrsverify'] = [
|
|
'type' => 'api'
|
|
];
|
|
|
|
$RNRSPrefs['rnrsverifyuserid'] = [
|
|
'type' => 'api'
|
|
];
|
|
|
|
$RNRSPrefs['rnrsverifyhash'] = [
|
|
'type' => 'api'
|
|
];
|
|
|
|
$RNRSPrefs['rnrsverifyhash2'] = [
|
|
'type' => 'api'
|
|
];
|
|
|
|
$RNRSPrefs['rnrsverifytime'] = [
|
|
'type' => 'api'
|
|
];
|
|
|
|
$preferences += $RNRSPrefs;
|
|
}
|
|
}
|