Category finder style cleanups
[lhc/web/wiklou.git] / includes / specials / SpecialRecentchanges.php
index c3d9d3e..17d7664 100644 (file)
@@ -192,8 +192,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
         */
        public function doMainQuery( $conds, $opts ) {
-               global $wgAllowCategorizedRecentChanges;
-
                $dbr = $this->getDB();
                $user = $this->getUser();
 
@@ -229,9 +227,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $opts['tagfilter']
                );
 
-               if ( !wfRunHooks( 'SpecialRecentChangesQuery',
-                       array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ),
-                       '1.23' )
+               if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
+                       $opts )
                ) {
                        return false;
                }
@@ -248,13 +245,22 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                );
 
                // Build the final data
-               if ( $wgAllowCategorizedRecentChanges ) {
+               if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
                        $this->filterByCategories( $rows, $opts );
                }
 
                return $rows;
        }
 
+       protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) {
+               return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
+                       && wfRunHooks(
+                               'SpecialRecentChangesQuery',
+                               array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ),
+                               '1.23'
+                       );
+       }
+
        public function outputFeedLinks() {
                $this->addFeedLinks( $this->getFeedQuery() );
        }
@@ -265,14 +271,14 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * @return array
         */
        private function getFeedQuery() {
-               global $wgFeedLimit;
                $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
                        // API handles empty parameters in a different way
                        return $value !== '';
                } );
                $query['action'] = 'feedrecentchanges';
-               if ( $query['limit'] > $wgFeedLimit ) {
-                       $query['limit'] = $wgFeedLimit;
+               $feedLimit = $this->getConfig()->get( 'FeedLimit' );
+               if ( $query['limit'] > $feedLimit ) {
+                       $query['limit'] = $feedLimit;
                }
 
                return $query;
@@ -285,11 +291,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * @param FormOptions $opts
         */
        public function outputChangesList( $rows, $opts ) {
-               global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
-
                $limit = $opts['limit'];
 
-               $showWatcherCount = $wgRCShowWatchingUsers
+               $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
                        && $this->getUser()->getOption( 'shownumberswatching' );
                $watcherCache = array();
 
@@ -307,7 +311,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $rc = RecentChange::newFromRow( $obj );
                        $rc->counter = $counter++;
                        # Check if the page has been updated since the last visit
-                       if ( $wgShowUpdatedMarker && !empty( $obj->wl_notificationtimestamp ) ) {
+                       if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) && !empty( $obj->wl_notificationtimestamp ) ) {
                                $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
                        } else {
                                $rc->notificationtimestamp = false; // Default
@@ -356,10 +360,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * Set the text to be displayed above the changes
         *
         * @param FormOptions $opts
+        * @param int $numRows Number of rows in the result to show after this header
         */
-       public function doHeader( $opts ) {
-               global $wgScript;
-
+       public function doHeader( $opts, $numRows ) {
                $this->setTopText( $opts );
 
                $defaults = $opts->getAllValues();
@@ -367,7 +370,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $panel = array();
                $panel[] = self::makeLegend( $this->getContext() );
-               $panel[] = $this->optionsPanel( $defaults, $nondefaults );
+               $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
                $panel[] = '<hr />';
 
                $extraOpts = $this->getExtraOptions( $opts );
@@ -411,7 +414,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
 
                $t = $this->getPageTitle();
                $out .= Html::hidden( 'title', $t->getPrefixedText() );
-               $form = Xml::tags( 'form', array( 'action' => $wgScript ), $out );
+               $form = Xml::tags( 'form', array( 'action' => wfScript() ), $out );
                $panel[] = $form;
                $panelString = implode( "\n", $panel );
 
@@ -461,8 +464,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $extraOpts = array();
                $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
 
-               global $wgAllowCategorizedRecentChanges;
-               if ( $wgAllowCategorizedRecentChanges ) {
+               if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
                        $extraOpts['category'] = $this->categoryFilterForm( $opts );
                }
 
@@ -593,9 +595,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                }
 
                # Look up
-               $c = new Categoryfinder;
-               $c->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
-               $match = $c->run();
+               $catFind = new CategoryFinder;
+               $catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
+               $match = $catFind->run();
 
                # Filter
                $newrows = array();
@@ -642,11 +644,10 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         *
         * @param array $defaults
         * @param array $nondefaults
+        * @param int $numRows Number of rows in the result to show after this header
         * @return string
         */
-       function optionsPanel( $defaults, $nondefaults ) {
-               global $wgRCLinkLimits, $wgRCLinkDays;
-
+       function optionsPanel( $defaults, $nondefaults, $numRows ) {
                $options = $nondefaults + $defaults;
 
                $note = '';
@@ -658,19 +659,24 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $lang = $this->getLanguage();
                $user = $this->getUser();
                if ( $options['from'] ) {
-                       $note .= $this->msg( 'rcnotefrom' )->numParams( $options['limit'] )->params(
-                               $lang->userTimeAndDate( $options['from'], $user ),
-                               $lang->userDate( $options['from'], $user ),
-                               $lang->userTime( $options['from'], $user ) )->parse() . '<br />';
+                       $note .= $this->msg( 'rcnotefrom' )
+                               ->numParams( $options['limit'] )
+                               ->params(
+                                       $lang->userTimeAndDate( $options['from'], $user ),
+                                       $lang->userDate( $options['from'], $user ),
+                                       $lang->userTime( $options['from'], $user )
+                               )
+                               ->numParams( $numRows )
+                               ->parse() . '<br />';
                }
 
                # Sort data for display and make sure it's unique after we've added user data.
-               $linkLimits = $wgRCLinkLimits;
+               $linkLimits = $this->getConfig()->get( 'RCLinkLimits' );
                $linkLimits[] = $options['limit'];
                sort( $linkLimits );
                $linkLimits = array_unique( $linkLimits );
 
-               $linkDays = $wgRCLinkDays;
+               $linkDays = $this->getConfig()->get( 'RCLinkDays' );
                $linkDays[] = $options['days'];
                sort( $linkDays );
                $linkDays = array_unique( $linkDays );