Merge "Update set of files cleaned up after parserTests"
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index a98447b..dd9f262 100644 (file)
@@ -28,9 +28,6 @@
  * @ingroup SpecialPage
  */
 class SpecialWatchlist extends ChangesListSpecialPage {
-       /**
-        * Constructor
-        */
        public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
                parent::__construct( $page, $restriction );
        }
@@ -58,6 +55,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        }
 
                        $output->redirect( $title->getLocalURL() );
+
                        return;
                }
 
@@ -66,11 +64,13 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $user = $this->getUser();
                $opts = $this->getOptions();
 
-               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
-                       $request->wasPosted() )
-               {
+               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker )
+                       && $request->getVal( 'reset' )
+                       && $request->wasPosted()
+               ) {
                        $user->clearAllNotifications();
                        $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
+
                        return;
                }
 
@@ -145,6 +145,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                // methods defined on WebRequest and removing this dependency would cause some code duplication.
                $request = new DerivativeRequest( $this->getRequest(), $params );
                $opts->fetchValuesFromRequest( $request );
+
                return $opts;
        }
 
@@ -160,7 +161,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                // Calculate cutoff
                if ( $opts['days'] > 0 ) {
-                       $conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $opts['days'] * 86400 ) ) );
+                       $conds[] = 'rc_timestamp > ' .
+                               $dbr->addQuotes( $dbr->timestamp( time() - intval( $opts['days'] * 86400 ) ) );
                }
 
                return $conds;
@@ -178,6 +180,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $dbr = $this->getDB();
                $user = $this->getUser();
+
                # Toggle watchlist content (all recent edits or just the latest)
                if ( $opts['extended'] ) {
                        $limitWatchlist = $user->getIntOption( 'wllimit' );
@@ -201,6 +204,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $tables = array( 'recentchanges', 'watchlist' );
                $fields = RecentChange::selectFields();
+               $query_options = array( 'ORDER BY' => 'rc_timestamp DESC' );
                $join_conds = array(
                        'watchlist' => array(
                                'INNER JOIN',
@@ -211,12 +215,12 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                ),
                        ),
                );
-               $options = array( 'ORDER BY' => 'rc_timestamp DESC' );
+
                if ( $wgShowUpdatedMarker ) {
                        $fields[] = 'wl_notificationtimestamp';
                }
                if ( $limitWatchlist ) {
-                       $options['LIMIT'] = $limitWatchlist;
+                       $query_options['LIMIT'] = $limitWatchlist;
                }
 
                $rollbacker = $user->isAllowed( 'rollback' );
@@ -244,11 +248,26 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                        ), LIST_OR );
                }
 
+               ChangeTags::modifyDisplayQuery(
+                       $tables,
+                       $fields,
+                       $conds,
+                       $join_conds,
+                       $query_options,
+                       ''
+               );
 
-               ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $options, '' );
-               wfRunHooks( 'SpecialWatchlistQuery', array( &$conds, &$tables, &$join_conds, &$fields, $opts ) );
+               wfRunHooks( 'SpecialWatchlistQuery',
+                       array( &$conds, &$tables, &$join_conds, &$fields, $opts ) );
 
-               return $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
+               return $dbr->select(
+                       $tables,
+                       $fields,
+                       $conds,
+                       __METHOD__,
+                       $query_options,
+                       $join_conds
+               );
        }
 
        /**
@@ -261,16 +280,39 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        }
 
        /**
-        * Send output to the OutputPage object, only called if not used feeds
+        * Output feed links.
+        */
+       public function outputFeedLinks() {
+               $user = $this->getUser();
+               $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
+               if ( $wlToken ) {
+                       $this->addFeedLinks( array(
+                               'action' => 'feedwatchlist',
+                               'allrev' => 1,
+                               'wlowner' => $user->getName(),
+                               'wltoken' => $wlToken,
+                       ) );
+               }
+       }
+
+       /**
+        * Build and output the actual changes list.
         *
         * @param ResultWrapper $rows Database rows
         * @param FormOptions $opts
         */
