From: Happy-melon Date: Sun, 13 Mar 2011 15:14:33 +0000 (+0000) Subject: Follow-up r83825: fix Block::parseTarget to recognise autoblocks separately, and... X-Git-Tag: 1.31.0-rc.0~31466 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=bb6644de69e4070cb25112e2d38b01328cc06354;p=lhc%2Fweb%2Fwiklou.git Follow-up r83825: fix Block::parseTarget to recognise autoblocks separately, and change Block::getRedactedName() to run the string through a system message for localisation --- diff --git a/includes/Block.php b/includes/Block.php index 6541284590..a58789ba07 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -758,13 +758,17 @@ class Block { /** * Get the block name, but with autoblocked IPs hidden as per standard privacy policy - * @return String + * @return String, text is escaped */ public function getRedactedName() { if ( $this->mAuto ) { - return '#' . $this->mId; + return HTML::rawElement( + 'span', + array( 'class' => 'mw-autoblockid' ), + wfMessage( 'autoblockid', $this->mId ) + ); } else { - return $this->mAddress; + return htmlspecialchars( $this->mAddress ); } } @@ -989,10 +993,20 @@ class Block { } /** - * Get the target and target type for this particular Block + * Get the target and target type for this particular Block. Note that for autoblocks, + * this returns the unredacted name; frontend functions need to call $block->getRedactedName() + * in this situation. * @return array( User|String, Block::TYPE_ constant ) + * FIXME: this should be an integral part of the Block member variables */ public function getTargetAndType(){ - return self::parseTarget( $this->mAddress ); + list( $target, $type ) = self::parseTarget( $this->mAddress ); + + # Check whether it's an autoblock + if( $type == self::TYPE_ID && $this->mAuto ){ + $type = self::TYPE_AUTO; + } + + return array( $target, $type ); } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index d716570677..49e9a8140f 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3021,6 +3021,7 @@ The latest block log entry is provided below for reference:', 'whatlinkshere-filters' => 'Filters', # Block/unblock +'autoblockid' => 'Autoblock #$1', 'blockip' => 'Block user', 'blockip-title' => 'Block user', 'blockip-legend' => 'Block user', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 73471d89b9..20a76925c0 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2045,6 +2045,7 @@ $wgMessageStructure = array( 'whatlinkshere-filters', ), 'block' => array( + 'autoblockid', 'blockip', 'blockip-title', 'blockip-legend',