* over to the tryUISubmit static method of this class.
*/
class Preferences {
- static $defaultPreferences = null;
- static $saveFilters = array(
- 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
- 'cols' => array( 'Preferences', 'filterIntval' ),
- 'rows' => array( 'Preferences', 'filterIntval' ),
- 'rclimit' => array( 'Preferences', 'filterIntval' ),
- 'wllimit' => array( 'Preferences', 'filterIntval' ),
- 'searchlimit' => array( 'Preferences', 'filterIntval' ),
+ /** @var array */
+ protected static $defaultPreferences = null;
+
+ /** @var array */
+ protected static $saveFilters = array(
+ 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
+ 'cols' => array( 'Preferences', 'filterIntval' ),
+ 'rows' => array( 'Preferences', 'filterIntval' ),
+ 'rclimit' => array( 'Preferences', 'filterIntval' ),
+ 'wllimit' => array( 'Preferences', 'filterIntval' ),
+ 'searchlimit' => array( 'Preferences', 'filterIntval' ),
);
// Stuff that shouldn't be saved as a preference.
/**
* @throws MWException
- * @param $user User
- * @param $context IContextSource
+ * @param User $user
+ * @param IContextSource $context
* @return array|null
*/
static function getPreferences( $user, IContextSource $context ) {
/**
* Pull option from a user account. Handles stuff like array-type preferences.
*
- * @param $name
- * @param $info
- * @param $user User
- * @return array|String
+ * @param string $name
+ * @param array $info
+ * @param User $user
+ * @return array|string
*/
static function getOptionFromUser( $name, $info, $user ) {
$val = $user->getOption( $name );
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
* @return void
*/
static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
'section' => 'personal/info',
);
- $defaultPreferences['userid'] = array(
- 'type' => 'info',
- 'label-message' => array( 'uid', $userName ),
- 'default' => $user->getId(),
- 'section' => 'personal/info',
- );
-
# Get groups to which the user belongs
$userEffectiveGroups = $user->getEffectiveGroups();
$userGroups = $userMembers = array();
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
* @return void
*/
static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences Array
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
*/
static function filesPreferences( $user, IContextSource $context, &$defaultPreferences ) {
## Files #####################################
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
* @return void
*/
static function datetimePreferences( $user, IContextSource $context, &$defaultPreferences ) {
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences Array
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
*/
static function renderingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
## Diffs ####################################
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences Array
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
*/
static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
global $wgAllowUserCssPrefs;
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences Array
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
*/
static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
global $wgRCMaxAge, $wgRCShowWatchingUsers;
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
*/
static function watchlistPreferences( $user, IContextSource $context, &$defaultPreferences ) {
global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge;
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $defaultPreferences Array
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences
*/
static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgContLang;
-
- $defaultPreferences['searcheverything'] = array(
- 'type' => 'toggle',
- 'label-message' => 'searcheverything-enable',
- 'section' => 'searchoptions/advancedsearchoptions',
- );
-
- $nsOptions = $wgContLang->getFormattedNamespaces();
- $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
- foreach ( $nsOptions as $ns => $name ) {
- if ( $ns < 0 ) {
- unset( $nsOptions[$ns] );
- }
+ foreach ( MWNamespace::getValidNamespaces() as $n ) {
+ $defaultPreferences[ 'searchNs' . $n ] = array(
+ 'type' => 'api',
+ );
}
-
- $defaultPreferences['searchnamespaces'] = array(
- 'type' => 'multiselect',
- 'label-message' => 'defaultns',
- 'options' => array_flip( $nsOptions ),
- 'section' => 'searchoptions/advancedsearchoptions',
- 'prefix' => 'searchNs',
- );
}
/**
}
/**
- * @param $user User The User object
- * @param $context IContextSource
- * @return Array: text/links to display as key; $skinkey as value
+ * @param User $user The User object
+ * @param IContextSource $context
+ * @return array Text/links to display as key; $skinkey as value
*/
static function generateSkinOptions( $user, IContextSource $context ) {
global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs;
}
/**
- * @param $context IContextSource
+ * @param IContextSource $context
* @return array
*/
static function getDateOptions( IContextSource $context ) {
}
/**
- * @param $context IContextSource
+ * @param IContextSource $context
* @return array
*/
static function getImageSizes( IContextSource $context ) {
}
/**
- * @param $context IContextSource
+ * @param IContextSource $context
* @return array
*/
static function getThumbSizes( IContextSource $context ) {
}
/**
- * @param $signature string
- * @param $alldata array
- * @param $form HTMLForm
+ * @param string $signature
+ * @param array $alldata
+ * @param HTMLForm $form
* @return bool|string
*/
static function validateSignature( $signature, $alldata, $form ) {
}
/**
- * @param $signature string
- * @param $alldata array
- * @param $form HTMLForm
+ * @param string $signature
+ * @param array $alldata
+ * @param HTMLForm $form
* @return string
*/
static function cleanSignature( $signature, $alldata, $form ) {
}
/**
- * @param $user User
- * @param $context IContextSource
- * @param $formClass string
- * @param array $remove array of items to remove
+ * @param User $user
+ * @param IContextSource $context
+ * @param string $formClass
+ * @param array $remove Array of items to remove
* @return HtmlForm
*/
static function getFormObject(
}
/**
- * @param $context IContextSource
+ * @param IContextSource $context
* @return array
*/
static function getTimezoneOptions( IContextSource $context ) {
}
/**
- * @param $value
- * @param $alldata
+ * @param string $value
+ * @param array $alldata
* @return int
*/
static function filterIntval( $value, $alldata ) {
}
/**
- * @param $tz
- * @param $alldata
+ * @param string $tz
+ * @param array $alldata
* @return string
*/
static function filterTimezoneInput( $tz, $alldata ) {
/**
* Handle the form submission if everything validated properly
*
- * @param $formData
- * @param $form PreferencesForm
+ * @param array $formData
+ * @param PreferencesForm $form
* @return bool|Status|string
*/
static function tryFormSubmit( $formData, $form ) {
// Fortunately, the realname field is MUCH simpler
// (not really "private", but still shouldn't be edited without permission)
- if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) ) {
+ if ( !in_array( 'realname', $wgHiddenPrefs )
+ && $user->isAllowed( 'editmyprivateinfo' )
+ && array_key_exists( 'realname', $formData )
+ ) {
$realName = $formData['realname'];
$user->setRealName( $realName );
}
}
/**
- * @param $formData
- * @param $form PreferencesForm
+ * @param array $formData
+ * @param PreferencesForm $form
* @return Status
*/
public static function tryUISubmit( $formData, $form ) {
* right.
*
* @deprecated since 1.20; use User::setEmailWithConfirmation() instead.
- * @param $user User
+ * @param User $user
* @param string $newaddr New email address
- * @return Array (true on success or Status on failure, info string)
+ * @return array (true on success or Status on failure, info string)
*/
public static function trySetUserEmail( User $user, $newaddr ) {
wfDeprecated( __METHOD__, '1.20' );
/**
* @deprecated since 1.19
- * @param $user User
+ * @param User $user
* @return array
*/
public static function loadOldSearchNs( $user ) {
private $modifiedUser;
/**
- * @param $user User
+ * @param User $user
*/
public function setModifiedUser( $user ) {
$this->modifiedUser = $user;
}
/**
- * @param $html string
- * @return String
+ * @param string $html
+ * @return string
*/
function wrapForm( $html ) {
$html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html );
}
/**
- * @return String
+ * @return string
*/
function getButtons() {
if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
/**
* Separate multi-option preferences into multiple preferences, since we
* have to store them separately
- * @param $data array
+ * @param array $data
* @return array
*/
function filterDataForSubmit( $data ) {
/**
* Get the "<legend>" for a given section key. Normally this is the
* prefs-$key message but we'll allow extensions to override it.
- * @param $key string
+ * @param string $key
* @return string
*/
function getLegend( $key ) {