X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialLockdb.php;h=d71ac6e19148cd7eb33705498645ea6da25beb33;hb=3c3b564ec2a8391bfacdc049aa95ee998bc8951a;hp=680e672c84982ebca02ec5b6df6830c3f47bb896;hpb=9a93faf4d4c92dccaf804968bee632c389d9abcc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php index 680e672c84..d71ac6e191 100644 --- a/includes/specials/SpecialLockdb.php +++ b/includes/specials/SpecialLockdb.php @@ -26,91 +26,53 @@ * * @ingroup SpecialPage */ -class SpecialLockdb extends SpecialPage { +class SpecialLockdb extends FormSpecialPage { var $reason = ''; public function __construct() { parent::__construct( 'Lockdb', 'siteadmin' ); } - public function execute( $par ) { - global $wgUser, $wgRequest; - - $this->setHeaders(); - - # Permission check - if( !$this->userCanExecute( $wgUser ) ) { - $this->displayRestrictionError(); - return; - } - - $this->outputHeader(); + public function requiresWrite() { + return false; + } - # If the lock file isn't writable, we can do sweet bugger all + public function checkExecutePermissions( User $user ) { global $wgReadOnlyFile; - if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { - self::notWritable(); - return; - } - - $action = $wgRequest->getVal( 'action' ); - $this->reason = $wgRequest->getVal( 'wpLockReason', '' ); - if ( $action == 'success' ) { - $this->showSuccess(); - } elseif ( $action == 'submit' && $wgRequest->wasPosted() && - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $this->doSubmit(); - } else { - $this->showForm(); + parent::checkExecutePermissions( $user ); + # If the lock file isn't writable, we can do sweet bugger all + if ( !is_writable( dirname( $wgReadOnlyFile ) ) ) { + throw new ErrorPageError( 'lockdb', 'lockfilenotwritable' ); } } - private function showForm( $err = '' ) { - global $wgOut, $wgUser; - - $wgOut->addWikiMsg( 'lockdbtext' ); - - if ( $err != '' ) { - $wgOut->setSubtitle( wfMsg( 'formerror' ) ); - $wgOut->addHTML( '
' . htmlspecialchars( $err ) . "
\n" ); - } - - $wgOut->addHTML( - Html::openElement( 'form', array( 'id' => 'lockdb', 'method' => 'POST', - 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ). "\n" . - wfMsgHtml( 'enterlockreason' ) . ":\n" . - Html::textarea( 'wpLockReason', $this->reason, array( 'rows' => 4 ) ). " -- " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " - " . Html::input( 'wpLock', wfMsg( 'lockbtn' ), 'submit' ) . " - - |
" . wfMsgExt( - 'lockedbyandtime', - array( 'content', 'parsemag' ), - $wgUser->getName(), - $wgContLang->date( $timestamp ), - $wgContLang->time( $timestamp ) - ) . "
\n" ); + fwrite( $fp, "\n" . $this->msg( 'lockedbyandtime', + $this->getUser()->getName(), + $wgContLang->date( $timestamp, false, false ), + $wgContLang->time( $timestamp, false, false ) + )->inContentLanguage()->text() . "
\n" ); fclose( $fp ); - $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); - } - - private function showSuccess() { - global $wgOut; - - $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); - $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) ); - $wgOut->addWikiMsg( 'lockdbsuccesstext' ); + return Status::newGood(); } - public static function notWritable() { - global $wgOut; - $wgOut->showErrorPage( 'lockdb', 'lockfilenotwritable' ); + public function onSuccess() { + $out = $this->getOutput(); + $out->addSubtitle( $this->msg( 'lockdbsuccesssub' ) ); + $out->addWikiMsg( 'lockdbsuccesstext' ); } }