From: Bartosz DziewoƄski Date: Fri, 3 Jan 2014 15:23:45 +0000 (+0100) Subject: ChangesListSpecialPage: Implement webOutput() X-Git-Tag: 1.31.0-rc.0~17070^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=720d0fa9e974573a176056c2be4b54c12fa33e99;p=lhc%2Fweb%2Fwiklou.git ChangesListSpecialPage: Implement webOutput() Split in two more functions: outputFeedLinks() and outputChangesList(). Change-Id: I62c6eab1c25c5ff3a71150205416e8f57764f6bc --- diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 3a99edab94..03bc8c2f12 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -319,16 +319,36 @@ abstract class ChangesListSpecialPage extends SpecialPage { /** * Send output to the OutputPage object, only called if not used feeds - * @todo This should do most, if not all, of the outputting now done by subclasses * * @param ResultWrapper $rows Database rows * @param FormOptions $opts */ - abstract public function webOutput( $rows, $opts ); + public function webOutput( $rows, $opts ) { + if ( !$this->including() ) { + $this->outputFeedLinks(); + $this->doHeader( $opts ); + } + + $this->outputChangesList( $rows, $opts ); + } + + /** + * Output feed links. + */ + public function outputFeedLinks() { + // nothing by default + } + + /** + * Build and output the actual changes list. + * + * @param array $rows Database rows + * @param FormOptions $opts + */ + abstract public function outputChangesList( $rows, $opts ); /** * Return the text to be displayed above the changes - * @todo Not called by anything, should be called by webOutput() * * @param FormOptions $opts * @return string XHTML diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 36a1d1cb17..07da6d9ee6 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -182,6 +182,8 @@ 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(); @@ -225,7 +227,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough // knowledge to use an index merge if it wants (it may use some other index though). - return $dbr->select( + $rows = $dbr->select( $tables, $fields, $conds + array( 'rc_new' => array( 0, 1 ) ), @@ -233,22 +235,35 @@ class SpecialRecentChanges extends ChangesListSpecialPage { array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit'] ) + $query_options, $join_conds ); + + // Build the final data + if ( $wgAllowCategorizedRecentChanges ) { + $this->filterByCategories( $rows, $opts ); + } + + return $rows; + } + + /** + * Output feed links. + */ + public function outputFeedLinks() { + $feedQuery = $this->getFeedQuery(); + if ( $feedQuery !== '' ) { + $this->getOutput()->setFeedAppendQuery( $feedQuery ); + } else { + $this->getOutput()->setFeedAppendQuery( false ); + } } /** - * Send output to the OutputPage object, only called if not used feeds + * Build and output the actual changes list. * * @param array $rows Database rows * @param FormOptions $opts */ - public function webOutput( $rows, $opts ) { - global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges; - - // Build the final data - - if ( $wgAllowCategorizedRecentChanges ) { - $this->filterByCategories( $rows, $opts ); - } + public function outputChangesList( $rows, $opts ) { + global $wgRCShowWatchingUsers, $wgShowUpdatedMarker; $limit = $opts['limit']; @@ -299,21 +314,6 @@ class SpecialRecentChanges extends ChangesListSpecialPage { } $rclistOutput .= $list->endRecentChangesList(); - // Print things out - - if ( !$this->including() ) { - // Output options box - $this->doHeader( $opts ); - } - - // And now for the content - $feedQuery = $this->getFeedQuery(); - if ( $feedQuery !== '' ) { - $this->getOutput()->setFeedAppendQuery( $feedQuery ); - } else { - $this->getOutput()->setFeedAppendQuery( false ); - } - if ( $rows->numRows() === 0 ) { $this->getOutput()->addHtml( '
' . $this->msg( 'recentchanges-noresult' )->parse() . '
' diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 147719248b..fbdaec460d 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -279,16 +279,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 ); @@ -327,35 +350,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( "
\n$1\n
", 'recentchanges-noresult' @@ -374,6 +368,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();