Index: trunk/phase3/includes/specials/SpecialLockdb.php |
— | — | @@ -34,12 +34,10 @@ |
35 | 35 | } |
36 | 36 | |
37 | 37 | public function execute( $par ) { |
38 | | - global $wgUser, $wgRequest; |
39 | | - |
40 | 38 | $this->setHeaders(); |
41 | 39 | |
42 | 40 | # Permission check |
43 | | - if( !$this->userCanExecute( $wgUser ) ) { |
| 41 | + if( !$this->userCanExecute( $this->getUser() ) ) { |
44 | 42 | $this->displayRestrictionError(); |
45 | 43 | return; |
46 | 44 | } |
— | — | @@ -49,17 +47,18 @@ |
50 | 48 | # If the lock file isn't writable, we can do sweet bugger all |
51 | 49 | global $wgReadOnlyFile; |
52 | 50 | if( !is_writable( dirname( $wgReadOnlyFile ) ) ) { |
53 | | - self::notWritable(); |
| 51 | + $this->getOutput()->addWikiMsg( 'lockfilenotwritable' ); |
54 | 52 | return; |
55 | 53 | } |
56 | 54 | |
57 | | - $action = $wgRequest->getVal( 'action' ); |
58 | | - $this->reason = $wgRequest->getVal( 'wpLockReason', '' ); |
| 55 | + $request = $this->getRequest(); |
| 56 | + $action = $request->getVal( 'action' ); |
| 57 | + $this->reason = $request->getVal( 'wpLockReason', '' ); |
59 | 58 | |
60 | 59 | if ( $action == 'success' ) { |
61 | 60 | $this->showSuccess(); |
62 | | - } elseif ( $action == 'submit' && $wgRequest->wasPosted() && |
63 | | - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 61 | + } elseif ( $action == 'submit' && $request->wasPosted() && |
| 62 | + $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { |
64 | 63 | $this->doSubmit(); |
65 | 64 | } else { |
66 | 65 | $this->showForm(); |
— | — | @@ -67,16 +66,15 @@ |
68 | 67 | } |
69 | 68 | |
70 | 69 | private function showForm( $err = '' ) { |
71 | | - global $wgOut, $wgUser; |
| 70 | + $out = $this->getOutput(); |
| 71 | + $out->addWikiMsg( 'lockdbtext' ); |
72 | 72 | |
73 | | - $wgOut->addWikiMsg( 'lockdbtext' ); |
74 | | - |
75 | 73 | if ( $err != '' ) { |
76 | | - $wgOut->setSubtitle( wfMsg( 'formerror' ) ); |
77 | | - $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); |
| 74 | + $out->setSubtitle( wfMsg( 'formerror' ) ); |
| 75 | + $out->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); |
78 | 76 | } |
79 | 77 | |
80 | | - $wgOut->addHTML( |
| 78 | + $out->addHTML( |
81 | 79 | Html::openElement( 'form', array( 'id' => 'lockdb', 'method' => 'POST', |
82 | 80 | 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ). "\n" . |
83 | 81 | wfMsgHtml( 'enterlockreason' ) . ":\n" . |
— | — | @@ -98,17 +96,16 @@ |
99 | 97 | </td> |
100 | 98 | </tr> |
101 | 99 | </table>\n" . |
102 | | - Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . |
| 100 | + Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) . "\n" . |
103 | 101 | Html::closeElement( 'form' ) |
104 | 102 | ); |
105 | 103 | |
106 | 104 | } |
107 | 105 | |
108 | 106 | private function doSubmit() { |
109 | | - global $wgOut, $wgUser, $wgContLang, $wgRequest; |
110 | | - global $wgReadOnlyFile; |
| 107 | + global $wgContLang, $wgReadOnlyFile; |
111 | 108 | |
112 | | - if ( ! $wgRequest->getCheck( 'wpLockConfirm' ) ) { |
| 109 | + if ( !$this->getRequest()->getCheck( 'wpLockConfirm' ) ) { |
113 | 110 | $this->showForm( wfMsg( 'locknoconfirm' ) ); |
114 | 111 | return; |
115 | 112 | } |
— | — | @@ -121,7 +118,7 @@ |
122 | 119 | # This used to show a file not found error, but the likeliest reason for fopen() |
123 | 120 | # to fail at this point is insufficient permission to write to the file...good old |
124 | 121 | # is_writable() is plain wrong in some cases, it seems... |
125 | | - self::notWritable(); |
| 122 | + $this->getOutput()->addWikiMsg( 'lockfilenotwritable' ); |
126 | 123 | return; |
127 | 124 | } |
128 | 125 | fwrite( $fp, $this->reason ); |
— | — | @@ -129,25 +126,19 @@ |
130 | 127 | fwrite( $fp, "\n<p>" . wfMsgExt( |
131 | 128 | 'lockedbyandtime', |
132 | 129 | array( 'content', 'parsemag' ), |
133 | | - $wgUser->getName(), |
| 130 | + $this->getUser()->getName(), |
134 | 131 | $wgContLang->date( $timestamp ), |
135 | 132 | $wgContLang->time( $timestamp ) |
136 | 133 | ) . "</p>\n" ); |
137 | 134 | fclose( $fp ); |
138 | 135 | |
139 | | - $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); |
| 136 | + $this->getOutput()->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); |
140 | 137 | } |
141 | 138 | |
142 | 139 | private function showSuccess() { |
143 | | - global $wgOut; |
144 | | - |
145 | | - $wgOut->setPagetitle( wfMsg( 'lockdb' ) ); |
146 | | - $wgOut->setSubtitle( wfMsg( 'lockdbsuccesssub' ) ); |
147 | | - $wgOut->addWikiMsg( 'lockdbsuccesstext' ); |
| 140 | + $out = $this->getOutput(); |
| 141 | + $out->setPagetitle( wfMsg( 'lockdb' ) ); |
| 142 | + $out->setSubtitle( wfMsg( 'lockdbsuccesssub' ) ); |
| 143 | + $out->addWikiMsg( 'lockdbsuccesstext' ); |
148 | 144 | } |
149 | | - |
150 | | - public static function notWritable() { |
151 | | - global $wgOut; |
152 | | - $wgOut->showErrorPage( 'lockdb', 'lockfilenotwritable' ); |
153 | | - } |
154 | 145 | } |
Index: trunk/phase3/includes/specials/SpecialUnlockdb.php |
— | — | @@ -33,24 +33,23 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function execute( $par ) { |
37 | | - global $wgUser, $wgRequest; |
38 | | - |
39 | 37 | $this->setHeaders(); |
40 | 38 | |
41 | 39 | # Permission check |
42 | | - if( !$this->userCanExecute( $wgUser ) ) { |
| 40 | + if( !$this->userCanExecute( $this->getUser() ) ) { |
43 | 41 | $this->displayRestrictionError(); |
44 | 42 | return; |
45 | 43 | } |
46 | 44 | |
47 | 45 | $this->outputHeader(); |
48 | 46 | |
49 | | - $action = $wgRequest->getVal( 'action' ); |
| 47 | + $request = $this->getRequest(); |
| 48 | + $action = $request->getVal( 'action' ); |
50 | 49 | |
51 | 50 | if ( $action == 'success' ) { |
52 | 51 | $this->showSuccess(); |
53 | | - } elseif ( $action == 'submit' && $wgRequest->wasPosted() && |
54 | | - $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 52 | + } elseif ( $action == 'submit' && $request->wasPosted() && |
| 53 | + $this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { |
55 | 54 | $this->doSubmit(); |
56 | 55 | } else { |
57 | 56 | $this->showForm(); |
— | — | @@ -58,22 +57,23 @@ |
59 | 58 | } |
60 | 59 | |
61 | 60 | private function showForm( $err = '' ) { |
62 | | - global $wgOut, $wgUser; |
63 | | - |
64 | 61 | global $wgReadOnlyFile; |
| 62 | + |
| 63 | + $out = $this->getOutput(); |
| 64 | + |
65 | 65 | if( !file_exists( $wgReadOnlyFile ) ) { |
66 | | - $wgOut->addWikiMsg( 'databasenotlocked' ); |
| 66 | + $out->addWikiMsg( 'databasenotlocked' ); |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | | - $wgOut->addWikiMsg( 'unlockdbtext' ); |
| 70 | + $out->addWikiMsg( 'unlockdbtext' ); |
71 | 71 | |
72 | 72 | if ( $err != '' ) { |
73 | | - $wgOut->setSubtitle( wfMsg( 'formerror' ) ); |
74 | | - $wgOut->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); |
| 73 | + $out->setSubtitle( wfMsg( 'formerror' ) ); |
| 74 | + $out->addHTML( '<p class="error">' . htmlspecialchars( $err ) . "</p>\n" ); |
75 | 75 | } |
76 | 76 | |
77 | | - $wgOut->addHTML( |
| 77 | + $out->addHTML( |
78 | 78 | Html::openElement( 'form', array( 'id' => 'unlockdb', 'method' => 'POST', |
79 | 79 | 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ) ) . " |
80 | 80 | <table> |
— | — | @@ -93,17 +93,16 @@ |
94 | 94 | </td> |
95 | 95 | </tr> |
96 | 96 | </table>\n" . |
97 | | - Html::hidden( 'wpEditToken', $wgUser->editToken() ) . "\n" . |
| 97 | + Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) . "\n" . |
98 | 98 | Html::closeElement( 'form' ) |
99 | 99 | ); |
100 | 100 | |
101 | 101 | } |
102 | 102 | |
103 | 103 | private function doSubmit() { |
104 | | - global $wgOut, $wgRequest, $wgReadOnlyFile; |
| 104 | + global $wgReadOnlyFile; |
105 | 105 | |
106 | | - $wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' ); |
107 | | - if ( !$wpLockConfirm ) { |
| 106 | + if ( !$this->getRequest()->getCheck( 'wpLockConfirm' ) ) { |
108 | 107 | $this->showForm( wfMsg( 'locknoconfirm' ) ); |
109 | 108 | return; |
110 | 109 | } |
— | — | @@ -112,18 +111,16 @@ |
113 | 112 | $res = unlink( $wgReadOnlyFile ); |
114 | 113 | wfRestoreWarnings(); |
115 | 114 | |
116 | | - if ( !$res ) { |
117 | | - $wgOut->showFileDeleteError( $wgReadOnlyFile ); |
118 | | - return; |
| 115 | + if ( $res ) { |
| 116 | + $this->getOutput()->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); |
| 117 | + } else { |
| 118 | + $this->getOutput()->addWikiMsg( 'filedeleteerror', $wgReadOnlyFile ); |
119 | 119 | } |
120 | | - |
121 | | - $wgOut->redirect( $this->getTitle()->getFullURL( 'action=success' ) ); |
122 | 120 | } |
123 | 121 | |
124 | 122 | private function showSuccess() { |
125 | | - global $wgOut; |
126 | | - |
127 | | - $wgOut->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) ); |
128 | | - $wgOut->addWikiMsg( 'unlockdbsuccesstext' ); |
| 123 | + $out = $this->getOutput(); |
| 124 | + $out->setSubtitle( wfMsg( 'unlockdbsuccesssub' ) ); |
| 125 | + $out->addWikiMsg( 'unlockdbsuccesstext' ); |
129 | 126 | } |
130 | 127 | } |