Jdlrobson has submitted this change and it was merged.
Change subject: Watchlist with PageImages fixes
......................................................................
Watchlist with PageImages fixes
* Fix watchlist query for users without rollback
* Return thumbs to feed view
Change-Id: Ib70acf1eb100ca747679629bb156120f9031e613
---
M includes/specials/SpecialMobileWatchlist.php
1 file changed, 37 insertions(+), 23 deletions(-)
Approvals:
JGonera: Looks good to me, but someone else must approve
Jdlrobson: Verified; Looks good to me, approved
diff --git a/includes/specials/SpecialMobileWatchlist.php
b/includes/specials/SpecialMobileWatchlist.php
index 2db64ee..1b2af0b 100644
--- a/includes/specials/SpecialMobileWatchlist.php
+++ b/includes/specials/SpecialMobileWatchlist.php
@@ -56,17 +56,28 @@
* @param array $tables
* @param array $fields
* @param array $join_conds
+ * @param $baseTable
+ *
+ * @return void
*/
- protected function doPageImages( array &$tables, array &$fields, array
&$join_conds ) {
+ 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=page_id',
+ "pp_page=$idField",
'pp_propname' => 'page_image',
),
);
@@ -188,7 +199,7 @@
}
}
- $this->doPageImages( $tables, $fields, $join_conds );
+ $this->doPageImages( $tables, $fields, $join_conds,
'recentchanges' );
switch( $this->filter ) {
case 'all':
@@ -244,7 +255,7 @@
'ORDER BY' => 'wl_namespace, wl_title'
);
- $this->doPageImages( $tables, $fields, $joinConds );
+ $this->doPageImages( $tables, $fields, $joinConds, 'page' );
$options['LIMIT'] = self::LIMIT + 1; // add one to decide
whether to show the more button
@@ -364,7 +375,25 @@
return $this->getLanguage()->date( $ts, true );
}
- function showFeedResultRow( $row ) {
+ private function renderThumb( $row ) {
+ if ( $this->usePageImages && !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 ) {
+ return Html::element( 'div',
+ array(
+ 'class' => 'listThumb '
. ( $thumb->getWidth() > $thumb->getHeight() ? 'listThumbH' : 'listThumbV' ),
+ 'style' =>
'background-image: url("' . wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ) .
'")',
+ )
+ );
+ }
+ }
+ }
+ return '';
+ }
+
+ private function showFeedResultRow( $row ) {
$output = $this->getOutput();
$title = Title::makeTitle( $row->rc_namespace, $row->rc_title );
@@ -406,6 +435,7 @@
$output->addHtml(
'<li>' .
Html::openElement( 'a', array( 'href' => $diffLink,
'class' => 'title' ) ) .
+ $this->renderThumb( $row ) .
Html::element( 'h2', array(), $titleText ).
Html::element( 'div', array( 'class' => $usernameClass
), $username ).
Html::element( 'p', array( 'class' => 'mw-mf-comment'
), $comment ) .
@@ -415,7 +445,7 @@
);
}
- function showListResultRow( $row ) {
+ private function showListResultRow( $row ) {
$output = $this->getOutput();
$title = Title::makeTitle( $row->wl_namespace, $row->wl_title );
@@ -423,26 +453,10 @@
$ts = new MWTimestamp( $row->rev_timestamp );
$lastModified = wfMessage(
'mobile-frontend-watchlist-modified', $ts->getHumanTimestamp() )->text();
- $thumbHtml = '';
- if ( $this->usePageImages && !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 ) {
- $thumbHtml = Html::element( 'div',
- array(
- 'class' => 'listThumb '
. ( $thumb->getWidth() > $thumb->getHeight() ? 'listThumbH' : 'listThumbV' ),
- 'style' =>
'background-image: url("' . wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ) .
'")',
- )
- );
- }
- }
- }
-
$output->addHtml(
Html::openElement( 'li', array( 'title' => $titleText )
) .
Html::openElement( 'a', array( 'href' =>
$title->getLocalUrl(), 'class' => 'title' ) ) .
- $thumbHtml .
+ $this->renderThumb( $row ) .
Html::element( 'h2', array(), $titleText ).
Html::element( 'div', array( 'class' => 'mw-mf-time' ),
$lastModified ) .
Html::closeElement( 'a' ) .
--
To view, visit https://gerrit.wikimedia.org/r/50810
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib70acf1eb100ca747679629bb156120f9031e613
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits