summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialLockdb.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
committerPierre Schmitz <pierre@archlinux.de>2011-06-22 11:28:20 +0200
commit9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch)
tree46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/specials/SpecialLockdb.php
parent78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff)
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/specials/SpecialLockdb.php')
-rw-r--r--includes/specials/SpecialLockdb.php140
1 files changed, 75 insertions, 65 deletions
diff --git a/includes/specials/SpecialLockdb.php b/includes/specials/SpecialLockdb.php
index 8c701dd6..aad3cea4 100644
--- a/includes/specials/SpecialLockdb.php
+++ b/includes/specials/SpecialLockdb.php
@@ -1,97 +1,108 @@
<?php
/**
+ * Implements Special:Lockdb
+ *
+ * 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
*/
/**
- * Constructor
+ * A form to make the database readonly (eg for maintenance purposes).
+ *
+ * @ingroup SpecialPage
*/
-function wfSpecialLockdb() {
- global $wgUser, $wgOut, $wgRequest;
+class SpecialLockdb extends SpecialPage {
+ var $reason = '';
- if( !$wgUser->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( '<p class="error">' . htmlspecialchars( $err ) . "</p>\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( <<<HTML
-<form id="lockdb" method="post" action="{$action}">
-{$elr}:
-<textarea name="wpLockReason" rows="10" cols="60" wrap="virtual">{$reason}</textarea>
-<table border="0">
+
+ $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 ) ). "
+<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( 'lockconfirm' ) . "</td>
</tr>
<tr>
- <td>&nbsp;</td>
- <td align="left">
- <input type="submit" name="wpLock" value="{$lb}" />
+ <td>&#160;</td>
+ " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . "
+ " . Html::input( 'wpLock', wfMsg( 'lockbtn' ), '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() {
- 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<p>(by " . $wgUser->getName() . " at " .
- $wgLang->timeanddate( wfTimestampNow() ) . ")</p>\n" );
+ $wgContLang->timeanddate( wfTimestampNow() ) . ")</p>\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' ) );