[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Unify Special:Contribs/DeletedContribs subtitle implementation

2016-08-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Unify Special:Contribs/DeletedContribs subtitle implementation
..


Unify Special:Contribs/DeletedContribs subtitle implementation

Basically all of the code was duplicated, except that Contribs had a
link to DeletedContribs, and DeletedContribs had a link to Contribs.

Now DeletedContribs will call the function in Contribs, and remove the
DeletedContribs link, and add its own link to Contribs instead of
needing to duplicate the entire list of links.

Change-Id: Ia004a4a69427fd5b554131b19b0e263523b7da67
---
M includes/specials/SpecialContributions.php
M includes/specials/SpecialDeletedContributions.php
2 files changed, 43 insertions(+), 105 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specials/SpecialContributions.php 
b/includes/specials/SpecialContributions.php
index ab46dda..0a98721 100644
--- a/includes/specials/SpecialContributions.php
+++ b/includes/specials/SpecialContributions.php
@@ -273,7 +273,7 @@
$talk = $userObj->getTalkPage();
$links = '';
if ( $talk ) {
-   $tools = $this->getUserLinks( $nt, $talk, $userObj );
+   $tools = self::getUserLinks( $this, $userObj );
$links = $this->getLanguage()->pipeList( $tools );
 
// Show a note if the user is blocked and display the 
last block log entry.
@@ -313,87 +313,93 @@
 
/**
 * Links to different places.
-* @param Title $userpage Target user page
-* @param Title $talkpage Talk page
+*
+* @note This function is also called in DeletedContributionsPage
+* @param SpecialPage $sp SpecialPage instance, for context
 * @param User $target Target user object
 * @return array
 */
-   public function getUserLinks( Title $userpage, Title $talkpage, User 
$target ) {
+   public static function getUserLinks( SpecialPage $sp, User $target ) {
 
$id = $target->getId();
$username = $target->getName();
+   $userpage = $target->getUserPage();
+   $talkpage = $target->getTalkPage();
 
-   $linkRenderer = $this->getLinkRenderer();
-   $tools[] = $linkRenderer->makeLink( $talkpage, $this->msg( 
'sp-contributions-talk' )->text() );
+   $linkRenderer = $sp->getLinkRenderer();
+   $tools['user-talk'] = $linkRenderer->makeLink(
+   $talkpage,
+   $sp->msg( 'sp-contributions-talk' )->text()
+   );
 
if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( 
$username ) ) ) {
-   if ( $this->getUser()->isAllowed( 'block' ) ) { # Block 
/ Change block / Unblock links
+   if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / 
Change block / Unblock links
if ( $target->isBlocked() && 
$target->getBlock()->getType() != Block::TYPE_AUTO ) {
-   $tools[] = 
$linkRenderer->makeKnownLink( # Change block link
+   $tools['block'] = 
$linkRenderer->makeKnownLink( # Change block link
SpecialPage::getTitleFor( 
'Block', $username ),
-   $this->msg( 'change-blocklink' 
)->text()
+   $sp->msg( 'change-blocklink' 
)->text()
);
-   $tools[] = 
$linkRenderer->makeKnownLink( # Unblock link
+   $tools['unblock'] = 
$linkRenderer->makeKnownLink( # Unblock link
SpecialPage::getTitleFor( 
'Unblock', $username ),
-   $this->msg( 'unblocklink' 
)->text()
+   $sp->msg( 'unblocklink' 
)->text()
);
} else { # User is not blocked
-   $tools[] = 
$linkRenderer->makeKnownLink( # Block link
+   $tools['block'] = 
$linkRenderer->makeKnownLink( # Block link
SpecialPage::getTitleFor( 
'Block', $username ),
-   $this->msg( 'blocklink' 
)->text()
+   $sp->msg( 'blocklink' )->text()
);
}
}
 
# Block log link
-   $tools[] = $linkRenderer->makeKnownLink(
+   

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Unify Special:Contribs/DeletedContribs subtitle implementation

2016-08-04 Thread Legoktm (Code Review)
Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303087

Change subject: Unify Special:Contribs/DeletedContribs subtitle implementation
..

Unify Special:Contribs/DeletedContribs subtitle implementation

Basically all of the code was duplicated, except that Contribs had a
link to DeletedContribs, and DeletedContribs had a link to Contribs.

Now DeletedContribs will call the function in Contribs, and remove the
DeletedContribs link, and add its own link to Contribs instead of
needing to duplicate the entire list of links.

Change-Id: Ia004a4a69427fd5b554131b19b0e263523b7da67
---
M includes/specials/SpecialContributions.php
M includes/specials/SpecialDeletedContributions.php
2 files changed, 40 insertions(+), 105 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/87/303087/1

diff --git a/includes/specials/SpecialContributions.php 
b/includes/specials/SpecialContributions.php
index ab46dda..ac71fe2 100644
--- a/includes/specials/SpecialContributions.php
+++ b/includes/specials/SpecialContributions.php
@@ -273,7 +273,7 @@
$talk = $userObj->getTalkPage();
$links = '';
if ( $talk ) {
-   $tools = $this->getUserLinks( $nt, $talk, $userObj );
+   $tools = self::getUserLinks( $this, $userObj );
$links = $this->getLanguage()->pipeList( $tools );
 
// Show a note if the user is blocked and display the 
last block log entry.
@@ -313,87 +313,90 @@
 
/**
 * Links to different places.
-* @param Title $userpage Target user page
-* @param Title $talkpage Talk page
+*
+* @note This function is also called in DeletedContributionsPage
+* @param SpecialPage $sp SpecialPage instance, for context
 * @param User $target Target user object
 * @return array
 */
-   public function getUserLinks( Title $userpage, Title $talkpage, User 
$target ) {
+   public static function getUserLinks( SpecialPage $sp, User $target ) {
 
$id = $target->getId();
$username = $target->getName();
+   $userpage = $target->getUserPage();
+   $talkpage = $target->getTalkPage();
 
-   $linkRenderer = $this->getLinkRenderer();
-   $tools[] = $linkRenderer->makeLink( $talkpage, $this->msg( 
'sp-contributions-talk' )->text() );
+   $linkRenderer = $sp->getLinkRenderer();
+   $tools['user-talk'] = $linkRenderer->makeLink( $talkpage, 
$sp->msg( 'sp-contributions-talk' )->text() );
 
if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( 
$username ) ) ) {
-   if ( $this->getUser()->isAllowed( 'block' ) ) { # Block 
/ Change block / Unblock links
+   if ( $sp->getUser()->isAllowed( 'block' ) ) { # Block / 
Change block / Unblock links
if ( $target->isBlocked() && 
$target->getBlock()->getType() != Block::TYPE_AUTO ) {
-   $tools[] = 
$linkRenderer->makeKnownLink( # Change block link
+   $tools['block'] = 
$linkRenderer->makeKnownLink( # Change block link
SpecialPage::getTitleFor( 
'Block', $username ),
-   $this->msg( 'change-blocklink' 
)->text()
+   $sp->msg( 'change-blocklink' 
)->text()
);
-   $tools[] = 
$linkRenderer->makeKnownLink( # Unblock link
+   $tools['unblock'] = 
$linkRenderer->makeKnownLink( # Unblock link
SpecialPage::getTitleFor( 
'Unblock', $username ),
-   $this->msg( 'unblocklink' 
)->text()
+   $sp->msg( 'unblocklink' 
)->text()
);
} else { # User is not blocked
-   $tools[] = 
$linkRenderer->makeKnownLink( # Block link
+   $tools['block'] = 
$linkRenderer->makeKnownLink( # Block link
SpecialPage::getTitleFor( 
'Block', $username ),
-   $this->msg( 'blocklink' 
)->text()
+   $sp->msg( 'blocklink' )->text()
);
}
}
 
# Block log link
-   $tools[] = $linkRenderer->makeKnownLink(
+   $tools['log-block'] =