-       public function webOutput( $rows, $opts ) {
+       public function outputChangesList( $rows, $opts ) {
                global $wgShowUpdatedMarker, $wgRCShowWatchingUsers;
 
                $dbr = $this->getDB();
                $user = $this->getUser();
+               $output = $this->getOutput();
+
+               # Show a message about slave lag, if applicable
+               $lag = wfGetLB()->safeGetLag( $dbr );
+               if ( $lag > 0 ) {
+                       $output->showLagWarning( $lag );
+               }
 
                $dbr->dataSeek( $rows, 0 );
 
@@ -309,35 +351,6 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                }
                $s .= $list->endRecentChangesList();
 
-               // Print things out
-
-               $output = $this->getOutput();
-
-               $output->addSubtitle(
-                       $this->msg( 'watchlistfor2', $user->getName() )
-                               ->rawParams( SpecialEditWatchlist::buildTools( null ) )
-               );
-
-               // Output options box
-               $this->doHeader( $opts );
-
-               // Add feed links
-               $wlToken = $user->getTokenFromOption( 'watchlisttoken' );
-               if ( $wlToken ) {
-                       $this->addFeedLinks( array(
-                               'action' => 'feedwatchlist',
-                               'allrev' => 1,
-                               'wlowner' => $user->getName(),
-                               'wltoken' => $wlToken,
-                       ) );
-               }
-
-               # Show a message about slave lag, if applicable
-               $lag = wfGetLB()->safeGetLag( $dbr );
-               if ( $lag > 0 ) {
-                       $output->showLagWarning( $lag );
-               }
-
                if ( $rows->numRows() == 0 ) {
                        $output->wrapWikiMsg(
                                "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
@@ -356,6 +369,11 @@ class SpecialWatchlist extends ChangesListSpecialPage {
        public function doHeader( $opts ) {
                $user = $this->getUser();
 
+               $this->getOutput()->addSubtitle(
+                       $this->msg( 'watchlistfor2', $user->getName() )
+                               ->rawParams( SpecialEditWatchlist::buildTools( null ) )
+               );
+
                $this->setTopText( $opts );
 
                $lang = $this->getLanguage();
@@ -363,7 +381,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                if ( $opts['days'] > 0 ) {
                        $timestamp = wfTimestampNow();
                        $wlInfo = $this->msg( 'wlnote2' )->numParams( round( $opts['days'] * 24 ) )->params(
-                               $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "<br />\n";
+                               $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
+                       )->parse() . "<br />\n";
                }
 
                $nondefaults = $opts->getChangedValues();
@@ -497,7 +516,9 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $label = $this->msg( $value ? 'show' : 'hide' )->escaped();
                $options[$name] = 1 - (int)$value;
 
-               return $this->msg( $message )->rawParams( Linker::linkKnown( $this->getPageTitle(), $label, array(), $options ) )->escaped();
+               return $this->msg( $message )
+                       ->rawParams( Linker::linkKnown( $this->getPageTitle(), $label, array(), $options ) )
+                       ->escaped();
        }
 
        protected function hoursLink( $h, $options = array() ) {
@@ -513,7 +534,8 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
        protected function daysLink( $d, $options = array() ) {
                $options['days'] = $d;
-               $message = ( $d ? $this->getLanguage()->formatNum( $d ) : $this->msg( 'watchlistall2' )->escaped() );
+               $message = $d ? $this->getLanguage()->formatNum( $d )
+                       : $this->msg( 'watchlistall2' )->escaped();
 
                return Linker::linkKnown(
                        $this->getPageTitle(),
@@ -541,6 +563,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                foreach ( $days as $d ) {
                        $days[$i++] = $this->daysLink( $d, $options );
                }
+
                return $this->msg( 'wlshowlast' )->rawParams(
                        $this->getLanguage()->pipeList( $hours ),
                        $this->getLanguage()->pipeList( $days ),