Split in two more functions: outputFeedLinks() and outputChangesList().
Change-Id: I62c6eab1c25c5ff3a71150205416e8f57764f6bc
/**
* 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
* @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
*/
public function doMainQuery( $conds, $opts ) {
+ global $wgAllowCategorizedRecentChanges;
+
$dbr = $this->getDB();
$user = $this->getUser();
// 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 ) ),
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'];
}
$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(
'<div class="mw-changeslist-empty">' . $this->msg( 'recentchanges-noresult' )->parse() . '</div>'
}
/**
- * 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 );
}
$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'
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();