X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FChangesListSpecialPage.php;h=0954c45383373833c7fdb6321a99728a65e438e7;hb=5a296a1113d1243962c6459281a0307dd3efb80f;hp=bbbd6a85851d77920b5f9b2e44645bc753c57d1c;hpb=8ef8af4244f0736b7b0c2bf6273b6c0e7e97a693;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index bbbd6a8585..0954c45383 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -766,6 +766,33 @@ abstract class ChangesListSpecialPage extends SpecialPage { } } + /** + * @see $wgRCLinkDays in DefaultSettings.php. + * @see $wgRCFilterByAge in DefaultSettings.php. + * @return int[] + */ + protected function getLinkDays() { + $linkDays = $this->getConfig()->get( 'RCLinkDays' ); + $filterByAge = $this->getConfig()->get( 'RCFilterByAge' ); + $maxAge = $this->getConfig()->get( 'RCMaxAge' ); + if ( $filterByAge ) { + // Trim it to only links which are within $wgRCMaxAge. + // Note that we allow one link higher than the max for things like + // "age 56 days" being accessible through the "60 days" link. + sort( $linkDays ); + + $maxAgeDays = $maxAge / ( 3600 * 24 ); + foreach ( $linkDays as $i => $days ) { + if ( $days >= $maxAgeDays ) { + array_splice( $linkDays, $i + 1 ); + break; + } + } + } + + return $linkDays; + } + /** * Include the modules and configuration for the RCFilters app. * Conditional on the user having the feature enabled. @@ -798,7 +825,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ), 'limitDefault' => $this->getDefaultLimit(), - 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ), + 'daysArray' => $this->getLinkDays(), 'daysDefault' => $this->getDefaultDays(), ] ); @@ -1106,7 +1133,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { * * There is light processing to simplify core maintenance. * @param array $definition - * @phan-param array $definition + * @phan-param array $definition */ protected function registerFiltersFromDefinitions( array $definition ) { $autoFillPriority = -1; @@ -1503,6 +1530,8 @@ abstract class ChangesListSpecialPage extends SpecialPage { if ( $opts[ 'namespace' ] !== '' ) { $namespaces = explode( ';', $opts[ 'namespace' ] ); + $namespaces = $this->expandSymbolicNamespaceFilters( $namespaces ); + if ( $opts[ 'associated' ] ) { $namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); $associatedNamespaces = array_map( @@ -1948,4 +1977,21 @@ abstract class ChangesListSpecialPage extends SpecialPage { public function getDefaultDays() { return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) ); } + + private function expandSymbolicNamespaceFilters( array $namespaces ) { + $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); + $symbolicFilters = [ + 'all-contents' => $nsInfo->getSubjectNamespaces(), + 'all-discussions' => $nsInfo->getTalkNamespaces(), + ]; + $additionalNamespaces = []; + foreach ( $symbolicFilters as $name => $values ) { + if ( in_array( $name, $namespaces ) ) { + $additionalNamespaces = array_merge( $additionalNamespaces, $values ); + } + } + $namespaces = array_diff( $namespaces, array_keys( $symbolicFilters ) ); + $namespaces = array_merge( $namespaces, $additionalNamespaces ); + return array_unique( $namespaces ); + } }