wiki.techinc.nl/includes/specials/SpecialRecentchanges.php

958 lines
28 KiB
PHP
Raw Normal View History

<?php
2010-06-21 12:59:04 +00:00
/**
* Implements Special:Recentchanges
2010-06-21 12:59:04 +00:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2010-06-21 12:59:04 +00:00
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup SpecialPage
2010-06-21 12:59:04 +00:00
*/
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
/**
* A special page that lists last changes made to the wiki
*
* @ingroup SpecialPage
*/
class SpecialRecentChanges extends ChangesListSpecialPage {
protected static $savedQueriesPreferenceName = 'rcfilters-saved-queries';
protected static $daysPreferenceName = 'rcdays'; // Use general RecentChanges preference
protected static $limitPreferenceName = 'rcfilters-limit'; // Use RCFilters-specific preference
protected static $collapsedPreferenceName = 'rcfilters-rc-collapsed';
private $watchlistFilterGroupDefinition;
public function __construct( $name = 'Recentchanges', $restriction = '' ) {
parent::__construct( $name, $restriction );
$this->watchlistFilterGroupDefinition = [
'name' => 'watchlist',
'title' => 'rcfilters-filtergroup-watchlist',
'class' => ChangesListStringOptionsFilterGroup::class,
'priority' => -9,
'isFullCoverage' => true,
'filters' => [
[
'name' => 'watched',
'label' => 'rcfilters-filter-watchlist-watched-label',
'description' => 'rcfilters-filter-watchlist-watched-description',
'cssClassSuffix' => 'watched',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
return $rc->getAttribute( 'wl_user' );
}
],
[
'name' => 'watchednew',
'label' => 'rcfilters-filter-watchlist-watchednew-label',
'description' => 'rcfilters-filter-watchlist-watchednew-description',
'cssClassSuffix' => 'watchednew',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
return $rc->getAttribute( 'wl_user' ) &&
$rc->getAttribute( 'rc_timestamp' ) &&
$rc->getAttribute( 'wl_notificationtimestamp' ) &&
$rc->getAttribute( 'rc_timestamp' ) >= $rc->getAttribute( 'wl_notificationtimestamp' );
},
],
[
'name' => 'notwatched',
'label' => 'rcfilters-filter-watchlist-notwatched-label',
'description' => 'rcfilters-filter-watchlist-notwatched-description',
'cssClassSuffix' => 'notwatched',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
return $rc->getAttribute( 'wl_user' ) === null;
},
]
],
'default' => ChangesListStringOptionsFilterGroup::NONE,
'queryCallable' => function ( $specialPageClassName, $context, $dbr,
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedValues ) {
sort( $selectedValues );
$notwatchedCond = 'wl_user IS NULL';
$watchedCond = 'wl_user IS NOT NULL';
$newCond = 'rc_timestamp >= wl_notificationtimestamp';
if ( $selectedValues === [ 'notwatched' ] ) {
$conds[] = $notwatchedCond;
return;
}
if ( $selectedValues === [ 'watched' ] ) {
$conds[] = $watchedCond;
return;
}
if ( $selectedValues === [ 'watchednew' ] ) {
$conds[] = $dbr->makeList( [
$watchedCond,
$newCond
], LIST_AND );
return;
}
if ( $selectedValues === [ 'notwatched', 'watched' ] ) {
// no filters
return;
}
if ( $selectedValues === [ 'notwatched', 'watchednew' ] ) {
$conds[] = $dbr->makeList( [
$notwatchedCond,
$dbr->makeList( [
$watchedCond,
$newCond
], LIST_AND )
], LIST_OR );
return;
}
if ( $selectedValues === [ 'watched', 'watchednew' ] ) {
$conds[] = $watchedCond;
return;
}
if ( $selectedValues === [ 'notwatched', 'watched', 'watchednew' ] ) {
// no filters
return;
}
}
];
}
/**
* Main execution point
*
* @param string $subpage
*/
public function execute( $subpage ) {
// Backwards-compatibility: redirect to new feed URLs
$feedFormat = $this->getRequest()->getVal( 'feed' );
if ( !$this->including() && $feedFormat ) {
$query = $this->getFeedQuery();
$query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss';
$this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
return;
}
// 10 seconds server-side caching max
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
$out = $this->getOutput();
$out->setCdnMaxage( 10 );
// Check if the client has a cached version
$lastmod = $this->checkLastModified();
if ( $lastmod === false ) {
return;
}
$this->addHelpLink(
'//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
true
);
parent::execute( $subpage );
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
}
/**
* @inheritDoc
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
*/
protected function transformFilterDefinition( array $filterDefinition ) {
if ( isset( $filterDefinition['showHideSuffix'] ) ) {
$filterDefinition['showHide'] = 'rc' . $filterDefinition['showHideSuffix'];
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
}
return $filterDefinition;
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
}
/**
* @inheritDoc
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
*/
protected function registerFilters() {
parent::registerFilters();
if (
!$this->including() &&
$this->getUser()->isLoggedIn() &&
$this->getUser()->isAllowed( 'viewmywatchlist' )
) {
$this->registerFiltersFromDefinitions( [ $this->watchlistFilterGroupDefinition ] );
$watchlistGroup = $this->getFilterGroup( 'watchlist' );
$watchlistGroup->getFilter( 'watched' )->setAsSupersetOf(
$watchlistGroup->getFilter( 'watchednew' )
);
}
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
$user = $this->getUser();
$significance = $this->getFilterGroup( 'significance' );
$hideMinor = $significance->getFilter( 'hideminor' );
$hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
$automated = $this->getFilterGroup( 'automated' );
$hideBots = $automated->getFilter( 'hidebots' );
$hideBots->setDefault( true );
$reviewStatus = $this->getFilterGroup( 'reviewStatus' );
if ( $reviewStatus !== null ) {
// Conditional on feature being available and rights
if ( $user->getBoolOption( 'hidepatrolled' ) ) {
$reviewStatus->setDefault( 'unpatrolled' );
$legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
$legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
$legacyHidePatrolled->setDefault( true );
}
}
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
$changeType = $this->getFilterGroup( 'changeType' );
$hideCategorization = $changeType->getFilter( 'hidecategorization' );
if ( $hideCategorization !== null ) {
// Conditional on feature being available
$hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
}
2005-05-04 21:56:14 +00:00
}
/**
* Get all custom filters
*
* @return array Map of filter URL param names to properties (msg/default)
*/
protected function getCustomFilters() {
if ( $this->customFilters === null ) {
$this->customFilters = parent::getCustomFilters();
Hooks::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters ], '1.23' );
}
return $this->customFilters;
}
/**
* Process $par and put options found in $opts. Used when including the page.
*
* @param string $par
* @param FormOptions $opts
*/
public function parseParameters( $par, FormOptions $opts ) {
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
parent::parseParameters( $par, $opts );
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
foreach ( $bits as $bit ) {
if ( is_numeric( $bit ) ) {
$opts['limit'] = $bit;
2011-05-09 22:57:44 +00:00
}
$m = [];
if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
2011-05-09 22:57:44 +00:00
$opts['limit'] = $m[1];
}
if ( preg_match( '/^days=(\d+(?:\.\d+)?)$/', $bit, $m ) ) {
2011-05-09 22:57:44 +00:00
$opts['days'] = $m[1];
}
if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) {
$opts['namespace'] = $m[1];
}
if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
$opts['tagfilter'] = $m[1];
}
}
}
/**
* @inheritDoc
*/
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
protected function doMainQuery( $tables, $fields, $conds, $query_options,
$join_conds, FormOptions $opts
) {
$dbr = $this->getDB();
$user = $this->getUser();
$rcQuery = RecentChange::getQueryInfo();
$tables = array_merge( $tables, $rcQuery['tables'] );
$fields = array_merge( $rcQuery['fields'], $fields );
$join_conds = array_merge( $join_conds, $rcQuery['joins'] );
// JOIN on watchlist for users
if ( $user->isLoggedIn() && $user->isAllowed( 'viewmywatchlist' ) ) {
$tables[] = 'watchlist';
$fields[] = 'wl_user';
$fields[] = 'wl_notificationtimestamp';
$join_conds['watchlist'] = [ 'LEFT JOIN', [
'wl_user' => $user->getId(),
'wl_title=rc_title',
'wl_namespace=rc_namespace'
] ];
}
// JOIN on page, used for 'last revision' filter highlight
$tables[] = 'page';
$fields[] = 'page_latest';
$join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
$tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : [];
ChangeTags::modifyDisplayQuery(
$tables,
$fields,
$conds,
$join_conds,
$query_options,
$tagFilter
);
if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
$opts )
) {
return false;
}
if ( $this->areFiltersInConflict() ) {
return false;
}
$orderByAndLimit = [
'ORDER BY' => 'rc_timestamp DESC',
'LIMIT' => $opts['limit']
];
if ( in_array( 'DISTINCT', $query_options ) ) {
// ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
// In order to prevent DISTINCT from causing query performance problems,
// we have to GROUP BY the primary key. This in turn requires us to add
// the primary key to the end of the ORDER BY, and the old ORDER BY to the
// start of the GROUP BY
$orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
$orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
}
// array_merge() is used intentionally here so that hooks can, should
// they so desire, override the ORDER BY / LIMIT condition(s); prior to
// MediaWiki 1.26 this used to use the plus operator instead, which meant
// that extensions weren't able to change these conditions
$query_options = array_merge( $orderByAndLimit, $query_options );
$rows = $dbr->select(
$tables,
$fields,
// rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
// knowledge to use an index merge if it wants (it may use some other index though).
$conds + [ 'rc_new' => [ 0, 1 ] ],
__METHOD__,
$query_options,
$join_conds
);
return $rows;
}
protected function runMainQueryHook( &$tables, &$fields, &$conds,
&$query_options, &$join_conds, $opts
) {
return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
&& Hooks::run(
'SpecialRecentChangesQuery',
[ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
'1.23'
);
}
protected function getDB() {
return wfGetDB( DB_REPLICA, 'recentchanges' );
}
public function outputFeedLinks() {
$this->addFeedLinks( $this->getFeedQuery() );
}
/**
* Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
*
* @return array
*/
protected function getFeedQuery() {
$query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
// API handles empty parameters in a different way
return $value !== '';
} );
$query['action'] = 'feedrecentchanges';
$feedLimit = $this->getConfig()->get( 'FeedLimit' );
if ( $query['limit'] > $feedLimit ) {
$query['limit'] = $feedLimit;
}
return $query;
}
/**
* Build and output the actual changes list.
*
* @param IResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function outputChangesList( $rows, $opts ) {
$limit = $opts['limit'];
$showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
&& $this->getUser()->getOption( 'shownumberswatching' );
$watcherCache = [];
$counter = 1;
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
$list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
$list->initChangesListRows( $rows );
$userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
$rclistOutput = $list->beginRecentChangesList();
if ( $this->isStructuredFilterUiEnabled() ) {
$rclistOutput .= $this->makeLegend();
}
foreach ( $rows as $obj ) {
if ( $limit == 0 ) {
2011-05-09 22:57:44 +00:00
break;
}
$rc = RecentChange::newFromRow( $obj );
# Skip CatWatch entries for hidden cats based on user preference
if (
$rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
!$userShowHiddenCats &&
$rc->getParam( 'hidden-cat' )
) {
continue;
}
$rc->counter = $counter++;
2008-12-20 08:36:14 +00:00
# Check if the page has been updated since the last visit
if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
&& !empty( $obj->wl_notificationtimestamp )
) {
2011-05-09 22:57:44 +00:00
$rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
2008-12-20 08:36:14 +00:00
} else {
$rc->notificationtimestamp = false; // Default
}
2008-12-20 08:36:14 +00:00
# Check the number of users watching the page
$rc->numberofWatchingusers = 0; // Default
if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
$watcherCache[$obj->rc_namespace][$obj->rc_title] =
MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(
new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
2011-05-09 22:57:44 +00:00
);
}
$rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
}
$changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
if ( $changeLine !== false ) {
$rclistOutput .= $changeLine;
--$limit;
}
2003-04-14 23:10:40 +00:00
}
$rclistOutput .= $list->endRecentChangesList();
if ( $rows->numRows() === 0 ) {
$this->outputNoResults();
if ( !$this->including() ) {
$this->getOutput()->setStatusCode( 404 );
}
} else {
$this->getOutput()->addHTML( $rclistOutput );
}
2003-04-14 23:10:40 +00:00
}
/**
* Set the text to be displayed above the changes
*
* @param FormOptions $opts
* @param int $numRows Number of rows in the result to show after this header
*/
public function doHeader( $opts, $numRows ) {
$this->setTopText( $opts );
$defaults = $opts->getAllValues();
$nondefaults = $opts->getChangedValues();
$panel = [];
if ( !$this->isStructuredFilterUiEnabled() ) {
$panel[] = $this->makeLegend();
}
$panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
$panel[] = '<hr />';
$extraOpts = $this->getExtraOptions( $opts );
$extraOptsCount = count( $extraOpts );
$count = 0;
$submit = ' ' . Xml::submitButton( $this->msg( 'recentchanges-submit' )->text() );
$out = Xml::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
foreach ( $extraOpts as $name => $optionRow ) {
# Add submit button to the last row only
++$count;
$addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
$out .= Xml::openElement( 'tr', [ 'class' => $name . 'Form' ] );
if ( is_array( $optionRow ) ) {
$out .= Xml::tags(
'td',
[ 'class' => 'mw-label mw-' . $name . '-label' ],
$optionRow[0]
);
$out .= Xml::tags(
'td',
[ 'class' => 'mw-input' ],
$optionRow[1] . $addSubmit
);
} else {
$out .= Xml::tags(
'td',
[ 'class' => 'mw-input', 'colspan' => 2 ],
$optionRow . $addSubmit
);
}
$out .= Xml::closeElement( 'tr' );
}
$out .= Xml::closeElement( 'table' );
$unconsumed = $opts->getUnconsumedValues();
foreach ( $unconsumed as $key => $value ) {
2010-10-31 16:33:48 +00:00
$out .= Html::hidden( $key, $value );
}
$t = $this->getPageTitle();
2010-10-31 16:33:48 +00:00
$out .= Html::hidden( 'title', $t->getPrefixedText() );
$form = Xml::tags( 'form', [ 'action' => wfScript() ], $out );
$panel[] = $form;
$panelString = implode( "\n", $panel );
$rcoptions = Xml::fieldset(
$this->msg( 'recentchanges-legend' )->text(),
$panelString,
[ 'class' => 'rcoptions cloptions' ]
);
// Insert a placeholder for RCFilters
if ( $this->isStructuredFilterUiEnabled() ) {
$rcfilterContainer = Html::element(
'div',
[ 'class' => 'rcfilters-container' ]
);
$loadingContainer = Html::rawElement(
'div',
[ 'class' => 'rcfilters-spinner' ],
Html::element(
'div',
[ 'class' => 'rcfilters-spinner-bounce' ]
)
);
// Wrap both with rcfilters-head
$this->getOutput()->addHTML(
Html::rawElement(
'div',
[ 'class' => 'rcfilters-head' ],
$rcfilterContainer . $rcoptions
)
);
// Add spinner
$this->getOutput()->addHTML( $loadingContainer );
} else {
$this->getOutput()->addHTML( $rcoptions );
}
$this->setBottomText( $opts );
}
/**
* Send the text to be displayed above the options
*
* @param FormOptions $opts Unused
*/
function setTopText( FormOptions $opts ) {
global $wgContLang;
$message = $this->msg( 'recentchangestext' )->inContentLanguage();
if ( !$message->isDisabled() ) {
// Parse the message in this weird ugly way to preserve the ability to include interlanguage
// links in it (T172461). In the future when T66969 is resolved, perhaps we can just use
// $message->parse() instead. This code is copied from Message::parseText().
$parserOutput = MessageCache::singleton()->parse(
$message->plain(),
$this->getPageTitle(),
/*linestart*/true,
// Message class sets the interface flag to false when parsing in a language different than
// user language, and this is wiki content language
/*interface*/false,
$wgContLang
);
$content = $parserOutput->getText( [
'enableSectionEditLinks' => false,
] );
// Add only metadata here (including the language links), text is added below
$this->getOutput()->addParserOutputMetadata( $parserOutput );
$langAttributes = [
'lang' => $wgContLang->getHtmlCode(),
'dir' => $wgContLang->getDir(),
];
$topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
if ( $this->isStructuredFilterUiEnabled() ) {
// Check whether the widget is already collapsed or expanded
$collapsedState = $this->getRequest()->getCookie( 'rcfilters-toplinks-collapsed-state' );
// Note that an empty/unset cookie means collapsed, so check for !== 'expanded'
$topLinksAttributes[ 'class' ] .= $collapsedState !== 'expanded' ?
' mw-recentchanges-toplinks-collapsed' : '';
$this->getOutput()->enableOOUI();
$contentTitle = new OOUI\ButtonWidget( [
'classes' => [ 'mw-recentchanges-toplinks-title' ],
'label' => new OOUI\HtmlSnippet( $this->msg( 'rcfilters-other-review-tools' )->parse() ),
'framed' => false,
'indicator' => $collapsedState !== 'expanded' ? 'down' : 'up',
'flags' => [ 'progressive' ],
] );
$contentWrapper = Html::rawElement( 'div',
array_merge(
[ 'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content' ],
$langAttributes
),
$content
);
$content = $contentTitle . $contentWrapper;
} else {
// Language direction should be on the top div only
// if the title is not there. If it is there, it's
// interface direction, and the language/dir attributes
// should be on the content itself
$topLinksAttributes = array_merge( $topLinksAttributes, $langAttributes );
}
$this->getOutput()->addHTML(
Html::rawElement( 'div', $topLinksAttributes, $content )
);
}
}
/**
* Get options to be displayed in a form
*
* @param FormOptions $opts
* @return array
*/
2011-05-09 22:57:44 +00:00
function getExtraOptions( $opts ) {
$opts->consumeValues( [
'namespace', 'invert', 'associated', 'tagfilter'
] );
$extraOpts = [];
$extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
$tagFilter = ChangeTags::buildTagFilterSelector(
$opts['tagfilter'], false, $this->getContext() );
2011-05-09 22:57:44 +00:00
if ( count( $tagFilter ) ) {
$extraOpts['tagfilter'] = $tagFilter;
2011-05-09 22:57:44 +00:00
}
// Don't fire the hook for subclasses. (Or should we?)
if ( $this->getName() === 'Recentchanges' ) {
Hooks::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
}
return $extraOpts;
}
/**
* Add page-specific modules.
*/
protected function addModules() {
parent::addModules();
$out = $this->getOutput();
$out->addModules( 'mediawiki.special.recentchanges' );
}
/**
* Get last modified date, for client caching
* Don't use this if we are using the patrol feature, patrol changes don't
* update the timestamp
*
* @return string|bool
*/
public function checkLastModified() {
$dbr = $this->getDB();
$lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ );
return $lastmod;
}
/**
* Creates the choose namespace selection
*
* @param FormOptions $opts
* @return string
*/
protected function namespaceFilterForm( FormOptions $opts ) {
$nsSelect = Html::namespaceSelector(
[ 'selected' => $opts['namespace'], 'all' => '' ],
[ 'name' => 'namespace', 'id' => 'namespace' ]
);
$nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
$invert = Xml::checkLabel(
$this->msg( 'invert' )->text(), 'invert', 'nsinvert',
$opts['invert'],
[ 'title' => $this->msg( 'tooltip-invert' )->text() ]
);
2011-05-09 22:57:44 +00:00
$associated = Xml::checkLabel(
$this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
$opts['associated'],
[ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
2011-05-09 22:57:44 +00:00
);
return [ $nsLabel, "$nsSelect $invert $associated" ];
}
/**
* Filter $rows by categories set in $opts
*
* @deprecated since 1.31
*
* @param IResultWrapper &$rows Database rows
* @param FormOptions $opts
*/
function filterByCategories( &$rows, FormOptions $opts ) {
wfDeprecated( __METHOD__, '1.31' );
$categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
if ( !count( $categories ) ) {
return;
}
# Filter categories
$cats = [];
foreach ( $categories as $cat ) {
$cat = trim( $cat );
if ( $cat == '' ) {
2011-05-09 22:57:44 +00:00
continue;
}
$cats[] = $cat;
}
# Filter articles
$articles = [];
$a2r = [];
$rowsarr = [];
foreach ( $rows as $k => $r ) {
$nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
$id = $nt->getArticleID();
if ( $id == 0 ) {
2011-05-09 22:57:44 +00:00
continue; # Page might have been deleted...
}
if ( !in_array( $id, $articles ) ) {
$articles[] = $id;
}
if ( !isset( $a2r[$id] ) ) {
$a2r[$id] = [];
}
$a2r[$id][] = $k;
$rowsarr[$k] = $r;
}
# Shortcut?
if ( !count( $articles ) || !count( $cats ) ) {
2011-05-09 22:57:44 +00:00
return;
}
# Look up
$catFind = new CategoryFinder;
$catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
$match = $catFind->run();
# Filter
$newrows = [];
foreach ( $match as $id ) {
foreach ( $a2r[$id] as $rev ) {
$k = $rev;
$newrows[$k] = $rowsarr[$k];
}
}
$rows = new FakeResultWrapper( array_values( $newrows ) );
}
2003-04-14 23:10:40 +00:00
/**
* Makes change an option link which carries all the other options
2010-07-03 21:09:25 +00:00
*
* @param string $title
* @param array $override Options to override
* @param array $options Current options
* @param bool $active Whether to show the link in bold
2012-02-09 21:36:14 +00:00
* @return string
*/
function makeOptionsLink( $title, $override, $options, $active = false ) {
$params = $this->convertParamsForLink( $override + $options );
if ( $active ) {
$title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
}
return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [
'data-params' => json_encode( $override ),
'data-keys' => implode( ',', array_keys( $override ) ),
], $params );
}
/**
* Creates the options panel.
2010-07-03 21:09:25 +00:00
*
* @param array $defaults
* @param array $nondefaults
* @param int $numRows Number of rows in the result to show after this header
2012-02-09 21:36:14 +00:00
* @return string
*/
function optionsPanel( $defaults, $nondefaults, $numRows ) {
$options = $nondefaults + $defaults;
$note = '';
$msg = $this->msg( 'rclegend' );
if ( !$msg->isDisabled() ) {
$note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
}
$lang = $this->getLanguage();
$user = $this->getUser();
Enable users to watch category membership changes #2 This is part of a chain that reverts: e412ff5ecc900991cce4f99b7a069f625a5694b3. NOTE: - The feature is disabled by default - User settings default to hiding changes - T109707 Touching a file on wikisource adds and removes it from a category... Even when page has no changes.... WTF? See linked issue, marked as stalled with a possible way forward for this patch. @see https://gerrit.wikimedia.org/r/#/c/235467/ Changes since version 1: - T109604 - Page names in comment are no longer url encoded / have _'s - T109638 & T110338 - Reserved username now used when we can't determine a username for the change (we could perhaps set the user and id to be blank in the RC table, but who knows what this might do) - T109688 - History links are now disabled in RC.... (could be fine for the introduction and worked on more in the future) - Categorization changes are now always patrolled - Touching on T109672 in this change emails will never be sent regarding categorization changes. (this can of course be changed in a followup) - Added $wgRCWatchCategoryMembership defaulting to true for enabling / disabling the feature - T109700 - for cases when no revision was retrieved for a category change set the bot flag to true. This means all changes caused by parser functions & Lua will be marked as bot, as will changes that cant find their revision due to slave lag.. Bug: T9148 Bug: T109604 Bug: T109638 Bug: T109688 Bug: T109700 Bug: T110338 Bug: T110340 Change-Id: I51c2c1254de862f24a26ef9dbbf027c6c83e9063
2015-08-24 17:40:06 +00:00
$config = $this->getConfig();
if ( $options['from'] ) {
$resetLink = $this->makeOptionsLink( $this->msg( 'rclistfromreset' ),
[ 'from' => '' ], $nondefaults );
$noteFromMsg = $this->msg( 'rcnotefrom' )
->numParams( $options['limit'] )
->params(
$lang->userTimeAndDate( $options['from'], $user ),
$lang->userDate( $options['from'], $user ),
$lang->userTime( $options['from'], $user )
)
->numParams( $numRows );
$note .= Html::rawElement(
'span',
[ 'class' => 'rcnotefrom' ],
$noteFromMsg->parse()
) .
' ' .
Html::rawElement(
'span',
[ 'class' => 'rcoptions-listfromreset' ],
$this->msg( 'parentheses' )->rawParams( $resetLink )->parse()
) .
'<br />';
}
# Sort data for display and make sure it's unique after we've added user data.
Enable users to watch category membership changes #2 This is part of a chain that reverts: e412ff5ecc900991cce4f99b7a069f625a5694b3. NOTE: - The feature is disabled by default - User settings default to hiding changes - T109707 Touching a file on wikisource adds and removes it from a category... Even when page has no changes.... WTF? See linked issue, marked as stalled with a possible way forward for this patch. @see https://gerrit.wikimedia.org/r/#/c/235467/ Changes since version 1: - T109604 - Page names in comment are no longer url encoded / have _'s - T109638 & T110338 - Reserved username now used when we can't determine a username for the change (we could perhaps set the user and id to be blank in the RC table, but who knows what this might do) - T109688 - History links are now disabled in RC.... (could be fine for the introduction and worked on more in the future) - Categorization changes are now always patrolled - Touching on T109672 in this change emails will never be sent regarding categorization changes. (this can of course be changed in a followup) - Added $wgRCWatchCategoryMembership defaulting to true for enabling / disabling the feature - T109700 - for cases when no revision was retrieved for a category change set the bot flag to true. This means all changes caused by parser functions & Lua will be marked as bot, as will changes that cant find their revision due to slave lag.. Bug: T9148 Bug: T109604 Bug: T109638 Bug: T109688 Bug: T109700 Bug: T110338 Bug: T110340 Change-Id: I51c2c1254de862f24a26ef9dbbf027c6c83e9063
2015-08-24 17:40:06 +00:00
$linkLimits = $config->get( 'RCLinkLimits' );
$linkLimits[] = $options['limit'];
sort( $linkLimits );
$linkLimits = array_unique( $linkLimits );
Enable users to watch category membership changes #2 This is part of a chain that reverts: e412ff5ecc900991cce4f99b7a069f625a5694b3. NOTE: - The feature is disabled by default - User settings default to hiding changes - T109707 Touching a file on wikisource adds and removes it from a category... Even when page has no changes.... WTF? See linked issue, marked as stalled with a possible way forward for this patch. @see https://gerrit.wikimedia.org/r/#/c/235467/ Changes since version 1: - T109604 - Page names in comment are no longer url encoded / have _'s - T109638 & T110338 - Reserved username now used when we can't determine a username for the change (we could perhaps set the user and id to be blank in the RC table, but who knows what this might do) - T109688 - History links are now disabled in RC.... (could be fine for the introduction and worked on more in the future) - Categorization changes are now always patrolled - Touching on T109672 in this change emails will never be sent regarding categorization changes. (this can of course be changed in a followup) - Added $wgRCWatchCategoryMembership defaulting to true for enabling / disabling the feature - T109700 - for cases when no revision was retrieved for a category change set the bot flag to true. This means all changes caused by parser functions & Lua will be marked as bot, as will changes that cant find their revision due to slave lag.. Bug: T9148 Bug: T109604 Bug: T109638 Bug: T109688 Bug: T109700 Bug: T110338 Bug: T110340 Change-Id: I51c2c1254de862f24a26ef9dbbf027c6c83e9063
2015-08-24 17:40:06 +00:00
$linkDays = $config->get( 'RCLinkDays' );
$linkDays[] = $options['days'];
sort( $linkDays );
$linkDays = array_unique( $linkDays );
// limit links
$cl = [];
foreach ( $linkLimits as $value ) {
$cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
[ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
}
$cl = $lang->pipeList( $cl );
// day links, reset 'from' to none
$dl = [];
foreach ( $linkDays as $value ) {
$dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
[ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
}
$dl = $lang->pipeList( $dl );
$showhide = [ 'show', 'hide' ];
$links = [];
foreach ( $this->getLegacyShowHideFilters() as $key => $filter ) {
$msg = $filter->getShowHide();
$linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
// Extensions can define additional filters, but don't need to define the corresponding
// messages. If they don't exist, just fall back to 'show' and 'hide'.
if ( !$linkMessage->exists() ) {
$linkMessage = $this->msg( $showhide[1 - $options[$key]] );
}
$link = $this->makeOptionsLink( $linkMessage->text(),
[ $key => 1 - $options[$key] ], $nondefaults );
$attribs = [
'class' => "$msg rcshowhideoption clshowhideoption",
'data-filter-name' => $filter->getName(),
];
if ( $filter->isFeatureAvailableOnStructuredUi( $this ) ) {
$attribs['data-feature-in-structured-ui'] = true;
Back-end of new RecentChanges page, refactoring Generate old RC, Related changes (it was already displayed and working on 'Related changes' before this change), and Watchlist/etc. and data for new UI from back-end. This moves everything used for defining the old (unstructured) and new (structured) filters into unified objects, ChangesListFilter and ChangesListFilterGroup (and sub-classes). This includes the query logic (see below) and logic for adding CSS attribution classes. This is a breaking change (for subclasses of ChangesListSpecialpage) due to the signature (and name) change of buildMainQueryConds and doMainQuery. An alternative that I don't think is a breaking change would be to put the filter->DB logic in runMainQueryHook, but then it's doing more than just running a hook. This is because it used to only build $conds here, but it's clear from filterOnUserExperienceLevel filters need more than this. I added all the DB parameters from the hook, but this could be debated. I have an checked and fixed the WMF-deployed extensions affected by this. Other than that, there should be full back-compat (including legacy filters not using the new system). * add hidepatrolled/hideunpatrolled to new UI. * Move userExpLevel from RC to ChangesListSpecialPage. Although for now the structured UI only displays on RC anyway, when it displays on watchlist, it seems we'll want userExpLevel there. Change this to make 'all' exclude unregistered users. * Don't have front-end convert none-selected to 'all' on string_options. * Needs the hideanons/hideliu special redirect to be done before this is merged (T151873) Bug: T152754 Bug: T152797 Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-02-14 07:55:37 +00:00
}
$links[] = Html::rawElement(
'span',
$attribs,
$this->msg( $msg )->rawParams( $link )->parse()
);
}
// show from this onward link
$timestamp = wfTimestampNow();
$now = $lang->userTimeAndDate( $timestamp, $user );
$timenow = $lang->userTime( $timestamp, $user );
$datenow = $lang->userDate( $timestamp, $user );
$pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
$rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, '' )
->parse() . '</span>';
$rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
$this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
[ 'from' => $timestamp ],
$nondefaults
) . '</span>';
return "{$note}$rclinks<br />$pipedLinks<br />$rclistfrom";
}
public function isIncludable() {
return true;
}
protected function getCacheTTL() {
return 60 * 5;
}
public function getDefaultLimit() {
$systemPrefValue = $this->getUser()->getIntOption( 'rclimit' );
// Prefer the RCFilters-specific preference if RCFilters is enabled
if ( $this->isStructuredFilterUiEnabled() ) {
return $this->getUser()->getIntOption( static::$limitPreferenceName, $systemPrefValue );
}
// Otherwise, use the system rclimit preference value
return $systemPrefValue;
}
}