Merge "RCFilters: define consistent interface in ChangesListFilterGroup"
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
index 34a7714..c3ce78e 100644 (file)
@@ -164,10 +164,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        true
                );
                parent::execute( $subpage );
-
-               if ( $this->isStructuredFilterUiEnabled() ) {
-                       $out->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', true );
-               }
        }
 
        /**
@@ -232,10 +228,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        public function getDefaultOptions() {
                $opts = parent::getDefaultOptions();
 
-               $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
-               $opts->add( 'limit', $this->getDefaultLimit() );
-               $opts->add( 'from', '' );
-
                $opts->add( 'categories', '' );
                $opts->add( 'categories_any', false );
 
@@ -287,36 +279,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                }
        }
 
-       public function validateOptions( FormOptions $opts ) {
-               $opts->validateIntBounds( 'limit', 0, 5000 );
-               $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
-               parent::validateOptions( $opts );
-       }
-
-       /**
-        * @inheritDoc
-        */
-       protected function buildQuery( &$tables, &$fields, &$conds,
-               &$query_options, &$join_conds, FormOptions $opts
-       ) {
-               $dbr = $this->getDB();
-               parent::buildQuery( $tables, $fields, $conds,
-                       $query_options, $join_conds, $opts );
-
-               // Calculate cutoff
-               $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
-               $cutoff = $dbr->timestamp( $cutoff_unixtime );
-
-               $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
-               if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
-                       $cutoff = $dbr->timestamp( $opts['from'] );
-               } else {
-                       $opts->reset( 'from' );
-               }
-
-               $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
-       }
-
        /**
         * @inheritDoc
         */
@@ -658,18 +620,22 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        if ( $this->isStructuredFilterUiEnabled() ) {
                                // Check whether the widget is already collapsed or expanded
                                $collapsedState = $this->getRequest()->getCookie( 'rcfilters-toplinks-collapsed-state' );
-                               $collapsedClass = $collapsedState === 'collapsed' ? 'mw-rcfilters-toplinks-collapsed' : '';
+                               // 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' ],
+                               ] );
 
-                               $contentTitle = Html::rawElement( 'div',
-                                       [ 'class' => 'mw-recentchanges-toplinks-title ' . $collapsedClass ],
-                                       $this->msg( 'rcfilters-other-review-tools' )->parse()
-                               );
                                $contentWrapper = Html::rawElement( 'div',
                                        array_merge(
-                                               [
-                                               'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content ' .
-                                                       $collapsedClass
-                                               ],
+                                               [ 'class' => 'mw-recentchanges-toplinks-content mw-collapsible-content' ],
                                                $langAttributes
                                        ),
                                        $content
@@ -949,40 +915,32 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $links = [];
 
-               $filterGroups = $this->getFilterGroups();
-
-               foreach ( $filterGroups as $groupName => $group ) {
-                       if ( !$group->isPerGroupRequestParameter() ) {
-                               foreach ( $group->getFilters() as $key => $filter ) {
-                                       if ( $filter->displaysOnUnstructuredUi( $this ) ) {
-                                               $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;
-                                               }
-
-                                               $links[] = Html::rawElement(
-                                                       'span',
-                                                       $attribs,
-                                                       $this->msg( $msg )->rawParams( $link )->escaped()
-                                               );
-                                       }
-                               }
+               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;
+                       }
+
+                       $links[] = Html::rawElement(
+                               'span',
+                               $attribs,
+                               $this->msg( $msg )->rawParams( $link )->escaped()
+                       );
                }
 
                // show from this onward link