X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecialpage%2FChangesListSpecialPage.php;h=282d7642399835a362b71fdc156776467570de30;hb=58858df842f91d9ea1c9f9b6f3c767d8b204886b;hp=51949839646ae7b2526602193b613757510dfab7;hpb=2b7fbceb23a4737de36cfc48d542a21dd6f53a7a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 5194983964..282d764239 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -39,6 +39,18 @@ abstract class ChangesListSpecialPage extends SpecialPage { */ protected static $savedQueriesPreferenceName; + /** + * Preference name for 'days'. Subclasses should override this. + * @var string + */ + protected static $daysPreferenceName; + + /** + * Preference name for 'limit'. Subclasses should override this. + * @var string + */ + protected static $limitPreferenceName; + /** @var string */ protected $rcSubpage; @@ -541,7 +553,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { public function execute( $subpage ) { $this->rcSubpage = $subpage; - $this->considerActionsForDefaultSavedQuery(); + $this->considerActionsForDefaultSavedQuery( $subpage ); $opts = $this->getOptions(); try { @@ -558,8 +570,15 @@ abstract class ChangesListSpecialPage extends SpecialPage { // 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; + $code = $rows->numRows() > 0 ? 200 : 204; $this->getOutput()->setStatusCode( $code ); + + if ( $this->getUser()->isAnon() !== + $this->getRequest()->getFuzzyBool( 'isAnon' ) + ) { + $this->getOutput()->setStatusCode( 205 ); + } + return; } @@ -610,9 +629,11 @@ abstract class ChangesListSpecialPage extends SpecialPage { * Check whether or not the page should load defaults, and if so, whether * a default saved query is relevant to be redirected to. If it is relevant, * redirect properly with all necessary query parameters. + * + * @param string $subpage */ - protected function considerActionsForDefaultSavedQuery() { - if ( !$this->isStructuredFilterUiEnabled() ) { + protected function considerActionsForDefaultSavedQuery( $subpage ) { + if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) { return; } @@ -658,7 +679,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { // but are still valid and requested in the URL $query = array_merge( $this->getRequest()->getValues(), $query ); unset( $query[ 'title' ] ); - $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) ); + $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) ); } else { // There's a default, but the version is not 2, and the server can't // actually recognize the query itself. This happens if it is before @@ -685,7 +706,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { */ protected function includeRcFiltersApp() { $out = $this->getOutput(); - if ( $this->isStructuredFilterUiEnabled() ) { + if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) { $jsData = $this->getStructuredFilterJsData(); $messages = []; @@ -722,6 +743,14 @@ abstract class ChangesListSpecialPage extends SpecialPage { 'wgStructuredChangeFiltersSavedQueriesPreferenceName', static::$savedQueriesPreferenceName ); + $out->addJsConfigVars( + 'wgStructuredChangeFiltersLimitPreferenceName', + static::$limitPreferenceName + ); + $out->addJsConfigVars( + 'wgStructuredChangeFiltersDaysPreferenceName', + static::$daysPreferenceName + ); $out->addJsConfigVars( 'StructuredChangeFiltersLiveUpdatePollingRate', @@ -1596,8 +1625,13 @@ abstract class ChangesListSpecialPage extends SpecialPage { # Collapsible $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' ); $collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : ''; + # Enhanced mode + $enhancedMode = $this->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) ); + $enhancedClass = $enhancedMode ? ' mw-enhanced' : ''; + + $legendClasses = $collapsedClass . $enhancedClass; $legend = - '
' . + '
' . $legendHeading . '
' . $legend . '
' . '
'; @@ -1617,7 +1651,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { ] ); $out->addModules( 'mediawiki.special.changeslist.legend.js' ); - if ( $this->isStructuredFilterUiEnabled() ) { + if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) { $out->addModules( 'mediawiki.rcfilters.filters.ui' ); $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' ); } @@ -1753,11 +1787,10 @@ abstract class ChangesListSpecialPage extends SpecialPage { return true; } - if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) { - return !$this->getUser()->getOption( 'rcenhancedfilters-disable' ); - } else { - return $this->getUser()->getOption( 'rcenhancedfilters' ); - } + return static::checkStructuredFilterUiEnabled( + $this->getConfig(), + $this->getUser() + ); } /** @@ -1774,14 +1807,42 @@ abstract class ChangesListSpecialPage extends SpecialPage { } } - abstract function getDefaultLimit(); + /** + * Static method to check whether StructuredFilter UI is enabled for the given user + * + * @since 1.31 + * @param Config $config + * @param User $user + * @return bool + */ + public static function checkStructuredFilterUiEnabled( Config $config, User $user ) { + if ( $config->get( 'StructuredChangeFiltersShowPreference' ) ) { + return !$user->getOption( 'rcenhancedfilters-disable' ); + } else { + return $user->getOption( 'rcenhancedfilters' ); + } + } + + /** + * Get the default value of the number of changes to display when loading + * the result set. + * + * @since 1.30 + * @return int + */ + public function getDefaultLimit() { + return $this->getUser()->getIntOption( static::$limitPreferenceName ); + } /** * 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. * + * @since 1.30 * @return float */ - abstract function getDefaultDays(); + public function getDefaultDays() { + return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) ); + } }