X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPreferences.php;h=c6b2bb6b9d6bb4a2ce8fed9ea68d3ee1e1c9ab02;hb=27757a7fdd3c6ffb56c470af7097c4c28cd4632d;hp=59deaec84ef903dfe9262f633c2e1593604c0940;hpb=155ddf6de4a2aa68dcdd8ca7d0f9db21ced4b228;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 59deaec84e..c6b2bb6b9d 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -1,69 +1,90 @@ setPageTitle( wfMsg( 'preferences' ) ); - $wgOut->setArticleRelated( false ); - $wgOut->setRobotPolicy( 'noindex,nofollow' ); - $wgOut->addScriptFile( 'prefs.js' ); - - $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. - - if ( $wgUser->isAnon() ) { - $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array($this->getTitle()->getPrefixedDBkey()) ); - return; - } - if ( wfReadOnly() ) { - $wgOut->readOnlyPage(); - return; + + public function execute( $par ) { + $this->setHeaders(); + $this->outputHeader(); + $out = $this->getOutput(); + $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. + + $user = $this->getUser(); + if ( $user->isAnon() ) { + throw new ErrorPageError( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) ); } - - if ($par == 'reset') { + $this->checkReadOnly(); + + if ( $par == 'reset' ) { $this->showResetForm(); return; } - if ( $wgRequest->getCheck( 'success' ) ) { - $wgOut->wrapWikiMsg( - '
$1
', + $out->addModules( 'mediawiki.special.preferences' ); + + if ( $this->getRequest()->getCheck( 'success' ) ) { + $out->wrapWikiMsg( + "
\n$1\n
", 'savedprefs' ); } - - $htmlForm = Preferences::getFormObject( $wgUser ); + + $htmlForm = Preferences::getFormObject( $user, $this->getContext() ); + $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) ); $htmlForm->show(); } - - function showResetForm() { - global $wgOut; - - $wgOut->addWikiMsg( 'prefs-reset-intro' ); - - $htmlForm = new HTMLForm( array(), 'prefs-restore' ); - - $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) ); - $htmlForm->setTitle( $this->getTitle('reset') ); - $htmlForm->setSubmitCallback( array( __CLASS__, 'submitReset' ) ); + + private function showResetForm() { + $this->getOutput()->addWikiMsg( 'prefs-reset-intro' ); + + $htmlForm = new HTMLForm( array(), $this->getContext(), 'prefs-restore' ); + + $htmlForm->setSubmitTextMsg( 'restoreprefs' ); + $htmlForm->setTitle( $this->getTitle( 'reset' ) ); + $htmlForm->setSubmitCallback( array( $this, 'submitReset' ) ); $htmlForm->suppressReset(); - + $htmlForm->show(); } - - static function submitReset( $formData ) { - global $wgUser, $wgOut; - $wgUser->resetOptions(); - - $url = SpecialPage::getTitleFor( 'Preferences')->getFullURL( 'success' ); - - $wgOut->redirect( $url ); - + + public function submitReset( $formData ) { + $user = $this->getUser(); + $user->resetOptions(); + $user->saveSettings(); + + $url = $this->getTitle()->getFullURL( 'success' ); + + $this->getOutput()->redirect( $url ); + return true; } }