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

Change subject: Use Special:EditWatchlist for A-Z View
......................................................................


Use Special:EditWatchlist for A-Z View

Also show all the pages in the A-Z view. Desktop does it
so why don't we?

Change-Id: I2a92e6bfd76fd41c5efef6988a95dad2d7fae6e1
Dependency: Id04c8b1f41894c724ca8ea403078b3389666ebc9
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
M includes/MobilePage.php
A includes/specials/SpecialMobileEditWatchlist.php
M includes/specials/SpecialMobileWatchlist.php
5 files changed, 157 insertions(+), 252 deletions(-)

Approvals:
  MaxSem: Looks good to me, but someone else must approve
  Kaldari: Looks good to me, approved
  Jdlrobson: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/MobileFrontend.php b/MobileFrontend.php
index 825737b..d6c377a 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -73,6 +73,7 @@
        'SpecialMobileOptions' => 'specials/SpecialMobileOptions',
        'SpecialMobileMenu' => 'specials/SpecialMobileMenu',
        'SpecialMobileWatchlist' => 'specials/SpecialMobileWatchlist',
+       'SpecialMobileEditWatchlist' => 'specials/SpecialMobileEditWatchlist',
        'SpecialMobileContributions' => 'specials/SpecialMobileContributions',
        'SpecialNearby' => 'specials/SpecialNearby',
        'SpecialMobileLanguages' => 'specials/SpecialMobileLanguages',
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 4f942c3..28fbbb1 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -328,6 +328,7 @@
                if ( $ctx->shouldDisplayMobileView() ) {
                        // Replace the standard watchlist view with our custom 
one
                        $list['Watchlist'] = 'SpecialMobileWatchlist';
+                       $list['EditWatchlist'] = 'SpecialMobileEditWatchlist';
 
                        /* Special:MobileContributions redefines 
Special:History in
                         * such a way that for Special:Contributions/Foo, Foo 
is a
diff --git a/includes/MobilePage.php b/includes/MobilePage.php
index 78c2c6e..8ffa259 100644
--- a/includes/MobilePage.php
+++ b/includes/MobilePage.php
@@ -47,10 +47,12 @@
        /**
         * Get a placeholder div container for thumbnails
         * @param string $className
+        * @param string $iconClassName controls size of thumbnail, defaults to 
icon-32px
+        * @return string
         */
-       static function getPlaceHolderThumbnailHtml( $className ) {
+       public static function getPlaceHolderThumbnailHtml( $className, 
$iconClassName = 'icon-32px' ) {
                return Html::element( 'div', array(
-                       'class' => 'listThumb list-thumb-placeholder icon 
icon-32px ' . $className,
+                       'class' => 'listThumb list-thumb-placeholder icon ' . 
$iconClassName . ' ' . $className,
                ) );
        }
 
diff --git a/includes/specials/SpecialMobileEditWatchlist.php 
b/includes/specials/SpecialMobileEditWatchlist.php
new file mode 100644
index 0000000..6af62c3
--- /dev/null
+++ b/includes/specials/SpecialMobileEditWatchlist.php
@@ -0,0 +1,113 @@
+<?php
+/**
+ * Represents a mobile version of Special:EditWatchlist
+ */
+
+class SpecialMobileEditWatchlist extends SpecialEditWatchlist {
+       protected function outputSubtitle() {
+               $user = $this->getUser();
+               $this->getOutput()->addHtml( 
SpecialMobileWatchlist::getWatchlistHeader( $user ) );
+       }
+
+       /**
+        * @param Title $title
+        * @param int $ts
+        * @param string $thumb
+        * @return string
+        */
+       public static function getLineHtml( Title $title, $ts, $thumb ) {
+               wfProfileIn( __METHOD__ );
+               $titleText = $title->getPrefixedText();
+               if ( $ts ) {
+                       $ts = new MWTimestamp( $ts );
+                       $lastModified = wfMessage(
+                               'mobile-frontend-watchlist-modified',
+                               $ts->getHumanTimestamp()
+                       )->text();
+                       $className = 'title';
+               } else {
+                       $className = 'title new';
+                       $lastModified = '';
+               }
+
+               $html =
+                       Html::openElement( 'li', array(
+                               'class' => 'page-summary',
+                               'title' => $titleText,
+                               'data-id' => $title->getArticleId()
+                       ) ) .
+                       Html::openElement( 'a', array( 'href' => 
$title->getLocalUrl(), 'class' => $className ) );
+               $html .= $thumb;
+               $html .=
+                       Html::element( 'h3', array(), $titleText ).
+                       Html::element( 'div', array( 'class' => 'info' ), 
$lastModified ) .
+                       Html::closeElement( 'a' ) .
+                       Html::closeElement( 'li' );
+
+               wfProfileOut( __METHOD__ );
+               return $html;
+       }
+
+       public function execute( $par ) {
+               $out = $this->getOutput();
+               // turn off #content element
+               $out->setProperty( 'unstyledContent', true );
+               if( $this->getUser()->isAnon() ) {
+                       // No watchlist for you.
+                       $out->setPageTitle( $this->msg( 'watchnologin' ) );
+                       $out->setRobotPolicy( 'noindex,nofollow' );
+                       $out->addHTML( 
SpecialMobileWatchlist::getAnonBannerHtml( $this->getPageTitle() ) );
+               } else {
+                       parent::execute( $par );
+                       $out->setPageTitle( $this->msg( 'watchlist' ) );
+               }
+       }
+
+       protected function executeViewEditWatchlist() {
+               $html = '';
+               $total = 0;
+               $images = array();
+               $watchlist = $this->getWatchlistInfo();
+               if ( !MobileContext::singleton()->imagesDisabled() ) {
+                       wfRunHooks( 'SpecialMobileEditWatchlist::images', array(
+                                       $this->getContext(),
+                                       &$watchlist,
+                                       &$images
+                               )
+                       );
+               }
+               foreach ( $watchlist as $ns => $pages ) {
+                       if ( $ns === NS_MAIN ) {
+                               $html .= '<ul class="watchlist page-list 
thumbs">';
+                               foreach ( array_keys( $pages ) as $dbkey ) {
+                                       $title = Title::makeTitleSafe( $ns, 
$dbkey );
+                                       $thumb = '';
+                                       if ( isset( $images[$ns][$dbkey] ) ) {
+                                               $mobilePage = new MobilePage( 
$title, wfFindFile( $images[$ns][$dbkey] ) );
+                                               $thumb = 
$mobilePage->getSmallThumbnailHtml();
+                                       }
+                                       if ( !$thumb ) {
+                                               $thumb = 
MobilePage::getPlaceHolderThumbnailHtml( 'needsPhoto', 'icon-max-x' );
+                                       }
+                                       $total += 1;
+                                       $html .= self::getLineHtml( $title, 
$title->getTouched(), $thumb );
+                               }
+                               $html .= '</ul>';
+                       }
+               }
+               if ( $total === 0 ) {
+                       $html .= SpecialMobileWatchlist::getEmptyListHtml( 
false, $this->getLanguage() );
+               }
+               $out = $this->getOutput();
+               $out->addHtml( $html );
+               $out->addModules( 'skins.minerva.special.watchlist.scripts' );
+               $out->addModuleStyles(
+                       array(
+                               'skins.minerva.special.styles',
+                               'mobile.pagelist.styles',
+                               'mobile.special.pagefeed.styles',
+                               'mobile.special.watchlist.styles'
+                       )
+               );
+       }
+}
diff --git a/includes/specials/SpecialMobileWatchlist.php 
b/includes/specials/SpecialMobileWatchlist.php
index 9d5d5fc..96a7bac 100644
--- a/includes/specials/SpecialMobileWatchlist.php
+++ b/includes/specials/SpecialMobileWatchlist.php
@@ -42,17 +42,26 @@
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'watchnologin' ) );
                $out->setRobotPolicy( 'noindex,nofollow' );
