Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -580,6 +580,7 @@ |
581 | 581 | 'SpecialExport' => 'includes/specials/SpecialExport.php', |
582 | 582 | 'SpecialImport' => 'includes/specials/SpecialImport.php', |
583 | 583 | 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php', |
| 584 | + 'SpecialLockdb' => 'includes/specials/SpecialLockdb.php', |
584 | 585 | 'SpecialMergeHistory' => 'includes/specials/SpecialMergeHistory.php', |
585 | 586 | 'SpecialMostlinkedtemplates' => 'includes/specials/SpecialMostlinkedtemplates.php', |
586 | 587 | 'SpecialPreferences' => 'includes/specials/SpecialPreferences.php', |
— | — | @@ -590,6 +591,7 @@ |
591 | 592 | 'SpecialSearch' => 'includes/specials/SpecialSearch.php', |
592 | 593 | 'SpecialStatistics' => 'includes/specials/SpecialStatistics.php', |
593 | 594 | 'SpecialTags' => 'includes/specials/SpecialTags.php', |
| 595 | + 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php', |
594 | 596 | 'SpecialUpload' => 'includes/specials/SpecialUpload.php', |
595 | 597 | 'SpecialVersion' => 'includes/specials/SpecialVersion.php', |
596 | 598 | 'SpecialWhatlinkshere' => 'includes/specials/SpecialWhatlinkshere.php', |
Index: trunk/phase3/includes/specials/SpecialLockdb.php |
— | — | @@ -1,97 +1,87 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * @file |
| 5 | + * A form to make the database readonly (eg for maintenance purposes). |
| 6 | + * |
5 | 7 | * @ingroup SpecialPage |
6 | 8 | */ |
| 9 | +class SpecialLockdb extends SpecialPage { |
| 10 | + var $reason = ''; |
7 | 11 | |
8 | | -/** |
9 | | - * Constructor |
10 | | - */ |
11 | | -function wfSpecialLockdb() { |
12 | | - global $wgUser, $wgOut, $wgRequest; |
13 | | - |
14 | | - if( !$wgUser->isAllowed( 'siteadmin' ) ) { |
15 | | - $wgOut->permissionRequired( 'siteadmin' ); |
16 | | - return; |
| 12 | + public function __construct() { |
| 13 | + parent::__construct( 'Lockdb', 'siteadmin' ); |
17 | 14 | } |
18 | 15 | |
19 | | - # If the lock file isn't writable, we can do sweet bugger all |
20 | | - global $wgReadOnlyFile; |
21 | | - if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { |
22 | | - DBLockForm::notWritable(); |
23 | | - return; |
24 | | - } |
| 16 | + public function execute( $par ) { |
| 17 | + global $wgUser, $wgOut, $wgRequest; |
25 | 18 | |
26 | | - $action = $wgRequest->getVal( 'action' ); |
27 | | - $f = new DBLockForm(); |
| 19 | + $this->setHeaders(); |
28 | 20 | |
29 | | - if ( 'success' == $action ) { |
30 | | - $f->showSuccess(); |
31 | | - } else if ( 'submit' == $action && $wgRequest->wasPosted() && |
32 | | - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
33 | | - $f->doSubmit(); |
34 | | - } else { |
35 | | - $f->showForm( '' ); |
36 | | - } |
37 | | -} |
| 21 | + if( !$wgUser->isAllowed( 'siteadmin' ) ) { |
| 22 | + $wgOut->permissionRequired( 'siteadmin' ); |
| 23 | + return; |
| 24 | + } |
38 | 25 | |
39 | | -/** |
40 | | - * A form to make the database readonly (eg for maintenance purposes). |
41 | | - * @ingroup SpecialPage |
42 | | - */ |
43 | | -class DBLockForm { |
44 | | - var $reason = ''; |
| 26 | + $this->outputHeader(); |
45 | 27 | |
46 | | - function DBLockForm() { |
47 | | - global $wgRequest; |
48 | | - $this->reason = $wgRequest->getText( 'wpLockReason' ); |
| 28 | + # If the lock file isn't writable, we can do sweet bugger all |
| 29 | + global $wgReadOnlyFile; |
| 30 | + if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { |
| 31 | + self::notWritable(); |
| 32 | + return; |
| 33 | + } |
| 34 | + |
| 35 | + $action = $wgRequest->getVal( 'action' ); |
| 36 | + $this->reason = $wgRequest->getVal( 'wpLockReason', '' ); |
| 37 | + |
| 38 | + if ( $action == 'success' ) { |
| 39 | + $this->showSuccess(); |
| 40 | + } else if ( $action == 'submit' && $wgRequest->wasPosted() && |
| 41 | + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 42 | + $this->doSubmit(); |
| 43 | + } else { |
| 44 | + $this->showForm(); |
| 45 | + } |
49 | 46 | } |
50 | 47 | |
51 | | - function showForm( $err ) { |
| 48 | + private function showForm( $err = '' ) { |
52 | 49 | global $wgOut, $wgUser; |
53 | 50 | |
54 | | - $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); |
55 | 51 | $wgOut->addWikiMsg( 'lockdbtext' ); |
56 | 52 | |
57 | | - if ( $err != "" ) { |
| 53 | + if ( $err != '' ) { |
58 | 54 | $wgOut->setSubtitle( wfMsg( 'formerror' ) ); |
59 | 55 | $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); |
60 | 56 | } |
61 | | - $lc = htmlspecialchars( wfMsg( 'lockconfirm' ) ); |
62 | | - $lb = htmlspecialchars( wfMsg( 'lockbtn' ) ); |
63 | | - $elr = htmlspecialchars( wfMsg( 'enterlockreason' ) ); |
64 | | - $titleObj = SpecialPage::getTitleFor( 'Lockdb' ); |
65 | | - $action = $titleObj->escapeLocalURL( 'action=submit' ); |
66 | | - $reason = htmlspecialchars( $this->reason ); |
67 | | - $token = htmlspecialchars( $wgUser->editToken() ); |
68 | 57 | |
69 | | - $wgOut->addHTML( <<<HTML |
70 | | -<form id="lockdb" method="post" action="{$action}"> |
71 | | -{$elr}: |
72 | | -<textarea name="wpLockReason" rows="10" cols="60" wrap="virtual">{$reason}</textarea> |
73 | | -<table border="0"> |
| 58 | + $wgOut->addHTML( |
| 59 | + Html::openElement( 'form', array( 'id' => 'lockdb', 'method' => 'POST', |
| 60 | + 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ). "\n" . |
| 61 | + wfMsgHtml( 'enterlockreason' ) . ":\n" . |
| 62 | + Html::textarea( 'wpLockReason', $this->reason, array( 'rows' => 4 ) ). " |
| 63 | +<table> |
74 | 64 | <tr> |
75 | | - <td align="right"> |
76 | | - <input type="checkbox" name="wpLockConfirm" /> |
| 65 | + " . Html::openElement( 'td', array( 'style' => 'text-align:right' ) ) . " |
| 66 | + " . Html::input( 'wpLockConfirm', null, 'checkbox' ) . " |
77 | 67 | </td> |
78 | | - <td align="left">{$lc}</td> |
| 68 | + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . |
| 69 | + wfMsgHtml( 'lockconfirm' ) . "</td> |
79 | 70 | </tr> |
80 | 71 | <tr> |
81 | 72 | <td> </td> |
82 | | - <td align="left"> |
83 | | - <input type="submit" name="wpLock" value="{$lb}" /> |
| 73 | + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " |
| 74 | + " . Html::input( 'wpLock', wfMsg( 'lockbtn' ), 'submit' ) . " |
84 | 75 | </td> |
85 | 76 | </tr> |
86 | | -</table> |
87 | | -<input type="hidden" name="wpEditToken" value="{$token}" /> |
88 | | -</form> |
89 | | -HTML |
90 | | -); |
| 77 | +</table>\n" . |
| 78 | + Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . |
| 79 | + Html::closeElement( 'form' ) |
| 80 | + ); |
91 | 81 | |
92 | 82 | } |
93 | 83 | |
94 | | - function doSubmit() { |
95 | | - global $wgOut, $wgUser, $wgLang, $wgRequest; |
| 84 | + private function doSubmit() { |
| 85 | + global $wgOut, $wgUser, $wgContLang, $wgRequest; |
96 | 86 | global $wgReadOnlyFile; |
97 | 87 | |
98 | 88 | if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) { |
— | — | @@ -109,14 +99,13 @@ |
110 | 100 | } |
111 | 101 | fwrite( $fp, $this->reason ); |
112 | 102 | fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " . |
113 | | - $wgLang->timeanddate( wfTimestampNow() ) . ")</p>\n" ); |
| 103 | + $wgContLang->timeanddate( wfTimestampNow() ) . ")</p>\n" ); |
114 | 104 | fclose( $fp ); |
115 | 105 | |
116 | | - $titleObj = SpecialPage::getTitleFor( 'Lockdb' ); |
117 | | - $wgOut->redirect( $titleObj->getFullURL( 'action=success' ) ); |
| 106 | + $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); |
118 | 107 | } |
119 | 108 | |
120 | | - function showSuccess() { |
| 109 | + private function showSuccess() { |
121 | 110 | global $wgOut; |
122 | 111 | |
123 | 112 | $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); |
Index: trunk/phase3/includes/specials/SpecialUnlockdb.php |
— | — | @@ -1,39 +1,41 @@ |
2 | 2 | <?php |
3 | | -/** |
4 | | - * @file |
5 | | - * @ingroup SpecialPage |
6 | | - */ |
7 | 3 | |
8 | 4 | /** |
| 5 | + * Implements Special:Unlockdb |
9 | 6 | * |
| 7 | + * @ingroup SpecialPage |
10 | 8 | */ |
11 | | -function wfSpecialUnlockdb() { |
12 | | - global $wgUser, $wgOut, $wgRequest; |
| 9 | +class SpecialUnlockdb extends SpecialPage { |
13 | 10 | |
14 | | - if( !$wgUser->isAllowed( 'siteadmin' ) ) { |
15 | | - $wgOut->permissionRequired( 'siteadmin' ); |
16 | | - return; |
| 11 | + public function __construct() { |
| 12 | + parent::__construct( 'Unlockdb', 'siteadmin' ); |
17 | 13 | } |
18 | 14 | |
19 | | - $action = $wgRequest->getVal( 'action' ); |
20 | | - $f = new DBUnlockForm(); |
| 15 | + public function execute( $par ) { |
| 16 | + global $wgUser, $wgOut, $wgRequest; |
21 | 17 | |
22 | | - if ( "success" == $action ) { |
23 | | - $f->showSuccess(); |
24 | | - } else if ( "submit" == $action && $wgRequest->wasPosted() && |
25 | | - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
26 | | - $f->doSubmit(); |
27 | | - } else { |
28 | | - $f->showForm( "" ); |
| 18 | + $this->setHeaders(); |
| 19 | + |
| 20 | + if( !$wgUser->isAllowed( 'siteadmin' ) ) { |
| 21 | + $wgOut->permissionRequired( 'siteadmin' ); |
| 22 | + return; |
| 23 | + } |
| 24 | + |
| 25 | + $this->outputHeader(); |
| 26 | + |
| 27 | + $action = $wgRequest->getVal( 'action' ); |
| 28 | + |
| 29 | + if ( $action == 'success' ) { |
| 30 | + $this->showSuccess(); |
| 31 | + } else if ( $action == 'submit' && $wgRequest->wasPosted() && |
| 32 | + $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 33 | + $this->doSubmit(); |
| 34 | + } else { |
| 35 | + $this->showForm(); |
| 36 | + } |
29 | 37 | } |
30 | | -} |
31 | 38 | |
32 | | -/** |
33 | | - * @ingroup SpecialPage |
34 | | - */ |
35 | | -class DBUnlockForm { |
36 | | - function showForm( $err ) |
37 | | - { |
| 39 | + private function showForm( $err = '' ) { |
38 | 40 | global $wgOut, $wgUser; |
39 | 41 | |
40 | 42 | global $wgReadOnlyFile; |
— | — | @@ -42,65 +44,57 @@ |
43 | 45 | return; |
44 | 46 | } |
45 | 47 | |
46 | | - $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); |
47 | | - $wgOut->addWikiMsg( "unlockdbtext" ); |
| 48 | + $wgOut->addWikiMsg( 'unlockdbtext' ); |
48 | 49 | |
49 | | - if ( $err != "" ) { |
50 | | - $wgOut->setSubtitle( wfMsg( "formerror" ) ); |
| 50 | + if ( $err != '' ) { |
| 51 | + $wgOut->setSubtitle( wfMsg( 'formerror' ) ); |
51 | 52 | $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); |
52 | 53 | } |
53 | | - $lc = htmlspecialchars( wfMsg( "unlockconfirm" ) ); |
54 | | - $lb = htmlspecialchars( wfMsg( "unlockbtn" ) ); |
55 | | - $titleObj = SpecialPage::getTitleFor( "Unlockdb" ); |
56 | | - $action = $titleObj->escapeLocalURL( "action=submit" ); |
57 | | - $token = htmlspecialchars( $wgUser->editToken() ); |
58 | 54 | |
59 | | - $wgOut->addHTML( <<<HTML |
60 | | - |
61 | | -<form id="unlockdb" method="post" action="{$action}"> |
62 | | -<table border="0"> |
| 55 | + $wgOut->addHTML( |
| 56 | + Html::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST', |
| 57 | + 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . " |
| 58 | +<table> |
63 | 59 | <tr> |
64 | | - <td align="right"> |
65 | | - <input type="checkbox" name="wpLockConfirm" /> |
| 60 | + " . Html::openElement( 'td', array( 'style' => 'text-align:right' ) ) . " |
| 61 | + " . Html::input( 'wpLockConfirm', null, 'checkbox' ) . " |
66 | 62 | </td> |
67 | | - <td align="left">{$lc}</td> |
| 63 | + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . |
| 64 | + wfMsgHtml( 'unlockconfirm' ) . "</td> |
68 | 65 | </tr> |
69 | 66 | <tr> |
70 | 67 | <td> </td> |
71 | | - <td align="left"> |
72 | | - <input type="submit" name="wpLock" value="{$lb}" /> |
| 68 | + " . Html::openElement( 'td', array( 'style' => 'text-align:left' ) ) . " |
| 69 | + " . Html::input( 'wpLock', wfMsg( 'unlockbtn' ), 'submit' ) . " |
73 | 70 | </td> |
74 | 71 | </tr> |
75 | | -</table> |
76 | | -<input type="hidden" name="wpEditToken" value="{$token}" /> |
77 | | -</form> |
78 | | -HTML |
79 | | -); |
| 72 | +</table>\n" . |
| 73 | + Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . |
| 74 | + Html::closeElement( 'form' ) |
| 75 | + ); |
80 | 76 | |
81 | 77 | } |
82 | 78 | |
83 | | - function doSubmit() { |
| 79 | + private function doSubmit() { |
84 | 80 | global $wgOut, $wgRequest, $wgReadOnlyFile; |
85 | 81 | |
86 | 82 | $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' ); |
87 | | - if ( ! $wpLockConfirm ) { |
88 | | - $this->showForm( wfMsg( "locknoconfirm" ) ); |
| 83 | + if ( !$wpLockConfirm ) { |
| 84 | + $this->showForm( wfMsg( 'locknoconfirm' ) ); |
89 | 85 | return; |
90 | 86 | } |
91 | | - if ( @! unlink( $wgReadOnlyFile ) ) { |
| 87 | + if ( @!unlink( $wgReadOnlyFile ) ) { |
92 | 88 | $wgOut->showFileDeleteError( $wgReadOnlyFile ); |
93 | 89 | return; |
94 | 90 | } |
95 | | - $titleObj = SpecialPage::getTitleFor( "Unlockdb" ); |
96 | | - $success = $titleObj->getFullURL( "action=success" ); |
97 | | - $wgOut->redirect( $success ); |
| 91 | + |
| 92 | + $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); |
98 | 93 | } |
99 | 94 | |
100 | | - function showSuccess() { |
| 95 | + private function showSuccess() { |
101 | 96 | global $wgOut; |
102 | 97 | |
103 | | - $wgOut->setPagetitle( wfMsg( "unlockdb" ) ); |
104 | | - $wgOut->setSubtitle( wfMsg( "unlockdbsuccesssub" ) ); |
105 | | - $wgOut->addWikiMsg( "unlockdbsuccesstext" ); |
| 98 | + $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) ); |
| 99 | + $wgOut->addWikiMsg( 'unlockdbsuccesstext' ); |
106 | 100 | } |
107 | 101 | } |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -152,8 +152,8 @@ |
153 | 153 | 'Statistics' => 'SpecialStatistics', |
154 | 154 | 'Allmessages' => 'SpecialAllmessages', |
155 | 155 | 'Version' => 'SpecialVersion', |
156 | | - 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ), |
157 | | - 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ), |
| 156 | + 'Lockdb' => 'SpecialLockdb', |
| 157 | + 'Unlockdb' => 'SpecialUnlockdb', |
158 | 158 | |
159 | 159 | # Redirecting special pages |
160 | 160 | 'LinkSearch' => array( 'SpecialPage', 'LinkSearch' ), |