From 66c1402e25f705cf15c3dd01daf6fbe0131dc416 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 13 Sep 2008 08:53:07 +0000 Subject: [PATCH] Cleanup for r40770: * Clean up protection form * Fix syntax typo (use '==', not '=') * Fix $2 message in movepage cascade warning --- includes/ProtectionForm.php | 53 ++++++++++++++------------- includes/Title.php | 2 +- includes/specials/SpecialMovepage.php | 15 +++----- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 617b953f43..212733ad97 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -268,17 +268,18 @@ class ProtectionForm { if( wfEmptyMsg( 'restriction-' . $action, $msg ) ) { $msg = $action; } - $label = Xml::element( 'label', - array( 'for' => "mwProtect-level-$action" ), - $msg ); - $out .= "$label"; - $out .= "" . - $this->buildSelector( $action, $selected ) . - ""; + $label = Xml::element( 'label', array( 'for' => "mwProtect-level-$action" ), $msg ); + $out .= "" . + "" . + " +
$label
" . $this->buildSelector( $action, $selected ) . ""; + + $reasonDropDown = Xml::listDropDown( 'wpProtectReasonList', + wfMsgForContent( 'protect-dropdown' ), + wfMsgForContent( 'protect-otherreason-op' ), '', 'mwProtect-reason', 4 ); $scExpiryOptions = wfMsgForContent( 'ipboptions' ); // FIXME: use its own message $showProtectOptions = ($scExpiryOptions !== '-' && !$this->disabled); - + $mProtectexpiry = Xml::label( wfMsg( 'protectexpiry' ), "mwProtectExpiryList-$action" ); $mProtectother = Xml::label( wfMsg( 'protect-othertime' ), "mwProtect-$action-expires" ); $expiryFormOptions = Xml::option( wfMsg( 'protect-othertime-op' ), "wpProtectExpiryList-$action" ); @@ -292,7 +293,7 @@ class ProtectionForm { # Add expiry dropdown if( $showProtectOptions && !$this->disabled ) { $out .= " -
@@ -305,30 +306,27 @@ class ProtectionForm { 'tabindex' => '2' ) + $this->disabledAttrib, $expiryFormOptions ) . " - "; +
{$mProtectexpiry}
"; } # Add custom expiry field $attribs = array( 'id' => "mwProtect-$action-expires", 'onkeyup' => 'protectExpiryUpdate(this)' ) + $this->disabledAttrib; - $out .= " + $out .= " - '; +
" . $mProtectother . ' ' . Xml::input( "mwProtect-expiry-$action", 60, $this->mExpiry[$action], $attribs ) . '
'; + $out .= ""; } - $reasonDropDown = Xml::listDropDown( 'wpProtectReasonList', - wfMsgForContent( 'protect-dropdown' ), - wfMsgForContent( 'protect-otherreason-op' ), '', 'mwProtect-reason', 4 ); - // JavaScript will add another row with a value-chaining checkbox - $out .= Xml::closeElement( 'tbody' ) . - Xml::closeElement( 'table' ) . - Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) . - Xml::openElement( 'tbody' ); + $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' ); + // JavaScript will add another row with a value-chaining checkbox if( $this->mTitle->exists() ) { + $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) . + Xml::openElement( 'tbody' ); $out .= ' ' . @@ -336,9 +334,13 @@ class ProtectionForm { $this->mCascade, $this->disabledAttrib ) . " \n"; + $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' ); } - # Add manual and custom reason field/selects + + # Add manual and custom reason field/selects as well as submit if( !$this->disabled ) { + $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) . + Xml::openElement( 'tbody' ); $out .= " @@ -371,11 +373,9 @@ class ProtectionForm { Xml::submitButton( wfMsg( 'confirm' ), array( 'id' => 'mw-Protect-submit' ) ) . " \n"; + $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' ); } - - $out .= Xml::closeElement( 'tbody' ) . - Xml::closeElement( 'table' ) . - Xml::closeElement( 'fieldset' ); + $out .= Xml::closeElement( 'fieldset' ); if ( !$this->disabled ) { $out .= Xml::closeElement( 'form' ) . @@ -453,7 +453,8 @@ class ProtectionForm { } } $script .= "[" . implode(',',$CascadeableLevels) . "];\n"; - $script .= 'protectInitialize("mwProtectSet","' . Xml::escapeJsString( wfMsg( 'protect-unchain' ) ) . '","' . count($this->mApplicableTypes) . '")'; + $script .= 'protectInitialize("mw-protect-table2","' . Xml::escapeJsString( wfMsg( 'protect-unchain' ) ) . + '","' . count($this->mApplicableTypes) . '")'; return Xml::tags( 'script', array( 'type' => 'text/javascript' ), $script ); } diff --git a/includes/Title.php b/includes/Title.php index 209d2f1568..79c875c175 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2503,7 +2503,7 @@ class Title { if ( $auth ) { global $wgUser; - $errors = array_merge($errors, + $errors = wfArrayMerge($errors, $this->getUserPermissionsErrors('move', $wgUser), $this->getUserPermissionsErrors('edit', $wgUser), $nt->getUserPermissionsErrors('move', $wgUser), diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index a912f84b18..fe8653f901 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -93,7 +93,7 @@ class MovePageForm { # when the form is first opened. $newTitle = $oldTitle; } else { - if( $err == '' ) { + if( empty($err) ) { $nt = Title::newFromURL( $this->newTitle ); if( $nt ) { # If a title was supplied, probably from the move log revert @@ -108,7 +108,7 @@ class MovePageForm { $newTitle = $this->newTitle; } - if ( $err == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) { + if ( !empty($err) && $err[0] == 'articleexists' && $wgUser->isAllowed( 'delete' ) ) { $wgOut->addWikiMsg( 'delete_and_move_text', $newTitle ); $movepagebtn = wfMsg( 'delete_and_move' ); $submitVar = 'wpDeleteAndMove'; @@ -144,9 +144,9 @@ class MovePageForm { $titleObj = SpecialPage::getTitleFor( 'Movepage' ); $token = htmlspecialchars( $wgUser->editToken() ); - if ( $err != '' ) { + if ( !empty($err) ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); - if( $err == 'hookaborted' ) { + if( $err[0] == 'hookaborted' ) { $errMsg = "

$hookErr

\n"; $wgOut->addHTML( $errMsg ); } else { @@ -292,12 +292,7 @@ class MovePageForm { $error = $ot->moveTo( $nt, true, $this->reason ); if ( $error !== true ) { - if (isset($error[0][0]) && $error[0][0] = 'cascadeprotected') { - $wgOut->showPermissionsErrorPage($error, 'move'); - return; - } - # FIXME: showForm() should handle multiple errors - call_user_func_array(array($this, 'showForm'), $error[0]); + call_user_func_array( array($this, 'showForm'), $error ); return; } -- 2.20.1