'searchlimit' => array( 'Preferences', 'filterIntval' ),
);
+ /**
+ * @throws MWException
+ * @param $user User
+ * @return array|null
+ */
static function getPreferences( $user ) {
- if ( self::$defaultPreferences )
+ if ( self::$defaultPreferences ) {
return self::$defaultPreferences;
+ }
$defaultPreferences = array();
return $defaultPreferences;
}
- // Pull option from a user account. Handles stuff like array-type preferences.
+ /**
+ * Pull option from a user account. Handles stuff like array-type preferences.
+ *
+ * @param $name
+ * @param $info
+ * @param $user User
+ * @return array|String
+ */
static function getOptionFromUser( $name, $info, $user ) {
$val = $user->getOption( $name );
return $val;
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function profilePreferences( $user, &$defaultPreferences ) {
global $wgLang, $wgUser;
## User info #####################################
);
if ( $wgAuth->allowPasswordChange() ) {
- $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Resetpass' ),
+ $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'ChangePassword' ),
wfMsgHtml( 'prefs-resetpass' ), array(),
array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) );
global $wgMaxSigChars, $wgOut, $wgParser;
// show a preview of the old signature first
- $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title , $user, new ParserOptions );
+ $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title, $user, new ParserOptions );
$oldsigHTML = $wgOut->parseInline( $oldsigWikiText );
$defaultPreferences['oldsig'] = array(
'type' => 'info',
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function skinPreferences( $user, &$defaultPreferences ) {
## Skin #####################################
global $wgLang, $wgAllowUserCss, $wgAllowUserJs;
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function filesPreferences( $user, &$defaultPreferences ) {
## Files #####################################
$defaultPreferences['imagesize'] = array(
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function datetimePreferences( $user, &$defaultPreferences ) {
global $wgLang;
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function renderingPreferences( $user, &$defaultPreferences ) {
## Page Rendering ##############################
global $wgAllowUserCssPrefs;
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function editingPreferences( $user, &$defaultPreferences ) {
global $wgUseExternalEditor, $wgAllowUserCssPrefs;
'section' => 'editing/advancedediting',
'label-message' => 'tog-showtoolbar',
);
- $defaultPreferences['minordefault'] = array(
- 'type' => 'toggle',
- 'section' => 'editing/advancedediting',
- 'label-message' => 'tog-minordefault',
- );
+
+ if ( $user->isAllowed( 'minoredit' ) ) {
+ $defaultPreferences['minordefault'] = array(
+ 'type' => 'toggle',
+ 'section' => 'editing/advancedediting',
+ 'label-message' => 'tog-minordefault',
+ );
+ }
if ( $wgUseExternalEditor ) {
$defaultPreferences['externaleditor'] = array(
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function rcPreferences( $user, &$defaultPreferences ) {
- global $wgRCMaxAge, $wgUseRCPatrol, $wgLang;
+ global $wgRCMaxAge, $wgLang;
## RecentChanges #####################################
$defaultPreferences['rcdays'] = array(
'section' => 'rc/advancedrc',
);
- if ( $wgUseRCPatrol ) {
+ if ( $user->useRCPatrol() ) {
$defaultPreferences['hidepatrolled'] = array(
'type' => 'toggle',
'section' => 'rc/advancedrc',
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ */
static function watchlistPreferences( $user, &$defaultPreferences ) {
global $wgUseRCPatrol, $wgEnableAPI;
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function searchPreferences( $user, &$defaultPreferences ) {
global $wgContLang;
'section' => 'searchoptions/displaysearchoptions',
'min' => 0,
);
- $defaultPreferences['contextlines'] = array(
- 'type' => 'int',
- 'label-message' => 'contextlines',
- 'section' => 'searchoptions/displaysearchoptions',
- 'min' => 0,
- );
- $defaultPreferences['contextchars'] = array(
- 'type' => 'int',
- 'label-message' => 'contextchars',
- 'section' => 'searchoptions/displaysearchoptions',
- 'min' => 0,
- );
global $wgEnableMWSuggest;
if ( $wgEnableMWSuggest ) {
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences Array
+ */
static function miscPreferences( $user, &$defaultPreferences ) {
## Misc #####################################
$defaultPreferences['diffonly'] = array(
}
/**
- * @param $user The User object
+ * @param $user User The User object
* @return Array: text/links to display as key; $skinkey as value
*/
static function generateSkinOptions( $user ) {
return $ret;
}
+ /**
+ * @return array
+ */
static function getDateOptions() {
global $wgLang;
$dateopts = $wgLang->getDatePreferences();
return $ret;
}
+ /**
+ * @return array
+ */
static function getImageSizes() {
global $wgImageLimits;
return $ret;
}
+ /**
+ * @return array
+ */
static function getThumbSizes() {
global $wgThumbLimits;
return $ret;
}
+ /**
+ * @param $signature
+ * @param $alldata
+ * @return bool|string
+ */
static function validateSignature( $signature, $alldata ) {
global $wgParser, $wgMaxSigChars, $wgLang;
if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
}
}
+ /**
+ * @param $signature string
+ * @param $alldata array
+ * @return string
+ */
static function cleanSignature( $signature, $alldata ) {
global $wgParser;
if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
return $signature;
}
+ /**
+ * @param $email
+ * @param $alldata
+ * @return bool|String
+ */
static function validateEmail( $email, $alldata ) {
- if ( $email && !User::isValidEmailAddr( $email ) ) {
+ if ( $email && !Sanitizer::validateEmail( $email ) ) {
return wfMsgExt( 'invalidemailaddress', 'parseinline' );
}
return true;
}
+ /**
+ * @param $user User
+ * @param $formClass string
+ * @return HtmlForm
+ */
static function getFormObject( $user, $formClass = 'PreferencesForm' ) {
$formDescriptor = Preferences::getPreferences( $user );
$htmlForm = new $formClass( $formDescriptor, 'prefs' );
return $htmlForm;
}
+ /**
+ * @return array
+ */
static function getTimezoneOptions() {
$opt = array();
- global $wgLocalTZoffset;
-
- $opt[wfMsg( 'timezoneuseserverdefault' )] = "System|$wgLocalTZoffset";
+ global $wgLocalTZoffset, $wgLocaltimezone;
+ // Check that $wgLocalTZoffset is the same as $wgLocaltimezone
+ if ( $wgLocalTZoffset == date( 'Z' ) / 60 ) {
+ $server_tz_msg = wfMsg( 'timezoneuseserverdefault', $wgLocaltimezone );
+ } else {
+ $tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) % 60 );
+ $server_tz_msg = wfMsg( 'timezoneuseserverdefault', $tzstring );
+ }
+ $opt[$server_tz_msg] = "System|$wgLocalTZoffset";
$opt[wfMsg( 'timezoneuseoffset' )] = 'other';
$opt[wfMsg( 'guesstimezone' )] = 'guess';
return $opt;
}
+ /**
+ * @param $value
+ * @param $alldata
+ * @return int
+ */
static function filterIntval( $value, $alldata ){
return intval( $value );
}
+ /**
+ * @param $tz
+ * @param $alldata
+ * @return string
+ */
static function filterTimezoneInput( $tz, $alldata ) {
$data = explode( '|', $tz, 3 );
switch ( $data[0] ) {
}
}
+ /**
+ * @param $formData
+ * @param $entryPoint string
+ * @return bool|Status|string
+ */
static function tryFormSubmit( $formData, $entryPoint = 'internal' ) {
global $wgUser, $wgEmailAuthentication, $wgEnableEmail;
return $result;
}
+ /**
+ * @param $formData
+ * @return Status
+ */
public static function tryUISubmit( $formData ) {
$res = self::tryFormSubmit( $formData, 'ui' );
return Status::newGood();
}
+ /**
+ * @param $user User
+ * @return array
+ */
public static function loadOldSearchNs( $user ) {
$searchableNamespaces = SearchEngine::searchableNamespaces();
// Back compat with old format
/** Some tweaks to allow js prefs to work */
class PreferencesForm extends HTMLForm {
+
+ /**
+ * @param $html string
+ * @return String
+ */
function wrapForm( $html ) {
$html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html );
return parent::wrapForm( $html );
}
+ /**
+ * @return String
+ */
function getButtons() {
$html = parent::getButtons();
return $html;
}
+ /**
+ * @param $data array
+ * @return array
+ */
function filterDataForSubmit( $data ) {
// Support for separating MultiSelect preferences into multiple preferences
// Due to lack of array support.
return $data;
}
+ /**
+ * Get the whole body of the form.
+ */
+ function getBody() {
+ return $this->displaySection( $this->mFieldTree, '', true );
+ }
}