Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1471,6 +1471,7 @@ |
1472 | 1472 | 'interwiki_addfailed', |
1473 | 1473 | 'interwiki_addintro', |
1474 | 1474 | 'interwiki_addtext', |
| 1475 | + 'interwiki-badprefix', |
1475 | 1476 | 'interwiki_defaultreason', |
1476 | 1477 | 'interwiki_defaulturl', |
1477 | 1478 | 'interwiki_deleted', |
Index: trunk/phase3/includes/specials/SpecialInterwiki.php |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | |
58 | 58 | $actionUrl = $this->getTitle()->getLocalURL( 'action=submit' ); |
59 | 59 | $token = $wgUser->editToken(); |
60 | | - $defaultreason = wfMsgForContent( 'interwiki_defaultreason' ); |
| 60 | + $defaultreason = $wgRequest->getVal( 'wpInterwikiReason' ) ? $wgRequest->getVal( 'wpInterwikiReason' ) : wfMsgForContent( 'interwiki_defaultreason' ); |
61 | 61 | |
62 | 62 | switch( $action ){ |
63 | 63 | case "delete": |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | $dbr = wfGetDB( DB_SLAVE ); |
96 | 96 | $row = $dbr->selectRow( 'interwiki', '*', array( 'iw_prefix' => $prefix ) ); |
97 | 97 | if( !$row ){ |
98 | | - $wgOut->wrapWikiMsg( '<div class="errorbox">$1</div>', array( 'interwiki_editerror', $prefix ) ); |
| 98 | + $this->error( wfMsg( 'interwiki_editerror', $prefix ) ); |
99 | 99 | return; |
100 | 100 | } |
101 | 101 | $prefix = '<tt>' . htmlspecialchars( $row->iw_prefix ) . '</tt>'; |
— | — | @@ -106,11 +106,12 @@ |
107 | 107 | $intromessage = wfMsgExt( 'interwiki_editintro', array( 'parseinline' ) ); |
108 | 108 | $button = wfMsg( 'edit' ); |
109 | 109 | } else { |
110 | | - $prefix = Xml::input( 'wpInterwikiPrefix', 20, false, array( 'tabindex'=>'1', 'id'=>'mw-interwiki-prefix', 'maxlength'=>'20' ) ); |
111 | | - $local = false; |
112 | | - $trans = false; |
| 110 | + $prefix = $wgRequest->getVal( 'wpInterwikiPrefix' ) ? $wgRequest->getVal( 'wpInterwikiPrefix' ) : $wgRequest->getVal( 'prefix' ); |
| 111 | + $prefix = Xml::input( 'wpInterwikiPrefix', 20, $prefix, array( 'tabindex'=>'1', 'id'=>'mw-interwiki-prefix', 'maxlength'=>'20' ) ); |
| 112 | + $local = $wgRequest->getCheck( 'wpInterwikiLocal' ); |
| 113 | + $trans = $wgRequest->getCheck( 'wpInterwikiTrans' ); |
113 | 114 | $old = ''; |
114 | | - $defaulturl = wfMsg( 'interwiki_defaulturl' ); |
| 115 | + $defaulturl = $wgRequest->getVal( 'wpInterwikiURL' ) ? $wgRequest->getVal( 'wpInterwikiURL' ) : wfMsg( 'interwiki_defaulturl' ); |
115 | 116 | $topmessage = wfMsgExt( 'interwiki_addtext', array( 'parseinline' ) ); |
116 | 117 | $intromessage = wfMsgExt( 'interwiki_addintro', array( 'parseinline' ) ); |
117 | 118 | $button = wfMsg( 'interwiki_addbutton' ); |
— | — | @@ -121,7 +122,6 @@ |
122 | 123 | $transmessage = wfMsg( 'interwiki_trans' ); |
123 | 124 | $reasonmessage = wfMsg( 'interwiki_reasonfield' ); |
124 | 125 | $urlmessage = wfMsg( 'interwiki_url' ); |
125 | | - $defaultreason = wfMsgForContent( 'interwiki_defaultreason' ); |
126 | 126 | |
127 | 127 | $wgOut->addHTML( |
128 | 128 | Xml::openElement( 'fieldset' ) . |
— | — | @@ -154,8 +154,13 @@ |
155 | 155 | function doSubmit() { |
156 | 156 | global $wgRequest, $wgOut; |
157 | 157 | $prefix = $wgRequest->getVal( 'wpInterwikiPrefix' ); |
| 158 | + $do = $wgRequest->getVal( 'wpInterwikiAction' ); |
| 159 | + if( preg_match( '/[\s:&=]/', $prefix ) ) { |
| 160 | + $this->error( wfMsg( 'interwiki-badprefix', $prefix ) ); |
| 161 | + $this->showForm( $do ); |
| 162 | + return; |
| 163 | + } |
158 | 164 | $reason = $wgRequest->getText( 'wpInterwikiReason' ); |
159 | | - $do = $wgRequest->getVal( 'wpInterwikiAction' ); |
160 | 165 | $selfTitle = $this->getTitle(); |
161 | 166 | $dbw = wfGetDB( DB_MASTER ); |
162 | 167 | switch( $do ){ |
— | — | @@ -163,7 +168,8 @@ |
164 | 169 | $dbw->delete( 'interwiki', array( 'iw_prefix' => $prefix ), __METHOD__ ); |
165 | 170 | |
166 | 171 | if ( $dbw->affectedRows() == 0 ) { |
167 | | - $wgOut->addWikiText( '<span class="error">' . wfMsg( 'interwiki_delfailed', $prefix ) . '</span>' ); |
| 172 | + $this->error( wfMsg( 'interwiki_delfailed', $prefix ) ); |
| 173 | + $this->showForm( $do ); |
168 | 174 | } else { |
169 | 175 | $wgOut->addWikiText( wfMsg( 'interwiki_deleted', $prefix )); |
170 | 176 | $wgOut->returnToMain( false, $selfTitle ); |
— | — | @@ -186,7 +192,8 @@ |
187 | 193 | } |
188 | 194 | |
189 | 195 | if( $dbw->affectedRows() == 0 ) { |
190 | | - $wgOut->wrapWikiMsg( '<span class="error">$1</span>', array( "interwiki_{$do}failed", $prefix ) ); |
| 196 | + $this->error( wfMsg( "interwiki_{$do}failed", $prefix ) ); |
| 197 | + $this->showForm( $do ); |
191 | 198 | } else { |
192 | 199 | $wgOut->addWikiMsg( "interwiki_{$do}ed", $prefix ); |
193 | 200 | $wgOut->returnToMain( false, $selfTitle ); |
— | — | @@ -218,7 +225,7 @@ |
219 | 226 | $res = $dbr->select( 'interwiki', '*' ); |
220 | 227 | $numrows = $res->numRows(); |
221 | 228 | if ( $numrows == 0 ) { |
222 | | - $wgOut->wrapWikiMsg( '<div class="errorbox">$1</div>', 'interwiki_error' ); |
| 229 | + $this->error( wfMsgWikiHtml( 'interwiki_error' ) ); |
223 | 230 | return; |
224 | 231 | } |
225 | 232 | |
— | — | @@ -259,4 +266,9 @@ |
260 | 267 | $out .= "</table><br />"; |
261 | 268 | $wgOut->addHTML( $out ); |
262 | 269 | } |
| 270 | + |
| 271 | + function error( $msg ) { |
| 272 | + global $wgOut; |
| 273 | + $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $msg ) ); |
| 274 | + } |
263 | 275 | } |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2196,6 +2196,7 @@ |
2197 | 2197 | 'interwiki_addintro' => 'You are adding a new interwiki prefix. |
2198 | 2198 | Remember that it cannot contain spaces ( ), colons (:), ampersands (&), or equal signs (=).', |
2199 | 2199 | 'interwiki_addtext' => 'Add an interwiki prefix', |
| 2200 | +'interwiki-badprefix' => '"$1" contains invalid characters', |
2200 | 2201 | 'interwiki_defaultreason' => 'no reason given', |
2201 | 2202 | 'interwiki_defaulturl' => 'http://www.example.com/$1', # only translate this message to other languages if you have to change it |
2202 | 2203 | 'interwiki_deleted' => 'Prefix "$1" was successfully removed from the interwiki table.', |