Merge "Add MessagesBi.php"
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
index 7cc0dc6..3e8bf12 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\FakeResultWrapper;
 
 /**
@@ -35,6 +35,7 @@ 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;
 
@@ -208,8 +209,12 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $reviewStatus = $this->getFilterGroup( 'reviewStatus' );
                if ( $reviewStatus !== null ) {
                        // Conditional on feature being available and rights
-                       $hidePatrolled = $reviewStatus->getFilter( 'hidepatrolled' );
-                       $hidePatrolled->setDefault( $user->getBoolOption( 'hidepatrolled' ) );
+                       if ( $user->getBoolOption( 'hidepatrolled' ) ) {
+                               $reviewStatus->setDefault( 'unpatrolled' );
+                               $legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
+                               $legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
+                               $legacyHidePatrolled->setDefault( true );
+                       }
                }
 
                $changeType = $this->getFilterGroup( 'changeType' );
@@ -220,34 +225,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                }
        }
 
-       /**
-        * Get a FormOptions object containing the default options
-        *
-        * @return FormOptions
-        */
-       public function getDefaultOptions() {
-               $opts = parent::getDefaultOptions();
-
-               $opts->add( 'categories', '' );
-               $opts->add( 'categories_any', false );
-
-               return $opts;
-       }
-
-       /**
-        * 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.
         *
@@ -359,11 +336,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $join_conds
                );
 
-               // Build the final data
-               if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
-                       $this->filterByCategories( $rows, $opts );
-               }
-
                return $rows;
        }
 
@@ -408,7 +380,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        /**
         * Build and output the actual changes list.
         *
-        * @param ResultWrapper $rows Database rows
+        * @param IResultWrapper $rows Database rows
         * @param FormOptions $opts
         */
        public function outputChangesList( $rows, $opts ) {
@@ -592,10 +564,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * @param FormOptions $opts Unused
         */
        function setTopText( FormOptions $opts ) {
-               global $wgContLang;
-
                $message = $this->msg( 'recentchangestext' )->inContentLanguage();
                if ( !$message->isDisabled() ) {
+                       $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                        // 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().
@@ -606,7 +577,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                                // 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
+                               $contLang
                        );
                        $content = $parserOutput->getText( [
                                'enableSectionEditLinks' => false,
@@ -615,8 +586,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $this->getOutput()->addParserOutputMetadata( $parserOutput );
 
                        $langAttributes = [
-                               'lang' => $wgContLang->getHtmlCode(),
-                               'dir' => $wgContLang->getDir(),
+                               'lang' => $contLang->getHtmlCode(),
+                               'dir' => $contLang->getDir(),
                        ];
 
                        $topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
@@ -667,16 +638,12 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         */
        function getExtraOptions( $opts ) {
                $opts->consumeValues( [
-                       'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
+                       'namespace', 'invert', 'associated', 'tagfilter'
                ] );
 
                $extraOpts = [];
                $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
 
-               if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
-                       $extraOpts['category'] = $this->categoryFilterForm( $opts );
-               }
-
                $tagFilter = ChangeTags::buildTagFilterSelector(
                        $opts['tagfilter'], false, $this->getContext() );
                if ( count( $tagFilter ) ) {
@@ -709,7 +676,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         */
        public function checkLastModified() {
                $dbr = $this->getDB();
-               $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
+               $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ );
 
                return $lastmod;
        }
@@ -740,29 +707,17 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                return [ $nsLabel, "$nsSelect $invert $associated" ];
        }
 
-       /**
-        * Create an input to filter changes by categories
-        *
-        * @param FormOptions $opts
-        * @return array
-        */
-       protected function categoryFilterForm( FormOptions $opts ) {
-               list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(),
-                       'categories', 'mw-categories', false, $opts['categories'] );
-
-               $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(),
-                       'categories_any', 'mw-categories_any', $opts['categories_any'] );
-
-               return [ $label, $input ];
-       }
-
        /**
         * Filter $rows by categories set in $opts
         *
-        * @param ResultWrapper &$rows Database rows
+        * @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 ) ) {