r49341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49340‎ | r49341 | r49342 >
Date:13:38, 9 April 2009
Author:werdna
Status:deferred
Tags:
Comment:
* Fix some fieldset labels
* Compatibility with existing prefs.js code, tweaks to prefs.js to make it work.

Still to fix:
* searchNsX, will probably migrate to a simple searchnamespaces option.
* Fieldset title l10n, will probably try to rename the messages.
* Hooks and integration, will break back-compat and fix relevant extensions used on Wikimedia.
* Timezone setting.
Modified paths:
  • /branches/preferences-work/phase3/includes/HTMLForm.php (modified) (history)
  • /branches/preferences-work/phase3/includes/Preferences.php (modified) (history)
  • /branches/preferences-work/phase3/includes/specials/SpecialPreferences.php (modified) (history)
  • /branches/preferences-work/phase3/skins/common/prefs.js (modified) (history)

Diff [purge]

Index: branches/preferences-work/phase3/skins/common/prefs.js
@@ -160,5 +160,5 @@
161161 }
162162 }
163163
164 -hookEvent("load", unhidetzbutton);
 164+//hookEvent("load", unhidetzbutton);
165165 hookEvent("load", tabbedprefs);
Index: branches/preferences-work/phase3/includes/HTMLForm.php
@@ -144,8 +144,13 @@
145145 $html .= Xml::hidden( 'wpEditToken', $wgUser->editToken() );
146146 $html .= Xml::hidden( 'title', $this->getTitle() );
147147
148 - $html .= Xml::submitButton( $this->getSubmitText() );
 148+ $attribs = array();
149149
 150+ if ( isset($this->mSubmitID) )
 151+ $attribs['id'] = $this->mSubmitID;
 152+
 153+ $html .= Xml::submitButton( $this->getSubmitText(), $attribs );
 154+
150155 $html = Xml::tags( 'form',
151156 array(
152157 'action' => $this->getTitle()->getFullURL(),
@@ -197,6 +202,10 @@
198203 return $this->mSubmitText;
199204 }
200205
 206+ function setSubmitID( $t ) {
 207+ $this->mSubmitID = $t;
 208+ }
 209+
201210 function setMessagePrefix( $p ) {
202211 $this->mMessagePrefix = $p;
203212 }
Index: branches/preferences-work/phase3/includes/specials/SpecialPreferences.php
@@ -24,12 +24,13 @@
2525
2626 $formDescriptor = Preferences::getPreferences( $wgUser );
2727
28 - $htmlForm = new HTMLForm( $formDescriptor, 'prefs' );
 28+ $htmlForm = new PreferencesForm( $formDescriptor, 'prefs' );
2929
3030 $htmlForm->setSubmitText( wfMsg('saveprefs') );
3131 $htmlForm->setTitle( $this->getTitle() );
 32+ $htmlForm->setSubmitID( 'prefsubmit' );
3233 $htmlForm->setSubmitCallback( array( 'SpecialPreferences', 'trySubmit' ) );
33 -
 34+
3435 $htmlForm->show();
3536 }
3637
@@ -93,3 +94,40 @@
9495 return true;
9596 }
9697 }
 98+
 99+/** Some tweaks to allow js prefs to work */
 100+class PreferencesForm extends HTMLForm {
 101+
 102+ function displayForm( $submitResult ) {
 103+ global $wgUser, $wgOut;
 104+
 105+ if ( $submitResult !== false ) {
 106+ $this->displayErrors( $submitResult );
 107+ }
 108+
 109+ $html = $this->displaySection( $this->mFieldTree );
 110+
 111+ // Hidden fields
 112+ $html .= Xml::hidden( 'wpEditToken', $wgUser->editToken() );
 113+ $html .= Xml::hidden( 'title', $this->getTitle() );
 114+
 115+ $attribs = array();
 116+
 117+ if ( isset($this->mSubmitID) )
 118+ $attribs['id'] = $this->mSubmitID;
 119+
 120+ $html .= Xml::submitButton( $this->getSubmitText(), $attribs );
 121+
 122+ $html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html );
 123+
 124+ $html = Xml::tags( 'form',
 125+ array(
 126+ 'action' => $this->getTitle()->getFullURL(),
 127+ 'method' => 'post',
 128+ ),
 129+ $html );
 130+
 131+ $wgOut->addHTML( $html );
 132+ }
 133+
 134+}
Index: branches/preferences-work/phase3/includes/Preferences.php
@@ -18,7 +18,7 @@
1919 'type' => 'info',
2020 'label-message' => 'username',
2121 'default' => $user->getName(),
22 - 'section' => 'user',
 22+ 'section' => 'personal',
2323 );
2424
2525 $defaultPreferences['userid'] =
@@ -26,7 +26,7 @@
2727 'type' => 'info',
2828 'label-message' => 'uid',
2929 'default' => $user->getId(),
30 - 'section' => 'user',
 30+ 'section' => 'personal',
3131 );
3232
3333 # Get groups to which the user belongs
@@ -48,7 +48,7 @@
4949 count($userEffectiveGroupsArray) ),
5050 'default' => $wgLang->commaList( $userEffectiveGroupsArray ),
5151 'raw' => true,
52 - 'section' => 'user',
 52+ 'section' => 'personal',
5353 );
5454
5555 $defaultPreferences['editcount'] =
@@ -56,7 +56,7 @@
5757 'type' => 'info',
5858 'label-message' => 'prefs-edits',
5959 'default' => $user->getEditCount(),
60 - 'section' => 'user',
 60+ 'section' => 'personal',
6161 );
6262
6363 if ($user->getRegistration()) {
@@ -65,7 +65,7 @@
6666 'type' => 'info',
6767 'label-message' => 'prefs-registration',
6868 'default' => $wgLang->timeanddate( $user->getRegistration() ),
69 - 'section' => 'user',
 69+ 'section' => 'personal',
7070 );
7171 }
7272
@@ -76,7 +76,7 @@
7777 array(
7878 'type' => 'text',
7979 'default' => $user->getRealName(),
80 - 'section' => 'user',
 80+ 'section' => 'personal',
8181 'label-message' => 'yourrealname',
8282 'help-message' => 'prefs-help-realname',
8383 );
@@ -88,7 +88,7 @@
8989 array(
9090 'type' => 'text',
9191 'default' => $user->getEmail(),
92 - 'section' => 'user',
 92+ 'section' => 'personal',
9393 'label-message' => 'youremail',
9494 'help-message' => $wgEmailConfirmToEdit
9595 ? 'prefs-help-email-required'
@@ -109,14 +109,14 @@
110110 'raw' => true,
111111 'default' => $link,
112112 'label-message' => 'yourpassword',
113 - 'section' => 'user',
 113+ 'section' => 'personal',
114114 );
115115 }
116116
117117 $defaultPreferences['gender'] =
118118 array(
119119 'type' => 'select',
120 - 'section' => 'user',
 120+ 'section' => 'personal',
121121 'options' => array(
122122 'male' => wfMsg('gender-male'),
123123 'female' => wfMsg('gender-female'),
@@ -141,7 +141,7 @@
142142 $defaultPreferences['language'] =
143143 array(
144144 'type' => 'select',
145 - 'section' => 'user',
 145+ 'section' => 'personal',
146146 'options' => $options,
147147 'default' => $wgContLanguageCode,
148148 'label-message' => 'yourlanguage',
@@ -173,7 +173,7 @@
174174 'label-message' => 'yourvariant',
175175 'type' => 'select',
176176 'options' => $options,
177 - 'section' => 'user',
 177+ 'section' => 'personal',
178178 );
179179 }
180180 }
@@ -195,14 +195,14 @@
196196 'label-message' => 'yournick',
197197 'validation-callback' =>
198198 array( 'Preferences', 'validateSignature' ),
199 - 'section' => 'user',
 199+ 'section' => 'personal',
200200 'filter-callback' => array( 'Preferences', 'cleanSignature' ),
201201 );
202202 $defaultPreferences['fancysig'] =
203203 array(
204204 'type' => 'toggle',
205205 'label-message' => 'tog-fancysig',
206 - 'section' => 'user'
 206+ 'section' => 'personal'
207207 );
208208
209209
@@ -353,13 +353,13 @@
354354 array(
355355 'type' => 'toggle',
356356 'label-message' => 'tog-usenewrc',
357 - 'section' => 'recentchanges',
 357+ 'section' => 'rc',
358358 );
359359 $defaultPreferences['rcdays'] =
360360 array(
361361 'type' => 'int',
362362 'label-message' => 'recentchangesdays',
363 - 'section' => 'recentchanges',
 363+ 'section' => 'rc',
364364 'min' => 1,
365365 'max' => ceil($wgRCMaxAge / (3600*24)),
366366 );
@@ -367,13 +367,13 @@
368368 array(
369369 'type' => 'int',
370370 'label-message' => 'recentchangescount',
371 - 'section' => 'recentchanges',
 371+ 'section' => 'rc',
372372 );
373373 $defaultPreferences['hideminor'] =
374374 array(
375375 'type' => 'toggle',
376376 'label-message' => 'tog-hideminor',
377 - 'section' => 'recentchanges',
 377+ 'section' => 'rc',
378378 );
379379
380380 global $wgUseRCPatrol;
@@ -381,13 +381,13 @@
382382 $defaultPreferences['hidepatrolled'] =
383383 array(
384384 'type' => 'toggle',
385 - 'section' => 'recentchanges',
 385+ 'section' => 'rc',
386386 'label-message' => 'tog-hidepatrolled',
387387 );
388388 $defaultPreferences['newpageshidepatrolled'] =
389389 array(
390390 'type' => 'toggle',
391 - 'section' => 'recentchanges',
 391+ 'section' => 'rc',
392392 'label-message' => 'tog-newpageshidepatrolled',
393393 );
394394 }
@@ -489,21 +489,21 @@
490490 array(
491491 'type' => 'int',
492492 'label-message' => 'resultsperpage',
493 - 'section' => 'search',
 493+ 'section' => 'searchoptions',
494494 'min' => 0,
495495 );
496496 $defaultPreferences['contextlines'] =
497497 array(
498498 'type' => 'int',
499499 'label-message' => 'contextlines',
500 - 'section' => 'search',
 500+ 'section' => 'searchoptions',
501501 'min' => 0,
502502 );
503503 $defaultPreferences['contextchars'] =
504504 array(
505505 'type' => 'int',
506506 'label-message' => 'contextchars',
507 - 'section' => 'search',
 507+ 'section' => 'searchoptions',
508508 'min' => 0,
509509 );
510510
@@ -522,7 +522,7 @@
523523 'type' => 'multiselect',
524524 'label-message' => 'defaultns',
525525 'options' => $nsOptions,
526 - 'section' => 'search',
 526+ 'section' => 'searchoptions',
527527 );
528528
529529 global $wgEnableMWSuggest;
@@ -531,7 +531,7 @@
532532 array(
533533 'type' => 'toggle',
534534 'label-message' => 'mwsuggest-disable',
535 - 'section' => 'search',
 535+ 'section' => 'searchoptions',
536536 );
537537 }
538538

Status & tagging log