'SpecialExport' => 'includes/specials/SpecialExport.php',
'SpecialImport' => 'includes/specials/SpecialImport.php',
'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php',
+ 'SpecialLockdb' => 'includes/specials/SpecialLockdb.php',
'SpecialMergeHistory' => 'includes/specials/SpecialMergeHistory.php',
'SpecialMostlinkedtemplates' => 'includes/specials/SpecialMostlinkedtemplates.php',
'SpecialPreferences' => 'includes/specials/SpecialPreferences.php',
'SpecialSearch' => 'includes/specials/SpecialSearch.php',
'SpecialStatistics' => 'includes/specials/SpecialStatistics.php',
'SpecialTags' => 'includes/specials/SpecialTags.php',
+ 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php',
'SpecialUpload' => 'includes/specials/SpecialUpload.php',
'SpecialVersion' => 'includes/specials/SpecialVersion.php',
'SpecialWhatlinkshere' => 'includes/specials/SpecialWhatlinkshere.php',
'Statistics' => 'SpecialStatistics',
'Allmessages' => 'SpecialAllmessages',
'Version' => 'SpecialVersion',
- 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
- 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
+ 'Lockdb' => 'SpecialLockdb',
+ 'Unlockdb' => 'SpecialUnlockdb',
# Redirecting special pages
'LinkSearch' => array( 'SpecialPage', 'LinkSearch' ),
<?php
-/**
- * @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();
+
+ # 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', '' );
- function DBLockForm() {
- global $wgRequest;
- $this->reason = $wgRequest->getText( '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> </td>
- <td align="left">
- <input type="submit" name="wpLock" value="{$lb}" />
+ " . 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' ) ) {
}
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' ) );
<?php
-/**
- * @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();
- if ( "success" == $action ) {
- $f->showSuccess();
- } else if ( "submit" == $action && $wgRequest->wasPosted() &&
- $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
- $f->doSubmit();
- } else {
- $f->showForm( "" );
+ $action = $wgRequest->getVal( 'action' );
+
+ 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;
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}" />
+ " . 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' );
}
}