r113590 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113589‎ | r113590 | r113591 >
Date:21:14, 11 March 2012
Author:reedy
Status:ok
Tags:
Comment:
More documentation and fixup of deprecated code
Modified paths:
  • /trunk/extensions/CheckUser/CheckUserLogPager.php (modified) (history)
  • /trunk/extensions/CheckUser/CheckUser_body.php (modified) (history)
  • /trunk/extensions/CheckUser/SpecialCheckUserLog.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/CheckUser_body.php
@@ -12,8 +12,6 @@
1313 public function __construct() {
1414 global $wgUser;
1515 parent::__construct( 'CheckUser', 'checkuser' );
16 -
17 - $this->sk = $wgUser->getSkin();
1816 }
1917
2018 public function execute( $subpage ) {
@@ -111,6 +109,15 @@
112110 );
113111 }
114112
 113+ /**
 114+ * @param $user
 115+ * @param $reason
 116+ * @param $checktype
 117+ * @param $ip
 118+ * @param $xff
 119+ * @param $name
 120+ * @param $period
 121+ */
115122 protected function showForm( $user, $reason, $checktype, $ip, $xff, $name, $period ) {
116123 global $wgOut, $wgUser;
117124 $action = $this->getTitle()->escapeLocalUrl();
@@ -174,6 +181,7 @@
175182 /**
176183 * Get a selector of time period options
177184 * @param int $selected, selected level
 185+ * @return string
178186 */
179187 protected function getPeriodMenu( $selected = null ) {
180188 $s = '<label for="period">' . wfMsgHtml( 'checkuser-period' ) . '</label>&#160;';
@@ -303,8 +311,14 @@
304312 return $safeUsers;
305313 }
306314
307 - // Give a "no matches found for X" message.
308 - // If $checkLast, then mention the last edit by this user or IP.
 315+ /**
 316+ * Give a "no matches found for X" message.
 317+ * If $checkLast, then mention the last edit by this user or IP.
 318+ *
 319+ * @param $userName
 320+ * @param bool $checkLast
 321+ * @return String
 322+ */
309323 protected function noMatchesMessage( $userName, $checkLast = true ) {
310324 global $wgLang;
311325 if ( $checkLast ) {
@@ -343,6 +357,10 @@
344358 return wfMsgExt( 'checkuser-nomatch', 'parse' );
345359 }
346360
 361+ /**
 362+ * @param $reason
 363+ * @return bool
 364+ */
347365 protected function checkReason( $reason ) {
348366 global $wgCheckUserForceSummary;
349367 return ( !$wgCheckUserForceSummary || strlen( $reason ) );
@@ -481,14 +499,14 @@
482500 if ( $block instanceof Block ) {
483501 if ( $block->getType() == Block::TYPE_RANGE ) {
484502 $userpage = Title::makeTitle( NS_USER, $block->getTarget() );
485 - $blocklog = $this->sk->makeKnownLinkObj(
 503+ $blocklog = Linker::makeKnownLinkObj(
486504 SpecialPage::getTitleFor( 'Log' ),
487505 wfMsgHtml( 'checkuser-blocked' ),
488506 'type=block&page=' . urlencode( $userpage->getPrefixedText() )
489507 );
490508 return ' <strong>(' . $blocklog . ' - ' . $block->getTarget() . ')</strong>';
491509 } elseif ( $block->getType() == Block::TYPE_AUTO ) {
492 - $blocklog = $this->sk->makeKnownLinkObj(
 510+ $blocklog = Linker::makeKnownLinkObj(
493511 SpecialPage::getTitleFor( 'BlockList' ),
494512 wfMsgHtml( 'checkuser-blocked' ),
495513 'ip=' . urlencode( "#{$block->getId()}" )
@@ -496,7 +514,7 @@
497515 return ' <strong>(' . $blocklog . ')</strong>';
498516 } else {
499517 $userpage = Title::makeTitle( NS_USER, $block->getTarget() );
500 - $blocklog = $this->sk->makeKnownLinkObj(
 518+ $blocklog = Linker::makeKnownLinkObj(
501519 SpecialPage::getTitleFor( 'Log' ),
502520 wfMsgHtml( 'checkuser-blocked' ),
503521 'type=block&page=' . urlencode( $userpage->getPrefixedText() )
@@ -563,7 +581,7 @@
564582 $ret = $dbr->select( 'cu_changes',
565583 array( 'cuc_ip_hex', 'COUNT(*) AS count', 'MIN(cuc_timestamp) AS first', 'MAX(cuc_timestamp) AS last' ),
566584 array( $ip_conds, $time_conds ),
567 - __METHOD___,
 585+ __METHOD__,
568586 array(
569587 'GROUP BY' => 'cuc_ip_hex',
570588 'ORDER BY' => 'cuc_ip_hex',
@@ -956,7 +974,7 @@
957975 # Load user object
958976 $user = User::newFromName( $name, false );
959977 # Add user tool links
960 - $s .= $this->sk->userLink( - 1 , $name ) . $this->sk->userToolLinks( - 1 , $name );
 978+ $s .= Linker::userLink( - 1 , $name ) . Linker::userToolLinks( - 1 , $name );
961979 # Add CheckUser link
962980 $s .= ' (<a href="' . $this->getTitle()->escapeLocalURL( 'user=' . urlencode( $name ) .
963981 '&reason=' . urlencode( $reason ) ) . '">' . wfMsgHtml( 'checkuser-check' ) . '</a>)';
@@ -1013,7 +1031,7 @@
10141032 list( $client, $trusted ) = CheckUserHooks::getClientIPfromXFF( $set[1], $set[0] );
10151033 $c = $trusted ? '#F0FFF0' : '#FFFFCC';
10161034 $s .= '&#160;&#160;&#160;<span style="background-color: ' . $c . '"><strong>XFF</strong>: ';
1017 - $s .= $this->sk->makeKnownLinkObj( $this->getTitle(),
 1035+ $s .= Linker::makeKnownLinkObj( $this->getTitle(),
10181036 htmlspecialchars( $set[1] ),
10191037 'user=' . urlencode( $client ) . '/xff' ) . '</span>';
10201038 }
@@ -1054,6 +1072,12 @@
10551073 $wgOut->addHTML( $s );
10561074 }
10571075
 1076+ /**
 1077+ * @param $ip
 1078+ * @param $userId
 1079+ * @param $user User
 1080+ * @return array
 1081+ */
10581082 protected function userBlockFlags( $ip, $userId, $user ) {
10591083 static $logs, $blocklist;
10601084 $logs = SpecialPage::getTitleFor( 'Log' );
@@ -1064,7 +1088,7 @@
10651089 // Range blocked?
10661090 if ( $block->getType() == Block::TYPE_RANGE ) {
10671091 $userpage = Title::makeTitle( NS_USER, $block->getTarget() );
1068 - $blocklog = $this->sk->makeKnownLinkObj(
 1092+ $blocklog = Linker::makeKnownLinkObj(
10691093 $logs,
10701094 wfMsgHtml( 'checkuser-blocked' ),
10711095 'type=block&page=' . urlencode( $userpage->getPrefixedText() )
@@ -1072,7 +1096,7 @@
10731097 $flags[] = '<strong>(' . $blocklog . ' - ' . $block->getTarget() . ')</strong>';
10741098 // Auto blocked?
10751099 } elseif ( $block->getType() == Block::TYPE_AUTO ) {
1076 - $blocklog = $this->sk->makeKnownLinkObj(
 1100+ $blocklog = Linker::makeKnownLinkObj(
10771101 $blocklist,
10781102 wfMsgHtml( 'checkuser-blocked' ),
10791103 'ip=' . urlencode( "#{$block->getId()}" )
@@ -1080,7 +1104,7 @@
10811105 $flags[] = '<strong>(' . $blocklog . ')</strong>';
10821106 } else {
10831107 $userpage = $user->getUserPage();
1084 - $blocklog = $this->sk->makeKnownLinkObj(
 1108+ $blocklog =Linker::makeKnownLinkObj(
10851109 $logs,
10861110 wfMsgHtml( 'checkuser-blocked' ),
10871111 'type=block&page=' . urlencode( $userpage->getPrefixedText() )
@@ -1092,7 +1116,7 @@
10931117 $flags[] = '<strong>(' . wfMsgHtml( 'checkuser-gblocked' ) . ')</strong>';
10941118 } elseif ( self::userWasBlocked( $user->getName() ) ) {
10951119 $userpage = $user->getUserPage();
1096 - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-wasblocked' ),
 1120+ $blocklog = Linker::makeKnownLinkObj( $logs, wfMsgHtml( 'checkuser-wasblocked' ),
10971121 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) );
10981122 $flags[] = '<strong>(' . $blocklog . ')</strong>';
10991123 }
@@ -1125,8 +1149,8 @@
11261150 # Show date
11271151 $line .= ' . . ' . $wgLang->time( wfTimestamp( TS_MW, $row->cuc_timestamp ), true, true ) . ' . . ';
11281152 # Userlinks
1129 - $line .= $this->sk->userLink( $row->cuc_user, $row->cuc_user_text );
1130 - $line .= $this->sk->userToolLinks( $row->cuc_user, $row->cuc_user_text );
 1153+ $line .= Linker::userLink( $row->cuc_user, $row->cuc_user_text );
 1154+ $line .= Linker::userToolLinks( $row->cuc_user, $row->cuc_user_text );
11311155 # Get block info
11321156 if ( isset( $flagCache[$row->cuc_user_text] ) ) {
11331157 $flags = $flagCache[$row->cuc_user_text];
@@ -1142,13 +1166,13 @@
11431167 }
11441168 # Action text, hackish ...
11451169 if ( $row->cuc_actiontext ) {
1146 - $line .= ' ' . $this->sk->formatComment( $row->cuc_actiontext ) . ' ';
 1170+ $line .= ' ' . Linker::formatComment( $row->cuc_actiontext ) . ' ';
11471171 }
11481172 # Comment
1149 - $line .= $this->sk->commentBlock( $row->cuc_comment );
 1173+ $line .= Linker::commentBlock( $row->cuc_comment );
11501174 $line .= '<br />&#160; &#160; &#160; &#160; <small>';
11511175 # IP
1152 - $line .= ' <strong>IP</strong>: ' . $this->sk->makeKnownLinkObj( $cuTitle,
 1176+ $line .= ' <strong>IP</strong>: ' . Linker::makeKnownLinkObj( $cuTitle,
11531177 htmlspecialchars( $row->cuc_ip ), 'user=' . urlencode( $row->cuc_ip ) . '&reason=' . urlencode( $reason ) );
11541178 # XFF
11551179 if ( $row->cuc_xff != null ) {
@@ -1157,7 +1181,7 @@
11581182 $c = $trusted ? '#F0FFF0' : '#FFFFCC';
11591183 $line .= '&#160;&#160;&#160;<span class="mw-checkuser-xff" style="background-color: ' . $c . '">' .
11601184 '<strong>XFF</strong>: ';
1161 - $line .= $this->sk->makeKnownLinkObj( $cuTitle,
 1185+ $line .= Linker::makeKnownLinkObj( $cuTitle,
11621186 htmlspecialchars( $row->cuc_xff ),
11631187 'user=' . urlencode( $client ) . '/xff&reason=' . urlencode( $reason ) ) . '</span>';
11641188 }
@@ -1180,11 +1204,11 @@
11811205 list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $row->cuc_title );
11821206 $logname = LogPage::logName( $logtype );
11831207 $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title );
1184 - $links = '(' . $this->sk->makeKnownLinkObj( $title, $logname ) . ')';
 1208+ $links = '(' . Linker::makeKnownLinkObj( $title, $logname ) . ')';
11851209 // Log items (newer format)
11861210 } elseif ( $row->cuc_type == RC_LOG ) {
11871211 $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title );
1188 - $links = '(' . $this->sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), $this->message['log'],
 1212+ $links = '(' . Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), $this->message['log'],
11891213 wfArrayToCGI( array( 'page' => $title->getPrefixedText() ) ) ) . ')';
11901214 } else {
11911215 $title = Title::makeTitle( $row->cuc_namespace, $row->cuc_title );
@@ -1193,14 +1217,14 @@
11941218 $links = '(' . $this->message['diff'] . ') ';
11951219 } else {
11961220 # Diff link
1197 - $links = ' (' . $this->sk->makeKnownLinkObj( $title, $this->message['diff'],
 1221+ $links = ' (' . Linker::makeKnownLinkObj( $title, $this->message['diff'],
11981222 wfArrayToCGI( array(
11991223 'curid' => $row->cuc_page_id,
12001224 'diff' => $row->cuc_this_oldid,
12011225 'oldid' => $row->cuc_last_oldid ) ) ) . ') ';
12021226 }
12031227 # History link
1204 - $links .= ' (' . $this->sk->makeKnownLinkObj( $title, $this->message['hist'],
 1228+ $links .= ' (' . Linker::makeKnownLinkObj( $title, $this->message['hist'],
12051229 wfArrayToCGI( array(
12061230 'curid' => $row->cuc_page_id,
12071231 'action' => 'history' ) ) ) . ') . . ';
@@ -1212,7 +1236,7 @@
12131237 $links .= '<span class="minor">' . $this->message['minoreditletter'] . '</span>';
12141238 }
12151239 # Page link
1216 - $links .= ' ' . $this->sk->makeLinkObj( $title );
 1240+ $links .= ' ' . Linker::makeLinkObj( $title );
12171241 }
12181242 return $links;
12191243 }
Index: trunk/extensions/CheckUser/CheckUserLogPager.php
@@ -5,10 +5,6 @@
66
77 function __construct( $specialPage, $searchConds, $y, $m ) {
88 parent::__construct();
9 - /*
10 - $this->messages = array_map( 'wfMsg',
11 - array( 'comma-separator', 'checkuser-log-userips', 'checkuser-log-ipedits', 'checkuser-log-ipusers',
12 - 'checkuser-log-ipedits-xff', 'checkuser-log-ipusers-xff' ) );*/
139
1410 $this->getDateCond( $y, $m );
1511 $this->searchConds = $searchConds ? $searchConds : array();
@@ -18,19 +14,17 @@
1915 function formatRow( $row ) {
2016 global $wgLang;
2117
22 - $skin = $this->getSkin();
23 -
2418 if ( $row->cul_reason === '' ) {
2519 $comment = '';
2620 } else {
27 - $comment = $skin->commentBlock( $row->cul_reason );
 21+ $comment = Linker::commentBlock( $row->cul_reason );
2822 }
2923
30 - $user = $skin->userLink( $row->cul_user, $row->user_name );
 24+ $user = Linker::userLink( $row->cul_user, $row->user_name );
3125
3226 if ( $row->cul_type == 'userips' || $row->cul_type == 'useredits' ) {
33 - $target = $skin->userLink( $row->cul_target_id, $row->cul_target_text ) .
34 - $skin->userToolLinks( $row->cul_target_id, $row->cul_target_text );
 27+ $target = Linker::userLink( $row->cul_target_id, $row->cul_target_text ) .
 28+ Linker::userToolLinks( $row->cul_target_id, $row->cul_target_text );
3529 } else {
3630 $target = $row->cul_target_text;
3731 }
@@ -47,6 +41,9 @@
4842 '</li>';
4943 }
5044
 45+ /**
 46+ * @return string
 47+ */
5148 function getStartBody() {
5249 if ( $this->getNumRows() ) {
5350 return '<ul>';
@@ -55,6 +52,9 @@
5653 }
5754 }
5855
 56+ /**
 57+ * @return string
 58+ */
5959 function getEndBody() {
6060 if ( $this->getNumRows() ) {
6161 return '</ul>';
@@ -63,6 +63,9 @@
6464 }
6565 }
6666
 67+ /**
 68+ * @return string
 69+ */
6770 function getEmptyBody() {
6871 return '<p>' . wfMsgHtml( 'checkuser-empty' ) . '</p>';
6972 }
Index: trunk/extensions/CheckUser/SpecialCheckUserLog.php
@@ -5,6 +5,14 @@
66 parent::__construct( 'CheckUserLog', 'checkuser-log' );
77 }
88
 9+ /**
 10+ * @var Title
 11+ */
 12+ var $checkUserFormTitle;
 13+
 14+ /**
 15+ * @return Title
 16+ */
917 function getCheckUserFormTitle() {
1018 if ( !isset( $this->checkUserFormTitle ) ) {
1119 $this->checkUserFormTitle = SpecialPage::getTitleFor('CheckUser');

Status & tagging log