r40780 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40779‎ | r40780 | r40781 >
Date:08:53, 13 September 2008
Author:aaron
Status:old
Tags:
Comment:
Cleanup for r40770:
* Clean up protection form
* Fix syntax typo (use '==', not '=')
* Fix $2 message in movepage cascade warning
Modified paths:
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMovepage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProtectionForm.php
@@ -268,17 +268,18 @@
269269 if( wfEmptyMsg( 'restriction-' . $action, $msg ) ) {
270270 $msg = $action;
271271 }
272 - $label = Xml::element( 'label',
273 - array( 'for' => "mwProtect-level-$action" ),
274 - $msg );
275 - $out .= "<tr><th>$label</th></tr>";
276 - $out .= "<tr><td>" .
277 - $this->buildSelector( $action, $selected ) .
278 - "</td></tr>";
 272+ $label = Xml::element( 'label', array( 'for' => "mwProtect-level-$action" ), $msg );
 273+ $out .= "<tr><td><table>" .
 274+ "<tr><th>$label</th><th></th></tr>" .
 275+ "<tr><td>" . $this->buildSelector( $action, $selected ) . "</td><td>";
 276+
 277+ $reasonDropDown = Xml::listDropDown( 'wpProtectReasonList',
 278+ wfMsgForContent( 'protect-dropdown' ),
 279+ wfMsgForContent( 'protect-otherreason-op' ), '', 'mwProtect-reason', 4 );
279280 $scExpiryOptions = wfMsgForContent( 'ipboptions' ); // FIXME: use its own message
280281
281282 $showProtectOptions = ($scExpiryOptions !== '-' && !$this->disabled);
282 -
 283+
283284 $mProtectexpiry = Xml::label( wfMsg( 'protectexpiry' ), "mwProtectExpiryList-$action" );
284285 $mProtectother = Xml::label( wfMsg( 'protect-othertime' ), "mwProtect-$action-expires" );
285286 $expiryFormOptions = Xml::option( wfMsg( 'protect-othertime-op' ), "wpProtectExpiryList-$action" );
@@ -292,7 +293,7 @@
293294 # Add expiry dropdown
294295 if( $showProtectOptions && !$this->disabled ) {
295296 $out .= "
296 - <tr>
 297+ <table><tr>
297298 <td class='mw-label'>
298299 {$mProtectexpiry}
299300 </td>
@@ -305,30 +306,27 @@
306307 'tabindex' => '2' ) + $this->disabledAttrib,
307308 $expiryFormOptions ) .
308309 "</td>
309 - </tr>";
 310+ </tr></table>";
310311 }
311312 # Add custom expiry field
312313 $attribs = array( 'id' => "mwProtect-$action-expires", 'onkeyup' => 'protectExpiryUpdate(this)' ) + $this->disabledAttrib;
313 - $out .= "<tr>
 314+ $out .= "<table><tr>
314315 <td class='mw-label'>" .
315316 $mProtectother .
316317 '</td>
317318 <td class="mw-input">' .
318319 Xml::input( "mwProtect-expiry-$action", 60, $this->mExpiry[$action], $attribs ) .
319320 '</td>
320 - </tr>';
 321+ </tr></table>';
 322+ $out .= "</td></tr></table></td></tr>";
321323 }
322 - $reasonDropDown = Xml::listDropDown( 'wpProtectReasonList',
323 - wfMsgForContent( 'protect-dropdown' ),
324 - wfMsgForContent( 'protect-otherreason-op' ), '', 'mwProtect-reason', 4 );
325324
 325+ $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
 326+
326327 // JavaScript will add another row with a value-chaining checkbox
327 - $out .= Xml::closeElement( 'tbody' ) .
328 - Xml::closeElement( 'table' ) .
329 - Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
330 - Xml::openElement( 'tbody' );
331 -
332328 if( $this->mTitle->exists() ) {
 329+ $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
 330+ Xml::openElement( 'tbody' );
333331 $out .= '<tr>
334332 <td></td>
335333 <td class="mw-input">' .
@@ -336,9 +334,13 @@
337335 $this->mCascade, $this->disabledAttrib ) .
338336 "</td>
339337 </tr>\n";
 338+ $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
