use Exception;
use Hooks;
use Html;
-use HtmlArmor;
use HTMLForm;
use HTMLFormField;
use IContextSource;
use Psr\Log\NullLogger;
use Skin;
use SpecialPage;
-use SpecialPreferences;
use Status;
use Title;
use UnexpectedValueException;
public function getFormDescriptor( User $user, IContextSource $context ) {
$preferences = [];
- if ( SpecialPreferences::isOouiEnabled( $context ) ) {
- OutputPage::setupOOUI(
- strtolower( $context->getSkin()->getSkinName() ),
- $context->getLanguage()->getDir()
- );
- }
+ OutputPage::setupOOUI(
+ strtolower( $context->getSkin()->getSkinName() ),
+ $context->getLanguage()->getDir()
+ );
$canIPUseHTTPS = wfCanIPUseHTTPS( $context->getRequest()->getIP() );
$this->profilePreferences( $user, $context, $preferences, $canIPUseHTTPS );
protected function profilePreferences(
User $user, IContextSource $context, &$defaultPreferences, $canIPUseHTTPS
) {
- $oouiEnabled = SpecialPreferences::isOouiEnabled( $context );
-
// retrieving user name for GENDER and misc.
$userName = $user->getName();
continue;
}
- if ( isset( $userGroupMemberships[$ueg] ) ) {
- $groupStringOrObject = $userGroupMemberships[$ueg];
- } else {
- $groupStringOrObject = $ueg;
- }
+ $groupStringOrObject = $userGroupMemberships[$ueg] ?? $ueg;
$userG = UserGroupMembership::getLink( $groupStringOrObject, $context, 'html' );
$userM = UserGroupMembership::getLink( $groupStringOrObject, $context, 'html',
if ( $canEditPrivateInfo && $this->authManager->allowsAuthenticationDataChange(
new PasswordAuthenticationRequest(), false )->isGood()
) {
- if ( $oouiEnabled ) {
- $link = new \OOUI\ButtonWidget( [
+ $defaultPreferences['password'] = [
+ 'type' => 'info',
+ 'raw' => true,
+ 'default' => (string)new \OOUI\ButtonWidget( [
'href' => SpecialPage::getTitleFor( 'ChangePassword' )->getLinkURL( [
'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText()
] ),
'label' => $context->msg( 'prefs-resetpass' )->text(),
- ] );
- } else {
- $link = $this->linkRenderer->makeLink( SpecialPage::getTitleFor( 'ChangePassword' ),
- $context->msg( 'prefs-resetpass' )->text(), [],
- [ 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ] );
- }
-
- $defaultPreferences['password'] = [
- 'type' => 'info',
- 'raw' => true,
- 'default' => (string)$link,
+ ] ),
'label-message' => 'yourpassword',
'section' => 'personal/info',
];
$user,
ParserOptions::newFromContext( $context )
);
- $oldsigHTML = $context->getOutput()->parseInline( $oldsigWikiText, true, true );
+ $oldsigHTML = Parser::stripOuterParagraph(
+ $context->getOutput()->parseAsContent( $oldsigWikiText )
+ );
$defaultPreferences['oldsig'] = [
'type' => 'info',
'raw' => true,
$emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : '';
if ( $canEditPrivateInfo && $this->authManager->allowsPropertyChange( 'emailaddress' ) ) {
- if ( $oouiEnabled ) {
- $link = new \OOUI\ButtonWidget( [
- 'href' => SpecialPage::getTitleFor( 'ChangeEmail' )->getLinkURL( [
- 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText()
- ] ),
- 'label' =>
- $context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->text(),
- ] );
-
- $emailAddress .= $emailAddress == '' ? $link : ( '<br />' . $link );
- } else {
- $link = $this->linkRenderer->makeLink(
- SpecialPage::getTitleFor( 'ChangeEmail' ),
+ $button = new \OOUI\ButtonWidget( [
+ 'href' => SpecialPage::getTitleFor( 'ChangeEmail' )->getLinkURL( [
+ 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText()
+ ] ),
+ 'label' =>
$context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->text(),
- [],
- [ 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ] );
+ ] );
- $emailAddress .= $emailAddress == '' ? $link : (
- $context->msg( 'word-separator' )->escaped()
- . $context->msg( 'parentheses' )->rawParams( $link )->escaped()
- );
- }
+ $emailAddress .= $emailAddress == '' ? $button : ( '<br />' . $button );
}
$defaultPreferences['emailaddress'] = [
$emailauthenticationclass = 'mw-email-authenticated';
} else {
$disableEmailPrefs = true;
- if ( $oouiEnabled ) {
- $emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
- new \OOUI\ButtonWidget( [
- 'href' => SpecialPage::getTitleFor( 'Confirmemail' )->getLinkURL(),
- 'label' => $context->msg( 'emailconfirmlink' )->text(),
- ] );
- } else {
- $emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
- $this->linkRenderer->makeKnownLink(
- SpecialPage::getTitleFor( 'Confirmemail' ),
- $context->msg( 'emailconfirmlink' )->text()
- ) . '<br />';
- }
+ $emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
+ new \OOUI\ButtonWidget( [
+ 'href' => SpecialPage::getTitleFor( 'Confirmemail' )->getLinkURL(),
+ 'label' => $context->msg( 'emailconfirmlink' )->text(),
+ ] );
$emailauthenticationclass = "mw-email-not-authenticated";
}
} else {
'section' => 'editing/editor',
'label-message' => 'tog-useeditwarning',
];
- $defaultPreferences['showtoolbar'] = [
- 'type' => 'toggle',
- 'section' => 'editing/editor',
- 'label-message' => 'tog-showtoolbar',
- ];
$defaultPreferences['previewonfirst'] = [
'type' => 'toggle',
];
}
- if ( $this->config->get( 'StructuredChangeFiltersShowPreference' ) ) {
- $defaultPreferences['rcenhancedfilters-disable'] = [
- 'type' => 'toggle',
- 'section' => 'rc/optoutrc',
- 'label-message' => 'rcfilters-preference-label',
- 'help-message' => 'rcfilters-preference-help',
- ];
- }
+ $defaultPreferences['rcenhancedfilters-disable'] = [
+ 'type' => 'toggle',
+ 'section' => 'rc/optoutrc',
+ 'label-message' => 'rcfilters-preference-label',
+ 'help-message' => 'rcfilters-preference-help',
+ ];
}
/**
protected function watchlistPreferences(
User $user, IContextSource $context, &$defaultPreferences
) {
- $oouiEnabled = SpecialPreferences::isOouiEnabled( $context );
-
$watchlistdaysMax = ceil( $this->config->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
# # Watchlist #####################################
];
foreach ( $editWatchlistModes as $mode => $options ) {
// Messages: prefs-editwatchlist-edit, prefs-editwatchlist-raw, prefs-editwatchlist-clear
- if ( $oouiEnabled ) {
- $editWatchlistLinks .=
- new \OOUI\ButtonWidget( [
- 'href' => SpecialPage::getTitleFor( 'EditWatchlist', $options['subpage'] )->getLinkURL(),
- 'flags' => $options[ 'flags' ],
- 'label' => new \OOUI\HtmlSnippet(
- $context->msg( "prefs-editwatchlist-{$mode}" )->parse()
- ),
- ] );
- } else {
- $editWatchlistLinksOld[] = $this->linkRenderer->makeKnownLink(
- SpecialPage::getTitleFor( 'EditWatchlist', $options['subpage'] ),
- new HtmlArmor( $context->msg( "prefs-editwatchlist-{$mode}" )->parse() )
- );
- }
+ $editWatchlistLinks .=
+ new \OOUI\ButtonWidget( [
+ 'href' => SpecialPage::getTitleFor( 'EditWatchlist', $options['subpage'] )->getLinkURL(),
+ 'flags' => $options[ 'flags' ],
+ 'label' => new \OOUI\HtmlSnippet(
+ $context->msg( "prefs-editwatchlist-{$mode}" )->parse()
+ ),
+ ] );
}
$defaultPreferences['editwatchlist'] = [
'type' => 'info',
'raw' => true,
- 'default' => $oouiEnabled ?
- $editWatchlistLinks :
- $context->getLanguage()->pipeList( $editWatchlistLinksOld ),
+ 'default' => $editWatchlistLinks,
'label-message' => 'prefs-editwatchlist-label',
'section' => 'watchlist/editwatchlist',
];
'type' => 'api',
];
- if ( $oouiEnabled ) {
- $tokenButton = new \OOUI\ButtonWidget( [
- 'href' => SpecialPage::getTitleFor( 'ResetTokens' )->getLinkURL( [
- 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText()
- ] ),
- 'label' => $context->msg( 'prefs-watchlist-managetokens' )->text(),
- ] );
- $defaultPreferences['watchlisttoken-info'] = [
- 'type' => 'info',
- 'section' => 'watchlist/tokenwatchlist',
- 'label-message' => 'prefs-watchlist-token',
- 'help-message' => 'prefs-help-tokenmanagement',
- 'raw' => true,
- 'default' => (string)$tokenButton,
- ];
- } else {
- $defaultPreferences['watchlisttoken-info'] = [
- 'type' => 'info',
- 'section' => 'watchlist/tokenwatchlist',
- 'label-message' => 'prefs-watchlist-token',
- 'default' => $user->getTokenFromOption( 'watchlisttoken' ),
- 'help-message' => 'prefs-help-watchlist-token2',
- ];
- }
+ $tokenButton = new \OOUI\ButtonWidget( [
+ 'href' => SpecialPage::getTitleFor( 'ResetTokens' )->getLinkURL( [
+ 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText()
+ ] ),
+ 'label' => $context->msg( 'prefs-watchlist-managetokens' )->text(),
+ ] );
+ $defaultPreferences['watchlisttoken-info'] = [
+ 'type' => 'info',
+ 'section' => 'watchlist/tokenwatchlist',
+ 'label-message' => 'prefs-watchlist-token',
+ 'help-message' => 'prefs-help-tokenmanagement',
+ 'raw' => true,
+ 'default' => (string)$tokenButton,
+ ];
- if ( $this->config->get( 'StructuredChangeFiltersShowWatchlistPreference' ) ) {
- $defaultPreferences['wlenhancedfilters-disable'] = [
- 'type' => 'toggle',
- 'section' => 'watchlist/optoutwatchlist',
- 'label-message' => 'rcfilters-watchlist-preference-label',
- 'help-message' => 'rcfilters-watchlist-preference-help',
- ];
- }
+ $defaultPreferences['wlenhancedfilters-disable'] = [
+ 'type' => 'toggle',
+ 'section' => 'watchlist/optoutwatchlist',
+ 'label-message' => 'rcfilters-watchlist-preference-label',
+ 'help-message' => 'rcfilters-watchlist-preference-help',
+ ];
}
/**
$formClass = PreferencesFormLegacy::class,
array $remove = []
) {
- if ( SpecialPreferences::isOouiEnabled( $context ) ) {
- // We use ButtonWidgets in some of the getPreferences() functions
- $context->getOutput()->enableOOUI();
- }
+ // We use ButtonWidgets in some of the getPreferences() functions
+ $context->getOutput()->enableOOUI();
$formDescriptor = $this->getFormDescriptor( $user, $context );
if ( count( $remove ) ) {
$urlOptions['eauth'] = 1;
}
- if (
- $context->getRequest()->getFuzzyBool( 'ooui' ) !==
- $context->getConfig()->get( 'OOUIPreferences' )
- ) {
- $urlOptions[ 'ooui' ] = $context->getRequest()->getFuzzyBool( 'ooui' ) ? 1 : 0;
- }
-
$urlOptions += $form->getExtraSuccessRedirectParameters();
$url = $form->getTitle()->getFullURL( $urlOptions );