From: Alexandre Emsenhuber Date: Mon, 7 Feb 2011 16:17:50 +0000 (+0000) Subject: Simplify a bit by passing directly the value returned by doUnblock() to showForm... X-Git-Tag: 1.31.0-rc.0~32140 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=94aad3b031bc94a6ad788bce671bab3db558442e;p=lhc%2Fweb%2Fwiklou.git Simplify a bit by passing directly the value returned by doUnblock() to showForm() in case of error --- diff --git a/includes/specials/SpecialIpblocklist.php b/includes/specials/SpecialIpblocklist.php index cc1c140b94..5ecad510ac 100644 --- a/includes/specials/SpecialIpblocklist.php +++ b/includes/specials/SpecialIpblocklist.php @@ -87,7 +87,7 @@ class IPUnblockForm extends SpecialPage { if( $action == 'unblock' ){ # Show unblock form - $this->showForm( '' ); + $this->showForm(); } elseif( $action == 'submit' && $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) @@ -116,19 +116,20 @@ class IPUnblockForm extends SpecialPage { /** * Generates the unblock form * - * @param $err string: error message + * @param $err String, Array or null: error message name or an array if + * there are parameters. Null indicates no error. * @return $out string: HTML form */ - function showForm( $err ) { + function showForm( $err = null ) { global $wgOut, $wgUser, $wgSysopUserBans; $wgOut->addWikiMsg( 'unblockiptext' ); $action = $this->getTitle()->getLocalURL( 'action=submit' ); - if ( $err != '' ) { + if ( $err !== null ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); - $wgOut->addWikiText( Html::rawElement( 'span', array( 'class' => 'error' ), $err ) . "\n" ); + $wgOut->wrapWikiMsg( "$1\n", $err ); } $addressPart = false; @@ -251,9 +252,8 @@ class IPUnblockForm extends SpecialPage { global $wgOut, $wgUser; $retval = self::doUnblock( $this->id, $this->ip, $this->reason, $range, $wgUser ); - if( !empty( $retval ) ) { - $key = array_shift( $retval ); - $this->showForm( wfMsgReal( $key, $retval ) ); + if ( count( $retval ) ) { + $this->showForm( $retval ); return; }