340339 }
341 - # Add manual and custom reason field/selects
 340+
 341+ # Add manual and custom reason field/selects as well as submit
342342 if( !$this->disabled ) {
 343+ $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) .
 344+ Xml::openElement( 'tbody' );
343345 $out .= "
344346 <tr>
345347 <td class='mw-label'>
@@ -371,12 +373,10 @@
372374 Xml::submitButton( wfMsg( 'confirm' ), array( 'id' => 'mw-Protect-submit' ) ) .
373375 "</td>
374376 </tr>\n";
 377+ $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
375378 }
 379+ $out .= Xml::closeElement( 'fieldset' );
376380
377 - $out .= Xml::closeElement( 'tbody' ) .
378 - Xml::closeElement( 'table' ) .
379 - Xml::closeElement( 'fieldset' );
380 -
381381 if ( !$this->disabled ) {
382382 $out .= Xml::closeElement( 'form' ) .
383383 $this->buildCleanupScript();
@@ -453,7 +453,8 @@
454454 }
455455 }
456456 $script .= "[" . implode(',',$CascadeableLevels) . "];\n";
457 - $script .= 'protectInitialize("mwProtectSet","' . Xml::escapeJsString( wfMsg( 'protect-unchain' ) ) . '","' . count($this->mApplicableTypes) . '")';
 457+ $script .= 'protectInitialize("mw-protect-table2","' . Xml::escapeJsString( wfMsg( 'protect-unchain' ) ) .
 458+ '","' . count($this->mApplicableTypes) . '")';
458459 return Xml::tags( 'script', array( 'type' => 'text/javascript' ), $script );
459460 }
460461
Index: trunk/phase3/includes/Title.php
@@ -2503,7 +2503,7 @@
25042504
25052505 if ( $auth ) {
25062506 global $wgUser;
2507 - $errors = array_merge($errors,
 2507+ $errors = wfArrayMerge($errors,
25082508 $this->getUserPermissionsErrors('move', $wgUser),
25092509 $this->getUserPermissionsErrors('edit', $wgUser),
25102510 $nt->getUserPermissionsErrors('move', $wgUser),
Index: trunk/phase3/includes/specials/SpecialMovepage.php
@@ -93,7 +93,7 @@
9494 # when the form is first opened.
9595 $newTitle = $oldTitle;
9696 } else {
97 - if( $err == '' ) {
 97+ if( empty($err) ) {
9898 $nt = Title::newFromURL( $this->newTitle );
9999 if( $nt ) {
100100 # If a title was supplied, probably from the move log revert
@@ -108,7 +108,7 @@
109109 $newTitle = $this->newTitle;
110110 }
111111
112 - if ( $err == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
 112+ if ( !empty($err) && $err[0] == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) {
113113 $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle );
114114 $movepagebtn = wfMsg( 'delete_and_move' );
115115 $submitVar = 'wpDeleteAndMove';
@@ -144,9 +144,9 @@
145145 $titleObj = SpecialPage::getTitleFor( 'Movepage' );
146146 $token = htmlspecialchars( $wgUser->editToken() );
147147
148 - if ( $err != '' ) {
 148+ if ( !empty($err) ) {
149149 $wgOut->setSubtitle( wfMsg( 'formerror' ) );
150 - if( $err == 'hookaborted' ) {
 150+ if( $err[0] == 'hookaborted' ) {
151151 $errMsg = "<p><strong class=\"error\">$hookErr</strong></p>\n";
152152 $wgOut->addHTML( $errMsg );
153153 } else {
@@ -292,12 +292,7 @@
293293
294294 $error = $ot->moveTo( $nt, true, $this->reason );
295295 if ( $error !== true ) {
296 - if (isset($error[0][0]) && $error[0][0] = 'cascadeprotected') {
297 - $wgOut->showPermissionsErrorPage($error, 'move');
298 - return;
299 - }
300 - # FIXME: showForm() should handle multiple errors
301 - call_user_func_array(array($this, 'showForm'), $error[0]);
 296+ call_user_func_array( array($this, 'showForm'), $error );
302297 return;
303298 }
304299

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40770(bug 12650) Make it possible to enter separate expiry times for each restrict...mrzman05:33, 13 September 2008