Index: trunk/extensions/Interwiki/Interwiki_body.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | * whether the user can modify the data. |
19 | 19 | */ |
20 | 20 | function getDescription() { |
21 | | - return wfMsg( $this->canModify() ? |
| 21 | + return wfMessage( $this->canModify() ? |
22 | 22 | 'interwiki' : 'interwiki-title-norights' ); |
23 | 23 | } |
24 | 24 | |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | case 'edit': |
44 | 44 | case 'add': |
45 | 45 | if( $this->canModify( $wgOut ) ) { |
46 | | - $this->showForm( $action ); |
| 46 | + $wgOut->addHTML( $this->showForm( $action ) ); |
47 | 47 | } |
48 | 48 | $wgOut->returnToMain( false, $return ); |
49 | 49 | break; |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | global $wgUser, $wgInterwikiCache; |
74 | 74 | if( !$wgUser->isAllowed( 'interwiki' ) ) { |
75 | 75 | # Check permissions |
76 | | - if( $out ) { $out->permissionRequired( 'interwiki' ); } |
| 76 | + if( $out ) { throw new PermissionsError( 'interwiki' ); } |
77 | 77 | return false; |
78 | 78 | } elseif( $wgInterwikiCache ) { |
79 | 79 | # Editing the interwiki cache is not supported |
— | — | @@ -87,101 +87,84 @@ |
88 | 88 | } |
89 | 89 | |
90 | 90 | function showForm( $action ) { |
91 | | - global $wgRequest, $wgUser, $wgOut; |
| 91 | + global $wgRequest, $wgUser; |
92 | 92 | |
93 | | - $actionUrl = $this->getTitle()->getLocalURL( 'action=submit' ); |
94 | | - $token = $wgUser->editToken(); |
| 93 | + $prefix = $wgRequest->getVal( 'prefix' ); |
| 94 | + $wpPrefix = ''; |
| 95 | + $label = array( 'class' => 'mw-label' ); |
| 96 | + $input = array( 'class' => 'mw-input' ); |
95 | 97 | |
96 | | - switch( $action ) { |
97 | | - case 'delete': |
98 | | - |
99 | | - $prefix = $wgRequest->getVal( 'prefix' ); |
100 | | - $button = wfMsg( 'delete' ); |
101 | | - $topmessage = wfMsg( 'interwiki_delquestion', $prefix ); |
102 | | - $deletingmessage = wfMsgExt( 'interwiki_deleting', array( 'parseinline' ), $prefix ); |
103 | | - $reasonmessage = wfMsg( 'deletecomment' ); |
104 | | - |
105 | | - $wgOut->addHTML( |
106 | | - Xml::openElement( 'fieldset' ) . |
107 | | - Xml::element( 'legend', null, $topmessage ) . |
108 | | - Xml::openElement( 'form', array( 'id' => 'mw-interwiki-deleteform', 'method' => 'post', 'action' => $actionUrl ) ) . |
109 | | - Xml::openElement( 'table' ) . |
110 | | - "<tr><td colspan='2'>$deletingmessage</td></tr>". |
111 | | - '<tr><td class="mw-label">' . Xml::label( $reasonmessage, 'mw-interwiki-deletereason' ) . '</td>' . |
112 | | - '<td class="mw-input">' . |
113 | | - Xml::input( 'wpInterwikiReason', 60, '', array( 'tabindex' => '1', 'id' => 'mw-interwiki-deletereason', 'maxlength' => '200' ) ) . |
114 | | - '</td></tr>' . |
115 | | - '<tr><td></td><td class="mw-submit">' . Xml::submitButton( $button, array( 'id' => 'mw-interwiki-submit' ) ) . |
116 | | - Html::hidden( 'wpInterwikiPrefix', $prefix ) . |
117 | | - Html::hidden( 'wpInterwikiAction', $action ) . |
118 | | - Html::hidden( 'wpEditToken', $token ) . |
119 | | - '</td></tr>' . |
120 | | - Xml::closeElement( 'table' ) . |
121 | | - Xml::closeElement( 'form' ) . |
122 | | - Xml::closeElement( 'fieldset' ) |
123 | | - ); |
124 | | - break; |
125 | | - case 'edit': |
126 | | - case 'add': |
127 | | - if( $action == 'edit' ){ |
128 | | - $prefix = $wgRequest->getVal( 'prefix' ); |
129 | | - $dbr = wfGetDB( DB_SLAVE ); |
130 | | - $row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ), __METHOD__ ); |
131 | | - if( !$row ) { |
132 | | - $this->error( 'interwiki_editerror', $prefix ); |
133 | | - return; |
134 | | - } |
135 | | - $prefix = '<tt>' . htmlspecialchars( $row->iw_prefix ) . '</tt>'; |
136 | | - $defaulturl = $row->iw_url; |
137 | | - $trans = $row->iw_trans; |
138 | | - $local = $row->iw_local; |
139 | | - $old = Html::hidden( 'wpInterwikiPrefix', $row->iw_prefix ); |
140 | | - $topmessage = wfMsgExt( 'interwiki_edittext', array( 'parseinline' ) ); |
141 | | - $intromessage = wfMsgExt( 'interwiki_editintro', array( 'parseinline' ) ); |
142 | | - $button = wfMsg( 'edit' ); |
143 | | - } else { |
144 | | - $prefix = $wgRequest->getVal( 'wpInterwikiPrefix' ) ? $wgRequest->getVal( 'wpInterwikiPrefix' ) : $wgRequest->getVal( 'prefix' ); |
145 | | - $prefix = Xml::input( 'wpInterwikiPrefix', 20, $prefix, array( 'tabindex' => '1', 'id' => 'mw-interwiki-prefix', 'maxlength' => '20' ) ); |
146 | | - $local = $wgRequest->getCheck( 'wpInterwikiLocal' ); |
147 | | - $trans = $wgRequest->getCheck( 'wpInterwikiTrans' ); |
148 | | - $old = ''; |
149 | | - $defaulturl = $wgRequest->getVal( 'wpInterwikiURL' ) ? $wgRequest->getVal( 'wpInterwikiURL' ) : wfMsg( 'interwiki-defaulturl' ); |
150 | | - $topmessage = wfMsgExt( 'interwiki_addtext', array( 'parseinline' ) ); |
151 | | - $intromessage = wfMsgExt( 'interwiki_addintro', array( 'parseinline' ) ); |
152 | | - $button = wfMsg( 'interwiki_addbutton' ); |
| 98 | + if( $action == 'delete' ) { |
| 99 | + $topmessage = wfMessage( 'interwiki_delquestion', $prefix )->parse(); |
| 100 | + $intromessage = wfMessage( 'interwiki_deleting', $prefix )->parse(); |
| 101 | + $wpPrefix = Html::hidden( 'wpInterwikiPrefix', $prefix ); |
| 102 | + $button = 'delete'; |
| 103 | + $formContent = ''; |
| 104 | + } elseif( $action == 'edit' ) { |
| 105 | + $dbr = wfGetDB( DB_SLAVE ); |
| 106 | + $row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ), __METHOD__ ); |
| 107 | + if( !$row ) { |
| 108 | + $this->error( 'interwiki_editerror', $prefix ); |
| 109 | + return; |
153 | 110 | } |
| 111 | + $prefix = $row->iw_prefix; |
| 112 | + $defaulturl = $row->iw_url; |
| 113 | + $trans = $row->iw_trans; |
| 114 | + $local = $row->iw_local; |
| 115 | + $wpPrefix = Html::hidden( 'wpInterwikiPrefix', $row->iw_prefix ); |
| 116 | + $topmessage = wfMessage( 'interwiki_edittext' )->parse(); |
| 117 | + $intromessage = wfMessage( 'interwiki_editintro' )->parse(); |
| 118 | + $button = 'edit'; |
| 119 | + } elseif( $action == 'add' ) { |
| 120 | + $prefix = $wgRequest->getVal( 'wpInterwikiPrefix' ) ? |
| 121 | + $wgRequest->getVal( 'wpInterwikiPrefix' ) : $wgRequest->getVal( 'prefix' ); |
| 122 | + $prefix = Xml::input( 'wpInterwikiPrefix', 20, $prefix, |
| 123 | + array( 'tabindex' => 1, 'id' => 'mw-interwiki-prefix', 'maxlength' => 20 ) ); |
| 124 | + $local = $wgRequest->getCheck( 'wpInterwikiLocal' ); |
| 125 | + $trans = $wgRequest->getCheck( 'wpInterwikiTrans' ); |
| 126 | + $defaulturl = $wgRequest->getVal( 'wpInterwikiURL' ) ? |
| 127 | + $wgRequest->getVal( 'wpInterwikiURL' ) : wfMessage( 'interwiki-defaulturl' ); |
| 128 | + $topmessage = wfMessage( 'interwiki_addtext' )->parse(); |
| 129 | + $intromessage = wfMessage( 'interwiki_addintro' )->parse(); |
| 130 | + $button = 'interwiki_addbutton'; |
| 131 | + } |
154 | 132 | |
155 | | - $prefixmessage = wfMsgHtml( 'interwiki-prefix-label' ); |
156 | | - $localmessage = wfMsg( 'interwiki-local-label' ); |
157 | | - $transmessage = wfMsg( 'interwiki-trans-label' ); |
158 | | - $reasonmessage = wfMsg( 'interwiki_reasonfield' ); |
159 | | - $urlmessage = wfMsg( 'interwiki-url-label' ); |
160 | | - |
161 | | - $wgOut->addHTML( |
162 | | - Xml::fieldset( $topmessage ) . |
163 | | - $intromessage . |
164 | | - Xml::openElement( 'form', array( 'id' => 'mw-interwiki-editform', 'method' => 'post', 'action' => $actionUrl ) ) . |
165 | | - Xml::openElement( 'table', array( 'id' => "mw-interwiki-$action" ) ) . |
166 | | - "<tr><td class='mw-label'>$prefixmessage</td><td><tt>$prefix</tt></td></tr>" . |
167 | | - '<tr><td class="mw-label">' . Xml::label( $localmessage, 'mw-interwiki-local' ) . '</td>' . |
168 | | - '<td class="mw-input">' . Xml::check( 'wpInterwikiLocal', $local, array( 'id' => 'mw-interwiki-local' ) ) . '</td></tr>' . |
169 | | - '<tr><td class="mw-label">' . Xml::label( $transmessage, 'mw-interwiki-trans' ) . '</td>' . |
170 | | - '<td class="mw-input">' . Xml::check( 'wpInterwikiTrans', $trans, array( 'id' => 'mw-interwiki-trans' ) ) . '</td></tr>' . |
171 | | - '<tr><td class="mw-label">' . Xml::label( $urlmessage, 'mw-interwiki-url' ) . '</td>' . |
172 | | - '<td class="mw-input">' . Xml::input( 'wpInterwikiURL', 60, $defaulturl, array( 'tabindex' => '1', 'maxlength' => '200', 'id' => 'mw-interwiki-url' ) ) . '</td></tr>' . |
173 | | - '<tr><td class="mw-label">' . Xml::label( $reasonmessage, 'mw-interwiki-editreason' ) . '</td>' . |
174 | | - '<td class="mw-input">' . Xml::input( 'wpInterwikiReason', 60, '', array( 'tabindex' => '1', 'id' => 'mw-interwiki-editreason', 'maxlength' => '200' ) ) . |
175 | | - Html::hidden( 'wpInterwikiAction', $action ) . |
176 | | - $old . |
177 | | - Html::hidden( 'wpEditToken', $token ) . |
178 | | - '</td></tr>' . |
179 | | - '<tr><td></td><td class="mw-submit">' . Xml::submitButton( $button, array( 'id' => 'mw-interwiki-submit' ) ) . '</td></tr>' . |
180 | | - Xml::closeElement( 'table' ) . |
181 | | - Xml::closeElement( 'form' ) . |
182 | | - Xml::closeElement( 'fieldset' ) |
| 133 | + if( $action == 'add' || $action == 'edit' ) { |
| 134 | + $formContent = Html::rawElement( 'tr', null, |
| 135 | + Html::element( 'td', $label, wfMessage( 'interwiki-prefix-label' ) ) . |
| 136 | + Html::rawElement( 'td', null, '<tt>' . $prefix . '</tt>' ) |
| 137 | + ) . Html::rawElement( 'tr', null, |
| 138 | + Html::rawElement( 'td', $label, Xml::label( wfMessage( 'interwiki-local-label' ), 'mw-interwiki-local' ) ) . |
| 139 | + Html::rawElement( 'td', $input, Xml::check( 'wpInterwikiLocal', $local, array( 'id' => 'mw-interwiki-local' ) ) ) |
| 140 | + ) . Html::rawElement( 'tr', null, |
| 141 | + Html::rawElement( 'td', $label, Xml::label( wfMessage( 'interwiki-trans-label' ), 'mw-interwiki-trans' ) ) . |
| 142 | + Html::rawElement( 'td', $input, Xml::check( 'wpInterwikiTrans', $trans, array( 'id' => 'mw-interwiki-trans' ) ) ) |
| 143 | + ) . Html::rawElement( 'tr', null, |
| 144 | + Html::rawElement( 'td', $label, Xml::label( wfMessage( 'interwiki-url-label' ), 'mw-interwiki-url' ) ) . |
| 145 | + Html::rawElement( 'td', $input, Xml::input( 'wpInterwikiURL', 60, $defaulturl, |
| 146 | + array( 'tabindex' => 1, 'maxlength' => 200, 'id' => 'mw-interwiki-url' ) ) ) |
183 | 147 | ); |
184 | | - break; |
185 | 148 | } |
| 149 | + |
| 150 | + return Xml::fieldset( $topmessage, Html::rawElement( 'form', |
| 151 | + array( 'id' => "mw-interwiki-{$action}form", 'method' => 'post', |
| 152 | + 'action' => $this->getTitle()->getLocalURL( 'action=submit' ) ), |
| 153 | + Html::element( 'p', null, $intromessage ) . |
| 154 | + Html::rawElement( 'table', array( 'id' => "mw-interwiki-{$action}" ), |
| 155 | + $formContent . Html::rawElement( 'tr', null, |
| 156 | + Html::rawElement( 'td', $label, Xml::label( wfMessage( 'interwiki_reasonfield' ), |
| 157 | + "mw-interwiki-{$action}reason" ) ) . |
| 158 | + Html::rawElement( 'td', $input, Xml::input( 'wpInterwikiReason', 60, '', |
| 159 | + array( 'tabindex' => 1, 'id' => "mw-interwiki-{$action}reason", 'maxlength' => 200 ) ) ) |
| 160 | + ) . Html::rawElement( 'tr', null, |
| 161 | + Html::rawElement( 'td', null, '' ) . |
| 162 | + Html::rawElement( 'td', array( 'class' => 'mw-submit' ), |
| 163 | + Xml::submitButton( wfMessage( $button )->text(), array( 'id' => 'mw-interwiki-submit' ) ) ) |
| 164 | + ) . $wpPrefix . |
| 165 | + Html::hidden( 'wpEditToken', $wgUser->editToken() ) . |
| 166 | + Html::hidden( 'wpInterwikiAction', $action ) |
| 167 | + ) |
| 168 | + ) ); |
186 | 169 | } |
187 | 170 | |
188 | 171 | function doSubmit() { |
— | — | @@ -267,7 +250,7 @@ |
268 | 251 | $wgOut->addWikiMsg( 'interwiki_intro_footer' ); |
269 | 252 | |
270 | 253 | if ( $canModify ) { |
271 | | - $addtext = wfMsgHtml( 'interwiki_addtext' ); |
| 254 | + $addtext = wfMessage( 'interwiki_addtext' )->escaped(); |
272 | 255 | $addlink = Linker::linkKnown( $this->getTitle( 'add' ), $addtext ); |
273 | 256 | $wgOut->addHTML( '<p class="mw-interwiki-addlink">' . $addlink . '</p>' ); |
274 | 257 | } |
— | — | @@ -290,11 +273,11 @@ |
291 | 274 | # Output the table header |
292 | 275 | $out .= Html::openElement( 'table', array( 'class' => 'mw-interwikitable wikitable sortable body' ) ) . "\n"; |
293 | 276 | $out .= Html::openElement( 'tr', array( 'id' => 'interwikitable-header' ) ) . |
294 | | - Html::element( 'th', null, wfMsgHtml( 'interwiki_prefix' ) ) . |
295 | | - Html::element( 'th', null, wfMsgHtml( 'interwiki_url' ) ) . |
296 | | - Html::element( 'th', null, wfMsgHtml( 'interwiki_local' ) ) . |
297 | | - Html::element( 'th', null, wfMsgHtml( 'interwiki_trans' ) ) . |
298 | | - ( $canModify ? Html::element( 'th', array( 'class' => 'unsortable' ), wfMsgHtml( 'interwiki_edit' ) ) : '' ); |
| 277 | + Html::element( 'th', null, wfMessage( 'interwiki_prefix' ) ) . |
| 278 | + Html::element( 'th', null, wfMessage( 'interwiki_url' ) ) . |
| 279 | + Html::element( 'th', null, wfMessage( 'interwiki_local' ) ) . |
| 280 | + Html::element( 'th', null, wfMessage( 'interwiki_trans' ) ) . |
| 281 | + ( $canModify ? Html::element( 'th', array( 'class' => 'unsortable' ), wfMessage( 'interwiki_edit' ) ) : '' ); |
299 | 282 | $out .= Html::closeElement( 'tr' ) . "\n"; |
300 | 283 | |
301 | 284 | $selfTitle = $this->getTitle(); |
— | — | @@ -305,15 +288,15 @@ |
306 | 289 | htmlspecialchars( $iwPrefix['iw_prefix'] ) ); |
307 | 290 | $out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-url' ), $iwPrefix['iw_url'] ); |
308 | 291 | $out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-local' ), |
309 | | - ( isset( $iwPrefix['iw_local'] ) ? wfMsgHtml( 'interwiki_' . $iwPrefix['iw_local'] ) : '-' ) ); |
| 292 | + ( isset( $iwPrefix['iw_local'] ) ? wfMessage( 'interwiki_' . $iwPrefix['iw_local'] ) : '-' ) ); |
310 | 293 | $out .= Html::element( 'td', array( 'class' => 'mw-interwikitable-trans' ), |
311 | | - ( isset( $iwPrefix['iw_trans'] ) ? wfMsgHtml( 'interwiki_' . $iwPrefix['iw_trans'] ) : '-' ) ); |
| 294 | + ( isset( $iwPrefix['iw_trans'] ) ? wfMessage( 'interwiki_' . $iwPrefix['iw_trans'] ) : '-' ) ); |
312 | 295 | if( $canModify ) { |
313 | 296 | $out .= Html::rawElement( 'td', array( 'class' => 'mw-interwikitable-modify' ), |
314 | | - Linker::linkKnown( $selfTitle, wfMsgHtml( 'edit' ), array(), |
| 297 | + Linker::linkKnown( $selfTitle, wfMessage( 'edit' )->escaped(), array(), |
315 | 298 | array( 'action' => 'edit', 'prefix' => $iwPrefix['iw_prefix'] ) ) . |
316 | | - wfMsg( 'comma-separator' ) . |
317 | | - Linker::linkKnown( $selfTitle, wfMsgHtml( 'delete' ), array(), |
| 299 | + wfMessage( 'comma-separator' ) . |
| 300 | + Linker::linkKnown( $selfTitle, wfMessage( 'delete' )->escaped(), array(), |
318 | 301 | array( 'action' => 'delete', 'prefix' => $iwPrefix['iw_prefix'] ) ) |
319 | 302 | ); |
320 | 303 | } |
— | — | @@ -326,8 +309,8 @@ |
327 | 310 | |
328 | 311 | static function addInfoRow( $align = 'start', $title, $text ) { |
329 | 312 | return Html::rawElement( 'tr', null, |
330 | | - Html::rawElement( 'th', array( 'class' => 'mw-align-' . $align ), wfMsg( $title ) ) . |
331 | | - Html::rawElement( 'td', null, wfMsgExt( $text, 'parseinline' ) ) |
| 313 | + Html::rawElement( 'th', array( 'class' => 'mw-align-' . $align ), wfMessage( $title )->escaped() ) . |
| 314 | + Html::rawElement( 'td', null, wfMessage( $text )->parse() ) |
332 | 315 | ); |
333 | 316 | } |
334 | 317 | |