Page MenuHomeWickedGov Phorge

PreferencesHooksHandler.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

PreferencesHooksHandler.php

<?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' => '&#160;',
'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

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)

Event Timeline