Jdlrobson has uploaded a new change for review.

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


Change subject: Beta: Override Special:Contributions and Special:RecentChanges 
with mobile equivalents
......................................................................

Beta: Override Special:Contributions and Special:RecentChanges with mobile 
equivalents

Obviously more work is needed on both of these views before pushing to
stable but at least they render much more nicely in the mobile skin.

Change-Id: Ia00fc297e9687ad8c08c17ad1a0f4df1832f1125
---
M MobileFrontend.i18n.php
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
M includes/specials/SpecialHistory.php
M includes/specials/SpecialMobileContributions.php
5 files changed, 53 insertions(+), 42 deletions(-)


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

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 138c72e..f149165 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -83,6 +83,7 @@
        'mobile-frontend-history' => 'View edit history of this page.',
        'mobile-frontend-history-404-title' => 'Bad title given',
        'mobile-frontend-history-404-desc' => "Cannot look at history for a 
page that doesn't exist. It may have been deleted or you may have followed a 
bad link.",
+       'mobile-frontend-contribution-summary' => 'All edits made by 
[[Special:UserProfile/$1|$1]]',
        'mobile-frontend-history-summary' => 'Page history for [[:$1]]',
        'mobile-frontend-last-modified-date' => 'Last modified on $1, at $2',
        'mobile-frontend-last-modified-seconds' => 'Last modified 
{{PLURAL:$1|$1 second|$1 seconds}} ago',
@@ -492,6 +493,10 @@
 * {{msg-mw|Mobile-frontend-last-modified-date}}',
        'mobile-frontend-history-404-title' => 'Title of the 404 error page 
shown when navigate to [[Special:History/Title of page that does not exist]]',
        'mobile-frontend-history-404-desc' => 'Explain the reasons why the user 
may have arrived on {{msg-mw|mobile-frontend-history-404-title}}',
+       'mobile-frontend-contribution-summary' => 'Summary text that appears at 
the top of the Special:Contributions page for a given username.
+
+Parameters:
+* $1 - username',
        'mobile-frontend-history-summary' => 'Summary text that appears at the 
top of the mobile history page for a given page.
 
 Parameters:
diff --git a/MobileFrontend.php b/MobileFrontend.php
index be90685..d5834ed 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -70,6 +70,7 @@
        'SpecialMobileOptions' => 'specials/SpecialMobileOptions',
        'SpecialMobileMenu' => 'specials/SpecialMobileMenu',
        'SpecialMobileWatchlist' => 'specials/SpecialMobileWatchlist',
+       'SpecialMobileContributions' => 'specials/SpecialMobileContributions',
        'SpecialNearby' => 'specials/SpecialNearby',
        'SpecialMobileNotifications' => 'specials/SpecialMobileNotifications',
        'MobileSpecialPage' => 'specials/MobileSpecialPage',
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index d460e68..b08297a 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -277,6 +277,12 @@
                if ( $ctx->shouldDisplayMobileView() ) {
                        // Replace the standard watchlist view with our custom 
one
                        $list['Watchlist'] = 'SpecialMobileWatchlist';
+                       if ( $ctx->isBetaGroupMember() ) {
+                               // Replace Recent Changes with history view (no 
parameters)
+                               $list['RecentChanges'] = 'SpecialHistory';
+                               // Replace User contributions with history view 
(no parameters)
+                               $list['Contributions'] = 
'SpecialMobileContributions';
+                       }
                        // FIXME: Make uploads work on desktop
                        $list['Uploads'] = 'SpecialUploads';
                        $list['Userlogin'] = 'SpecialMobileUserlogin';
diff --git a/includes/specials/SpecialHistory.php 
b/includes/specials/SpecialHistory.php
index 7fc0224..59e6509 100644
--- a/includes/specials/SpecialHistory.php
+++ b/includes/specials/SpecialHistory.php
@@ -4,11 +4,46 @@
        const LIMIT = 50;
        protected $mode = 'beta';
 
