Merge "Use HTMLForm to generate the form on Special:ListFiles"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 94de5ce..8f2f86b 100644 (file)
@@ -38,8 +38,6 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * @param string $subpage
         */
        function execute( $subpage ) {
-               global $wgEnotifWatchlist, $wgShowUpdatedMarker;
-
                // Anons don't get a watchlist
                $this->requireLogin( 'watchlistanontext' );
 
@@ -66,7 +64,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $user = $this->getUser();
                $opts = $this->getOptions();
 
-               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker )
+               $config = $this->getConfig();
+               if ( ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) )
                        && $request->getVal( 'reset' )
                        && $request->wasPosted()
                ) {
@@ -83,7 +82,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
@@ -198,8 +197,6 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
         */
        public function doMainQuery( $conds, $opts ) {
-               global $wgShowUpdatedMarker;
-
                $dbr = $this->getDB();
                $user = $this->getUser();
 
@@ -238,7 +235,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        ),
                );
 
-               if ( $wgShowUpdatedMarker ) {
+               if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
                        $fields[] = 'wl_notificationtimestamp';
                }
                if ( $limitWatchlist ) {
@@ -279,9 +276,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        ''
                );
 
-               wfRunHooks( 'SpecialWatchlistQuery',
-                       array( &$conds, &$tables, &$join_conds, &$fields, $opts ),
-                       '1.23' );
+               $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts );
 
                return $dbr->select(
                        $tables,
@@ -293,6 +288,15 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                );
        }
 
+       protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) {
+               return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
+                       && wfRunHooks(
+                               'SpecialWatchlistQuery',
+                               array( &$conds, &$tables, &$join_conds, &$fields, $opts ),
+                               '1.23'
+                       );
+       }
+
        /**
         * Return a DatabaseBase object for reading
         *
@@ -325,8 +329,6 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * @param FormOptions $opts
         */
        public function outputChangesList( $rows, $opts ) {
-               global $wgShowUpdatedMarker, $wgRCShowWatchingUsers;
-
                $dbr = $this->getDB();
                $user = $this->getUser();
                $output = $this->getOutput();
@@ -359,13 +361,13 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $rc = RecentChange::newFromRow( $obj );
                        $rc->counter = $counter++;
 
-                       if ( $wgShowUpdatedMarker ) {
+                       if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) {
                                $updated = $obj->wl_notificationtimestamp;
                        } else {
                                $updated = false;
                        }
 
-                       if ( $wgRCShowWatchingUsers && $user->getOption( 'shownumberswatching' ) ) {
+                       if ( $this->getConfig()->get( 'RCShowWatchingUsers' ) && $user->getOption( 'shownumberswatching' ) ) {
                                $rc->numberofWatchingusers = $dbr->selectField( 'watchlist',
                                        'COUNT(*)',
                                        array(
@@ -391,8 +393,9 @@ class SpecialWatchlist 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 ) {
+       public function doHeader( $opts, $numRows ) {
                $user = $this->getUser();
 
                $this->getOutput()->addSubtitle(
@@ -406,7 +409,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $wlInfo = '';
                if ( $opts['days'] > 0 ) {
                        $timestamp = wfTimestampNow();
-                       $wlInfo = $this->msg( 'wlnote2' )->numParams( round( $opts['days'] * 24 ) )->params(
+                       $wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
                                $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
                        )->parse() . "<br />\n";
                }
@@ -486,14 +489,13 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        function setTopText( FormOptions $opts ) {
-               global $wgEnotifWatchlist, $wgShowUpdatedMarker;
-
                $nondefaults = $opts->getChangedValues();
                $form = "";
                $user = $this->getUser();
 
                $dbr = $this->getDB();
                $numItems = $this->countItems( $dbr );
+               $showUpdatedMarker = $this->getConfig()->get( 'ShowUpdatedMarker' );
 
                // Show watchlist header
                $form .= "<p>";
@@ -501,16 +503,16 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        $form .= $this->msg( 'nowatchlist' )->parse() . "\n";
                } else {
                        $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
-                       if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) {
+                       if ( $this->getConfig()->get( 'EnotifWatchlist' ) && $user->getOption( 'enotifwatchlistpages' ) ) {
                                $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
                        }
-                       if ( $wgShowUpdatedMarker ) {
+                       if ( $showUpdatedMarker ) {
                                $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
                        }
                }
                $form .= "</p>";
 
-               if ( $numItems > 0 && $wgShowUpdatedMarker ) {
+               if ( $numItems > 0 && $showUpdatedMarker ) {
                        $form .= Xml::openElement( 'form', array( 'method' => 'post',
                                'action' => $this->getPageTitle()->getLocalURL(),
                                'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .