Jdlrobson has uploaded a new change for review.

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


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/14/93514/1

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index d19745c..0e798cd 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -340,6 +340,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' => 'Member 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' => 'Member 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' => 'Member 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}}]].',
@@ -940,6 +941,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..08d76cf 100644
--- a/includes/MobileUserInfo.php
+++ b/includes/MobileUserInfo.php
@@ -116,6 +116,34 @@
        }
 
        /**
+        * Returns the last edit of the user.
+        *
+        * @return Revision|false
+        */
+       public function getLastEdit() {
+               $conds = array(
+                       'rev_user' => $this->user->getId(),
+               );
+               $options = array(
+                       'LIMIT' => 1,
+                       'ORDER BY' => 'rev_timestamp DESC',
+                       'USE INDEX' => 'page_timestamp',
+               );
+
+               $dbr = wfGetDB( DB_SLAVE, 'revision' );
+               wfProfileIn( __METHOD__ . '-query' );
+               $res = $dbr->select( 'revision', 'rev_id', $conds, __METHOD__, 
$options );
+               $row = $res->fetchRow();
+               if ( $row ) {
+                       $rev = Revision::newFromId( $row['rev_id'] );
+               } else {
+                       $rev = false;
+               }
+               wfProfileOut( __METHOD__ . '-query' );
+               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 a768792..19fae46 100644
--- a/includes/specials/SpecialUserProfile.php
+++ b/includes/specials/SpecialUserProfile.php
@@ -84,6 +84,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' => 
'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(
@@ -172,7 +193,7 @@
                                        . $this->getUserSummary()
                                        . $this->getTalkLink()
                                        . Html::element( 'h2', array(), 
'Activity & contributions' )
-                                       . $this->getLastUpload() . 
$this->getLastThanks()
+                                       . $this->getLastUpload() . 
$this->getLastThanks() . $this->getLastEdit()
                                        . $this->getUserFooterHtml()
                                        . Html::closeElement( 'div' );
                        } else {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9cdff3803b490bc5e9efa37ef2d480e43f95d5d7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to