X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialLockdb.php;h=aad3cea41adc2e83e6c86f255c24fcaa3c022baf;hb=f17cf7ef0eff66f5286253eebe47d675769db7da;hp=8c701dd60b372e54e77c7df216d65c34211f2451;hpb=b6e0df246f8dda61643d9aba36d9f9e802c909ec;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php index 8c701dd60b..aad3cea41a 100644 --- a/includes/specials/SpecialLockdb.php +++ b/includes/specials/SpecialLockdb.php @@ -1,97 +1,108 @@ isAllowed( 'siteadmin' ) ) { - $wgOut->permissionRequired( 'siteadmin' ); - return; + public function __construct() { + parent::__construct( 'Lockdb', 'siteadmin' ); } - # If the lock file isn't writable, we can do sweet bugger all - global $wgReadOnlyFile; - if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { - DBLockForm::notWritable(); - return; - } + public function execute( $par ) { + global $wgUser, $wgOut, $wgRequest; - $action = $wgRequest->getVal( 'action' ); - $f = new DBLockForm(); + $this->setHeaders(); - if ( 'success' == $action ) { - $f->showSuccess(); - } else if ( 'submit' == $action && $wgRequest->wasPosted() && - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $f->doSubmit(); - } else { - $f->showForm( '' ); - } -} + if( !$wgUser->isAllowed( 'siteadmin' ) ) { + $wgOut->permissionRequired( 'siteadmin' ); + return; + } -/** - * A form to make the database readonly (eg for maintenance purposes). - * @ingroup SpecialPage - */ -class DBLockForm { - var $reason = ''; + $this->outputHeader(); - function DBLockForm() { - global $wgRequest; - $this->reason = $wgRequest->getText( 'wpLockReason' ); + # If the lock file isn't writable, we can do sweet bugger all + global $wgReadOnlyFile; + if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { + self::notWritable(); + return; + } + + $action = $wgRequest->getVal( 'action' ); + $this->reason = $wgRequest->getVal( 'wpLockReason', '' ); + + if ( $action == 'success' ) { + $this->showSuccess(); + } else if ( $action == 'submit' && $wgRequest->wasPosted() && + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + $this->doSubmit(); + } else { + $this->showForm(); + } } - function showForm( $err ) { + private function showForm( $err = '' ) { global $wgOut, $wgUser; - $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); $wgOut->addWikiMsg( 'lockdbtext' ); - if ( $err != "" ) { + if ( $err != '' ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); $wgOut->addHTML( '

' . htmlspecialchars( $err ) . "

\n" ); } - $lc = htmlspecialchars( wfMsg( 'lockconfirm' ) ); - $lb = htmlspecialchars( wfMsg( 'lockbtn' ) ); - $elr = htmlspecialchars( wfMsg( 'enterlockreason' ) ); - $titleObj = SpecialPage::getTitleFor( 'Lockdb' ); - $action = $titleObj->escapeLocalURL( 'action=submit' ); - $reason = htmlspecialchars( $this->reason ); - $token = htmlspecialchars( $wgUser->editToken() ); - - $wgOut->addHTML( << -{$elr}: - - + + $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' ) ) . + wfMsgHtml( 'lockconfirm' ) . " - - + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " + " . Html::input( 'wpLock', wfMsg( 'lockbtn' ), 'submit' ) . " -
- + " . Html::openElement( 'td', array( 'style' => 'text-align:right' ) ) . " + " . Html::input( 'wpLockConfirm', null, 'checkbox' ) . " {$lc}
  - +  
- - -HTML -); +\n" . + Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . + Html::closeElement( 'form' ) + ); } - function doSubmit() { - global $wgOut, $wgUser, $wgLang, $wgRequest; + private function doSubmit() { + global $wgOut, $wgUser, $wgContLang, $wgRequest; global $wgReadOnlyFile; if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) { @@ -109,14 +120,13 @@ HTML } fwrite( $fp, $this->reason ); fwrite( $fp, "\n

(by " . $wgUser->getName() . " at " . - $wgLang->timeanddate( wfTimestampNow() ) . ")

\n" ); + $wgContLang->timeanddate( wfTimestampNow() ) . ")

\n" ); fclose( $fp ); - $titleObj = SpecialPage::getTitleFor( 'Lockdb' ); - $wgOut->redirect( $titleObj->getFullURL( 'action=success' ) ); + $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); } - function showSuccess() { + private function showSuccess() { global $wgOut; $wgOut->setPagetitle( wfMsg( 'lockdb' ) );