jenkins-bot has submitted this change and it was merged.

Change subject: Card 1362: Show last edit on Special:UserProfile
......................................................................


Card 1362: Show last edit on Special:UserProfile

Page images have not been added yet. This will require an abstraction
to avoid rewriting the same code used in Watchlist.

Change-Id: I9cdff3803b490bc5e9efa37ef2d480e43f95d5d7
---
M MobileFrontend.i18n.php
M includes/MobileUserInfo.php
M includes/specials/SpecialUserProfile.php
3 files changed, 56 insertions(+), 1 deletion(-)

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



diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 1aa0c86..594f8a6 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -346,6 +346,7 @@
        'mobile-frontend-profile-userpage-link' => 'Visit user page.',
        'mobile-frontend-requires-optin' => 'This page is not available unless 
you opt into our beta mode. Visit the [[Special:MobileOptions|settings page]] 
to opt in.',
        'mobile-frontend-profile-last-thanked' => '{{GENDER:$1|Last thanked}} 
by [[Special:UserProfile/$1|$1]] for an edit to [[$2]].',
+       'mobile-frontend-profile-last-edit' => 'Edited [[$1]], 
{{PLURAL:$2|yesterday|$2 days ago|0=earlier today}}.',
        'mobile-frontend-profile-footer-days' => 'Registered for {{PLURAL:$2|1 
day|$2 days}} with [[Special:Contributions/$1|{{PLURAL:$3|1 edit|$3 edits}}]] 
and [[Special:Uploads/$1|{{PLURAL:$4|1 upload|$4 uploads|500=500+ uploads}}]].',
        'mobile-frontend-profile-footer-months' => 'Registered for over 
{{PLURAL:$2|1 month|$2 months}} with [[Special:Contributions/$1|{{PLURAL:$3|1 
edit|$3 edits}}]] and [[Special:Uploads/$1|{{PLURAL:$4|1 upload|$4 
uploads|500=500+ uploads}}]].',
        'mobile-frontend-profile-footer-years' => 'Registered for over 
{{PLURAL:$2|1 year|$2 years}} with [[Special:Contributions/$1|{{PLURAL:$3|1 
edit|$3 edits}}]] and [[Special:Uploads/$1|{{PLURAL:$4|1 upload|$4 
uploads|500=500+ uploads}}]].',
@@ -956,6 +957,11 @@
 * $1 - name of user who thanked, can be used for GENDER
 * $2 - title of page for editing which the thank was given
 * $3 - (optional) name of user who was thanked, for GENDER support',
+       'mobile-frontend-profile-last-edit' => 'Identifies the last page edited 
by the user
+
+Parameters:
+* $1 - Name of the page that was edited
+* $2 - How many days ago it was edited.',
        'mobile-frontend-profile-footer-days' => 'Generates the informative 
footer on Special:UserProfile
 
 Parameters:
diff --git a/includes/MobileUserInfo.php b/includes/MobileUserInfo.php
index 8382003..da30183 100644
--- a/includes/MobileUserInfo.php
+++ b/includes/MobileUserInfo.php
@@ -116,6 +116,33 @@
        }
 
        /**
+        * Returns the last edit of the user
+        *
+        * @return Revision|false
+        */
+       public function getLastEdit() {
+               wfProfileIn( __METHOD__ );
+               $conds = array(
+                       'rev_user' => $this->user->getId(),
+               );
+               $options = array(
+                       'LIMIT' => 1,
+                       'ORDER BY' => 'rev_timestamp DESC',
+               );
+
+               $dbr = wfGetDB( DB_SLAVE, 'revision' );
+               $res = $dbr->select( 'revision', 'rev_id', $conds, __METHOD__, 
$options );
+               $row = $res->fetchObject();
+               if ( $row ) {
+                       $rev = Revision::newFromId( $row->rev_id );
+               } else {
+                       $rev = false;
+               }
+               wfProfileOut( __METHOD__ );
+               return $rev;
+       }
+
+       /**
         * Returns user who last thanked current user. Requires Extension:Echo
         *
         * @return array|null
diff --git a/includes/specials/SpecialUserProfile.php 
b/includes/specials/SpecialUserProfile.php
index 08885aa..62f47e0 100644
--- a/includes/specials/SpecialUserProfile.php
+++ b/includes/specials/SpecialUserProfile.php
@@ -85,6 +85,27 @@
                return $html;
        }
 
+       protected function getLastEdit() {
+               wfProfileIn( __METHOD__ );
+               $rev = $this->userInfo->getLastEdit();
+               if ( $rev ) {
+                       $daysAgo = $this->getDaysAgo( new MWTimestamp( 
wfTimestamp( TS_UNIX, $rev->getTimestamp() ) ) );
+                       $html = Html::openElement( 'div', array( 'class' => 
'card' ) )
+                               . Html::openElement( 'div', array( 'class' => 
'container caption' ) )
+                               . $this->msg( 
'mobile-frontend-profile-last-edit',
+                                       $rev->getTitle(),
+                                       $daysAgo
+                               )->parse()
+                               . '</div>'
+                               . '</div>';
+               } else {
+                       $html = '';
+               }
+
+               wfProfileOut( __METHOD__ );
+               return $html;
+       }
+
        protected function getTalkLink() {
                // replace secondary icon
                $attrs = array(
@@ -165,7 +186,8 @@
                        if ( $this->targetUser->getId() ) {
                                // prepare content
                                $this->userInfo = new MobileUserInfo( 
$this->targetUser );
-                               $activityHtml = $this->getLastUpload() . 
$this->getLastThanks();
+                               $activityHtml = $this->getLastUpload() . 
$this->getLastThanks()
+                                       . $this->getLastEdit();
                                $html = Html::openElement( 'div', array( 
'class' => 'profile' ) )
                                        . Html::element( 'h1', array(), 
$this->targetUser->getName() )
                                        . $this->getUserSummary()

-- 
To view, visit https://gerrit.wikimedia.org/r/93514
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9cdff3803b490bc5e9efa37ef2d480e43f95d5d7
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to