r46246 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46245‎ | r46246 | r46247 >
Date:09:41, 26 January 2009
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
* (bug 13040) Gender switch in user preferences
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialPreferences.php
@@ -26,7 +26,7 @@
2727 var $mUserLanguage, $mUserVariant;
2828 var $mSearch, $mRecent, $mRecentDays, $mTimeZone, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
2929 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
30 - var $mUnderline, $mWatchlistEdits;
 30+ var $mUnderline, $mWatchlistEdits, $mGender;
3131
3232 /**
3333 * Constructor
@@ -66,6 +66,7 @@
6767 $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
6868 $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
6969 $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' );
 70+ $this->mGender = $request->getVal( 'wpGender' );
7071
7172 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
7273 $this->mPosted &&
@@ -207,6 +208,15 @@
208209 }
209210 }
210211
 212+ function validateGender( $val ) {
 213+ $valid = array( 'male', 'female', 'unknown' );
 214+ if ( in_array($val, $valid) ) {
 215+ return $val;
 216+ } else {
 217+ return User::getDefaultOption( 'gender' );
 218+ }
 219+ }
 220+
211221 /**
212222 * @access private
213223 */
@@ -272,6 +282,7 @@
273283 $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
274284 $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) );
275285 $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest );
 286+ $wgUser->setOption( 'gender', $this->validateGender( $this->mGender ) );
276287
277288 # Set search namespace options
278289 foreach( $this->mSearchNs as $i => $value ) {
@@ -423,6 +434,7 @@
424435 $this->mUnderline = $wgUser->getOption( 'underline' );
425436 $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' );
426437 $this->mDisableMWSuggest = $wgUser->getBoolOption( 'disablesuggest' );
 438+ $this->mGender = $wgUser->getOption( 'gender' );
427439
428440 $togs = User::getToggles();
429441 foreach ( $togs as $tname ) {
@@ -735,8 +747,20 @@
736748 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
737749 );
738750
739 - list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage );
 751+ $gender = new XMLSelect( 'wpGender', 'wpGender', $this->mGender );
 752+ $gender->addOption( wfMsg( 'gender-unknown' ), 'unknown' );
 753+ $gender->addOption( wfMsg( 'gender-male' ), 'male' );
 754+ $gender->addOption( wfMsg( 'gender-female' ), 'female' );
 755+
740756 $wgOut->addHTML(
 757+ $this->tableRow(
 758+ Xml::label( wfMsg( 'yourgender' ), 'wpGender' ),
 759+ $gender->getHTML()
 760+ )
 761+ );
 762+
 763+ list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage, false );
 764+ $wgOut->addHTML(
741765 $this->tableRow( $lsLabel, $lsSelect )
742766 );
743767
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -286,6 +286,7 @@
287287 'servername' => array( 0, 'SERVERNAME' ),
288288 'scriptpath' => array( 0, 'SCRIPTPATH' ),
289289 'grammar' => array( 0, 'GRAMMAR:' ),
 290+ 'gender' => array( 0, 'GENDER:' ),
290291 'notitleconvert' => array( 0, '__NOTITLECONVERT__', '__NOTC__'),
291292 'nocontentconvert' => array( 0, '__NOCONTENTCONVERT__', '__NOCC__'),
292293 'currentweek' => array( 1, 'CURRENTWEEK' ),
@@ -908,6 +909,10 @@
909910 Check HTML tags.',
910911 'badsiglength' => 'The signature is too long.
911912 It must be under $1 {{PLURAL:$1|character|characters}}.',
 913+'yourgender' => 'Gender:',
 914+'gender-unknown' => 'Unspecified',
 915+'gender-male' => 'Male',
 916+'gender-female' => 'Female',
912917 'email' => 'E-mail',
913918 'prefs-help-realname' => 'Real name is optional.
914919 If you choose to provide it, this will be used for giving you attribution for your work.',
Index: trunk/phase3/RELEASE-NOTES
@@ -62,6 +62,7 @@
6363 * More helpful error message on raw page access if PHP_SELF isn't set
6464 * (bug 17145) Specific categories can be excluded from Special:UnusedCategories
6565 with __IGNOREUNUSED__
 66+* (bug 13040) Gender switch in user preferences
6667
6768 === Bug fixes in 1.15 ===
6869 * (bug 16968) Special:Upload no longer throws useless warnings.

Follow-up revisions

RevisionCommit summaryAuthorDate
r46247* (bug 13040) {{GENDER:}} magic word for interface messagesnikerabbit09:48, 26 January 2009
r46248Follow up on r46246: register message keyssiebrand09:52, 26 January 2009
r47196* (bug 13040) Gender-aware user namespace aliases...nikerabbit19:54, 12 February 2009
r47391Revert r47196, r47219 "* (bug 13040) Gender-aware user namespace aliases" and...brion23:00, 17 February 2009

Comments

#Comment by Simetrical (talk | contribs)   15:33, 26 January 2009

Is there any good reason to have a gender option unconditionally? I mean, is there any point in adding the extra option for the English Wikipedia or whatever, where no one really needs it (as opposed to gendered languages, where it would be useful)? It seems out-of-place and unexplained, among options of more obvious utility.

#Comment by Nikerabbit (talk | contribs)   18:20, 26 January 2009

Don't know about reasons why one would want to disable it. In the case you described it should be disabled or enabled according to ui language, which seems too much work for little benefit (even English can use he/she).

One good reason to have it unconditionally is less settings to tweak and simpler code.

Status & tagging log