+       /**  @var String name of the special page */
+       protected $specialPageName = 'History';
+
        /**  @var Title|null if no title passed */
        protected $title;
 
        public function __construct() {
-               parent::__construct( 'History' );
+               parent::__construct( $this->specialPageName );
+       }
+
+       /**
+        * Returns a list of query conditions that should be run against the 
revision table
+        *
+        * @return Array: List of conditions
+        */
+       protected function getQueryConditions() {
+               if ( $this->title ) {
+                       $conds = array(
+                               'rev_page' => $this->title->getArticleID(),
+                       );
+               } else {
+                       $conds = array();
+               }
+               return $conds;
+       }
+
+       /**
+        * Adds HTML to render a header at the top of the feed
+        * @param {string} msg: A message to print in the header bar (HTML or 
plain text)
+        *
+        * @return Array: List of conditions
+        */
+       protected function renderHeaderBar( $msg ) {
+               $this->getOutput()->addHtml(
+                       Html::openElement( 'div', array( 'class' => 
'page-header-bar' ) ) .
+                       Html::openElement( 'div' ) .
+                       $msg .
+                       Html::closeElement( 'div' ) .
+                       Html::closeElement( 'div' )
+               );
        }
 
        public function executeWhenAvailable( $par = '' ) {
@@ -20,13 +55,7 @@
                        // enter article history view
                        $this->title = Title::newFromText( $par );
                        if ( $this->title && $this->title->exists() ) {
-                               $out->addHtml(
-                                       Html::openElement( 'div', array( 
'class' => 'page-header-bar' ) ) .
-                                       Html::openElement( 'div' ) .
-                                       $this->msg( 
'mobile-frontend-history-summary', $this->title->getText() )->parse() .
-                                       Html::closeElement( 'div' ) .
-                                       Html::closeElement( 'div' )
-                               );
+                               $this->renderHeaderBar( $this->msg( 
'mobile-frontend-history-summary', $this->title->getText() )->parse() );
                        } else {
                                wfHttpError( 404, $this->msg( 
'mobile-frontend-history-404-title' )->text(),
                                        $this->msg( 
'mobile-frontend-history-404-desc' )->text() );
@@ -41,13 +70,7 @@
        protected function doQuery() {
                wfProfileIn( __METHOD__ );
                $table = 'revision';
-               if ( $this->title ) {
-                       $conds = array(
-                               'rev_page' => $this->title->getArticleID(),
-                       );
-               } else {
-                       $conds = array();
-               }
+               $conds = $this->getQueryConditions();
                $options = array(
                        'ORDER BY' => 'rev_timestamp DESC',
                        'USE INDEX' => 'page_timestamp',
diff --git a/includes/specials/SpecialMobileContributions.php 
b/includes/specials/SpecialMobileContributions.php
index fa124d5..00d86e3 100644
--- a/includes/specials/SpecialMobileContributions.php
+++ b/includes/specials/SpecialMobileContributions.php
@@ -10,22 +10,14 @@
                if ( $par ) {
                        // enter article history view
                        $this->user = User::newFromName( $par );
-                       $out->addHtml(
-                               Html::openElement( 'div', array( 'class' => 
'page-header-bar' ) ) .
-                               Html::openElement( 'div' ) .
-                               $this->msg( 
'mobile-frontend-contribution-summary', $this->user->getName() )->parse() .
-                               Html::closeElement( 'div' ) .
-                               Html::closeElement( 'div' )
-                       );
+                       $this->renderHeaderBar( $this->msg( 
'mobile-frontend-contribution-summary', $this->user->getName() )->parse() );
                }
                $res = $this->doQuery();
                $this->showHistory( $res );
                wfProfileOut( __METHOD__ );
        }
 
-       protected function doQuery() {
-               wfProfileIn( __METHOD__ );
-               $table = 'revision';
+       protected function getQueryConditions() {
                if ( $this->user ) {
                        $conds = array(
                                'rev_user' => $this->user->getID(),
@@ -33,22 +25,6 @@
                } else {
                        $conds = array();
                }
-               $options = array(
-                       'ORDER BY' => 'rev_timestamp DESC',
-                       'USE INDEX' => 'page_timestamp',
-               );
-
-               $options['LIMIT'] = self::LIMIT + 1;
-
-               $tables = array( $table );
-               $dbr = wfGetDB( DB_SLAVE, $table );
-               $fields = array( '*' );
-
-               wfProfileIn( __METHOD__ . '-query' );
-               $res = $dbr->select( $tables, $fields, $conds, __METHOD__, 
$options );
-               wfProfileOut( __METHOD__ . '-query' );
-
-               wfProfileOut( __METHOD__ );
-               return $res;
+               return $conds;
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia00fc297e9687ad8c08c17ad1a0f4df1832f1125
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