diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
commit | 9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch) | |
tree | 46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/specials/SpecialUnlockdb.php | |
parent | 78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff) |
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/specials/SpecialUnlockdb.php')
-rw-r--r-- | includes/specials/SpecialUnlockdb.php | 127 |
1 files changed, 71 insertions, 56 deletions
diff --git a/includes/specials/SpecialUnlockdb.php b/includes/specials/SpecialUnlockdb.php index fe38a48a..c71b554b 100644 --- a/includes/specials/SpecialUnlockdb.php +++ b/includes/specials/SpecialUnlockdb.php @@ -1,39 +1,62 @@ <?php /** + * Implements Special:Unlockdb + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup SpecialPage */ /** + * Implements Special:Unlockdb * + * @ingroup SpecialPage */ -function wfSpecialUnlockdb() { - global $wgUser, $wgOut, $wgRequest; +class SpecialUnlockdb extends SpecialPage { - if( !$wgUser->isAllowed( 'siteadmin' ) ) { - $wgOut->permissionRequired( 'siteadmin' ); - return; + public function __construct() { + parent::__construct( 'Unlockdb', 'siteadmin' ); } - $action = $wgRequest->getVal( 'action' ); - $f = new DBUnlockForm(); + public function execute( $par ) { + global $wgUser, $wgOut, $wgRequest; + + $this->setHeaders(); + + if( !$wgUser->isAllowed( 'siteadmin' ) ) { + $wgOut->permissionRequired( 'siteadmin' ); + return; + } + + $this->outputHeader(); + + $action = $wgRequest->getVal( 'action' ); - if ( "success" == $action ) { - $f->showSuccess(); - } else if ( "submit" == $action && $wgRequest->wasPosted() && - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { - $f->doSubmit(); - } else { - $f->showForm( "" ); + if ( $action == 'success' ) { + $this->showSuccess(); + } else if ( $action == 'submit' && $wgRequest->wasPosted() && + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { + $this->doSubmit(); + } else { + $this->showForm(); + } } -} -/** - * @ingroup SpecialPage - */ -class DBUnlockForm { - function showForm( $err ) - { + private function showForm( $err = '' ) { global $wgOut, $wgUser; global $wgReadOnlyFile; @@ -42,65 +65,57 @@ class DBUnlockForm { return; } - $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); - $wgOut->addWikiMsg( "unlockdbtext" ); + $wgOut->addWikiMsg( 'unlockdbtext' ); - if ( $err != "" ) { - $wgOut->setSubtitle( wfMsg( "formerror" ) ); + if ( $err != '' ) { + $wgOut->setSubtitle( wfMsg( 'formerror' ) ); $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); } - $lc = htmlspecialchars( wfMsg( "unlockconfirm" ) ); - $lb = htmlspecialchars( wfMsg( "unlockbtn" ) ); - $titleObj = SpecialPage::getTitleFor( "Unlockdb" ); - $action = $titleObj->escapeLocalURL( "action=submit" ); - $token = htmlspecialchars( $wgUser->editToken() ); - $wgOut->addHTML( <<<HTML - -<form id="unlockdb" method="post" action="{$action}"> -<table border="0"> + $wgOut->addHTML( + Html::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST', + 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . " +<table> <tr> - <td align="right"> - <input type="checkbox" name="wpLockConfirm" /> + " . Html::openElement( 'td', array( 'style' => 'text-align:right' ) ) . " + " . Html::input( 'wpLockConfirm', null, 'checkbox' ) . " </td> - <td align="left">{$lc}</td> + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . + wfMsgHtml( 'unlockconfirm' ) . "</td> </tr> <tr> - <td> </td> - <td align="left"> - <input type="submit" name="wpLock" value="{$lb}" /> + <td> </td> + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " + " . Html::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . " </td> </tr> -</table> -<input type="hidden" name="wpEditToken" value="{$token}" /> -</form> -HTML -); +</table>\n" . + Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . + Html::closeElement( 'form' ) + ); } - function doSubmit() { + private function doSubmit() { global $wgOut, $wgRequest, $wgReadOnlyFile; $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' ); - if ( ! $wpLockConfirm ) { - $this->showForm( wfMsg( "locknoconfirm" ) ); + if ( !$wpLockConfirm ) { + $this->showForm( wfMsg( 'locknoconfirm' ) ); return; } - if ( @! unlink( $wgReadOnlyFile ) ) { + if ( @!unlink( $wgReadOnlyFile ) ) { $wgOut->showFileDeleteError( $wgReadOnlyFile ); return; } - $titleObj = SpecialPage::getTitleFor( "Unlockdb" ); - $success = $titleObj->getFullURL( "action=success" ); - $wgOut->redirect( $success ); + + $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); } - function showSuccess() { + private function showSuccess() { global $wgOut; - $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); - $wgOut->setSubtitle( wfMsg( "unlockdbsuccesssub" ) ); - $wgOut->addWikiMsg( "unlockdbsuccesstext" ); + $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) ); + $wgOut->addWikiMsg( 'unlockdbsuccesstext' ); } } |