global $wgOut, $wgUser, $wgSysopUserBans, $wgContLang;
$wgOut->setPagetitle( wfMsg( 'blockip' ) );
- $wgOut->addWikiText( wfMsg( 'blockiptext' ) );
+ $wgOut->addWikiMsg( 'blockiptext' );
if($wgSysopUserBans) {
$mIpaddress = Xml::label( wfMsg( 'ipadressorusername' ), 'mw-bi-target' );
} else {
- $mIpaddress = Xml::label( wfMsg( 'ipadress' ), 'mw-bi-target' );
+ $mIpaddress = Xml::label( wfMsg( 'ipaddress' ), 'mw-bi-target' );
}
$mIpbexpiry = Xml::label( wfMsg( 'ipbexpiry' ), 'wpBlockExpiry' );
$mIpbother = Xml::label( wfMsg( 'ipbother' ), 'mw-bi-other' );
$mIpbothertime = wfMsgHtml( 'ipbotheroption' );
$mIpbreasonother = Xml::label( wfMsg( 'ipbreason' ), 'wpBlockReasonList' );
$mIpbreason = Xml::label( wfMsg( 'ipbotherreason' ), 'mw-bi-reason' );
- $mIpbreasonotherlist = wfMsgHtml( 'ipbreasonotherlist' );
$titleObj = SpecialPage::getTitleFor( 'Blockip' );
$action = $titleObj->escapeLocalURL( "action=submit" );
$blockExpiryFormOptions .= "<option value=\"$value\"$selected>$show</option>";
}
- $scBlockReasonList = wfMsgForContent( 'ipbreason-dropdown' );
- $blockReasonList = '';
- if ( $scBlockReasonList != '' && $scBlockReasonList != '-' ) {
- $blockReasonList = "<option value=\"other\">$mIpbreasonotherlist</option>";
- $optgroup = "";
- foreach ( explode( "\n", $scBlockReasonList ) as $option) {
- $value = trim( htmlspecialchars($option) );
- if ( $value == '' ) {
- continue;
- } elseif ( substr( $value, 0, 1) == '*' && substr( $value, 1, 1) != '*' ) {
- // A new group is starting ...
- $value = trim( substr( $value, 1 ) );
- $blockReasonList .= "$optgroup<optgroup label=\"$value\">";
- $optgroup = "</optgroup>";
- } elseif ( substr( $value, 0, 2) == '**' ) {
- // groupmember
- $selected = "";
- $value = trim( substr( $value, 2 ) );
- if ( $this->BlockReasonList === $value)
- $selected = ' selected="selected"';
- $blockReasonList .= "<option value=\"$value\"$selected>$value</option>";
- } else {
- // groupless block reason
- $selected = "";
- if ( $this->BlockReasonList === $value)
- $selected = ' selected="selected"';
- $blockReasonList .= "$optgroup<option value=\"$value\"$selected>$value</option>";
- $optgroup = "";
- }
- }
- $blockReasonList .= $optgroup;
- }
+ $reasonDropDown = Xml::listDropDown( 'wpBlockReasonList',
+ wfMsgForContent( 'ipbreason-dropdown' ),
+ wfMsgForContent( 'ipbreasonotherlist' ), '', 'wpBlockDropDown', 4 );
$token = $wgUser->editToken();
$wgOut->addHTML( "
<script type=\"text/javascript\" src=\"$wgStylePath/common/block.js?$wgStyleVersion\">
</script>
-<form id=\"blockip\" method=\"post\" action=\"{$action}\">
- <table border='0'>
- <tr>
- <td align=\"$alignRight\">{$mIpaddress}</td>
- <td>
- " . Xml::input( 'wpBlockAddress', 45, $this->BlockAddress,
- array(
- 'tabindex' => '1',
- 'id' => 'mw-bi-target',
- 'onchange' => 'updateBlockOptions()' ) ) . "
- </td>
- </tr>
- <tr>");
- if ($showblockoptions) {
+<form id=\"blockip\" method=\"post\" action=\"{$action}\">" .
+ Xml::openElement( 'fieldset' ) .
+ Xml::element( 'legend', null, wfMsg( 'blockip-legend' ) ) .
+ Xml::openElement( 'table', array ( 'border' => '0', 'id' => 'mw-blockip-table' ) ) .
+ "<tr>
+ <td align=\"$alignRight\">{$mIpaddress}</td>
+ <td>" .
+ Xml::input( 'wpBlockAddress', 45, $this->BlockAddress,
+ array(
+ 'tabindex' => '1',
+ 'id' => 'mw-bi-target',
+ 'onchange' => 'updateBlockOptions()' ) ). "
+ </td>
+ </tr>
+ <tr>"
+ );
+ if ( $showblockoptions ) {
$wgOut->addHTML("
- <td align=\"$alignRight\">{$mIpbexpiry}</td>
- <td>
- <select tabindex='2' id='wpBlockExpiry' name=\"wpBlockExpiry\" onchange=\"considerChangingExpiryFocus()\">
- $blockExpiryFormOptions
- </select>
- </td>
- ");
+ <td align=\"$alignRight\">{$mIpbexpiry}</td>
+ <td>
+ <select tabindex='2' id='wpBlockExpiry' name=\"wpBlockExpiry\" onchange=\"considerChangingExpiryFocus()\">
+ $blockExpiryFormOptions
+ </select>
+ </td>"
+ );
}
$wgOut->addHTML("
- </tr>
- <tr id='wpBlockOther'>
- <td align=\"$alignRight\">{$mIpbother}</td>
- <td>
- " . Xml::input( 'wpBlockOther', 45, $this->BlockOther,
- array( 'tabindex' => '3', 'id' => 'mw-bi-other' ) ) . "
- </td>
- </tr>");
- if ( $blockReasonList != '' ) {
- $wgOut->addHTML("
+ </tr>
+ <tr id='wpBlockOther'>
+ <td align=\"$alignRight\">{$mIpbother}</td>
+ <td>" .
+ Xml::input( 'wpBlockOther', 45, $this->BlockOther,
+ array( 'tabindex' => '3', 'id' => 'mw-bi-other' ) ) . "
+ </td>
+ </tr>
<tr>
<td align=\"$alignRight\">{$mIpbreasonother}</td>
<td>
- <select tabindex='4' id=\"wpBlockReasonList\" name=\"wpBlockReasonList\">
- $blockReasonList
- </select>
+ $reasonDropDown
</td>
- </tr>");
- }
- $wgOut->addHTML("
- <tr id=\"wpBlockReason\">
- <td align=\"$alignRight\">{$mIpbreason}</td>
- <td>
- " . Xml::input( 'wpBlockReason', 45, $this->BlockReason,
- array( 'tabindex' => '5', 'id' => 'mw-bi-reason',
- 'maxlength'=> '200' ) ) . "
- </td>
- </tr>
- <tr id='wpAnonOnlyRow'>
- <td> </td>
- <td>
- " . wfCheckLabel( wfMsgHtml( 'ipbanononly' ),
- 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly,
- array( 'tabindex' => '6' ) ) . "
- </td>
- </tr>
- <tr id='wpCreateAccountRow'>
- <td> </td>
- <td>
- " . wfCheckLabel( wfMsgHtml( 'ipbcreateaccount' ),
- 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount,
- array( 'tabindex' => '7' ) ) . "
- </td>
- </tr>
- <tr id='wpEnableAutoblockRow'>
- <td> </td>
- <td>
- " . wfCheckLabel( wfMsgHtml( 'ipbenableautoblock' ),
+ </tr>
+ <tr id=\"wpBlockReason\">
+ <td align=\"$alignRight\">{$mIpbreason}</td>
+ <td>" .
+ Xml::input( 'wpBlockReason', 45, $this->BlockReason,
+ array( 'tabindex' => '5', 'id' => 'mw-bi-reason', 'maxlength'=> '200' ) ) . "
+ </td>
+ </tr>
+ <tr id='wpAnonOnlyRow'>
+ <td> </td>
+ <td>" .
+ wfCheckLabel( wfMsgHtml( 'ipbanononly' ),
+ 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly,
+ array( 'tabindex' => '6' ) ) . "
+ </td>
+ </tr>
+ <tr id='wpCreateAccountRow'>
+ <td> </td>
+ <td>" .
+ wfCheckLabel( wfMsgHtml( 'ipbcreateaccount' ),
+ 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount,
+ array( 'tabindex' => '7' ) ) . "
+ </td>
+ </tr>
+ <tr id='wpEnableAutoblockRow'>
+ <td> </td>
+ <td>" .
+ wfCheckLabel( wfMsgHtml( 'ipbenableautoblock' ),
'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock,
- array( 'tabindex' => '8' ) ) . "
- </td>
- </tr>
- ");
-
+ array( 'tabindex' => '8' ) ) . "
+ </td>
+ </tr>"
+ );
+
global $wgSysopEmailBans;
if ( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) {
$wgOut->addHTML("
- <tr id='wpEnableEmailBan'>
- <td> </td>
- <td>
- " . wfCheckLabel( wfMsgHtml( 'ipbemailban' ),
+ <tr id='wpEnableEmailBan'>
+ <td> </td>
+ <td>" .
+ wfCheckLabel( wfMsgHtml( 'ipbemailban' ),
'wpEmailBan', 'wpEmailBan', $this->BlockEmail,
- array( 'tabindex' => '10' )) . "
- </td>
- </tr>
- ");
+ array( 'tabindex' => '10' )) . "
+ </td>
+ </tr>"
+ );
}
// Allow some users to hide name from block log, blocklist and listusers
if ( $wgUser->isAllowed( 'hideuser' ) ) {
$wgOut->addHTML("
- <tr id='wpEnableHideUser'>
- <td> </td>
- <td>
- " . wfCheckLabel( wfMsgHtml( 'ipbhidename' ),
+ <tr id='wpEnableHideUser'>
+ <td> </td>
+ <td>" .
+ wfCheckLabel( wfMsgHtml( 'ipbhidename' ),
'wpHideName', 'wpHideName', $this->BlockHideName,
- array( 'tabindex' => '9' ) ) . "
- </td>
- </tr>
- ");
+ array( 'tabindex' => '9' ) ) . "
+ </td>
+ </tr>"
+ );
}
-
+
$wgOut->addHTML("
- <tr>
- <td style='padding-top: 1em'> </td>
- <td style='padding-top: 1em'>
- " . Xml::submitButton( wfMsg( 'ipbsubmit' ),
- array( 'name' => 'wpBlock', 'tabindex' => '11' ) ) . "
- </td>
- </tr>
- </table>" .
- Xml::hidden( 'wpEditToken', $token ) .
+ <tr>
+ <td style='padding-top: 1em'> </td>
+ <td style='padding-top: 1em'>" .
+ Xml::submitButton( wfMsg( 'ipbsubmit' ),
+ array( 'name' => 'wpBlock', 'tabindex' => '11' ) ) . "
+ </td>
+ </tr>" .
+ Xml::closeElement( 'table' ) .
+ Xml::hidden( 'wpEditToken', $token ) .
+ Xml::closeElement( 'fieldset' ) .
"</form>
<script type=\"text/javascript\">updateBlockOptions()</script>
-\n" );
+\n"
+ );
$wgOut->addHtml( $this->getConvenienceLinks() );
}
}
- const BLOCK_SUCCESS = 0; // Success
- const BLOCK_RANGE_INVALID = 1; // Invalid IP range
- const BLOCK_RANGE_DISABLED = 2; // Sysops can't block ranges
- const BLOCK_NONEXISTENT_USER = 3; // No such user
- const BLOCK_IP_INVALID = 4; // Invalid IP address
- const BLOCK_EXPIRY_INVALID = 5; // Invalid expiry time
- const BLOCK_ALREADY_BLOCKED = 6; // User is already blocked
/**
* Backend block code.
* $userID and $expiry will be filled accordingly
- * Returns one of the BLOCK_* constants
+ * @return array(message key, arguments) on failure, empty array on success
*/
function doBlock(&$userId = null, &$expiry = null)
{
# IPv4
if ( $wgSysopRangeBans ) {
if ( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < 16 || $matches[2] > 32 ) {
- return self::BLOCK_RANGE_INVALID;
+ return array('ip_range_invalid');
}
$this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
} else {
# Range block illegal
- return self::BLOCK_RANGE_DISABLED;
+ return array('range_block_disabled');
}
} else if ( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) {
# IPv6
if ( $wgSysopRangeBans ) {
if ( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) {
- return self::BLOCK_RANGE_INVALID;
+ return array('ip_range_invalid');
}
$this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
} else {
# Range block illegal
- return self::BLOCK_RANGE_DISABLED;
+ return array('range_block_disabled');
}
} else {
# Username block
$user = User::newFromName( $this->BlockAddress );
if( !is_null( $user ) && $user->getID() ) {
# Use canonical name
- $this->BlockAddress = $user->getName();
$userId = $user->getID();
+ $this->BlockAddress = $user->getName();
} else {
- return self::BLOCK_NONEXISTENT_USER;
+ return array('nosuchusershort', htmlspecialchars( $user ? $user->getName() : $this->BlockAddress ) );
}
} else {
- return self::BLOCK_IP_INVALID;
+ return array('badipaddress');
}
}
}
$expirestr = $this->BlockOther;
if (strlen($expirestr) == 0) {
- return self::BLOCK_EXPIRY_INVALID;
+ return array('ipb_expiry_invalid');
}
if ( $expirestr == 'infinite' || $expirestr == 'indefinite' ) {
$expiry = strtotime( $expirestr );
if ( $expiry < 0 || $expiry === false ) {
- return self::BLOCK_EXPIRY_INVALID;
+ return array('ipb_expiry_invalid');
}
$expiry = wfTimestamp( TS_MW, $expiry );
if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
if ( !$block->insert() ) {
- return self::BLOCK_ALREADY_BLOCKED;
+ return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
}
wfRunHooks('BlockIpComplete', array($block, $wgUser));
$reasonstr, $logParams );
# Report to the user
- return self::BLOCK_SUCCESS;
+ return array();
}
+ else
+ return array('hookaborted');
}
/**
{
global $wgOut;
$retval = $this->doBlock();
- switch($retval)
- {
- case self::BLOCK_RANGE_INVALID:
- $this->showForm( wfMsg( 'ip_range_invalid' ) );
- return;
- case self::BLOCK_RANGE_DISABLED:
- $this->showForm( wfMsg( 'range_block_disabled' ) );
- return;
- case self::BLOCK_NONEXISTENT_USER:
- $this->showForm( wfMsg( 'nosuchusershort', htmlspecialchars( $this->BlockAddress ) ) );
- return;
- case self::BLOCK_IP_INVALID:
- $this->showForm( wfMsg( 'badipaddress' ) );
- return;
- case self::BLOCK_EXPIRY_INVALID:
- $this->showForm( wfMsg( 'ipb_expiry_invalid' ) );
- return;
- case self::BLOCK_ALREADY_BLOCKED:
- $this->showForm( wfMsg( 'ipb_already_blocked', htmlspecialchars( $this->BlockAddress ) ) );
- return;
- case self::BLOCK_SUCCESS:
- $titleObj = SpecialPage::getTitleFor( 'Blockip' );
- $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip=' .
- urlencode( $this->BlockAddress ) ) );
- return;
- default:
- throw new MWException( __METHOD__ . ": Unknown return value ``{$retval}''" );
+ if(empty($retval)) {
+ $titleObj = SpecialPage::getTitleFor( 'Blockip' );
+ $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip=' .
+ urlencode( $this->BlockAddress ) ) );
+ return;
}
+ $key = array_shift($retval);
+ $this->showForm(wfMsgReal($key, $retval));
}
function showSuccess() {
$wgOut->setPagetitle( wfMsg( 'blockip' ) );
$wgOut->setSubtitle( wfMsg( 'blockipsuccesssub' ) );
- $text = wfMsg( 'blockipsuccesstext', $this->BlockAddress );
- $wgOut->addWikiText( $text );
+ $text = wfMsgExt( 'blockipsuccesstext', array( 'parse' ), $this->BlockAddress );
+ $wgOut->addHtml( $text );
}
function showLogFragment( $out, $title ) {
- $out->addHtml( wfElement( 'h2', NULL, LogPage::logName( 'block' ) ) );
+ $out->addHtml( Xml::element( 'h2', NULL, LogPage::logName( 'block' ) ) );
$request = new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'block' ) );
$viewer = new LogViewer( new LogReader( $request ) );
$viewer->showList( $out );
private function getConvenienceLinks() {
global $wgUser;
$skin = $wgUser->getSkin();
- $links[] = $skin->makeLink ( 'MediaWiki:ipbreason-dropdown', wfMsgHtml( 'ipb-edit-dropdown' ) );
+ $links[] = $skin->makeLink ( 'MediaWiki:Ipbreason-dropdown', wfMsgHtml( 'ipb-edit-dropdown' ) );
$links[] = $this->getUnblockLink( $skin );
$links[] = $this->getBlockListLink( $skin );
return '<p class="mw-ipb-conveniencelinks">' . implode( ' | ', $links ) . '</p>';