Index: trunk/extensions/Interwiki/Interwiki_body.php |
— | — | @@ -27,35 +27,36 @@ |
28 | 28 | * @param $par Mixed: parameter passed to the page or null |
29 | 29 | */ |
30 | 30 | public function execute( $par ) { |
31 | | - global $wgRequest, $wgOut, $wgUser; |
32 | | - |
33 | 31 | $this->setHeaders(); |
34 | 32 | $this->outputHeader(); |
35 | 33 | |
36 | | - $wgOut->addModuleStyles( 'SpecialInterwiki' ); |
| 34 | + $out = $this->getOutput(); |
| 35 | + $request = $this->getRequest(); |
37 | 36 | |
38 | | - $action = $par ? $par : $wgRequest->getVal( 'action', $par ); |
| 37 | + $out->addModuleStyles( 'SpecialInterwiki' ); |
| 38 | + |
| 39 | + $action = $par ? $par : $request->getVal( 'action', $par ); |
39 | 40 | $return = $this->getTitle(); |
40 | 41 | |
41 | 42 | switch( $action ) { |
42 | 43 | case 'delete': |
43 | 44 | case 'edit': |
44 | 45 | case 'add': |
45 | | - if( $this->canModify( $wgOut ) ) { |
46 | | - $wgOut->addHTML( $this->showForm( $action ) ); |
| 46 | + if( $this->canModify( $out ) ) { |
| 47 | + $out->addHTML( $this->showForm( $action ) ); |
47 | 48 | } |
48 | | - $wgOut->returnToMain( false, $return ); |
| 49 | + $out->returnToMain( false, $return ); |
49 | 50 | break; |
50 | 51 | case 'submit': |
51 | | - if( !$this->canModify( $wgOut ) ) { |
| 52 | + if( !$this->canModify( $out ) ) { |
52 | 53 | # Error msg added by canModify() |
53 | | - } elseif( !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
| 54 | + } elseif( !$request->wasPosted() || !$this->getUser()->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { |
54 | 55 | // Prevent cross-site request forgeries |
55 | | - $wgOut->addWikiMsg( 'sessionfailure' ); |
| 56 | + $out->addWikiMsg( 'sessionfailure' ); |
56 | 57 | } else { |
57 | 58 | $this->doSubmit(); |
58 | 59 | } |
59 | | - $wgOut->returnToMain( false, $return ); |
| 60 | + $out->returnToMain( false, $return ); |
60 | 61 | break; |
61 | 62 | default: |
62 | 63 | $this->showList(); |
— | — | @@ -69,8 +70,8 @@ |
70 | 71 | * @return Boolean |
71 | 72 | */ |
72 | 73 | public function canModify( $out = false ) { |
73 | | - global $wgUser, $wgInterwikiCache; |
74 | | - if( !$wgUser->isAllowed( 'interwiki' ) ) { |
| 74 | + global $wgInterwikiCache; |
| 75 | + if( !$this->getUser()->isAllowed( 'interwiki' ) ) { |
75 | 76 | # Check permissions |
76 | 77 | if( $out ) { throw new PermissionsError( 'interwiki' ); } |
77 | 78 | return false; |
— | — | @@ -87,9 +88,9 @@ |
88 | 89 | } |
89 | 90 | |
90 | 91 | function showForm( $action ) { |
91 | | - global $wgRequest, $wgUser; |
| 92 | + $request = $this->getRequest(); |
92 | 93 | |
93 | | - $prefix = $wgRequest->getVal( 'prefix' ); |
| 94 | + $prefix = $request->getVal( 'prefix' ); |
94 | 95 | $wpPrefix = ''; |
95 | 96 | $label = array( 'class' => 'mw-label' ); |
96 | 97 | $input = array( 'class' => 'mw-input' ); |
— | — | @@ -116,12 +117,12 @@ |
117 | 118 | $intromessage = wfMessage( 'interwiki_editintro' )->text(); |
118 | 119 | $button = 'edit'; |
119 | 120 | } elseif( $action == 'add' ) { |
120 | | - $prefix = $wgRequest->getVal( 'wpInterwikiPrefix', $wgRequest->getVal( 'prefix' ) ); |
| 121 | + $prefix = $request->getVal( 'wpInterwikiPrefix', $request->getVal( 'prefix' ) ); |
121 | 122 | $prefix = Xml::input( 'wpInterwikiPrefix', 20, $prefix, |
122 | 123 | array( 'tabindex' => 1, 'id' => 'mw-interwiki-prefix', 'maxlength' => 20 ) ); |
123 | | - $local = $wgRequest->getCheck( 'wpInterwikiLocal' ); |
124 | | - $trans = $wgRequest->getCheck( 'wpInterwikiTrans' ); |
125 | | - $defaulturl = $wgRequest->getVal( 'wpInterwikiURL', wfMessage( 'interwiki-defaulturl' )->text() ); |
| 124 | + $local = $request->getCheck( 'wpInterwikiLocal' ); |
| 125 | + $trans = $request->getCheck( 'wpInterwikiTrans' ); |
| 126 | + $defaulturl = $request->getVal( 'wpInterwikiURL', wfMessage( 'interwiki-defaulturl' )->text() ); |
126 | 127 | $topmessage = wfMessage( 'interwiki_addtext' )->text(); |
127 | 128 | $intromessage = wfMessage( 'interwiki_addintro' )->text(); |
128 | 129 | $button = 'interwiki_addbutton'; |
— | — | @@ -159,23 +160,23 @@ |
160 | 161 | Html::rawElement( 'td', array( 'class' => 'mw-submit' ), |
161 | 162 | Xml::submitButton( wfMessage( $button )->text(), array( 'id' => 'mw-interwiki-submit' ) ) ) |
162 | 163 | ) . $wpPrefix . |
163 | | - Html::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 164 | + Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) . |
164 | 165 | Html::hidden( 'wpInterwikiAction', $action ) |
165 | 166 | ) |
166 | 167 | ) ); |
167 | 168 | } |
168 | 169 | |
169 | 170 | function doSubmit() { |
170 | | - global $wgRequest, $wgOut; |
171 | | - $prefix = $wgRequest->getVal( 'wpInterwikiPrefix' ); |
172 | | - $do = $wgRequest->getVal( 'wpInterwikiAction' ); |
| 171 | + $request = $this->getRequest(); |
| 172 | + $prefix = $request->getVal( 'wpInterwikiPrefix' ); |
| 173 | + $do = $request->getVal( 'wpInterwikiAction' ); |
173 | 174 | // show an error if the prefix is invalid (only when adding one) |
174 | 175 | if( preg_match( '/[\s:&=]/', $prefix ) && $do == 'add' ) { |
175 | 176 | $this->error( 'interwiki-badprefix', htmlspecialchars( $prefix ) ); |
176 | 177 | $this->showForm( $do ); |
177 | 178 | return; |
178 | 179 | } |
179 | | - $reason = $wgRequest->getText( 'wpInterwikiReason' ); |
| 180 | + $reason = $request->getText( 'wpInterwikiReason' ); |
180 | 181 | $selfTitle = $this->getTitle(); |
181 | 182 | $dbw = wfGetDB( DB_MASTER ); |
182 | 183 | switch( $do ){ |
— | — | @@ -186,16 +187,16 @@ |
187 | 188 | $this->error( 'interwiki_delfailed', $prefix ); |
188 | 189 | $this->showForm( $do ); |
189 | 190 | } else { |
190 | | - $wgOut->addWikiMsg( 'interwiki_deleted', $prefix ); |
| 191 | + $this->getOutput()->addWikiMsg( 'interwiki_deleted', $prefix ); |
191 | 192 | $log = new LogPage( 'interwiki' ); |
192 | 193 | $log->addEntry( 'iw_delete', $selfTitle, $reason, array( $prefix ) ); |
193 | 194 | } |
194 | 195 | break; |
195 | 196 | case 'edit': |
196 | 197 | case 'add': |
197 | | - $theurl = $wgRequest->getVal( 'wpInterwikiURL' ); |
198 | | - $local = $wgRequest->getCheck( 'wpInterwikiLocal' ) ? 1 : 0; |
199 | | - $trans = $wgRequest->getCheck( 'wpInterwikiTrans' ) ? 1 : 0; |
| 198 | + $theurl = $request->getVal( 'wpInterwikiURL' ); |
| 199 | + $local = $request->getCheck( 'wpInterwikiLocal' ) ? 1 : 0; |
| 200 | + $trans = $request->getCheck( 'wpInterwikiTrans' ) ? 1 : 0; |
200 | 201 | $data = array( |
201 | 202 | 'iw_prefix' => $prefix, |
202 | 203 | 'iw_url' => $theurl, |
— | — | @@ -219,7 +220,7 @@ |
220 | 221 | $this->error( "interwiki_{$do}failed", $prefix ); |
221 | 222 | $this->showForm( $do ); |
222 | 223 | } else { |
223 | | - $wgOut->addWikiMsg( "interwiki_{$do}ed", $prefix ); |
| 224 | + $this->getOutput()->addWikiMsg( "interwiki_{$do}ed", $prefix ); |
224 | 225 | $log = new LogPage( 'interwiki' ); |
225 | 226 | $log->addEntry( 'iw_' . $do, $selfTitle, $reason, array( $prefix, $theurl, $trans, $local ) ); |
226 | 227 | } |
— | — | @@ -228,12 +229,10 @@ |
229 | 230 | } |
230 | 231 | |
231 | 232 | function showList() { |
232 | | - global $wgOut; |
233 | | - |
234 | 233 | $canModify = $this->canModify(); |
235 | 234 | |
236 | | - $wgOut->addWikiMsg( 'interwiki_intro' ); |
237 | | - $wgOut->addHTML( |
| 235 | + $this->getOutput()->addWikiMsg( 'interwiki_intro' ); |
| 236 | + $this->getOutput()->addHTML( |
238 | 237 | Html::rawElement( 'table', array( 'class' => 'mw-interwikitable wikitable intro' ), |
239 | 238 | self::addInfoRow( 'start', 'interwiki_prefix', 'interwiki_prefix_intro' ) . |
240 | 239 | self::addInfoRow( 'start', 'interwiki_url', 'interwiki_url_intro' ) . |
— | — | @@ -245,12 +244,12 @@ |
246 | 245 | self::addInfoRow( 'end', 'interwiki_1', 'interwiki_local_1_intro' ) |
247 | 246 | ) . "\n" |
248 | 247 | ); |
249 | | - $wgOut->addWikiMsg( 'interwiki_intro_footer' ); |
| 248 | + $this->getOutput()->addWikiMsg( 'interwiki_intro_footer' ); |
250 | 249 | |
251 | 250 | if ( $canModify ) { |
252 | 251 | $addtext = wfMessage( 'interwiki_addtext' )->escaped(); |
253 | 252 | $addlink = Linker::linkKnown( $this->getTitle( 'add' ), $addtext ); |
254 | | - $wgOut->addHTML( '<p class="mw-interwiki-addlink">' . $addlink . '</p>' ); |
| 253 | + $this->getOutput()->addHTML( '<p class="mw-interwiki-addlink">' . $addlink . '</p>' ); |
255 | 254 | } |
256 | 255 | |
257 | 256 | if( !method_exists( 'Interwiki', 'getAllPrefixes' ) ) { |
— | — | @@ -302,7 +301,7 @@ |
303 | 302 | } |
304 | 303 | $out .= Html::closeElement( 'table' ); |
305 | 304 | |
306 | | - $wgOut->addHTML( $out ); |
| 305 | + $this->getOutput()->addHTML( $out ); |
307 | 306 | } |
308 | 307 | |
309 | 308 | static function addInfoRow( $align = 'start', $title, $text ) { |
— | — | @@ -313,9 +312,21 @@ |
314 | 313 | } |
315 | 314 | |
316 | 315 | function error() { |
317 | | - global $wgOut; |
318 | 316 | $args = func_get_args(); |
319 | | - $wgOut->wrapWikiMsg( "<p class='error'>$1</p>", $args ); |
| 317 | + $this->getOutput()->wrapWikiMsg( "<p class='error'>$1</p>", $args ); |
320 | 318 | } |
321 | 319 | |
322 | 320 | } |
| 321 | + |
| 322 | +/** |
| 323 | + * Needed to pass the URL as a raw parameter, because it contains $1 |
| 324 | +*/ |
| 325 | +class InterwikiLogFormatter extends LogFormatter { |
| 326 | + protected function getMessageParameters() { |
| 327 | + $params = parent::getMessageParameters(); |
| 328 | + if( isset( $params[4] ) ) { |
| 329 | + $params[4] = Message::rawParam( $params[4] ); |
| 330 | + } |
| 331 | + return $params; |
| 332 | + } |
| 333 | +} |
Index: trunk/extensions/Interwiki/Interwiki.i18n.php |
— | — | @@ -85,11 +85,11 @@ |
86 | 86 | |
87 | 87 | # interwiki log |
88 | 88 | 'interwiki_logpagename' => 'Interwiki table log', |
89 | | - 'interwiki_log_added' => 'added prefix "$2" ($3) (trans: $4) (local: $5) to the interwiki table', |
90 | | - 'interwiki_log_edited' => 'modified prefix "$2" : ($3) (trans: $4) (local: $5) in the interwiki table', |
91 | | - 'interwiki_log_deleted' => 'removed prefix "$2" from the interwiki table', |
| 89 | + 'logentry-interwiki-iw_add' => '$1 {{GENDER:$2|added}} prefix "$4" ($5) (trans: $6; local: $7) to the interwiki table', |
| 90 | + 'logentry-interwiki-iw_edit' => '$1 {{GENDER:$2|modified}} prefix "$4" ($5) (trans: $6; local: $7) in the interwiki table', |
| 91 | + 'logentry-interwiki-iw_delete' => '$1 {{GENDER:$2|removed}} prefix "$4" from the interwiki table', |
92 | 92 | 'interwiki_logpagetext' => 'This is a log of changes to the [[Special:Interwiki|interwiki table]].', |
93 | | - 'interwiki_logentry' => '', # do not translate this message |
| 93 | + 'logentry-interwiki-interwiki' => '', # do not translate this message |
94 | 94 | |
95 | 95 | # rights |
96 | 96 | 'right-interwiki' => 'Edit interwiki data', |
— | — | @@ -153,9 +153,9 @@ |
154 | 154 | {{Identical|Add}}', |
155 | 155 | 'interwiki_editerror' => 'Error message when modifying a prefix has failed.', |
156 | 156 | 'interwiki_logpagename' => 'Part of the interwiki extension. This message is shown as page title on Special:Log/interwiki.', |
157 | | - 'interwiki_log_added' => 'Shows up in "Special:Log/interwiki" when someone has added a prefix. Leave parameters and text between brackets exactly as it is. (This message is preceded by the username who added it.)', |
158 | | - 'interwiki_log_edited' => 'Shows up in "Special:Log/interwiki" when someone has modified a prefix. Leave parameters and text between brackets exactly as it is. (This message is preceded by the username of the user who modified it.)', |
159 | | - 'interwiki_log_deleted' => 'Shows up in "Special:Log/interwiki" when someone removed a prefix. This message is preceded by the username of the user who deleted it.', |
| 157 | + 'logentry-interwiki-iw_add' => 'Shows up in "Special:Log/interwiki" when someone has added a prefix. Leave parameters and text between brackets exactly as it is. $1 is the username of the user who added it.', |
| 158 | + 'logentry-interwiki-iw_edit' => 'Shows up in "Special:Log/interwiki" when someone has modified a prefix. Leave parameters and text between brackets exactly as it is. $1 the username of the user who modified it.', |
| 159 | + 'logentry-interwiki-iw_delete' => 'Shows up in "Special:Log/interwiki" when someone removed a prefix. $1 is the username of the user who deleted it.', |
160 | 160 | 'interwiki_logpagetext' => 'Part of the interwiki extension. Summary shown on Special:Log/interwiki.', |
161 | 161 | 'right-interwiki' => '{{doc-right}}', |
162 | 162 | 'action-interwiki' => '{{doc-action}}', |
Index: trunk/extensions/Interwiki/Interwiki.php |
— | — | @@ -52,7 +52,6 @@ |
53 | 53 | $wgLogTypes[] = 'interwiki'; |
54 | 54 | $wgLogNames['interwiki'] = 'interwiki_logpagename'; |
55 | 55 | $wgLogHeaders['interwiki'] = 'interwiki_logpagetext'; |
56 | | -$wgLogActions['interwiki/interwiki'] = 'interwiki_logentry'; |
57 | | -$wgLogActions['interwiki/iw_add'] = 'interwiki_log_added'; |
58 | | -$wgLogActions['interwiki/iw_delete'] = 'interwiki_log_deleted'; |
59 | | -$wgLogActions['interwiki/iw_edit'] = 'interwiki_log_edited'; |
| 56 | +$wgAutoloadClasses['InterwikiLogFormatter'] = $dir . 'Interwiki_body.php'; |
| 57 | +# interwiki, iw_add, iw_delete, iw_edit |
| 58 | +$wgLogActionsHandlers['interwiki/*'] = 'InterwikiLogFormatter'; |