* @ingroup SpecialPage
*/
abstract class ChangesListSpecialPage extends SpecialPage {
+ /**
+ * Preference name for saved queries. Subclasses that use saved queries should override this.
+ * @var string
+ */
+ protected static $savedQueriesPreferenceName;
+
/** @var string */
protected $rcSubpage;
public function __construct( $name, $restriction ) {
parent::__construct( $name, $restriction );
+ $nonRevisionTypes = [ RC_LOG ];
+ Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
+
$this->filterGroupDefinitions = [
[
'name' => 'registration',
'description' => 'rcfilters-filter-lastrevision-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
- $conds[] = 'rc_this_oldid <> page_latest';
+ &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
+ $conds[] = $dbr->makeList(
+ [
+ 'rc_this_oldid <> page_latest',
+ 'rc_type' => $nonRevisionTypes,
+ ],
+ LIST_OR
+ );
},
'cssClassSuffix' => 'last',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
'description' => 'rcfilters-filter-previousrevision-description',
'default' => false,
'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
- &$query_options, &$join_conds ) {
- $conds[] = 'rc_this_oldid = page_latest';
+ &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
+ $conds[] = $dbr->makeList(
+ [
+ 'rc_this_oldid = page_latest',
+ 'rc_type' => $nonRevisionTypes,
+ ],
+ LIST_OR
+ );
},
'cssClassSuffix' => 'previous',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
- $this->setHeaders();
- $this->outputHeader();
- $this->addModules();
-
$rows = $this->getRows();
$opts = $this->getOptions();
if ( $rows === false ) {
$rows = new FakeResultWrapper( [] );
}
+ // Used by Structured UI app to get results without MW chrome
+ if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
+ $this->getOutput()->setArticleBodyOnly( true );
+ }
+
+ // Used by "live update" and "view newest" to check
+ // if there's new changes with minimal data transfer
+ if ( $this->getRequest()->getBool( 'peek' ) ) {
+ $code = $rows->numRows() > 0 ? 200 : 204;
+ $this->getOutput()->setStatusCode( $code );
+ return;
+ }
+
$batch = new LinkBatch;
foreach ( $rows as $row ) {
$batch->add( NS_USER, $row->rc_user_text );
}
}
$batch->execute();
+
+ $this->setHeaders();
+ $this->outputHeader();
+ $this->addModules();
$this->webOutput( $rows, $opts );
$rows->free();
/**
* Include the modules and configuration for the RCFilters app.
* Conditional on the user having the feature enabled.
+ *
+ * If it is disabled, add a <body> class marking that
*/
protected function includeRcFiltersApp() {
+ $out = $this->getOutput();
if ( $this->isStructuredFilterUiEnabled() ) {
- $out = $this->getOutput();
$jsData = $this->getStructuredFilterJsData();
$messages = [];
$messages[$key] = $this->msg( $key )->plain();
}
+ $out->addBodyClasses( 'mw-rcfilters-enabled' );
+
$out->addHTML(
ResourceLoader::makeInlineScript(
ResourceLoader::makeMessageSetScript( $messages )
)
);
- $experimentalStructuredChangeFilters =
- $this->getConfig()->get( 'StructuredChangeFiltersEnableExperimentalViews' );
-
$out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
- $out->addJsConfigVars(
- 'wgStructuredChangeFiltersEnableExperimentalViews',
- $experimentalStructuredChangeFilters
- );
- $out->addJsConfigVars(
- 'wgStructuredChangeFiltersEnableLiveUpdate',
- $this->getConfig()->get( 'StructuredChangeFiltersEnableLiveUpdate' )
- );
+
$out->addJsConfigVars(
'wgRCFiltersChangeTags',
$this->buildChangeTagList()
'daysDefault' => $this->getDefaultDays(),
]
);
+
+ $out->addJsConfigVars(
+ 'StructuredChangeFiltersLiveUpdatePollingRate',
+ $this->getConfig()->get( 'StructuredChangeFiltersLiveUpdatePollingRate' )
+ );
+
+ if ( static::$savedQueriesPreferenceName ) {
+ $savedQueries = FormatJson::decode(
+ $this->getUser()->getOption( static::$savedQueriesPreferenceName )
+ );
+ if ( $savedQueries && isset( $savedQueries->default ) ) {
+ // If there is a default saved query, show a loading spinner,
+ // since the frontend is going to reload the results
+ $out->addBodyClasses( 'mw-rcfilters-ui-loading' );
+ }
+ $out->addJsConfigVars(
+ 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
+ static::$savedQueriesPreferenceName
+ );
+ }
+ } else {
+ $out->addBodyClasses( 'mw-rcfilters-disabled' );
}
}
* ChangesListFilterGroup constructors.
*
* There is light processing to simplify core maintenance.
+ * @param array $definition
*/
protected function registerFiltersFromDefinitions( array $definition ) {
$autoFillPriority = -1;
abstract function getDefaultLimit();
+ /**
+ * Get the default value of the number of days to display when loading
+ * the result set.
+ * Supports fractional values, and should be cast to a float.
+ *
+ * @return float
+ */
abstract function getDefaultDays();
}