*/
static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
## Remove preferences that wikis don't want to use
- global $wgHiddenPrefs;
- foreach ( $wgHiddenPrefs as $pref ) {
+ foreach ( $context->getConfig()->get( 'HiddenPrefs' ) as $pref ) {
if ( isset( $defaultPreferences[$pref] ) ) {
unset( $defaultPreferences[$pref] );
}
* @return void
*/
static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgAuth, $wgContLang, $wgParser, $wgLanguageCode,
- $wgDisableLangConversion, $wgMaxSigChars,
- $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
- $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
- $wgSecureLogin;
+ global $wgAuth, $wgContLang, $wgParser;
+ $config = $context->getConfig();
// retrieving user name for GENDER and misc.
$userName = $user->getName();
);
}
// Only show prefershttps if secure login is turned on
- if ( $wgSecureLogin && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) {
+ if ( $config->get( 'SecureLogin' ) && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) {
$defaultPreferences['prefershttps'] = array(
'type' => 'toggle',
'label-message' => 'tog-prefershttps',
// Language
$languages = Language::fetchLanguageNames( null, 'mw' );
- if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
- $languages[$wgLanguageCode] = $wgLanguageCode;
+ $languageCode = $config->get( 'LanguageCode' );
+ if ( !array_key_exists( $languageCode, $languages ) ) {
+ $languages[$languageCode] = $languageCode;
}
ksort( $languages );
);
// see if there are multiple language variants to choose from
- if ( !$wgDisableLangConversion ) {
+ if ( !$config->get( 'DisableLangConversion' ) ) {
foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
if ( $langCode == $wgContLang->getCode() ) {
$variants = $wgContLang->getVariants();
);
$defaultPreferences['nickname'] = array(
'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info',
- 'maxlength' => $wgMaxSigChars,
+ 'maxlength' => $config->get( 'MaxSigChars' ),
'label-message' => 'yournick',
'validation-callback' => array( 'Preferences', 'validateSignature' ),
'section' => 'personal/signature',
## Email stuff
- if ( $wgEnableEmail ) {
+ if ( $config->get( 'EnableEmail' ) ) {
if ( $canViewPrivateInfo ) {
- $helpMessages[] = $wgEmailConfirmToEdit
+ $helpMessages[] = $config->get( 'EmailConfirmToEdit' )
? 'prefs-help-email-required'
: 'prefs-help-email';
- if ( $wgEnableUserEmail ) {
+ if ( $config->get( 'EnableUserEmail' ) ) {
// additional messages when users can send email to each other
$helpMessages[] = 'prefs-help-email-others';
}
$disableEmailPrefs = false;
- if ( $wgEmailAuthentication ) {
+ if ( $config->get( 'EmailAuthentication' ) ) {
$emailauthenticationclass = 'mw-email-not-authenticated';
if ( $user->getEmail() ) {
if ( $user->getEmailAuthenticationTimestamp() ) {
}
}
- if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
+ if ( $config->get( 'EnableUserEmail' ) && $user->isAllowed( 'sendemail' ) ) {
$defaultPreferences['disablemail'] = array(
'type' => 'toggle',
'invert' => true,
);
}
- if ( $wgEnotifWatchlist ) {
+ if ( $config->get( 'EnotifWatchlist' ) ) {
$defaultPreferences['enotifwatchlistpages'] = array(
'type' => 'toggle',
'section' => 'personal/email',
'disabled' => $disableEmailPrefs,
);
}
- if ( $wgEnotifUserTalk ) {
+ if ( $config->get( 'EnotifUserTalk' ) ) {
$defaultPreferences['enotifusertalkpages'] = array(
'type' => 'toggle',
'section' => 'personal/email',
'disabled' => $disableEmailPrefs,
);
}
- if ( $wgEnotifUserTalk || $wgEnotifWatchlist ) {
+ if ( $config->get( 'EnotifUserTalk' ) || $config->get( 'EnotifWatchlist' ) ) {
$defaultPreferences['enotifminoredits'] = array(
'type' => 'toggle',
'section' => 'personal/email',
'disabled' => $disableEmailPrefs,
);
- if ( $wgEnotifRevealEditorAddress ) {
+ if ( $config->get( 'EnotifRevealEditorAddress' ) ) {
$defaultPreferences['enotifrevealaddr'] = array(
'type' => 'toggle',
'section' => 'personal/email',
*/
static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
## Skin #####################################
- global $wgAllowUserCss, $wgAllowUserJs;
// Skin selector, if there is at least one valid skin
$skinOptions = self::generateSkinOptions( $user, $context );
);
}
+ $config = $context->getConfig();
+ $allowUserCss = $config->get( 'AllowUserCss' );
+ $allowUserJs = $config->get( 'AllowUserJs' );
# Create links to user CSS/JS pages for all skins
# This code is basically copied from generateSkinOptions(). It'd
# be nice to somehow merge this back in there to avoid redundancy.
- if ( $wgAllowUserCss || $wgAllowUserJs ) {
+ if ( $allowUserCss || $allowUserJs ) {
$linkTools = array();
$userName = $user->getName();
- if ( $wgAllowUserCss ) {
+ if ( $allowUserCss ) {
$cssPage = Title::makeTitleSafe( NS_USER, $userName . '/common.css' );
$linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() );
}
- if ( $wgAllowUserJs ) {
+ if ( $allowUserJs ) {
$jsPage = Title::makeTitleSafe( NS_USER, $userName . '/common.js' );
$linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
}
);
## Page Rendering ##############################
- global $wgAllowUserCssPrefs;
- if ( $wgAllowUserCssPrefs ) {
+ if ( $context->getConfig()->get( 'AllowUserCssPrefs' ) ) {
$defaultPreferences['underline'] = array(
'type' => 'select',
'options' => array(
* @param array $defaultPreferences
*/
static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgAllowUserCssPrefs;
-
## Editing #####################################
$defaultPreferences['editsectiononrightclick'] = array(
'type' => 'toggle',
'label-message' => 'tog-editondblclick',
);
- if ( $wgAllowUserCssPrefs ) {
+ if ( $context->getConfig()->get( 'AllowUserCssPrefs' ) ) {
$defaultPreferences['editfont'] = array(
'type' => 'select',
'section' => 'editing/editor',
* @param array $defaultPreferences
*/
static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgRCMaxAge, $wgRCShowWatchingUsers;
-
+ $config = $context->getConfig();
+ $rcMaxAge = $config->get( 'RCMaxAge' );
## RecentChanges #####################################
$defaultPreferences['rcdays'] = array(
'type' => 'float',
'label-message' => 'recentchangesdays',
'section' => 'rc/displayrc',
'min' => 1,
- 'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ),
+ 'max' => ceil( $rcMaxAge / ( 3600 * 24 ) ),
'help' => $context->msg( 'recentchangesdays-max' )->numParams(
- ceil( $wgRCMaxAge / ( 3600 * 24 ) ) )->text()
+ ceil( $rcMaxAge / ( 3600 * 24 ) ) )->text()
);
$defaultPreferences['rclimit'] = array(
'type' => 'int',
);
}
- if ( $wgRCShowWatchingUsers ) {
+ if ( $config->get( 'RCShowWatchingUsers' ) ) {
$defaultPreferences['shownumberswatching'] = array(
'type' => 'toggle',
'section' => 'rc/advancedrc',
* @param array $defaultPreferences
*/
static function watchlistPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge;
-
- $watchlistdaysMax = ceil( $wgRCMaxAge / ( 3600 * 24 ) );
+ $config = $context->getConfig();
+ $watchlistdaysMax = ceil( $config->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
## Watchlist #####################################
$defaultPreferences['watchlistdays'] = array(
'label-message' => 'tog-watchlisthideliu',
);
- if ( $wgUseRCPatrol ) {
+ if ( $context->getConfig()->get( 'UseRCPatrol' ) ) {
$defaultPreferences['watchlisthidepatrolled'] = array(
'type' => 'toggle',
'section' => 'watchlist/advancedwatchlist',
}
}
- if ( $wgEnableAPI ) {
+ if ( $config->get( 'EnableAPI' ) ) {
$defaultPreferences['watchlisttoken'] = array(
'type' => 'api',
);
* @return array Text/links to display as key; $skinkey as value
*/
static function generateSkinOptions( $user, IContextSource $context ) {
- global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs;
$ret = array();
$mptitle = Title::newMainPage();
}
asort( $validSkinNames );
+ $config = $context->getConfig();
+ $defaultSkin = $config->get( 'DefaultSkin' );
+ $allowUserCss = $config->get( 'AllowUserCss' );
+ $allowUserJs = $config->get( 'AllowUserJs' );
+
$foundDefault = false;
foreach ( $validSkinNames as $skinkey => $sn ) {
$linkTools = array();
# Mark the default skin
- if ( $skinkey == $wgDefaultSkin ) {
+ if ( $skinkey == $defaultSkin ) {
$linkTools[] = $context->msg( 'default' )->escaped();
$foundDefault = true;
}
$linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
# Create links to user CSS/JS pages
- if ( $wgAllowUserCss ) {
+ if ( $allowUserCss ) {
$cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.css' );
$linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() );
}
- if ( $wgAllowUserJs ) {
+ if ( $allowUserJs ) {
$jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.js' );
$linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() );
}
// Bug 19237
}
- // KLUGE: site default might not be valid for user language
+ // FIXME KLUGE: site default might not be valid for user language
global $wgDefaultUserOptions;
if ( !in_array( $wgDefaultUserOptions['date'], $dateopts ) ) {
$wgDefaultUserOptions['date'] = 'default';
* @return array
*/
static function getImageSizes( IContextSource $context ) {
- global $wgImageLimits;
-
$ret = array();
$pixels = $context->msg( 'unit-pixel' )->text();
- foreach ( $wgImageLimits as $index => $limits ) {
+ foreach ( $context->getConfig()->get( 'ImageLimits' ) as $index => $limits ) {
$display = "{$limits[0]}×{$limits[1]}" . $pixels;
$ret[$display] = $index;
}
* @return array
*/
static function getThumbSizes( IContextSource $context ) {
- global $wgThumbLimits;
-
$ret = array();
$pixels = $context->msg( 'unit-pixel' )->text();
- foreach ( $wgThumbLimits as $index => $size ) {
+ foreach ( $context->getConfig()->get( 'ThumbLimits' ) as $index => $size ) {
$display = $size . $pixels;
$ret[$display] = $index;
}
* @return bool|string
*/
static function validateSignature( $signature, $alldata, $form ) {
- global $wgParser, $wgMaxSigChars;
- if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
+ global $wgParser;
+ $maxSigChars = $form->getConfig()->get( 'MaxSigChars' );
+ if ( mb_strlen( $signature ) > $maxSigChars ) {
return Xml::element( 'span', array( 'class' => 'error' ),
- $form->msg( 'badsiglength' )->numParams( $wgMaxSigChars )->text() );
+ $form->msg( 'badsiglength' )->numParams( $maxSigChars )->text() );
} elseif ( isset( $alldata['fancysig'] ) &&
$alldata['fancysig'] &&
$wgParser->validateSig( $signature ) === false
static function getTimezoneOptions( IContextSource $context ) {
$opt = array();
- global $wgLocalTZoffset;
+ $localTZoffset = $context->getConfig()->get( 'LocalTZoffset' );
$timestamp = MWTimestamp::getLocalInstance();
- // Check that $wgLocalTZoffset is the same as the local time zone offset
- if ( $wgLocalTZoffset == $timestamp->format( 'Z' ) / 60 ) {
+ // Check that the LocalTZoffset is the same as the local time zone offset
+ if ( $localTZoffset == $timestamp->format( 'Z' ) / 60 ) {
$server_tz_msg = $context->msg(
'timezoneuseserverdefault',
$timestamp->getTimezone()->getName()
} else {
$tzstring = sprintf(
'%+03d:%02d',
- floor( $wgLocalTZoffset / 60 ),
- abs( $wgLocalTZoffset ) % 60
+ floor( $localTZoffset / 60 ),
+ abs( $localTZoffset ) % 60
);
$server_tz_msg = $context->msg( 'timezoneuseserverdefault', $tzstring )->text();
}
- $opt[$server_tz_msg] = "System|$wgLocalTZoffset";
+ $opt[$server_tz_msg] = "System|$localTZoffset";
$opt[$context->msg( 'timezoneuseoffset' )->text()] = 'other';
$opt[$context->msg( 'guesstimezone' )->text()] = 'guess';
* @return bool|Status|string
*/
static function tryFormSubmit( $formData, $form ) {
- global $wgHiddenPrefs, $wgAuth;
+ global $wgAuth;
$user = $form->getModifiedUser();
+ $hiddenPrefs = $form->getConfig()->get( 'HiddenPrefs' );
$result = true;
if ( !$user->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
// Fortunately, the realname field is MUCH simpler
// (not really "private", but still shouldn't be edited without permission)
- if ( !in_array( 'realname', $wgHiddenPrefs )
+ if ( !in_array( 'realname', $hiddenPrefs )
&& $user->isAllowed( 'editmyprivateinfo' )
&& array_key_exists( 'realname', $formData )
) {
# If users have saved a value for a preference which has subsequently been disabled
# via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
# is subsequently re-enabled
- foreach ( $wgHiddenPrefs as $pref ) {
+ foreach ( $hiddenPrefs as $pref ) {
# If the user has not set a non-default value here, the default will be returned
# and subsequently discarded
$formData[$pref] = $user->getOption( $pref, null, true );
*/
public function getLine( array $feed, RecentChange $rc, $actionComment ) {
global $wgCanonicalServer, $wgServerName, $wgScriptPath;
- $attrib = $rc->getAttributes();
$packet = array(
// Usually, RC ID is exposed only for patrolling purposes,
// but there is no real reason not to expose it in other cases,
// and I can see how this may be potentially useful for clients.
- 'id' => $attrib['rc_id'],
- 'type' => RecentChange::parseFromRCType( $attrib['rc_type'] ),
+ 'id' => $rc->getAttribute( 'rc_id' ),
+ 'type' => RecentChange::parseFromRCType( $rc->getAttribute( 'rc_type' ) ),
'namespace' => $rc->getTitle()->getNamespace(),
'title' => $rc->getTitle()->getPrefixedText(),
- 'comment' => $attrib['rc_comment'],
- 'timestamp' => (int)wfTimestamp( TS_UNIX, $attrib['rc_timestamp'] ),
- 'user' => $attrib['rc_user_text'],
- 'bot' => (bool)$attrib['rc_bot'],
+ 'comment' => $rc->getAttribute( 'rc_comment' ),
+ 'timestamp' => (int)wfTimestamp( TS_UNIX, $rc->getAttribute( 'rc_timestamp' ) ),
+ 'user' => $rc->getAttribute( 'rc_user_text' ),
+ 'bot' => (bool)$rc->getAttribute( 'rc_bot' ),
);
if ( isset( $feed['channel'] ) ) {
$packet['channel'] = $feed['channel'];
}
- $type = $attrib['rc_type'];
+ $type = $rc->getAttribute( 'rc_type' );
if ( $type == RC_EDIT || $type == RC_NEW ) {
global $wgUseRCPatrol, $wgUseNPPatrol;
- $packet['minor'] = (bool)$attrib['rc_minor'];
+ $packet['minor'] = (bool)$rc->getAttribute( 'rc_minor' );
if ( $wgUseRCPatrol || ( $type == RC_NEW && $wgUseNPPatrol ) ) {
- $packet['patrolled'] = (bool)$attrib['rc_patrolled'];
+ $packet['patrolled'] = (bool)$rc->getAttribute( 'rc_patrolled' );
}
}
switch ( $type ) {
case RC_EDIT:
$packet['length'] = array(
- 'old' => $attrib['rc_old_len'],
- 'new' => $attrib['rc_new_len']
+ 'old' => $rc->getAttribute( 'rc_old_len' ),
+ 'new' => $rc->getAttribute( 'rc_new_len' )
);
$packet['revision'] = array(
- 'old' => $attrib['rc_last_oldid'],
- 'new' => $attrib['rc_this_oldid']
+ 'old' => $rc->getAttribute( 'rc_last_oldid' ),
+ 'new' => $rc->getAttribute( 'rc_this_oldid' )
);
break;
case RC_NEW:
- $packet['length'] = array( 'old' => null, 'new' => $attrib['rc_new_len'] );
- $packet['revision'] = array( 'old' => null, 'new' => $attrib['rc_this_oldid'] );
+ $packet['length'] = array( 'old' => null, 'new' => $rc->getAttribute( 'rc_new_len' ) );
+ $packet['revision'] = array( 'old' => null, 'new' => $rc->getAttribute( 'rc_this_oldid' ) );
break;
case RC_LOG:
- $packet['log_id'] = $attrib['rc_logid'];
- $packet['log_type'] = $attrib['rc_log_type'];
- $packet['log_action'] = $attrib['rc_log_action'];
- if ( $attrib['rc_params'] ) {
+ $packet['log_id'] = $rc->getAttribute( 'rc_logid' );
+ $packet['log_type'] = $rc->getAttribute( 'rc_log_type' );
+ $packet['log_action'] = $rc->getAttribute( 'rc_log_action' );
+ if ( $rc->getAttribute( 'rc_params' ) ) {
wfSuppressWarnings();
- $params = unserialize( $attrib['rc_params'] );
+ $params = unserialize( $rc->getAttribute( 'rc_params' ) );
wfRestoreWarnings();
if (
// If it's an actual serialised false...
- $attrib['rc_params'] == serialize( false ) ||
+ $rc->getAttribute( 'rc_params' ) == serialize( false ) ||
// Or if we did not get false back when trying to unserialise
$params !== false
) {
}
$packet['log_params'] = $logParams;
} else {
- $packet['log_params'] = explode( "\n", $attrib['rc_params'] );
+ $packet['log_params'] = explode( "\n", $rc->getAttribute( 'rc_params' ) );
}
}
$packet['log_action_comment'] = $actionComment;