Merge "Absolutely position "legend" on grouped results"
[lhc/web/wiklou.git] / includes / specialpage / ChangesListSpecialPage.php
index 0e99c3c..6cb56d4 100644 (file)
@@ -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;
 
@@ -722,6 +734,14 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                'wgStructuredChangeFiltersSavedQueriesPreferenceName',
                                static::$savedQueriesPreferenceName
                        );
+                       $out->addJsConfigVars(
+                               'wgStructuredChangeFiltersLimitPreferenceName',
+                               static::$limitPreferenceName
+                       );
+                       $out->addJsConfigVars(
+                               'wgStructuredChangeFiltersDaysPreferenceName',
+                               static::$daysPreferenceName
+                       );
 
                        $out->addJsConfigVars(
                                'StructuredChangeFiltersLiveUpdatePollingRate',
@@ -1758,11 +1778,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 self::checkStructuredFilterUiEnabled(
+                       $this->getConfig(),
+                       $this->getUser()
+               );
        }
 
        /**
@@ -1779,14 +1798,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 User object
+        * @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 ) );
+       }
 }