Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4128280
PreferencesHooksHandler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PreferencesHooksHandler.php
View Options
<?php
namespace
MediaWiki\Extension\Math\HookHandlers
;
use
MediaWiki\Extension\Math\MathConfig
;
use
MediaWiki\Logger\LoggerFactory
;
use
MediaWiki\Preferences\Hook\GetPreferencesHook
;
use
MediaWiki\User\Hook\UserGetDefaultOptionsHook
;
class
PreferencesHooksHandler
implements
UserGetDefaultOptionsHook
,
GetPreferencesHook
{
/** @var MathConfig */
private
$mathConfig
;
/**
* @param MathConfig $mathConfig
*/
public
function
__construct
(
MathConfig
$mathConfig
)
{
$this
->
mathConfig
=
$mathConfig
;
}
/** @inheritDoc */
public
function
onUserGetDefaultOptions
(
&
$defaultOptions
)
{
// Normalize the default use option in case it's not a valid rendering mode. BUG 64844
$mode
=
$defaultOptions
[
'math'
]
=
MathConfig
::
normalizeRenderingMode
(
$defaultOptions
[
'math'
]
);
if
(
!
$this
->
mathConfig
->
isValidRenderingMode
(
$mode
)
)
{
$validModes
=
$this
->
mathConfig
->
getValidRenderingModes
();
LoggerFactory
::
getInstance
(
'Math'
)
->
error
(
"Misconfiguration: wgDefaultUserOptions['math'] is not an enabled mode"
,
[
'valid_modes'
=>
$validModes
,
'configured_default'
=>
$mode
,
]
);
$defaultOptions
[
'math'
]
=
$validModes
[
0
];
}
}
/** @inheritDoc */
public
function
onGetPreferences
(
$user
,
&
$preferences
)
{
$preferences
[
'math'
]
=
[
'type'
=>
'radio'
,
'options-messages'
=>
array_flip
(
$this
->
mathConfig
->
getValidRenderingModeKeys
()
),
'label'
=>
' '
,
'section'
=>
'rendering/math'
,
];
$preferences
[
'math-popups'
]
=
[
'type'
=>
'toggle'
,
'label-message'
=>
'popups-settings-option-math-tooltip'
,
'section'
=>
'rendering/math'
,
'help-message'
=>
'popups-settings-option-math-tooltip-description'
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 09:10 (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b0/3e/3e3a23ce0e209cf60efb82d67628
Default Alt Text
PreferencesHooksHandler.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment