Index: trunk/phase3/includes/HTMLForm.php |
— | — | @@ -277,7 +277,7 @@ |
278 | 278 | |
279 | 279 | $data = $this->filterDataForSubmit( $this->mFieldData ); |
280 | 280 | |
281 | | - $res = call_user_func( $callback, $data ); |
| 281 | + $res = call_user_func( $callback, $data, $this ); |
282 | 282 | |
283 | 283 | return $res; |
284 | 284 | } |
Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -39,25 +39,26 @@ |
40 | 40 | /** |
41 | 41 | * @throws MWException |
42 | 42 | * @param $user User |
| 43 | + * @param $context IContextSource |
43 | 44 | * @return array|null |
44 | 45 | */ |
45 | | - static function getPreferences( $user ) { |
| 46 | + static function getPreferences( $user, IContextSource $context ) { |
46 | 47 | if ( self::$defaultPreferences ) { |
47 | 48 | return self::$defaultPreferences; |
48 | 49 | } |
49 | 50 | |
50 | 51 | $defaultPreferences = array(); |
51 | 52 | |
52 | | - self::profilePreferences( $user, $defaultPreferences ); |
53 | | - self::skinPreferences( $user, $defaultPreferences ); |
54 | | - self::filesPreferences( $user, $defaultPreferences ); |
55 | | - self::datetimePreferences( $user, $defaultPreferences ); |
56 | | - self::renderingPreferences( $user, $defaultPreferences ); |
57 | | - self::editingPreferences( $user, $defaultPreferences ); |
58 | | - self::rcPreferences( $user, $defaultPreferences ); |
59 | | - self::watchlistPreferences( $user, $defaultPreferences ); |
60 | | - self::searchPreferences( $user, $defaultPreferences ); |
61 | | - self::miscPreferences( $user, $defaultPreferences ); |
| 53 | + self::profilePreferences( $user, $context, $defaultPreferences ); |
| 54 | + self::skinPreferences( $user, $context, $defaultPreferences ); |
| 55 | + self::filesPreferences( $user, $context, $defaultPreferences ); |
| 56 | + self::datetimePreferences( $user, $context, $defaultPreferences ); |
| 57 | + self::renderingPreferences( $user, $context, $defaultPreferences ); |
| 58 | + self::editingPreferences( $user, $context, $defaultPreferences ); |
| 59 | + self::rcPreferences( $user, $context, $defaultPreferences ); |
| 60 | + self::watchlistPreferences( $user, $context, $defaultPreferences ); |
| 61 | + self::searchPreferences( $user, $context, $defaultPreferences ); |
| 62 | + self::miscPreferences( $user, $context, $defaultPreferences ); |
62 | 63 | |
63 | 64 | wfRunHooks( 'GetPreferences', array( $user, &$defaultPreferences ) ); |
64 | 65 | |
— | — | @@ -127,11 +128,16 @@ |
128 | 129 | |
129 | 130 | /** |
130 | 131 | * @param $user User |
| 132 | + * @param $context IContextSource |
131 | 133 | * @param $defaultPreferences |
132 | 134 | * @return void |
133 | 135 | */ |
134 | | - static function profilePreferences( $user, &$defaultPreferences ) { |
135 | | - global $wgLang; |
| 136 | + static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) { |
| 137 | + global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode, |
| 138 | + $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars, |
| 139 | + $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication, |
| 140 | + $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress; |
| 141 | + |
136 | 142 | ## User info ##################################### |
137 | 143 | // Information panel |
138 | 144 | $defaultPreferences['username'] = array( |
— | — | @@ -165,17 +171,16 @@ |
166 | 172 | asort( $userGroups ); |
167 | 173 | asort( $userMembers ); |
168 | 174 | |
| 175 | + $lang = $context->getLang(); |
| 176 | + |
169 | 177 | $defaultPreferences['usergroups'] = array( |
170 | 178 | 'type' => 'info', |
171 | | - 'label' => wfMsgExt( |
172 | | - 'prefs-memberingroups', 'parseinline', |
173 | | - $wgLang->formatNum( count( $userGroups ) ) |
174 | | - ), |
175 | | - 'default' => wfMsgExt( |
176 | | - 'prefs-memberingroups-type', array(), |
177 | | - $wgLang->commaList( $userGroups ), |
178 | | - $wgLang->commaList( $userMembers ) |
179 | | - ), |
| 179 | + 'label' => $context->msg( 'prefs-memberingroups' )->numParams( |
| 180 | + count( $userGroups ) )->parse(), |
| 181 | + 'default' => $context->msg( 'prefs-memberingroups-type', |
| 182 | + $lang->commaList( $userGroups ), |
| 183 | + $lang->commaList( $userMembers ) |
| 184 | + )->plain(), |
180 | 185 | 'raw' => true, |
181 | 186 | 'section' => 'personal/info', |
182 | 187 | ); |
— | — | @@ -183,7 +188,7 @@ |
184 | 189 | $defaultPreferences['editcount'] = array( |
185 | 190 | 'type' => 'info', |
186 | 191 | 'label-message' => 'prefs-edits', |
187 | | - 'default' => $wgLang->formatNum( $user->getEditCount() ), |
| 192 | + 'default' => $lang->formatNum( $user->getEditCount() ), |
188 | 193 | 'section' => 'personal/info', |
189 | 194 | ); |
190 | 195 | |
— | — | @@ -191,18 +196,17 @@ |
192 | 197 | $defaultPreferences['registrationdate'] = array( |
193 | 198 | 'type' => 'info', |
194 | 199 | 'label-message' => 'prefs-registration', |
195 | | - 'default' => wfMsgExt( |
196 | | - 'prefs-registration-date-time', 'parsemag', |
197 | | - $wgLang->timeanddate( $user->getRegistration(), true ), |
198 | | - $wgLang->date( $user->getRegistration(), true ), |
199 | | - $wgLang->time( $user->getRegistration(), true ) |
200 | | - ), |
| 200 | + 'default' => $context->msg( |
| 201 | + 'prefs-registration-date-time', |
| 202 | + $lang->timeanddate( $user->getRegistration(), true ), |
| 203 | + $lang->date( $user->getRegistration(), true ), |
| 204 | + $lang->time( $user->getRegistration(), true ) |
| 205 | + )->parse(), |
201 | 206 | 'section' => 'personal/info', |
202 | 207 | ); |
203 | 208 | } |
204 | 209 | |
205 | 210 | // Actually changeable stuff |
206 | | - global $wgAuth; |
207 | 211 | $defaultPreferences['realname'] = array( |
208 | 212 | 'type' => $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', |
209 | 213 | 'default' => $user->getRealName(), |
— | — | @@ -215,9 +219,9 @@ |
216 | 220 | 'type' => 'select', |
217 | 221 | 'section' => 'personal/info', |
218 | 222 | 'options' => array( |
219 | | - wfMsg( 'gender-male' ) => 'male', |
220 | | - wfMsg( 'gender-female' ) => 'female', |
221 | | - wfMsg( 'gender-unknown' ) => 'unknown', |
| 223 | + $context->msg( 'gender-male' )->text() => 'male', |
| 224 | + $context->msg( 'gender-female' )->text() => 'female', |
| 225 | + $context->msg( 'gender-unknown' )->text() => 'unknown', |
222 | 226 | ), |
223 | 227 | 'label-message' => 'yourgender', |
224 | 228 | 'help-message' => 'prefs-help-gender', |
— | — | @@ -225,7 +229,7 @@ |
226 | 230 | |
227 | 231 | if ( $wgAuth->allowPasswordChange() ) { |
228 | 232 | $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ), |
229 | | - wfMsgHtml( 'prefs-resetpass' ), array(), |
| 233 | + $context->msg( 'prefs-resetpass' )->escaped(), array(), |
230 | 234 | array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) ); |
231 | 235 | |
232 | 236 | $defaultPreferences['password'] = array( |
— | — | @@ -236,21 +240,16 @@ |
237 | 241 | 'section' => 'personal/info', |
238 | 242 | ); |
239 | 243 | } |
240 | | - global $wgCookieExpiration; |
241 | 244 | if ( $wgCookieExpiration > 0 ) { |
242 | 245 | $defaultPreferences['rememberpassword'] = array( |
243 | 246 | 'type' => 'toggle', |
244 | | - 'label' => wfMsgExt( |
245 | | - 'tog-rememberpassword', |
246 | | - array( 'parsemag' ), |
247 | | - $wgLang->formatNum( ceil( $wgCookieExpiration / ( 3600 * 24 ) ) ) |
248 | | - ), |
| 247 | + 'label' => $context->msg( 'tog-rememberpassword' )->numParams( |
| 248 | + ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(), |
249 | 249 | 'section' => 'personal/info', |
250 | 250 | ); |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Language |
254 | | - global $wgLanguageCode; |
255 | 254 | $languages = Language::getLanguageNames( false ); |
256 | 255 | if ( !array_key_exists( $wgLanguageCode, $languages ) ) { |
257 | 256 | $languages[$wgLanguageCode] = $wgLanguageCode; |
— | — | @@ -269,8 +268,6 @@ |
270 | 269 | 'label-message' => 'yourlanguage', |
271 | 270 | ); |
272 | 271 | |
273 | | - global $wgContLang, $wgDisableLangConversion; |
274 | | - global $wgDisableTitleConversion; |
275 | 272 | /* see if there are multiple language variants to choose from*/ |
276 | 273 | $variantArray = array(); |
277 | 274 | if ( !$wgDisableLangConversion ) { |
— | — | @@ -300,18 +297,16 @@ |
301 | 298 | |
302 | 299 | if ( count( $variantArray ) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion ) { |
303 | 300 | $defaultPreferences['noconvertlink'] = |
304 | | - array( |
| 301 | + array( |
305 | 302 | 'type' => 'toggle', |
306 | 303 | 'section' => 'personal/i18n', |
307 | 304 | 'label-message' => 'tog-noconvertlink', |
308 | 305 | ); |
309 | 306 | } |
310 | 307 | |
311 | | - global $wgMaxSigChars, $wgOut, $wgParser; |
312 | | - |
313 | 308 | // show a preview of the old signature first |
314 | | - $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title, $user, new ParserOptions ); |
315 | | - $oldsigHTML = $wgOut->parseInline( $oldsigWikiText, true, true ); |
| 309 | + $oldsigWikiText = $wgParser->preSaveTransform( "~~~", $context->getTitle(), $user, new ParserOptions ); |
| 310 | + $oldsigHTML = $context->getOutput()->parseInline( $oldsigWikiText, true, true ); |
316 | 311 | $defaultPreferences['oldsig'] = array( |
317 | 312 | 'type' => 'info', |
318 | 313 | 'raw' => true, |
— | — | @@ -336,11 +331,7 @@ |
337 | 332 | |
338 | 333 | ## Email stuff |
339 | 334 | |
340 | | - global $wgEnableEmail; |
341 | 335 | if ( $wgEnableEmail ) { |
342 | | - global $wgEmailConfirmToEdit; |
343 | | - global $wgEnableUserEmail; |
344 | | - |
345 | 336 | $helpMessages[] = $wgEmailConfirmToEdit |
346 | 337 | ? 'prefs-help-email-required' |
347 | 338 | : 'prefs-help-email' ; |
— | — | @@ -352,7 +343,7 @@ |
353 | 344 | |
354 | 345 | $link = Linker::link( |
355 | 346 | SpecialPage::getTitleFor( 'ChangeEmail' ), |
356 | | - wfMsgHtml( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' ), |
| 347 | + $context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(), |
357 | 348 | array(), |
358 | 349 | array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) ); |
359 | 350 | |
— | — | @@ -369,8 +360,6 @@ |
370 | 361 | 'section' => 'personal/email', |
371 | 362 | ); |
372 | 363 | |
373 | | - global $wgEmailAuthentication; |
374 | | - |
375 | 364 | $disableEmailPrefs = false; |
376 | 365 | |
377 | 366 | if ( $wgEmailAuthentication ) { |
— | — | @@ -379,25 +368,23 @@ |
380 | 369 | // date and time are separate parameters to facilitate localisation. |
381 | 370 | // $time is kept for backward compat reasons. |
382 | 371 | // 'emailauthenticated' is also used in SpecialConfirmemail.php |
383 | | - $time = $wgLang->timeAndDate( $user->getEmailAuthenticationTimestamp(), true ); |
384 | | - $d = $wgLang->date( $user->getEmailAuthenticationTimestamp(), true ); |
385 | | - $t = $wgLang->time( $user->getEmailAuthenticationTimestamp(), true ); |
386 | | - $emailauthenticated = wfMsgExt( |
387 | | - 'emailauthenticated', 'parseinline', |
388 | | - array( $time, $d, $t ) |
389 | | - ) . '<br />'; |
| 372 | + $time = $lang->timeAndDate( $user->getEmailAuthenticationTimestamp(), true ); |
| 373 | + $d = $lang->date( $user->getEmailAuthenticationTimestamp(), true ); |
| 374 | + $t = $lang->time( $user->getEmailAuthenticationTimestamp(), true ); |
| 375 | + $emailauthenticated = $context->msg( 'emailauthenticated', |
| 376 | + $time, $d, $t )->parse() . '<br />'; |
390 | 377 | $disableEmailPrefs = false; |
391 | 378 | } else { |
392 | 379 | $disableEmailPrefs = true; |
393 | | - $emailauthenticated = wfMsgExt( 'emailnotauthenticated', 'parseinline' ) . '<br />' . |
| 380 | + $emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' . |
394 | 381 | Linker::linkKnown( |
395 | 382 | SpecialPage::getTitleFor( 'Confirmemail' ), |
396 | | - wfMsg( 'emailconfirmlink' ) |
| 383 | + $context->msg( 'emailconfirmlink' )->escaped() |
397 | 384 | ) . '<br />'; |
398 | 385 | } |
399 | 386 | } else { |
400 | 387 | $disableEmailPrefs = true; |
401 | | - $emailauthenticated = wfMsgHtml( 'noemailprefs' ); |
| 388 | + $emailauthenticated = $context->msg( 'noemailprefs' )->escaped(); |
402 | 389 | } |
403 | 390 | |
404 | 391 | $defaultPreferences['emailauthentication'] = array( |
— | — | @@ -426,7 +413,6 @@ |
427 | 414 | ); |
428 | 415 | } |
429 | 416 | |
430 | | - global $wgEnotifWatchlist; |
431 | 417 | if ( $wgEnotifWatchlist ) { |
432 | 418 | $defaultPreferences['enotifwatchlistpages'] = array( |
433 | 419 | 'type' => 'toggle', |
— | — | @@ -435,7 +421,6 @@ |
436 | 422 | 'disabled' => $disableEmailPrefs, |
437 | 423 | ); |
438 | 424 | } |
439 | | - global $wgEnotifUserTalk; |
440 | 425 | if ( $wgEnotifUserTalk ) { |
441 | 426 | $defaultPreferences['enotifusertalkpages'] = array( |
442 | 427 | 'type' => 'toggle', |
— | — | @@ -452,7 +437,6 @@ |
453 | 438 | 'disabled' => $disableEmailPrefs, |
454 | 439 | ); |
455 | 440 | |
456 | | - global $wgEnotifRevealEditorAddress; |
457 | 441 | if ( $wgEnotifRevealEditorAddress ) { |
458 | 442 | $defaultPreferences['enotifrevealaddr'] = array( |
459 | 443 | 'type' => 'toggle', |
— | — | @@ -467,16 +451,17 @@ |
468 | 452 | |
469 | 453 | /** |
470 | 454 | * @param $user User |
| 455 | + * @param $context IContextSource |
471 | 456 | * @param $defaultPreferences |
472 | 457 | * @return void |
473 | 458 | */ |
474 | | - static function skinPreferences( $user, &$defaultPreferences ) { |
| 459 | + static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
475 | 460 | ## Skin ##################################### |
476 | | - global $wgLang, $wgAllowUserCss, $wgAllowUserJs; |
| 461 | + global $wgAllowUserCss, $wgAllowUserJs; |
477 | 462 | |
478 | 463 | $defaultPreferences['skin'] = array( |
479 | 464 | 'type' => 'radio', |
480 | | - 'options' => self::generateSkinOptions( $user ), |
| 465 | + 'options' => self::generateSkinOptions( $user, $context ), |
481 | 466 | 'label' => ' ', |
482 | 467 | 'section' => 'rendering/skin', |
483 | 468 | ); |
— | — | @@ -489,18 +474,18 @@ |
490 | 475 | |
491 | 476 | if ( $wgAllowUserCss ) { |
492 | 477 | $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.css' ); |
493 | | - $linkTools[] = Linker::link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) ); |
| 478 | + $linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() ); |
494 | 479 | } |
495 | 480 | |
496 | 481 | if ( $wgAllowUserJs ) { |
497 | 482 | $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.js' ); |
498 | | - $linkTools[] = Linker::link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) ); |
| 483 | + $linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() ); |
499 | 484 | } |
500 | 485 | |
501 | 486 | $defaultPreferences['commoncssjs'] = array( |
502 | 487 | 'type' => 'info', |
503 | 488 | 'raw' => true, |
504 | | - 'default' => $wgLang->pipeList( $linkTools ), |
| 489 | + 'default' => $context->getLang()->pipeList( $linkTools ), |
505 | 490 | 'label-message' => 'prefs-common-css-js', |
506 | 491 | 'section' => 'rendering/skin', |
507 | 492 | ); |
— | — | @@ -508,7 +493,7 @@ |
509 | 494 | |
510 | 495 | $selectedSkin = $user->getOption( 'skin' ); |
511 | 496 | if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) { |
512 | | - $settings = array_flip( $wgLang->getQuickbarSettings() ); |
| 497 | + $settings = array_flip( $context->getLang()->getQuickbarSettings() ); |
513 | 498 | |
514 | 499 | $defaultPreferences['quickbar'] = array( |
515 | 500 | 'type' => 'radio', |
— | — | @@ -521,19 +506,20 @@ |
522 | 507 | |
523 | 508 | /** |
524 | 509 | * @param $user User |
| 510 | + * @param $context IContextSource |
525 | 511 | * @param $defaultPreferences Array |
526 | 512 | */ |
527 | | - static function filesPreferences( $user, &$defaultPreferences ) { |
| 513 | + static function filesPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
528 | 514 | ## Files ##################################### |
529 | 515 | $defaultPreferences['imagesize'] = array( |
530 | 516 | 'type' => 'select', |
531 | | - 'options' => self::getImageSizes(), |
| 517 | + 'options' => self::getImageSizes( $context ), |
532 | 518 | 'label-message' => 'imagemaxsize', |
533 | 519 | 'section' => 'rendering/files', |
534 | 520 | ); |
535 | 521 | $defaultPreferences['thumbsize'] = array( |
536 | 522 | 'type' => 'select', |
537 | | - 'options' => self::getThumbSizes(), |
| 523 | + 'options' => self::getThumbSizes( $context ), |
538 | 524 | 'label-message' => 'thumbsize', |
539 | 525 | 'section' => 'rendering/files', |
540 | 526 | ); |
— | — | @@ -541,14 +527,13 @@ |
542 | 528 | |
543 | 529 | /** |
544 | 530 | * @param $user User |
| 531 | + * @param $context IContextSource |
545 | 532 | * @param $defaultPreferences |
546 | 533 | * @return void |
547 | 534 | */ |
548 | | - static function datetimePreferences( $user, &$defaultPreferences ) { |
549 | | - global $wgLang; |
550 | | - |
| 535 | + static function datetimePreferences( $user, IContextSource $context, &$defaultPreferences ) { |
551 | 536 | ## Date and time ##################################### |
552 | | - $dateOptions = self::getDateOptions(); |
| 537 | + $dateOptions = self::getDateOptions( $context ); |
553 | 538 | if ( $dateOptions ) { |
554 | 539 | $defaultPreferences['date'] = array( |
555 | 540 | 'type' => 'radio', |
— | — | @@ -560,9 +545,10 @@ |
561 | 546 | |
562 | 547 | // Info |
563 | 548 | $now = wfTimestampNow(); |
| 549 | + $lang = $context->getLang(); |
564 | 550 | $nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ), |
565 | | - $wgLang->time( $now, true ) ); |
566 | | - $nowserver = $wgLang->time( $now, false ) . |
| 551 | + $lang->time( $now, true ) ); |
| 552 | + $nowserver = $lang->time( $now, false ) . |
567 | 553 | Html::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 + (int)substr( $now, 10, 2 ) ); |
568 | 554 | |
569 | 555 | $defaultPreferences['nowserver'] = array( |
— | — | @@ -594,7 +580,7 @@ |
595 | 581 | $defaultPreferences['timecorrection'] = array( |
596 | 582 | 'class' => 'HTMLSelectOrOtherField', |
597 | 583 | 'label-message' => 'timezonelegend', |
598 | | - 'options' => self::getTimezoneOptions(), |
| 584 | + 'options' => self::getTimezoneOptions( $context ), |
599 | 585 | 'default' => $tzSetting, |
600 | 586 | 'size' => 20, |
601 | 587 | 'section' => 'datetime/timeoffset', |
— | — | @@ -603,18 +589,19 @@ |
604 | 590 | |
605 | 591 | /** |
606 | 592 | * @param $user User |
| 593 | + * @param $context IContextSource |
607 | 594 | * @param $defaultPreferences Array |
608 | 595 | */ |
609 | | - static function renderingPreferences( $user, &$defaultPreferences ) { |
| 596 | + static function renderingPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
610 | 597 | ## Page Rendering ############################## |
611 | 598 | global $wgAllowUserCssPrefs; |
612 | 599 | if ( $wgAllowUserCssPrefs ) { |
613 | 600 | $defaultPreferences['underline'] = array( |
614 | 601 | 'type' => 'select', |
615 | 602 | 'options' => array( |
616 | | - wfMsg( 'underline-never' ) => 0, |
617 | | - wfMsg( 'underline-always' ) => 1, |
618 | | - wfMsg( 'underline-default' ) => 2, |
| 603 | + $context->msg( 'underline-never' )->text() => 0, |
| 604 | + $context->msg( 'underline-always' )->text() => 1, |
| 605 | + $context->msg( 'underline-default' )->text() => 2, |
619 | 606 | ), |
620 | 607 | 'label-message' => 'tog-underline', |
621 | 608 | 'section' => 'rendering/advancedrendering', |
— | — | @@ -622,9 +609,9 @@ |
623 | 610 | } |
624 | 611 | |
625 | 612 | $stubThresholdValues = array( 50, 100, 500, 1000, 2000, 5000, 10000 ); |
626 | | - $stubThresholdOptions = array( wfMsg( 'stub-threshold-disabled' ) => 0 ); |
| 613 | + $stubThresholdOptions = array( $context->msg( 'stub-threshold-disabled' )->text() => 0 ); |
627 | 614 | foreach ( $stubThresholdValues as $value ) { |
628 | | - $stubThresholdOptions[wfMsg( 'size-bytes', $value )] = $value; |
| 615 | + $stubThresholdOptions[$context->msg( 'size-bytes', $value )->text()] = $value; |
629 | 616 | } |
630 | 617 | |
631 | 618 | $defaultPreferences['stubthreshold'] = array( |
— | — | @@ -632,14 +619,14 @@ |
633 | 620 | 'section' => 'rendering/advancedrendering', |
634 | 621 | 'options' => $stubThresholdOptions, |
635 | 622 | 'size' => 20, |
636 | | - 'label' => wfMsg( 'stub-threshold' ), // Raw HTML message. Yay? |
| 623 | + 'label' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay? |
637 | 624 | ); |
638 | 625 | |
639 | 626 | if ( $wgAllowUserCssPrefs ) { |
640 | 627 | $defaultPreferences['highlightbroken'] = array( |
641 | 628 | 'type' => 'toggle', |
642 | 629 | 'section' => 'rendering/advancedrendering', |
643 | | - 'label' => wfMsg( 'tog-highlightbroken' ), // Raw HTML |
| 630 | + 'label' => $context->msg( 'tog-highlightbroken' )->text(), // Raw HTML |
644 | 631 | ); |
645 | 632 | $defaultPreferences['showtoc'] = array( |
646 | 633 | 'type' => 'toggle', |
— | — | @@ -680,9 +667,10 @@ |
681 | 668 | |
682 | 669 | /** |
683 | 670 | * @param $user User |
| 671 | + * @param $context IContextSource |
684 | 672 | * @param $defaultPreferences Array |
685 | 673 | */ |
686 | | - static function editingPreferences( $user, &$defaultPreferences ) { |
| 674 | + static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
687 | 675 | global $wgUseExternalEditor, $wgAllowUserCssPrefs; |
688 | 676 | |
689 | 677 | ## Editing ##################################### |
— | — | @@ -707,10 +695,10 @@ |
708 | 696 | 'section' => 'editing/advancedediting', |
709 | 697 | 'label-message' => 'editfont-style', |
710 | 698 | 'options' => array( |
711 | | - wfMsg( 'editfont-default' ) => 'default', |
712 | | - wfMsg( 'editfont-monospace' ) => 'monospace', |
713 | | - wfMsg( 'editfont-sansserif' ) => 'sans-serif', |
714 | | - wfMsg( 'editfont-serif' ) => 'serif', |
| 699 | + $context->msg( 'editfont-default' )->text() => 'default', |
| 700 | + $context->msg( 'editfont-monospace' )->text() => 'monospace', |
| 701 | + $context->msg( 'editfont-sansserif' )->text() => 'sans-serif', |
| 702 | + $context->msg( 'editfont-serif' )->text() => 'serif', |
715 | 703 | ) |
716 | 704 | ); |
717 | 705 | } |
— | — | @@ -785,10 +773,11 @@ |
786 | 774 | |
787 | 775 | /** |
788 | 776 | * @param $user User |
| 777 | + * @param $context IContextSource |
789 | 778 | * @param $defaultPreferences Array |
790 | 779 | */ |
791 | | - static function rcPreferences( $user, &$defaultPreferences ) { |
792 | | - global $wgRCMaxAge, $wgLang; |
| 780 | + static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
| 781 | + global $wgRCMaxAge, $wgRCShowWatchingUsers; |
793 | 782 | |
794 | 783 | ## RecentChanges ##################################### |
795 | 784 | $defaultPreferences['rcdays'] = array( |
— | — | @@ -797,11 +786,8 @@ |
798 | 787 | 'section' => 'rc/displayrc', |
799 | 788 | 'min' => 1, |
800 | 789 | 'max' => ceil( $wgRCMaxAge / ( 3600 * 24 ) ), |
801 | | - 'help' => wfMsgExt( |
802 | | - 'recentchangesdays-max', |
803 | | - array( 'parsemag' ), |
804 | | - $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) |
805 | | - ) |
| 790 | + 'help' => $context->msg( 'recentchangesdays-max' )->numParams( |
| 791 | + ceil( $wgRCMaxAge / ( 3600 * 24 ) ) )->text() |
806 | 792 | ); |
807 | 793 | $defaultPreferences['rclimit'] = array( |
808 | 794 | 'type' => 'int', |
— | — | @@ -833,7 +819,6 @@ |
834 | 820 | ); |
835 | 821 | } |
836 | 822 | |
837 | | - global $wgRCShowWatchingUsers; |
838 | 823 | if ( $wgRCShowWatchingUsers ) { |
839 | 824 | $defaultPreferences['shownumberswatching'] = array( |
840 | 825 | 'type' => 'toggle', |
— | — | @@ -845,9 +830,10 @@ |
846 | 831 | |
847 | 832 | /** |
848 | 833 | * @param $user User |
| 834 | + * @param $context IContextSource |
849 | 835 | * @param $defaultPreferences |
850 | 836 | */ |
851 | | - static function watchlistPreferences( $user, &$defaultPreferences ) { |
| 837 | + static function watchlistPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
852 | 838 | global $wgUseRCPatrol, $wgEnableAPI; |
853 | 839 | |
854 | 840 | ## Watchlist ##################################### |
— | — | @@ -856,7 +842,7 @@ |
857 | 843 | 'min' => 0, |
858 | 844 | 'max' => 7, |
859 | 845 | 'section' => 'watchlist/displaywatchlist', |
860 | | - 'help' => wfMsgHtml( 'prefs-watchlist-days-max' ), |
| 846 | + 'help' => $context->msg( 'prefs-watchlist-days-max' )->escaped(), |
861 | 847 | 'label-message' => 'prefs-watchlist-days', |
862 | 848 | ); |
863 | 849 | $defaultPreferences['wllimit'] = array( |
— | — | @@ -864,7 +850,7 @@ |
865 | 851 | 'min' => 0, |
866 | 852 | 'max' => 1000, |
867 | 853 | 'label-message' => 'prefs-watchlist-edits', |
868 | | - 'help' => wfMsgHtml( 'prefs-watchlist-edits-max' ), |
| 854 | + 'help' => $context->msg( 'prefs-watchlist-edits-max' )->escaped(), |
869 | 855 | 'section' => 'watchlist/displaywatchlist', |
870 | 856 | ); |
871 | 857 | $defaultPreferences['extendwatchlist'] = array( |
— | — | @@ -914,7 +900,7 @@ |
915 | 901 | 'type' => 'text', |
916 | 902 | 'section' => 'watchlist/advancedwatchlist', |
917 | 903 | 'label-message' => 'prefs-watchlist-token', |
918 | | - 'help' => wfMsgHtml( 'prefs-help-watchlist-token', $hash ) |
| 904 | + 'help' => $context->msg( 'prefs-help-watchlist-token', $hash )->escaped() |
919 | 905 | ); |
920 | 906 | } |
921 | 907 | |
— | — | @@ -942,10 +928,11 @@ |
943 | 929 | |
944 | 930 | /** |
945 | 931 | * @param $user User |
| 932 | + * @param $context IContextSource |
946 | 933 | * @param $defaultPreferences Array |
947 | 934 | */ |
948 | | - static function searchPreferences( $user, &$defaultPreferences ) { |
949 | | - global $wgContLang; |
| 935 | + static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
| 936 | + global $wgContLang, $wgEnableMWSuggest, $wgVectorUseSimpleSearch; |
950 | 937 | |
951 | 938 | ## Search ##################################### |
952 | 939 | $defaultPreferences['searchlimit'] = array( |
— | — | @@ -955,7 +942,6 @@ |
956 | 943 | 'min' => 0, |
957 | 944 | ); |
958 | 945 | |
959 | | - global $wgEnableMWSuggest; |
960 | 946 | if ( $wgEnableMWSuggest ) { |
961 | 947 | $defaultPreferences['disablesuggest'] = array( |
962 | 948 | 'type' => 'toggle', |
— | — | @@ -964,7 +950,6 @@ |
965 | 951 | ); |
966 | 952 | } |
967 | 953 | |
968 | | - global $wgVectorUseSimpleSearch; |
969 | 954 | if ( $wgVectorUseSimpleSearch ) { |
970 | 955 | $defaultPreferences['vector-simplesearch'] = array( |
971 | 956 | 'type' => 'toggle', |
— | — | @@ -989,7 +974,7 @@ |
990 | 975 | $displayNs = str_replace( '_', ' ', $name ); |
991 | 976 | |
992 | 977 | if ( !$displayNs ) { |
993 | | - $displayNs = wfMsg( 'blanknamespace' ); |
| 978 | + $displayNs = $context->msg( 'blanknamespace' )->text(); |
994 | 979 | } |
995 | 980 | |
996 | 981 | $displayNs = htmlspecialchars( $displayNs ); |
— | — | @@ -1007,9 +992,12 @@ |
1008 | 993 | |
1009 | 994 | /** |
1010 | 995 | * @param $user User |
| 996 | + * @param $context IContextSource |
1011 | 997 | * @param $defaultPreferences Array |
1012 | 998 | */ |
1013 | | - static function miscPreferences( $user, &$defaultPreferences ) { |
| 999 | + static function miscPreferences( $user, IContextSource $context, &$defaultPreferences ) { |
| 1000 | + global $wgContLang; |
| 1001 | + |
1014 | 1002 | ## Misc ##################################### |
1015 | 1003 | $defaultPreferences['diffonly'] = array( |
1016 | 1004 | 'type' => 'toggle', |
— | — | @@ -1023,8 +1011,6 @@ |
1024 | 1012 | ); |
1025 | 1013 | |
1026 | 1014 | // Stuff from Language::getExtraUserToggles() |
1027 | | - global $wgContLang; |
1028 | | - |
1029 | 1015 | $toggles = $wgContLang->getExtraUserToggles(); |
1030 | 1016 | |
1031 | 1017 | foreach ( $toggles as $toggle ) { |
— | — | @@ -1038,14 +1024,15 @@ |
1039 | 1025 | |
1040 | 1026 | /** |
1041 | 1027 | * @param $user User The User object |
| 1028 | + * @param $context IContextSource |
1042 | 1029 | * @return Array: text/links to display as key; $skinkey as value |
1043 | 1030 | */ |
1044 | | - static function generateSkinOptions( $user ) { |
1045 | | - global $wgDefaultSkin, $wgLang, $wgAllowUserCss, $wgAllowUserJs; |
| 1031 | + static function generateSkinOptions( $user, IContextSource $context ) { |
| 1032 | + global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs; |
1046 | 1033 | $ret = array(); |
1047 | 1034 | |
1048 | 1035 | $mptitle = Title::newMainPage(); |
1049 | | - $previewtext = wfMsgHtml( 'skin-preview' ); |
| 1036 | + $previewtext = $context->msg( 'skin-preview' )->text(); |
1050 | 1037 | |
1051 | 1038 | # Only show members of Skin::getSkinNames() rather than |
1052 | 1039 | # $skinNames (skins is all skin names from Language.php) |
— | — | @@ -1054,7 +1041,7 @@ |
1055 | 1042 | # Sort by UI skin name. First though need to update validSkinNames as sometimes |
1056 | 1043 | # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI). |
1057 | 1044 | foreach ( $validSkinNames as $skinkey => &$skinname ) { |
1058 | | - $msg = wfMessage( "skinname-{$skinkey}" ); |
| 1045 | + $msg = $context->msg( "skinname-{$skinkey}" ); |
1059 | 1046 | if ( $msg->exists() ) { |
1060 | 1047 | $skinname = htmlspecialchars( $msg->text() ); |
1061 | 1048 | } |
— | — | @@ -1066,7 +1053,7 @@ |
1067 | 1054 | |
1068 | 1055 | # Mark the default skin |
1069 | 1056 | if ( $skinkey == $wgDefaultSkin ) { |
1070 | | - $linkTools[] = wfMsgHtml( 'default' ); |
| 1057 | + $linkTools[] = $context->msg( 'default' )->escaped(); |
1071 | 1058 | } |
1072 | 1059 | |
1073 | 1060 | # Create preview link |
— | — | @@ -1076,15 +1063,15 @@ |
1077 | 1064 | # Create links to user CSS/JS pages |
1078 | 1065 | if ( $wgAllowUserCss ) { |
1079 | 1066 | $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.css' ); |
1080 | | - $linkTools[] = Linker::link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) ); |
| 1067 | + $linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() ); |
1081 | 1068 | } |
1082 | 1069 | |
1083 | 1070 | if ( $wgAllowUserJs ) { |
1084 | 1071 | $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.js' ); |
1085 | | - $linkTools[] = Linker::link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) ); |
| 1072 | + $linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() ); |
1086 | 1073 | } |
1087 | 1074 | |
1088 | | - $display = $sn . ' ' . wfMsg( 'parentheses', $wgLang->pipeList( $linkTools ) ); |
| 1075 | + $display = $sn . ' ' . $context->msg( 'parentheses', $context->getLang()->pipeList( $linkTools ) )->text(); |
1089 | 1076 | $ret[$display] = $skinkey; |
1090 | 1077 | } |
1091 | 1078 | |
— | — | @@ -1092,11 +1079,11 @@ |
1093 | 1080 | } |
1094 | 1081 | |
1095 | 1082 | /** |
| 1083 | + * @param $context IContextSource |
1096 | 1084 | * @return array |
1097 | 1085 | */ |
1098 | | - static function getDateOptions() { |
1099 | | - global $wgLang; |
1100 | | - $dateopts = $wgLang->getDatePreferences(); |
| 1086 | + static function getDateOptions( IContextSource $context ) { |
| 1087 | + $dateopts = $context->getLang()->getDatePreferences(); |
1101 | 1088 | |
1102 | 1089 | $ret = array(); |
1103 | 1090 | |
— | — | @@ -1115,9 +1102,9 @@ |
1116 | 1103 | $epoch = wfTimestampNow(); |
1117 | 1104 | foreach ( $dateopts as $key ) { |
1118 | 1105 | if ( $key == 'default' ) { |
1119 | | - $formatted = wfMsgHtml( 'datedefault' ); |
| 1106 | + $formatted = $context->msg( 'datedefault' )->escaped(); |
1120 | 1107 | } else { |
1121 | | - $formatted = htmlspecialchars( $wgLang->timeanddate( $epoch, false, $key ) ); |
| 1108 | + $formatted = htmlspecialchars( $context->getLang()->timeanddate( $epoch, false, $key ) ); |
1122 | 1109 | } |
1123 | 1110 | $ret[$formatted] = $key; |
1124 | 1111 | } |
— | — | @@ -1126,15 +1113,17 @@ |
1127 | 1114 | } |
1128 | 1115 | |
1129 | 1116 | /** |
| 1117 | + * @param $context IContextSource |
1130 | 1118 | * @return array |
1131 | 1119 | */ |
1132 | | - static function getImageSizes() { |
| 1120 | + static function getImageSizes( IContextSource $context ) { |
1133 | 1121 | global $wgImageLimits; |
1134 | 1122 | |
1135 | 1123 | $ret = array(); |
| 1124 | + $pixels = $context->msg( 'unit-pixel' )->text(); |
1136 | 1125 | |
1137 | 1126 | foreach ( $wgImageLimits as $index => $limits ) { |
1138 | | - $display = "{$limits[0]}×{$limits[1]}" . wfMsg( 'unit-pixel' ); |
| 1127 | + $display = "{$limits[0]}×{$limits[1]}" . $pixels; |
1139 | 1128 | $ret[$display] = $index; |
1140 | 1129 | } |
1141 | 1130 | |
— | — | @@ -1142,15 +1131,17 @@ |
1143 | 1132 | } |
1144 | 1133 | |
1145 | 1134 | /** |
| 1135 | + * @param $context IContextSource |
1146 | 1136 | * @return array |
1147 | 1137 | */ |
1148 | | - static function getThumbSizes() { |
| 1138 | + static function getThumbSizes( IContextSource $context ) { |
1149 | 1139 | global $wgThumbLimits; |
1150 | 1140 | |
1151 | 1141 | $ret = array(); |
| 1142 | + $pixels = $context->msg( 'unit-pixel' )->text(); |
1152 | 1143 | |
1153 | 1144 | foreach ( $wgThumbLimits as $index => $size ) { |
1154 | | - $display = $size . wfMsg( 'unit-pixel' ); |
| 1145 | + $display = $size . $pixels; |
1155 | 1146 | $ret[$display] = $index; |
1156 | 1147 | } |
1157 | 1148 | |
— | — | @@ -1163,13 +1154,10 @@ |
1164 | 1155 | * @return bool|string |
1165 | 1156 | */ |
1166 | 1157 | static function validateSignature( $signature, $alldata ) { |
1167 | | - global $wgParser, $wgMaxSigChars, $wgLang; |
| 1158 | + global $wgParser, $wgMaxSigChars; |
1168 | 1159 | if ( mb_strlen( $signature ) > $wgMaxSigChars ) { |
1169 | 1160 | return Xml::element( 'span', array( 'class' => 'error' ), |
1170 | | - wfMsgExt( 'badsiglength', 'parsemag', |
1171 | | - $wgLang->formatNum( $wgMaxSigChars ) |
1172 | | - ) |
1173 | | - ); |
| 1161 | + wfMessage( 'badsiglength' )->numParams( $wgMaxSigChars )->text() ); |
1174 | 1162 | } elseif ( isset( $alldata['fancysig'] ) && |
1175 | 1163 | $alldata['fancysig'] && |
1176 | 1164 | false === $wgParser->validateSig( $signature ) ) { |
— | — | @@ -1217,17 +1205,22 @@ |
1218 | 1206 | * @param $user User |
1219 | 1207 | * @param $context IContextSource |
1220 | 1208 | * @param $formClass string |
| 1209 | + * @param $remove Array: array of items to remove |
1221 | 1210 | * @return HtmlForm |
1222 | 1211 | */ |
1223 | | - static function getFormObject( $user, IContextSource $context, $formClass = 'PreferencesForm' ) { |
1224 | | - $formDescriptor = Preferences::getPreferences( $user ); |
| 1212 | + static function getFormObject( $user, IContextSource $context, $formClass = 'PreferencesForm', array $remove = array() ) { |
| 1213 | + $formDescriptor = Preferences::getPreferences( $user, $context ); |
| 1214 | + if ( count( $remove ) ) { |
| 1215 | + $removeKeys = array_flip( $remove ); |
| 1216 | + $formDescriptor = array_diff_key( $formDescriptor, $removeKeys ); |
| 1217 | + } |
1225 | 1218 | $htmlForm = new $formClass( $formDescriptor, $context, 'prefs' ); |
1226 | 1219 | |
| 1220 | + $htmlForm->setModifiedUser( $user ); |
1227 | 1221 | $htmlForm->setId( 'mw-prefs-form' ); |
1228 | 1222 | $htmlForm->setSubmitText( wfMsg( 'saveprefs' ) ); |
1229 | 1223 | # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save' |
1230 | 1224 | $htmlForm->setSubmitTooltip( 'preferences-save' ); |
1231 | | - $htmlForm->setTitle( SpecialPage::getTitleFor( 'Preferences' ) ); |
1232 | 1225 | $htmlForm->setSubmitID( 'prefsubmit' ); |
1233 | 1226 | $htmlForm->setSubmitCallback( array( 'Preferences', 'tryFormSubmit' ) ); |
1234 | 1227 | |
— | — | @@ -1237,20 +1230,20 @@ |
1238 | 1231 | /** |
1239 | 1232 | * @return array |
1240 | 1233 | */ |
1241 | | - static function getTimezoneOptions() { |
| 1234 | + static function getTimezoneOptions( IContextSource $context ) { |
1242 | 1235 | $opt = array(); |
1243 | 1236 | |
1244 | 1237 | global $wgLocalTZoffset, $wgLocaltimezone; |
1245 | 1238 | // Check that $wgLocalTZoffset is the same as $wgLocaltimezone |
1246 | 1239 | if ( $wgLocalTZoffset == date( 'Z' ) / 60 ) { |
1247 | | - $server_tz_msg = wfMsg( 'timezoneuseserverdefault', $wgLocaltimezone ); |
| 1240 | + $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $wgLocaltimezone )->text(); |
1248 | 1241 | } else { |
1249 | 1242 | $tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) % 60 ); |
1250 | | - $server_tz_msg = wfMsg( 'timezoneuseserverdefault', $tzstring ); |
| 1243 | + $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $tzstring )->text(); |
1251 | 1244 | } |
1252 | 1245 | $opt[$server_tz_msg] = "System|$wgLocalTZoffset"; |
1253 | | - $opt[wfMsg( 'timezoneuseoffset' )] = 'other'; |
1254 | | - $opt[wfMsg( 'guesstimezone' )] = 'guess'; |
| 1246 | + $opt[$context->msg( 'timezoneuseoffset' )->text()] = 'other'; |
| 1247 | + $opt[$context->msg( 'guesstimezone' )->text()] = 'guess'; |
1255 | 1248 | |
1256 | 1249 | if ( function_exists( 'timezone_identifiers_list' ) ) { |
1257 | 1250 | # Read timezone list |
— | — | @@ -1258,16 +1251,16 @@ |
1259 | 1252 | sort( $tzs ); |
1260 | 1253 | |
1261 | 1254 | $tzRegions = array(); |
1262 | | - $tzRegions['Africa'] = wfMsg( 'timezoneregion-africa' ); |
1263 | | - $tzRegions['America'] = wfMsg( 'timezoneregion-america' ); |
1264 | | - $tzRegions['Antarctica'] = wfMsg( 'timezoneregion-antarctica' ); |
1265 | | - $tzRegions['Arctic'] = wfMsg( 'timezoneregion-arctic' ); |
1266 | | - $tzRegions['Asia'] = wfMsg( 'timezoneregion-asia' ); |
1267 | | - $tzRegions['Atlantic'] = wfMsg( 'timezoneregion-atlantic' ); |
1268 | | - $tzRegions['Australia'] = wfMsg( 'timezoneregion-australia' ); |
1269 | | - $tzRegions['Europe'] = wfMsg( 'timezoneregion-europe' ); |
1270 | | - $tzRegions['Indian'] = wfMsg( 'timezoneregion-indian' ); |
1271 | | - $tzRegions['Pacific'] = wfMsg( 'timezoneregion-pacific' ); |
| 1255 | + $tzRegions['Africa'] = $context->msg( 'timezoneregion-africa' )->text(); |
| 1256 | + $tzRegions['America'] = $context->msg( 'timezoneregion-america' )->text(); |
| 1257 | + $tzRegions['Antarctica'] = $context->msg( 'timezoneregion-antarctica' )->text(); |
| 1258 | + $tzRegions['Arctic'] = $context->msg( 'timezoneregion-arctic' )->text(); |
| 1259 | + $tzRegions['Asia'] = $context->msg( 'timezoneregion-asia' )->text(); |
| 1260 | + $tzRegions['Atlantic'] = $context->msg( 'timezoneregion-atlantic' )->text(); |
| 1261 | + $tzRegions['Australia'] = $context->msg( 'timezoneregion-australia' )->text(); |
| 1262 | + $tzRegions['Europe'] = $context->msg( 'timezoneregion-europe' )->text(); |
| 1263 | + $tzRegions['Indian'] = $context->msg( 'timezoneregion-indian' )->text(); |
| 1264 | + $tzRegions['Pacific'] = $context->msg( 'timezoneregion-pacific' )->text(); |
1272 | 1265 | asort( $tzRegions ); |
1273 | 1266 | |
1274 | 1267 | $prefill = array_fill_keys( array_values( $tzRegions ), array() ); |
— | — | @@ -1340,12 +1333,14 @@ |
1341 | 1334 | |
1342 | 1335 | /** |
1343 | 1336 | * @param $formData |
| 1337 | + * @param $form HTMLForm |
1344 | 1338 | * @param $entryPoint string |
1345 | 1339 | * @return bool|Status|string |
1346 | 1340 | */ |
1347 | | - static function tryFormSubmit( $formData, $entryPoint = 'internal' ) { |
1348 | | - global $wgUser; |
| 1341 | + static function tryFormSubmit( $formData, $form, $entryPoint = 'internal' ) { |
| 1342 | + global $wgHiddenPrefs; |
1349 | 1343 | |
| 1344 | + $user = $form->getModifiedUser(); |
1350 | 1345 | $result = true; |
1351 | 1346 | |
1352 | 1347 | // Filter input |
— | — | @@ -1363,10 +1358,9 @@ |
1364 | 1359 | ); |
1365 | 1360 | |
1366 | 1361 | // Fortunately, the realname field is MUCH simpler |
1367 | | - global $wgHiddenPrefs; |
1368 | 1362 | if ( !in_array( 'realname', $wgHiddenPrefs ) ) { |
1369 | 1363 | $realName = $formData['realname']; |
1370 | | - $wgUser->setRealName( $realName ); |
| 1364 | + $user->setRealName( $realName ); |
1371 | 1365 | } |
1372 | 1366 | |
1373 | 1367 | foreach ( $saveBlacklist as $b ) { |
— | — | @@ -1380,18 +1374,18 @@ |
1381 | 1375 | foreach( $wgHiddenPrefs as $pref ){ |
1382 | 1376 | # If the user has not set a non-default value here, the default will be returned |
1383 | 1377 | # and subsequently discarded |
1384 | | - $formData[$pref] = $wgUser->getOption( $pref, null, true ); |
| 1378 | + $formData[$pref] = $user->getOption( $pref, null, true ); |
1385 | 1379 | } |
1386 | 1380 | |
1387 | 1381 | // Keeps old preferences from interfering due to back-compat |
1388 | 1382 | // code, etc. |
1389 | | - $wgUser->resetOptions(); |
| 1383 | + $user->resetOptions(); |
1390 | 1384 | |
1391 | 1385 | foreach ( $formData as $key => $value ) { |
1392 | | - $wgUser->setOption( $key, $value ); |
| 1386 | + $user->setOption( $key, $value ); |
1393 | 1387 | } |
1394 | 1388 | |
1395 | | - $wgUser->saveSettings(); |
| 1389 | + $user->saveSettings(); |
1396 | 1390 | |
1397 | 1391 | return $result; |
1398 | 1392 | } |
— | — | @@ -1400,22 +1394,21 @@ |
1401 | 1395 | * @param $formData |
1402 | 1396 | * @return Status |
1403 | 1397 | */ |
1404 | | - public static function tryUISubmit( $formData ) { |
1405 | | - $res = self::tryFormSubmit( $formData, 'ui' ); |
| 1398 | + public static function tryUISubmit( $formData, $form ) { |
| 1399 | + $res = self::tryFormSubmit( $formData, $form, 'ui' ); |
1406 | 1400 | |
1407 | 1401 | if ( $res ) { |
1408 | | - $urlOptions = array( 'success' ); |
| 1402 | + $urlOptions = array( 'success' => 1 ); |
1409 | 1403 | |
1410 | 1404 | if ( $res === 'eauth' ) { |
1411 | | - $urlOptions[] = 'eauth'; |
| 1405 | + $urlOptions['eauth'] = 1; |
1412 | 1406 | } |
1413 | 1407 | |
1414 | | - $queryString = implode( '&', $urlOptions ); |
| 1408 | + $urlOptions += $form->getExtraSuccessRedirectParameters(); |
1415 | 1409 | |
1416 | | - $url = SpecialPage::getTitleFor( 'Preferences' )->getFullURL( $queryString ); |
| 1410 | + $url = $form->getTitle()->getFullURL( $urlOptions ); |
1417 | 1411 | |
1418 | | - global $wgOut; |
1419 | | - $wgOut->redirect( $url ); |
| 1412 | + $form->getContext()->getOutput()->redirect( $url ); |
1420 | 1413 | } |
1421 | 1414 | |
1422 | 1415 | return Status::newGood(); |
— | — | @@ -1483,8 +1476,31 @@ |
1484 | 1477 | |
1485 | 1478 | /** Some tweaks to allow js prefs to work */ |
1486 | 1479 | class PreferencesForm extends HTMLForm { |
| 1480 | + private $modifiedUser; |
1487 | 1481 | |
| 1482 | + public function setModifiedUser( $user ) { |
| 1483 | + $this->modifiedUser = $user; |
| 1484 | + } |
| 1485 | + |
| 1486 | + public function getModifiedUser() { |
| 1487 | + if ( $this->modifiedUser === null ) { |
| 1488 | + return $this->getUser(); |
| 1489 | + } else { |
| 1490 | + return $this->modifiedUser; |
| 1491 | + } |
| 1492 | + } |
| 1493 | + |
1488 | 1494 | /** |
| 1495 | + * Get extra parameters for the query string when redirecting after |
| 1496 | + * successful save. |
| 1497 | + * |
| 1498 | + * @return array() |
| 1499 | + */ |
| 1500 | + public function getExtraSuccessRedirectParameters() { |
| 1501 | + return array(); |
| 1502 | + } |
| 1503 | + |
| 1504 | + /** |
1489 | 1505 | * @param $html string |
1490 | 1506 | * @return String |
1491 | 1507 | */ |