+               $out->addHTML(
+                       self::getAnonBannerHtml( $this->getPageTitle() )
+               );
+       }
+
+       /**
+        * Get HTML representing a banner prompting you to login.
+        * @param Title $pageTitle
+        * @return string html
+        */
+       public static function getAnonBannerHtml( $pageTitle ) {
                $link = Linker::linkKnown(
                        SpecialPage::getTitleFor( 'Userlogin' ),
-                       $this->msg( 'loginreqlink' )->escaped(),
+                       wfMessage( 'loginreqlink' )->escaped(),
                        array(),
-                       array( 'returnto' => 
$this->getPageTitle()->getPrefixedText() )
+                       array( 'returnto' => $pageTitle->getPrefixedText() )
                );
-               $out->addHTML(
-                       Html::openElement( 'div', array( 'class' => 'alert 
warning' ) ) .
-                       $this->msg( 'watchlistanontext' )->rawParams( $link 
)->parse() .
-                       Html::closeElement( 'div' )
-               );
+               return Html::openElement( 'div', array( 'class' => 'alert 
warning' ) ) .
+                       wfMessage( 'watchlistanontext' )->rawParams( $link 
)->parse() .
+                               Html::closeElement( 'div' );
        }
 
        /**
@@ -96,10 +105,12 @@
 
                // This needs to be done before calling getWatchlistHeader
                $this->updateStickyTabs();
-
-               $output->addHtml( '<div class="content-header">' . 
$this->getWatchlistHeader() . '</div>' );
+               if ( $this->optionsChanged ) {
+                       $user->saveSettings();
+               }
 
                if ( $this->view === 'feed' ) {
+                       $output->addHtml( $this->getWatchlistHeader( $user ) );
                        $this->showRecentChangesHeader();
                        $res = $this->doFeedQuery();
 
@@ -109,17 +120,7 @@
                                $this->showEmptyList( true );
                        }
                } else {
-                       $this->filter = $this->getRequest()->getVal( 'filter', 
'articles' );
-                       $res = $this->doListQuery();
-                       if ( $res->numRows() ) {
-                               $this->showListResults( $res );
-                       } else {
-                               $this->showEmptyList( false );
-                       }
-               }
-
-               if ( $this->optionsChanged ) {
-                       $user->saveSettings();
+                       $output->redirect( SpecialPage::getTitleFor( 
'EditWatchlist' )->getLocalURL() );
                }
 
                wfProfileOut( __METHOD__ );
@@ -154,44 +155,11 @@
        }
 
        /**
-        * Add thumbs to a query, if installed and other preconditions are met
-        *
-        * @param array $tables
-        * @param array $fields
-        * @param array $join_conds
-        * @param $baseTable
-        *
-        * @return void
-        */
-       protected function doPageImages( array &$tables, array &$fields, array 
&$join_conds, $baseTable ) {
-               if ( !$this->usePageImages ) {
-                       return;
-               }
-               if ( $baseTable === 'page' ) {
-                       if ( !in_array( 'page', $tables ) ) {
-                               $tables[] = 'page';
-                       }
-                       $idField = 'page_id';
-               } else { // recentchanges
-                       $idField = 'rc_cur_id';
-               }
-               $tables[] = 'page_props';
-               $fields[] = 'pp_value';
-               $join_conds['page_props'] = array(
-                       'LEFT JOIN',
-                       array(
-                               "pp_page=$idField",
-                               'pp_propname' => 'page_image',
-                       ),
-               );
-       }
-
-       /**
         * Get the header for the watchlist page
+        * @param User user
         * @return string Parsed HTML
         */
-       protected function getWatchlistHeader() {
-               $user = $this->getUser();
+       public static function getWatchlistHeader( User $user ) {
                $sp = SpecialPage::getTitleFor( 'Watchlist' );
                $attrsList = $attrsFeed = array();
                $view = $user->getOption( 
SpecialMobileWatchlist::VIEW_OPTION_NAME, 'a-z' );
@@ -224,7 +192,7 @@
                        Html::closeElement( 'li' ) .
                        Html::closeElement( 'ul' );
 
-               return $html;
+               return '<div class="content-header">' . $html . '</div>';
        }
 
        /**
@@ -331,59 +299,6 @@
        }
 
        /**
-        * Get watchlist items for a-z view
-        * @return ResultWrapper
-        *
-        * @see doPageImages()
-        */
-       function doListQuery() {
-               wfProfileIn( __METHOD__ );
-
-               $user = $this->getUser();
-               $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
-
-               # Possible where conditions
-               $conds = $this->getNSConditions( 'wl_namespace' );
-               $conds['wl_user'] = $user->getId();
-               $tables = array( 'watchlist', 'page', 'revision' );
-               $fields = array(
-                       'wl_namespace','wl_title',
-                       // get the timestamp of the last change only
-                       'MAX(' . $dbr->tableName( 'revision' ) . 
'.rev_timestamp) AS rev_timestamp'
-               );
-               $joinConds = array(
-                       'page' => array( 'LEFT JOIN', array(
-                               'wl_namespace = page_namespace',
-                               'wl_title = page_title'
-                       )       ),
-                       'revision' => array( 'LEFT JOIN', array(
-                               'page_id = rev_page'
-                       ) )
-               );
-               $options = array(
-                       'GROUP BY' => 'wl_namespace, wl_title',
-                       'ORDER BY' => 'wl_namespace, wl_title'
-               );
-
-               $this->doPageImages( $tables, $fields, $joinConds, 'page' );
-
-               $options['LIMIT'] = self::LIMIT + 1; // add one to decide 
whether to show the more button
-
-               if ( $this->fromPageTitle ) {
-                       $ns = $this->fromPageTitle->getNamespace();
-                       $titleQuoted = $dbr->addQuotes( 
$this->fromPageTitle->getDBkey() );
-                       $conds[] = "wl_namespace > $ns OR (wl_namespace = $ns 
AND wl_title >= $titleQuoted)";
-               }
-
-               wfProfileIn( __METHOD__ . '-query' );
-               $res = $dbr->select( $tables, $fields, $conds, __METHOD__, 
$options, $joinConds );
-               wfProfileOut( __METHOD__ . '-query' );
-
-               wfProfileOut( __METHOD__ );
-               return $res;
-       }
-
-       /**
         * Show results of doFeedQuery
         * @param ResultWrapper $res ResultWrapper returned from db
         *
@@ -391,21 +306,6 @@
         */
        protected function showFeedResults( ResultWrapper $res ) {
                $this->showResults( $res, true );
-       }
-
-       /**
-        * Show results of doListQuery after an ul element added
-        * @param ResultWrapper $res ResultWrapper returned from db
-        *
-        * @see showResults()
-        */
-       protected function showListResults( ResultWrapper $res ) {
-               $output = $this->getOutput();
-               $output->addHtml(
-                       Html::openElement( 'ul', array( 'class' => 'watchlist ' 
. 'page-list thumbs' ) )
-               );
-
-               $this->showResults( $res, false );
        }
 
        /**
@@ -420,44 +320,13 @@
 
                $output = $this->getOutput();
 
-               $lookahead = 1;
-               $fromTitle = false;
-
                if ( $feed ) {
                        foreach( $res as $row ) {
                                $this->showFeedResultRow( $row );
                        }
-               } else {
-                       foreach( $res as $row ) {
-                               if ( $lookahead <= self::LIMIT ) {
-                                       $this->showListResultRow( $row );
-                               } else {
-                                       $fromTitle = Title::makeTitle( 
$row->wl_namespace, $row->wl_title );
-                               }
-                               $lookahead++;
-                       }
                }
 
                $output->addHtml( '</ul>' );
-
-               if ( $fromTitle !== false ) {
-                       $output->addHtml(
-                               Html::openElement( 'a',
-                                       array(
-                                               'href' => 
SpecialPage::getTitleFor( 'Watchlist' )->
-                                                       getLocalUrl(
-                                                               array(
-                                                                       'from' 
=> $fromTitle->getPrefixedText(),
-                                                                       
'filter' => $this->filter,
-                                                               )
-                                                       ),
-                                               'class' => 'more',
-                                       )
-                               ) .
-                               wfMessage( 'mobile-frontend-watchlist-more' 
)->escaped() .
-                               Html::closeElement( 'a' )
-                       );
-               }
 
                wfProfileOut( __METHOD__ );
        }
@@ -467,9 +336,19 @@
         * @param boolean $feed Render as feed (true) or list (false) view?
         */
        function showEmptyList( $feed ) {
+               $this->getOutput()->addHtml( self::getEmptyListHtml( $feed, 
$this->getLanguage() ) );
+       }
+
+       /**
+        * Get the HTML needed to show if a user doesn't watch any page, show 
information
+        * how to watch pages where no pages have been watched.
+        * @param boolean $feed Render as feed (true) or list (false) view?
+        * @param Language $lang The language of the current mode
+        * @return string
+        */
+       public static function getEmptyListHtml( $feed, $lang ) {
                global $wgExtensionAssetsPath;
-               $output = $this->getOutput();
-               $dir = $this->getLanguage()->isRTL() ? 'rtl' : 'ltr';
+               $dir = $lang->isRTL() ? 'rtl' : 'ltr';
 
                $imgUrl = $wgExtensionAssetsPath . 
"/MobileFrontend/images/emptywatchlist-page-actions-$dir.png";
 
@@ -485,62 +364,13 @@
                        ) );
                }
 
-               $output->addHtml(
-                       Html::openElement( 'div', array( 'class' => 'info 
empty-page' ) ) .
+               return Html::openElement( 'div', array( 'class' => 'info 
empty-page' ) ) .
                                $msg .
                                Html::element( 'a',
                                        array( 'class' => 'button', 'href' => 
Title::newMainPage()->getLocalUrl() ),
                                        wfMessage( 
'mobile-frontend-watchlist-back-home' )->plain()
                                ) .
-                               Html::closeElement( 'div' )
-               );
-       }
-
-       /**
-        * Render a thumbnail returned from db as PageImage or a needsPhoto 
placeholder to add a picture
-        * @param object $row a row of the returned db result
-        * @return array
-        *
-        * @todo FIXME: Refactor to use MobilePage
-        */
-       private function renderThumb( $row ) {
-               wfProfileIn( __METHOD__ );
-
-               if ( $this->usePageImages ) {
-                       $needsPhoto = true;
-                       $props = array(
-                               'class' => 'listThumb needsPhoto icon 
icon-max-x',
-                       );
-                       if ( !is_null( $row->pp_value ) ) {
-                               $file = wfFindFile( $row->pp_value );
-                               if ( $file ) {
-                                       $thumb = $file->transform( array(
-                                               'width' => self::THUMB_SIZE,
-                                               'height' => self::THUMB_SIZE )
-                                       );
-
-                                       if ( $thumb ) {
-                                               $needsPhoto = false;
-                                               $props = array(
-                                                       'class' => 'listThumb ' 
. ( $thumb->getWidth() > $thumb->getHeight()
-                                                               ? 'icon 
icon-max-y'
-                                                               : 'icon 
icon-max-x' ),
-                                                       'style' => 
'background-image: url("' .
-                                                               wfExpandUrl( 
$thumb->getUrl(), PROTO_CURRENT ) . '")',
-                                               );
-                                       }
-                               }
-                       }
-                       return array(
-                               'html' => Html::element( 'div', $props ),
-                               'needsPhoto' => $needsPhoto,
-                       );
-               }
-
-               wfProfileOut( __METHOD__ );
-               return array(
-                       'html' => '',
-               );
+                               Html::closeElement( 'div' );
        }
 
        /**
@@ -582,48 +412,6 @@
 
                $this->renderFeedItemHtml( $ts, $diffLink, $username, $comment, 
$title, $isAnon, $bytes,
                        $isMinor );
-               wfProfileOut( __METHOD__ );
-       }
-
-       /**
-        * Render a result row in list view
-        * @param object $row a row of db result
-        */
-       protected function showListResultRow( $row ) {
-               wfProfileIn( __METHOD__ );
-
-               $output = $this->getOutput();
-               $title = Title::makeTitle( $row->wl_namespace, $row->wl_title );
-               $titleText = $title->getPrefixedText();
-               $ts = $row->rev_timestamp;
-               if ( $ts ) {
-                       $ts = new MWTimestamp( $ts );
-                       $lastModified = wfMessage(
-                               'mobile-frontend-watchlist-modified',
-                               $ts->getHumanTimestamp()
-                       )->text();
-                       $className = 'title';
-               } else {
-                       $className = 'title new';
-                       $lastModified = '';
-               }
-
-               $thumb = $this->renderThumb( $row );
-
-               $output->addHtml(
-                       Html::openElement( 'li', array(
-                               'class' => 'page-summary',
-                               'title' => $titleText,
-                               'data-id' => $title->getArticleId()
-                       ) ) .
-                       Html::openElement( 'a', array( 'href' => 
$title->getLocalUrl(), 'class' => $className ) ) .
-                       $thumb['html'] .
-                       Html::element( 'h3', array(), $titleText ).
-                       Html::element( 'div', array( 'class' => 'info' ), 
$lastModified ) .
-                       Html::closeElement( 'a' ) .
-                       Html::closeElement( 'li' )
-               );
-
                wfProfileOut( __METHOD__ );
        }
 

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

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

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

Reply via email to