Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1524,6 +1524,9 @@ |
1525 | 1525 | 'protect-expiring', |
1526 | 1526 | 'protect-cascade', |
1527 | 1527 | 'protect-cantedit', |
| 1528 | + 'protect-otheroption', |
| 1529 | + 'protect-otherreason', |
| 1530 | + 'protect-dropdown', |
1528 | 1531 | 'restriction-type', |
1529 | 1532 | 'restriction-level', |
1530 | 1533 | 'minimum-size', |
Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -65,8 +65,14 @@ |
66 | 66 | : array(); |
67 | 67 | |
68 | 68 | $this->mReason = $wgRequest->getText( 'mwProtect-reason' ); |
| 69 | + $this->mReasonList = $wgRequest->getText( 'wpProtectReasonList' ); |
69 | 70 | $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade', $this->mCascade ); |
70 | | - $this->mExpiry = $wgRequest->getText( 'mwProtect-expiry', $this->mExpiry ); |
| 71 | + // Let dropdown have 'infinite' for unprotected pages |
| 72 | + if( !($expiry = $wgRequest->getText( 'mwProtect-expiry' )) && $this->mExpiry != 'infinite' ) { |
| 73 | + $expiry = $this->mExpiry; |
| 74 | + } |
| 75 | + $this->mExpiry = $expiry; |
| 76 | + $this->mExpiryList = $wgRequest->getText( 'wpProtectExpiryList', $this->mExpiry ? '' : 'infinite' ); |
71 | 77 | |
72 | 78 | foreach( $this->mApplicableTypes as $action ) { |
73 | 79 | $val = $wgRequest->getVal( "mwProtect-level-$action" ); |
— | — | @@ -150,20 +156,29 @@ |
151 | 157 | |
152 | 158 | function save() { |
153 | 159 | global $wgRequest, $wgUser, $wgOut; |
154 | | - |
155 | | - if( $this->disabled ) { |
| 160 | + # Permission check! |
| 161 | + if ( $this->disabled ) { |
156 | 162 | $this->show(); |
157 | 163 | return false; |
158 | 164 | } |
159 | 165 | |
160 | 166 | $token = $wgRequest->getVal( 'wpEditToken' ); |
161 | | - if( !$wgUser->matchEditToken( $token ) ) { |
| 167 | + if ( !$wgUser->matchEditToken( $token ) ) { |
162 | 168 | $this->show( wfMsg( 'sessionfailure' ) ); |
163 | 169 | return false; |
164 | 170 | } |
165 | | - |
| 171 | + |
| 172 | + # Create reason string. Use list and/or custom string. |
| 173 | + $reasonstr = $this->mReasonList; |
| 174 | + if ( $reasonstr != 'other' && $this->mReason != '' ) { |
| 175 | + // Entry from drop down menu + additional comment |
| 176 | + $reasonstr .= ': ' . $this->mReason; |
| 177 | + } elseif ( $reasonstr == 'other' ) { |
| 178 | + $reasonstr = $this->mReason; |
| 179 | + } |
| 180 | + # Custom expiry takes precedence |
166 | 181 | if ( strlen( $this->mExpiry ) == 0 ) { |
167 | | - $this->mExpiry = 'infinite'; |
| 182 | + $this->mExpiry = strlen($this->mExpiryList) ? $this->mExpiryList : 'infinite'; |
168 | 183 | } |
169 | 184 | |
170 | 185 | if ( $this->mExpiry == 'infinite' || $this->mExpiry == 'indefinite' ) { |
— | — | @@ -185,7 +200,6 @@ |
186 | 201 | $this->show( wfMsg( 'protect_expiry_old' ) ); |
187 | 202 | return false; |
188 | 203 | } |
189 | | - |
190 | 204 | } |
191 | 205 | |
192 | 206 | # They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied |
— | — | @@ -199,9 +213,9 @@ |
200 | 214 | $this->mCascade = false; |
201 | 215 | |
202 | 216 | if ($this->mTitle->exists()) { |
203 | | - $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason, $this->mCascade, $expiry ); |
| 217 | + $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $reasonstr, $this->mCascade, $expiry ); |
204 | 218 | } else { |
205 | | - $ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $this->mReason, $expiry ); |
| 219 | + $ok = $this->mTitle->updateTitleProtection( $this->mRestrictions['create'], $reasonstr, $expiry ); |
206 | 220 | } |
207 | 221 | |
208 | 222 | if( !$ok ) { |
— | — | @@ -225,13 +239,20 @@ |
226 | 240 | function buildForm() { |
227 | 241 | global $wgUser; |
228 | 242 | |
| 243 | + $mProtectexpiry = Xml::label( wfMsg( 'protectexpiry' ), 'mwProtectExpiryList' ); |
| 244 | + $mProtectother = Xml::label( wfMsg( 'protect-otheroption' ), 'expires' ); |
| 245 | + $mProtectreasonother = Xml::label( wfMsg( 'protectcomment' ), 'wpProtectReasonList' ); |
| 246 | + $mProtectreason = Xml::label( wfMsg( 'protect-otherreason' ), 'mwProtect-reason' ); |
| 247 | + |
229 | 248 | $out = ''; |
230 | 249 | if( !$this->disabled ) { |
231 | 250 | $out .= $this->buildScript(); |
232 | 251 | // The submission needs to reenable the move permission selector |
233 | 252 | // if it's in locked mode, or some browsers won't submit the data. |
234 | | - $out .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->mTitle->getLocalUrl( 'action=protect' ), 'id' => 'mw-Protect-Form', 'onsubmit' => 'protectEnable(true)' ) ) . |
235 | | - Xml::hidden( 'wpEditToken',$wgUser->editToken() ); |
| 253 | + $out .= Xml::openElement( 'form', array( 'method' => 'post', |
| 254 | + 'action' => $this->mTitle->getLocalUrl( 'action=protect' ), |
| 255 | + 'id' => 'mw-Protect-Form', 'onsubmit' => 'protectEnable(true)' ) ); |
| 256 | + $out .= Xml::hidden( 'wpEditToken',$wgUser->editToken() ); |
236 | 257 | } |
237 | 258 | |
238 | 259 | $out .= Xml::openElement( 'fieldset' ) . |
— | — | @@ -255,9 +276,27 @@ |
256 | 277 | "</td>"; |
257 | 278 | } |
258 | 279 | $out .= "</tr>\n"; |
| 280 | + |
| 281 | + $scExpiryOptions = wfMsgForContent( 'ipboptions' ); // FIXME: use its own message |
259 | 282 | |
| 283 | + $showProtectOptions = ($scExpiryOptions !== '-' && !$this->disabled); |
| 284 | + if( !$showProtectOptions ) |
| 285 | + $mProtectother = $mProtectexpiry; |
| 286 | + |
| 287 | + $expiryFormOptions = Xml::option( wfMsg( 'protect-otheroption' ), 'wpProtectExpiryList' ); |
| 288 | + foreach( explode(',', $scExpiryOptions) as $option ) { |
| 289 | + if ( strpos($option, ":") === false ) $option = "$option:$option"; |
| 290 | + list($show, $value) = explode(":", $option); |
| 291 | + $show = htmlspecialchars($show); |
| 292 | + $value = htmlspecialchars($value); |
| 293 | + $expiryFormOptions .= Xml::option( $show, $value, $this->mExpiryList === $value ? true : false ) . "\n"; |
| 294 | + } |
| 295 | + |
| 296 | + $reasonDropDown = Xml::listDropDown( 'wpProtectReasonList', |
| 297 | + wfMsgForContent( 'protect-dropdown' ), |
| 298 | + wfMsgForContent( 'protect-otherreason' ), '', 'mwProtect-reason', 4 ); |
| 299 | + |
260 | 300 | // JavaScript will add another row with a value-chaining checkbox |
261 | | - |
262 | 301 | $out .= Xml::closeElement( 'tbody' ) . |
263 | 302 | Xml::closeElement( 'table' ) . |
264 | 303 | Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) . |
— | — | @@ -267,29 +306,57 @@ |
268 | 307 | $out .= '<tr> |
269 | 308 | <td></td> |
270 | 309 | <td class="mw-input">' . |
271 | | - Xml::checkLabel( wfMsg( 'protect-cascade' ), 'mwProtect-cascade', 'mwProtect-cascade', $this->mCascade, $this->disabledAttrib ) . |
| 310 | + Xml::checkLabel( wfMsg( 'protect-cascade' ), 'mwProtect-cascade', 'mwProtect-cascade', |
| 311 | + $this->mCascade, $this->disabledAttrib ) . |
272 | 312 | "</td> |
273 | 313 | </tr>\n"; |
274 | 314 | } |
275 | | - |
| 315 | + # Add expiry dropdown |
| 316 | + if( $showProtectOptions && !$this->disabled ) { |
| 317 | + $out .= " |
| 318 | + <tr> |
| 319 | + <td class='mw-label'> |
| 320 | + {$mProtectexpiry} |
| 321 | + </td> |
| 322 | + <td class='mw-input'>" . |
| 323 | + Xml::tags( 'select', |
| 324 | + array( |
| 325 | + 'id' => 'mwProtectExpiryList', |
| 326 | + 'name' => 'wpProtectExpiryList', |
| 327 | + 'onchange' => "document.getElementById('expires').value='';", |
| 328 | + 'tabindex' => '2' ) + $this->disabledAttrib, |
| 329 | + $expiryFormOptions ) . |
| 330 | + "</td> |
| 331 | + </tr>"; |
| 332 | + } |
| 333 | + # Add custom expiry field |
276 | 334 | $attribs = array( 'id' => 'expires' ) + $this->disabledAttrib; |
277 | 335 | $out .= "<tr> |
278 | 336 | <td class='mw-label'>" . |
279 | | - Xml::label( wfMsgExt( 'protectexpiry', array( 'parseinline' ) ), 'expires' ) . |
| 337 | + $mProtectother . |
280 | 338 | '</td> |
281 | 339 | <td class="mw-input">' . |
282 | 340 | Xml::input( 'mwProtect-expiry', 60, $this->mExpiry, $attribs ) . |
283 | 341 | '</td> |
284 | 342 | </tr>'; |
285 | | - |
| 343 | + # Add manual and custom reason field/selects |
286 | 344 | if( !$this->disabled ) { |
287 | | - $id = 'mwProtect-reason'; |
288 | | - $out .= "<tr> |
289 | | - <td class='mw-label'>" . |
290 | | - Xml::label( wfMsg( 'protectcomment' ), $id ) . |
291 | | - '</td> |
292 | | - <td class="mw-input">' . |
293 | | - Xml::input( $id, 60, $this->mReason, array( 'type' => 'text', 'id' => $id, 'maxlength' => 255 ) ) . |
| 345 | + $out .= " |
| 346 | + <tr> |
| 347 | + <td class='mw-label'> |
| 348 | + {$mProtectreasonother} |
| 349 | + </td> |
| 350 | + <td class='mw-input'> |
| 351 | + {$reasonDropDown} |
| 352 | + </td> |
| 353 | + </tr> |
| 354 | + <tr> |
| 355 | + <td class='mw-label'> |
| 356 | + {$mProtectreason} |
| 357 | + </td> |
| 358 | + <td class='mw-input'>" . |
| 359 | + Xml::input( 'mwProtect-reason', 60, $this->mReason, array( 'type' => 'text', |
| 360 | + 'id' => 'mwProtect-reason', 'maxlength' => 255 ) ) . |
294 | 361 | "</td> |
295 | 362 | </tr> |
296 | 363 | <tr> |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -663,7 +663,7 @@ |
664 | 664 | 'deletethispage' => 'Delete this page', |
665 | 665 | 'undelete_short' => 'Undelete {{PLURAL:$1|one edit|$1 edits}}', |
666 | 666 | 'protect' => 'Protect', |
667 | | -'protect_change' => 'change protection', |
| 667 | +'protect_change' => 'change', |
668 | 668 | 'protectthispage' => 'Protect this page', |
669 | 669 | 'unprotect' => 'Unprotect', |
670 | 670 | 'unprotectthispage' => 'Unprotect this page', |
— | — | @@ -2298,6 +2298,13 @@ |
2299 | 2299 | 'protect-expiring' => 'expires $1 (UTC)', |
2300 | 2300 | 'protect-cascade' => 'Protect pages included in this page (cascading protection)', |
2301 | 2301 | 'protect-cantedit' => 'You cannot change the protection levels of this page, because you do not have permission to edit it.', |
| 2302 | +'protect-otheroption' => 'other', |
| 2303 | +'protect-otherreason' => 'other/additional:', |
| 2304 | +'protect-dropdown' => '*Common protection reasons |
| 2305 | +** Excessive vandalism |
| 2306 | +** Excessive spamming |
| 2307 | +** Counter-productive edit warring |
| 2308 | +** High traffic page', |
2302 | 2309 | 'restriction-type' => 'Permission:', |
2303 | 2310 | 'restriction-level' => 'Restriction level:', |
2304 | 2311 | 'minimum-size' => 'Min size', |