r19610 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19609‎ | r19610 | r19611 >
Date:19:56, 23 January 2007
Author:leon
Status:old
Tags:
Comment:
* Added an option to make Linker::userToolLinks() show the contribs link
red when the user has no edits. Linker::userToolLinksRedContribs() is an
alias to that which should be used to make it more self documentating.
-- Diese und --
M includes/Linker.php
M includes/SpecialLog.php
M RELEASE-NOTES
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/SpecialLog.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -754,10 +754,10 @@
755755 /**
756756 * @param $userId Integer: user id in database.
757757 * @param $userText String: user name in database.
 758+ * @param $redContribsWhenNoEdits Bool: return a red contribs link when the user had no edits and this is true.
758759 * @return string HTML fragment with talk and/or block links
759 - * @private
760760 */
761 - function userToolLinks( $userId, $userText ) {
 761+ public function userToolLinks( $userId, $userText, $redContribsWhenNoEdits = false ) {
762762 global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans;
763763 $talkable = !( $wgDisableAnonTalk && 0 == $userId );
764764 $blockable = ( $wgSysopUserBans || 0 == $userId );
@@ -767,9 +767,15 @@
768768 $items[] = $this->userTalkLink( $userId, $userText );
769769 }
770770 if( $userId ) {
 771+ // check if the user has an edit
 772+ if( $redContribsWhenNoEdits && User::edits( $userId ) == 0 ) {
 773+ $style = "class='new'";
 774+ } else {
 775+ $style = '';
 776+ }
771777 $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
772 - $items[] = $this->makeKnownLinkObj( $contribsPage ,
773 - wfMsgHtml( 'contribslink' ) );
 778+
 779+ $items[] = $this->makeKnownLinkObj( $contribsPage, wfMsgHtml( 'contribslink' ), '', '', '', '', $style );
774780 }
775781 if( $blockable && $wgUser->isAllowed( 'block' ) ) {
776782 $items[] = $this->blockLink( $userId, $userText );
@@ -783,6 +789,14 @@
784790 }
785791
786792 /**
 793+ * Alias for userToolLinks( $userId, $userText, true );
 794+ */
 795+ public function userToolLinksRedContribs( $userId, $userText ) {
 796+ return $this->userToolLinks( $userId, $userText, true );
 797+ }
 798+
 799+
 800+ /**
787801 * @param $userId Integer: user id in database.
788802 * @param $userText String: user name in database.
789803 * @return string HTML fragment with user talk link
Index: trunk/phase3/includes/SpecialLog.php
@@ -311,7 +311,7 @@
312312 $linkCache->addBadLinkObj( $title );
313313 }
314314
315 - $userLink = $this->skin->userLink( $s->log_user, $s->user_name ) . $this->skin->userToolLinks( $s->log_user, $s->user_name );
 315+ $userLink = $this->skin->userLink( $s->log_user, $s->user_name ) . $this->skin->userToolLinksRedContribs( $s->log_user, $s->user_name );
316316 $comment = $this->skin->commentBlock( $s->log_comment );
317317 $paramArray = LogPage::extractParams( $s->log_params );
318318 $revert = '';
Index: trunk/phase3/RELEASE-NOTES
@@ -141,6 +141,9 @@
142142 * (bug 3717) Update user count for AuthPlugin account autocreation
143143 * (bug 8719) Firefox release notes lie! Fix tooltips for Firefox 2 on x11;
144144 accesskeys default settings appear to be same as Windows.
 145+* Added an option to make Linker::userToolLinks() show the contribs link
 146+ red when the user has no edits. Linker::userToolLinksRedContribs() is an
 147+ alias to that which should be used to make it more self documentating.
145148
146149
147150 == Languages updated ==