/** * Build and output the actual changes list. * * @param ResultWrapper $rows Database rows * @param FormOptions $opts */ public function outputChangesList($rows, $opts) { $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); } # If no rows to display, show message before try to render the list if ($rows->numRows() == 0) { $output->wrapWikiMsg("<div class='mw-changeslist-empty'>\n\$1\n</div>", 'recentchanges-noresult'); return; } $dbr->dataSeek($rows, 0); $list = ChangesList::newFromContext($this->getContext()); $list->setWatchlistDivs(); $list->initChangesListRows($rows); $dbr->dataSeek($rows, 0); $s = $list->beginRecentChangesList(); $counter = 1; foreach ($rows as $obj) { # Make RC entry $rc = RecentChange::newFromRow($obj); $rc->counter = $counter++; if ($this->getConfig()->get('ShowUpdatedMarker')) { $updated = $obj->wl_notificationtimestamp; } else { $updated = false; } if ($this->getConfig()->get('RCShowWatchingUsers') && $user->getOption('shownumberswatching')) { $rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__); } else { $rc->numberofWatchingusers = 0; } $changeLine = $list->recentChangesLine($rc, $updated, $counter); if ($changeLine !== false) { $s .= $changeLine; } } $s .= $list->endRecentChangesList(); $output->addHTML($s); }
/** * Send output to the OutputPage object, only called if not used feeds * * @param array $rows Database rows * @param FormOptions $opts */ public function webOutput($rows, $opts) { global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges; $limit = $opts['limit']; 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 ($wgAllowCategorizedRecentChanges) { $this->filterByCategories($rows, $opts); } $showNumsWachting = $this->getUser()->getOption('shownumberswatching'); $showWatcherCount = $wgRCShowWatchingUsers && $showNumsWachting; $watcherCache = array(); $dbr = wfGetDB(DB_SLAVE); $counter = 1; $list = ChangesList::newFromContext($this->getContext()); $s = $list->beginRecentChangesList(); foreach ($rows as $obj) { if ($limit == 0) { break; } $rc = RecentChange::newFromRow($obj); $rc->counter = $counter++; # Check if the page has been updated since the last visit if ($wgShowUpdatedMarker && !empty($obj->wl_notificationtimestamp)) { $rc->notificationtimestamp = $obj->rc_timestamp >= $obj->wl_notificationtimestamp; } else { $rc->notificationtimestamp = false; // Default } # Check the number of users watching the page $rc->numberofWatchingusers = 0; // Default if ($showWatcherCount && $obj->rc_namespace >= 0) { if (!isset($watcherCache[$obj->rc_namespace][$obj->rc_title])) { $watcherCache[$obj->rc_namespace][$obj->rc_title] = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__ . '-watchers'); } $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title]; } $changeLine = $list->recentChangesLine($rc, !empty($obj->wl_user), $counter); if ($changeLine !== false) { $s .= $changeLine; --$limit; } } $s .= $list->endRecentChangesList(); $this->getOutput()->addHTML($s); }
/** * Build and output the actual changes list. * * @param array $rows Database rows * @param FormOptions $opts */ public function outputChangesList($rows, $opts) { $limit = $opts['limit']; $showWatcherCount = $this->getConfig()->get('RCShowWatchingUsers') && $this->getUser()->getOption('shownumberswatching'); $watcherCache = array(); $dbr = $this->getDB(); $counter = 1; $list = ChangesList::newFromContext($this->getContext()); $list->initChangesListRows($rows); $rclistOutput = $list->beginRecentChangesList(); foreach ($rows as $obj) { if ($limit == 0) { break; } $rc = RecentChange::newFromRow($obj); $rc->counter = $counter++; # Check if the page has been updated since the last visit if ($this->getConfig()->get('ShowUpdatedMarker') && !empty($obj->wl_notificationtimestamp)) { $rc->notificationtimestamp = $obj->rc_timestamp >= $obj->wl_notificationtimestamp; } else { $rc->notificationtimestamp = false; // Default } # Check the number of users watching the page $rc->numberofWatchingusers = 0; // Default if ($showWatcherCount && $obj->rc_namespace >= 0) { if (!isset($watcherCache[$obj->rc_namespace][$obj->rc_title])) { $watcherCache[$obj->rc_namespace][$obj->rc_title] = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__ . '-watchers'); } $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title]; } $changeLine = $list->recentChangesLine($rc, !empty($obj->wl_user), $counter); if ($changeLine !== false) { $rclistOutput .= $changeLine; --$limit; } } $rclistOutput .= $list->endRecentChangesList(); if ($rows->numRows() === 0) { $this->getOutput()->addHtml('<div class="mw-changeslist-empty">' . $this->msg('recentchanges-noresult')->parse() . '</div>'); if (!$this->including()) { $this->getOutput()->setStatusCode(404); } } else { $this->getOutput()->addHTML($rclistOutput); } }
/** * Execute * @param $par Parameter passed to the page */ function execute( $par ) { global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker; $user = $this->getUser(); $output = $this->getOutput(); # Anons don't get a watchlist if ( $user->isAnon() ) { $output->setPageTitle( $this->msg( 'watchnologin' ) ); $output->setRobotPolicy( 'noindex,nofollow' ); $llink = Linker::linkKnown( SpecialPage::getTitleFor( 'Userlogin' ), $this->msg( 'loginreqlink' )->escaped(), array(), array( 'returnto' => $this->getTitle()->getPrefixedText() ) ); $output->addHTML( $this->msg( 'watchlistanontext' )->rawParams( $llink )->parse() ); return; } // Check permissions $this->checkPermissions(); // Add feed links $wlToken = $user->getTokenFromOption( 'watchlisttoken' ); if ( $wlToken ) { $this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', 'wlowner' => $user->getName(), 'wltoken' => $wlToken ) ); } $this->setHeaders(); $this->outputHeader(); $output->addSubtitle( $this->msg( 'watchlistfor2', $user->getName() )->rawParams( SpecialEditWatchlist::buildTools( null ) ) ); $request = $this->getRequest(); $mode = SpecialEditWatchlist::getMode( $request, $par ); if ( $mode !== false ) { # TODO: localise? switch ( $mode ) { case SpecialEditWatchlist::EDIT_CLEAR: $mode = 'clear'; break; case SpecialEditWatchlist::EDIT_RAW: $mode = 'raw'; break; default: $mode = null; } $title = SpecialPage::getTitleFor( 'EditWatchlist', $mode ); $output->redirect( $title->getLocalURL() ); return; } $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); $nitems = $this->countItems( $dbr ); if ( $nitems == 0 ) { $output->addWikiMsg( 'nowatchlist' ); return; } // @todo use FormOptions! $defaults = array( /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ), /* bool */ 'hideMinor' => (int)$user->getBoolOption( 'watchlisthideminor' ), /* bool */ 'hideBots' => (int)$user->getBoolOption( 'watchlisthidebots' ), /* bool */ 'hideAnons' => (int)$user->getBoolOption( 'watchlisthideanons' ), /* bool */ 'hideLiu' => (int)$user->getBoolOption( 'watchlisthideliu' ), /* bool */ 'hidePatrolled' => (int)$user->getBoolOption( 'watchlisthidepatrolled' ), /* bool */ 'hideOwn' => (int)$user->getBoolOption( 'watchlisthideown' ), /* bool */ 'extended' => (int)$user->getBoolOption( 'extendwatchlist' ), /* ? */ 'namespace' => '', //means all /* ? */ 'invert' => false, /* bool */ 'associated' => false, ); $this->customFilters = array(); wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) ); foreach ( $this->customFilters as $key => $params ) { $defaults[$key] = $params['default']; } # Extract variables from the request, falling back to user preferences or # other default values if these don't exist $values = array(); $values['days'] = floatval( $request->getVal( 'days', $defaults['days'] ) ); $values['hideMinor'] = (int)$request->getBool( 'hideMinor', $defaults['hideMinor'] ); $values['hideBots'] = (int)$request->getBool( 'hideBots', $defaults['hideBots'] ); $values['hideAnons'] = (int)$request->getBool( 'hideAnons', $defaults['hideAnons'] ); $values['hideLiu'] = (int)$request->getBool( 'hideLiu', $defaults['hideLiu'] ); $values['hideOwn'] = (int)$request->getBool( 'hideOwn', $defaults['hideOwn'] ); $values['hidePatrolled'] = (int)$request->getBool( 'hidePatrolled', $defaults['hidePatrolled'] ); $values['extended'] = (int)$request->getBool( 'extended', $defaults['extended'] ); foreach ( $this->customFilters as $key => $params ) { $values[$key] = (int)$request->getBool( $key, $defaults[$key] ); } # Get namespace value, if supplied, and prepare a WHERE fragment $nameSpace = $request->getIntOrNull( 'namespace' ); $invert = $request->getBool( 'invert' ); $associated = $request->getBool( 'associated' ); if ( !is_null( $nameSpace ) ) { $eq_op = $invert ? '!=' : '='; $bool_op = $invert ? 'AND' : 'OR'; $nameSpace = intval( $nameSpace ); // paranioa if ( !$associated ) { $nameSpaceClause = "rc_namespace $eq_op $nameSpace"; } else { $associatedNS = MWNamespace::getAssociated( $nameSpace ); $nameSpaceClause = "rc_namespace $eq_op $nameSpace " . $bool_op . " rc_namespace $eq_op $associatedNS"; } } else { $nameSpace = ''; $nameSpaceClause = ''; } $values['namespace'] = $nameSpace; $values['invert'] = $invert; $values['associated'] = $associated; // Dump everything here $nondefaults = array(); foreach ( $defaults as $name => $defValue ) { wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults ); } if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) && $request->wasPosted() ) { $user->clearAllNotifications(); $output->redirect( $this->getTitle()->getFullURL( $nondefaults ) ); return; } # Possible where conditions $conds = array(); if ( $values['days'] > 0 ) { $conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $values['days'] * 86400 ) ) ); } # Toggles if ( $values['hideOwn'] ) { $conds[] = 'rc_user != ' . $user->getId(); } if ( $values['hideBots'] ) { $conds[] = 'rc_bot = 0'; } if ( $values['hideMinor'] ) { $conds[] = 'rc_minor = 0'; } if ( $values['hideLiu'] ) { $conds[] = 'rc_user = 0'; } if ( $values['hideAnons'] ) { $conds[] = 'rc_user != 0'; } if ( $user->useRCPatrol() && $values['hidePatrolled'] ) { $conds[] = 'rc_patrolled != 1'; } if ( $nameSpaceClause ) { $conds[] = $nameSpaceClause; } # Toggle watchlist content (all recent edits or just the latest) if ( $values['extended'] ) { $limitWatchlist = $user->getIntOption( 'wllimit' ); $usePage = false; } else { # Top log Ids for a page are not stored $nonRevisionTypes = array( RC_LOG ); wfRunHooks( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) ); if ( $nonRevisionTypes ) { if ( count( $nonRevisionTypes ) === 1 ) { // if only one use an equality instead of IN condition $nonRevisionTypes = reset( $nonRevisionTypes ); } $conds[] = $dbr->makeList( array( 'rc_this_oldid=page_latest', 'rc_type' => $nonRevisionTypes, ), LIST_OR ); } $limitWatchlist = 0; $usePage = true; } # Show a message about slave lag, if applicable $lag = wfGetLB()->safeGetLag( $dbr ); if ( $lag > 0 ) { $output->showLagWarning( $lag ); } # Create output $form = ''; # Show watchlist header $form .= "<p>"; $form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n"; if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) { $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n"; } if ( $wgShowUpdatedMarker ) { $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n"; } $form .= "</p>"; if ( $wgShowUpdatedMarker ) { $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'id' => 'mw-watchlist-resetbutton' ) ) . "\n" . Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" . Html::hidden( 'reset', 'all' ) . "\n"; foreach ( $nondefaults as $key => $value ) { $form .= Html::hidden( $key, $value ) . "\n"; } $form .= Xml::closeElement( 'form' ) . "\n"; } $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'id' => 'mw-watchlist-form' ) ); $form .= Xml::fieldset( $this->msg( 'watchlist-options' )->text(), false, array( 'id' => 'mw-watchlist-options' ) ); $tables = array( 'recentchanges', 'watchlist' ); $fields = RecentChange::selectFields(); $join_conds = array( 'watchlist' => array( 'INNER JOIN', array( 'wl_user' => $user->getId(), 'wl_namespace=rc_namespace', 'wl_title=rc_title' ), ), ); $options = array( 'ORDER BY' => 'rc_timestamp DESC' ); if ( $wgShowUpdatedMarker ) { $fields[] = 'wl_notificationtimestamp'; } if ( $limitWatchlist ) { $options['LIMIT'] = $limitWatchlist; } $rollbacker = $user->isAllowed( 'rollback' ); if ( $usePage || $rollbacker ) { $tables[] = 'page'; $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' ); if ( $rollbacker ) { $fields[] = 'page_latest'; } } // Log entries with DELETED_ACTION must not show up unless the user has // the necessary rights. if ( !$user->isAllowed( 'deletedhistory' ) ) { $bitmask = LogPage::DELETED_ACTION; } elseif ( !$user->isAllowed( 'suppressrevision' ) ) { $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED; } else { $bitmask = 0; } if ( $bitmask ) { $conds[] = $dbr->makeList( array( 'rc_type != ' . RC_LOG, $dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask", ), LIST_OR ); } ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $options, '' ); wfRunHooks( 'SpecialWatchlistQuery', array( &$conds, &$tables, &$join_conds, &$fields, $values ) ); $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds ); $numRows = $res->numRows(); /* Start bottom header */ $lang = $this->getLanguage(); $wlInfo = ''; if ( $values['days'] > 0 ) { $timestamp = wfTimestampNow(); $wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $values['days'] * 24 ) )->params( $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "<br />\n"; } $cutofflinks = $this->cutoffLinks( $values['days'], $nondefaults ) . "<br />\n"; # Spit out some control panel links $filters = array( 'hideMinor' => 'rcshowhideminor', 'hideBots' => 'rcshowhidebots', 'hideAnons' => 'rcshowhideanons', 'hideLiu' => 'rcshowhideliu', 'hideOwn' => 'rcshowhidemine', 'hidePatrolled' => 'rcshowhidepatr' ); foreach ( $this->customFilters as $key => $params ) { $filters[$key] = $params['msg']; } // Disable some if needed if ( !$user->useNPPatrol() ) { unset( $filters['hidePatrolled'] ); } $links = array(); foreach ( $filters as $name => $msg ) { $links[] = $this->showHideLink( $nondefaults, $msg, $name, $values[$name] ); } $hiddenFields = $nondefaults; unset( $hiddenFields['namespace'] ); unset( $hiddenFields['invert'] ); unset( $hiddenFields['associated'] ); # Namespace filter and put the whole form together. $form .= $wlInfo; $form .= $cutofflinks; $form .= $lang->pipeList( $links ) . "\n"; $form .= "<hr />\n<p>"; $form .= Html::namespaceSelector( array( 'selected' => $nameSpace, 'all' => '', 'label' => $this->msg( 'namespace' )->text() ), array( 'name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector', ) ) . ' '; $form .= Xml::checkLabel( $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $invert, array( 'title' => $this->msg( 'tooltip-invert' )->text() ) ) . ' '; $form .= Xml::checkLabel( $this->msg( 'namespace_association' )->text(), 'associated', 'associated', $associated, array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() ) ) . ' '; $form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "</p>\n"; foreach ( $hiddenFields as $key => $value ) { $form .= Html::hidden( $key, $value ) . "\n"; } $form .= Xml::closeElement( 'fieldset' ) . "\n"; $form .= Xml::closeElement( 'form' ) . "\n"; $output->addHTML( $form ); # If there's nothing to show, stop here if ( $numRows == 0 ) { $output->wrapWikiMsg( "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult' ); return; } /* End bottom header */ /* Do link batch query */ $linkBatch = new LinkBatch; foreach ( $res as $row ) { $userNameUnderscored = str_replace( ' ', '_', $row->rc_user_text ); if ( $row->rc_user != 0 ) { $linkBatch->add( NS_USER, $userNameUnderscored ); } $linkBatch->add( NS_USER_TALK, $userNameUnderscored ); $linkBatch->add( $row->rc_namespace, $row->rc_title ); } $linkBatch->execute(); $dbr->dataSeek( $res, 0 ); $list = ChangesList::newFromContext( $this->getContext() ); $list->setWatchlistDivs(); $s = $list->beginRecentChangesList(); $counter = 1; foreach ( $res as $obj ) { # Make RC entry $rc = RecentChange::newFromRow( $obj ); $rc->counter = $counter++; if ( $wgShowUpdatedMarker ) { $updated = $obj->wl_notificationtimestamp; } else { $updated = false; } if ( $wgRCShowWatchingUsers && $user->getOption( 'shownumberswatching' ) ) { $rc->numberofWatchingusers = $dbr->selectField( 'watchlist', 'COUNT(*)', array( 'wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title, ), __METHOD__ ); } else { $rc->numberofWatchingusers = 0; } $changeLine = $list->recentChangesLine( $rc, $updated, $counter ); if ( $changeLine !== false ) { $s .= $changeLine; } } $s .= $list->endRecentChangesList(); $output->addHTML( $s ); }
/** * Build and output the actual changes list. * * @param ResultWrapper $rows Database rows * @param FormOptions $opts */ public function outputChangesList($rows, $opts) { $limit = $opts['limit']; $showWatcherCount = $this->getConfig()->get('RCShowWatchingUsers') && $this->getUser()->getOption('shownumberswatching'); $watcherCache = []; $dbr = $this->getDB(); $counter = 1; $list = ChangesList::newFromContext($this->getContext()); $list->initChangesListRows($rows); $userShowHiddenCats = $this->getUser()->getBoolOption('showhiddencats'); $rclistOutput = $list->beginRecentChangesList(); foreach ($rows as $obj) { if ($limit == 0) { break; } $rc = RecentChange::newFromRow($obj); # Skip CatWatch entries for hidden cats based on user preference if ($rc->getAttribute('rc_type') == RC_CATEGORIZE && !$userShowHiddenCats && $rc->getParam('hidden-cat')) { continue; } $rc->counter = $counter++; # Check if the page has been updated since the last visit if ($this->getConfig()->get('ShowUpdatedMarker') && !empty($obj->wl_notificationtimestamp)) { $rc->notificationtimestamp = $obj->rc_timestamp >= $obj->wl_notificationtimestamp; } else { $rc->notificationtimestamp = false; // Default } # Check the number of users watching the page $rc->numberofWatchingusers = 0; // Default if ($showWatcherCount && $obj->rc_namespace >= 0) { if (!isset($watcherCache[$obj->rc_namespace][$obj->rc_title])) { $watcherCache[$obj->rc_namespace][$obj->rc_title] = MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(new TitleValue((int) $obj->rc_namespace, $obj->rc_title)); } $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title]; } $changeLine = $list->recentChangesLine($rc, !empty($obj->wl_user), $counter); if ($changeLine !== false) { $rclistOutput .= $changeLine; --$limit; } } $rclistOutput .= $list->endRecentChangesList(); if ($rows->numRows() === 0) { $this->getOutput()->addHTML('<div class="mw-changeslist-empty">' . $this->msg('recentchanges-noresult')->parse() . '</div>'); if (!$this->including()) { $this->getOutput()->setStatusCode(404); } } else { $this->getOutput()->addHTML($rclistOutput); } }
function revisionInfo($row) { global $wgUser; $changes = ChangesList::newFromContext(RequestContext::getMain()); $out = $changes->beginRecentChangesList(); $rc = RecentChange::newFromCurRow($row); $rc->counter = 0; // ??? $out .= $changes->recentChangesLine($rc); $out .= $changes->endRecentChangesList(); return $out; }
/** * Build and output the actual changes list. * * @param ResultWrapper $rows Database rows * @param FormOptions $opts */ public function outputChangesList($rows, $opts) { $dbr = $this->getDB(); $user = $this->getUser(); $output = $this->getOutput(); # Show a message about replica DB lag, if applicable $lag = wfGetLB()->safeGetLag($dbr); if ($lag > 0) { $output->showLagWarning($lag); } # If no rows to display, show message before try to render the list if ($rows->numRows() == 0) { $output->wrapWikiMsg("<div class='mw-changeslist-empty'>\n\$1\n</div>", 'recentchanges-noresult'); return; } $dbr->dataSeek($rows, 0); $list = ChangesList::newFromContext($this->getContext()); $list->setWatchlistDivs(); $list->initChangesListRows($rows); $dbr->dataSeek($rows, 0); if ($this->getConfig()->get('RCShowWatchingUsers') && $user->getOption('shownumberswatching')) { $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore(); } $s = $list->beginRecentChangesList(); $userShowHiddenCats = $this->getUser()->getBoolOption('showhiddencats'); $counter = 1; foreach ($rows as $obj) { # Make RC entry $rc = RecentChange::newFromRow($obj); # Skip CatWatch entries for hidden cats based on user preference if ($rc->getAttribute('rc_type') == RC_CATEGORIZE && !$userShowHiddenCats && $rc->getParam('hidden-cat')) { continue; } $rc->counter = $counter++; if ($this->getConfig()->get('ShowUpdatedMarker')) { $updated = $obj->wl_notificationtimestamp; } else { $updated = false; } if (isset($watchedItemStore)) { $rcTitleValue = new TitleValue((int) $obj->rc_namespace, $obj->rc_title); $rc->numberofWatchingusers = $watchedItemStore->countWatchers($rcTitleValue); } else { $rc->numberofWatchingusers = 0; } $changeLine = $list->recentChangesLine($rc, $updated, $counter); if ($changeLine !== false) { $s .= $changeLine; } } $s .= $list->endRecentChangesList(); $output->addHTML($s); }
/** * Execute * @param $par Parameter passed to the page */ function execute($par) { global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker; $user = $this->getUser(); $output = $this->getOutput(); # Anons don't get a watchlist if ($user->isAnon()) { $output->setPageTitle($this->msg('watchnologin')); $output->setRobotPolicy('noindex,nofollow'); $llink = Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), $this->msg('loginreqlink')->escaped(), array(), array('returnto' => $this->getTitle()->getPrefixedText())); $output->addHTML($this->msg('watchlistanontext')->rawParams($llink)->parse()); return; } // Add feed links $wlToken = $user->getOption('watchlisttoken'); if (!$wlToken) { $wlToken = MWCryptRand::generateHex(40); $user->setOption('watchlisttoken', $wlToken); $user->saveSettings(); } $this->addFeedLinks(array('action' => 'feedwatchlist', 'allrev' => 'allrev', 'wlowner' => $user->getName(), 'wltoken' => $wlToken)); $this->setHeaders(); $this->outputHeader(); $output->addSubtitle($this->msg('watchlistfor2', $user->getName())->rawParams(SpecialEditWatchlist::buildTools(null))); $request = $this->getRequest(); $mode = SpecialEditWatchlist::getMode($request, $par); if ($mode !== false) { # TODO: localise? switch ($mode) { case SpecialEditWatchlist::EDIT_CLEAR: $mode = 'clear'; break; case SpecialEditWatchlist::EDIT_RAW: $mode = 'raw'; break; default: $mode = null; } $title = SpecialPage::getTitleFor('EditWatchlist', $mode); $output->redirect($title->getLocalUrl()); return; } $nitems = $this->countItems(); if ($nitems == 0) { $output->addWikiMsg('nowatchlist'); return; } // @TODO: use FormOptions! $defaults = array('days' => floatval($user->getOption('watchlistdays')), 'hideMinor' => (int) $user->getBoolOption('watchlisthideminor'), 'hideBots' => (int) $user->getBoolOption('watchlisthidebots'), 'hideAnons' => (int) $user->getBoolOption('watchlisthideanons'), 'hideLiu' => (int) $user->getBoolOption('watchlisthideliu'), 'hidePatrolled' => (int) $user->getBoolOption('watchlisthidepatrolled'), 'hideOwn' => (int) $user->getBoolOption('watchlisthideown'), 'namespace' => 'all', 'invert' => false, 'associated' => false); $this->customFilters = array(); wfRunHooks('SpecialWatchlistFilters', array($this, &$this->customFilters)); foreach ($this->customFilters as $key => $params) { $defaults[$key] = $params['msg']; } # Extract variables from the request, falling back to user preferences or # other default values if these don't exist $prefs['days'] = floatval($user->getOption('watchlistdays')); $prefs['hideminor'] = $user->getBoolOption('watchlisthideminor'); $prefs['hidebots'] = $user->getBoolOption('watchlisthidebots'); $prefs['hideanons'] = $user->getBoolOption('watchlisthideanons'); $prefs['hideliu'] = $user->getBoolOption('watchlisthideliu'); $prefs['hideown'] = $user->getBoolOption('watchlisthideown'); $prefs['hidepatrolled'] = $user->getBoolOption('watchlisthidepatrolled'); # Get query variables $values = array(); $values['days'] = $request->getVal('days', $prefs['days']); $values['hideMinor'] = (int) $request->getBool('hideMinor', $prefs['hideminor']); $values['hideBots'] = (int) $request->getBool('hideBots', $prefs['hidebots']); $values['hideAnons'] = (int) $request->getBool('hideAnons', $prefs['hideanons']); $values['hideLiu'] = (int) $request->getBool('hideLiu', $prefs['hideliu']); $values['hideOwn'] = (int) $request->getBool('hideOwn', $prefs['hideown']); $values['hidePatrolled'] = (int) $request->getBool('hidePatrolled', $prefs['hidepatrolled']); foreach ($this->customFilters as $key => $params) { $values[$key] = (int) $request->getBool($key); } # Get namespace value, if supplied, and prepare a WHERE fragment $nameSpace = $request->getIntOrNull('namespace'); $invert = $request->getBool('invert'); $associated = $request->getBool('associated'); if (!is_null($nameSpace)) { $eq_op = $invert ? '!=' : '='; $bool_op = $invert ? 'AND' : 'OR'; $nameSpace = intval($nameSpace); // paranioa if (!$associated) { $nameSpaceClause = "rc_namespace {$eq_op} {$nameSpace}"; } else { $associatedNS = MWNamespace::getAssociated($nameSpace); $nameSpaceClause = "rc_namespace {$eq_op} {$nameSpace} " . $bool_op . " rc_namespace {$eq_op} {$associatedNS}"; } } else { $nameSpace = ''; $nameSpaceClause = ''; } $values['namespace'] = $nameSpace; $values['invert'] = $invert; $values['associated'] = $associated; if (is_null($values['days']) || !is_numeric($values['days'])) { $big = 1000; /* The magical big */ if ($nitems > $big) { # Set default cutoff shorter $values['days'] = $defaults['days'] = 12.0 / 24.0; # 12 hours... } else { $values['days'] = $defaults['days']; # default cutoff for shortlisters } } else { $values['days'] = floatval($values['days']); } // Dump everything here $nondefaults = array(); foreach ($defaults as $name => $defValue) { wfAppendToArrayIfNotDefault($name, $values[$name], $defaults, $nondefaults); } if (($wgEnotifWatchlist || $wgShowUpdatedMarker) && $request->getVal('reset') && $request->wasPosted()) { $user->clearAllNotifications(); $output->redirect($this->getTitle()->getFullUrl($nondefaults)); return; } $dbr = wfGetDB(DB_SLAVE, 'watchlist'); # Possible where conditions $conds = array(); if ($values['days'] > 0) { $conds[] = "rc_timestamp > '" . $dbr->timestamp(time() - intval($values['days'] * 86400)) . "'"; } # If the watchlist is relatively short, it's simplest to zip # down its entirety and then sort the results. # If it's relatively long, it may be worth our while to zip # through the time-sorted page list checking for watched items. # Up estimate of watched items by 15% to compensate for talk pages... # Toggles if ($values['hideOwn']) { $conds[] = 'rc_user != ' . $user->getId(); } if ($values['hideBots']) { $conds[] = 'rc_bot = 0'; } if ($values['hideMinor']) { $conds[] = 'rc_minor = 0'; } if ($values['hideLiu']) { $conds[] = 'rc_user = 0'; } if ($values['hideAnons']) { $conds[] = 'rc_user != 0'; } if ($user->useRCPatrol() && $values['hidePatrolled']) { $conds[] = 'rc_patrolled != 1'; } if ($nameSpaceClause) { $conds[] = $nameSpaceClause; } # Toggle watchlist content (all recent edits or just the latest) if ($user->getOption('extendwatchlist')) { $limitWatchlist = intval($user->getOption('wllimit')); $usePage = false; } else { # Top log Ids for a page are not stored $conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG; $limitWatchlist = 0; $usePage = true; } # Show a message about slave lag, if applicable $lag = wfGetLB()->safeGetLag($dbr); if ($lag > 0) { $output->showLagWarning($lag); } # Create output form $form = Xml::fieldset($this->msg('watchlist-options')->text(), false, array('id' => 'mw-watchlist-options')); # Show watchlist header $form .= $this->msg('watchlist-details')->numParams($nitems)->parse(); if ($user->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) { $form .= $this->msg('wlheader-enotif')->parseAsBlock() . "\n"; } if ($wgShowUpdatedMarker) { $form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-resetbutton')) . $this->msg('wlheader-showupdated')->parse() . ' ' . Xml::submitButton($this->msg('enotif_reset')->text(), array('name' => 'dummy')) . Html::hidden('reset', 'all'); foreach ($nondefaults as $key => $value) { $form .= Html::hidden($key, $value); } $form .= Xml::closeElement('form'); } $form .= '<hr />'; $tables = array('recentchanges', 'watchlist'); $fields = RecentChange::selectFields(); $join_conds = array('watchlist' => array('INNER JOIN', array('wl_user' => $user->getId(), 'wl_namespace=rc_namespace', 'wl_title=rc_title'))); $options = array('ORDER BY' => 'rc_timestamp DESC'); if ($wgShowUpdatedMarker) { $fields[] = 'wl_notificationtimestamp'; } if ($limitWatchlist) { $options['LIMIT'] = $limitWatchlist; } $rollbacker = $user->isAllowed('rollback'); if ($usePage || $rollbacker) { $tables[] = 'page'; $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id'); if ($rollbacker) { $fields[] = 'page_latest'; } } ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, ''); wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields)); $res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds); $numRows = $res->numRows(); /* Start bottom header */ $lang = $this->getLanguage(); $wlInfo = ''; if ($values['days'] > 0) { $timestamp = wfTimestampNow(); $wlInfo = $this->msg('wlnote')->numParams($numRows, round($values['days'] * 24))->params($lang->userDate($timestamp, $user), $lang->userTime($timestamp, $user))->parse() . '<br />'; } $cutofflinks = "\n" . $this->cutoffLinks($values['days'], $nondefaults) . "<br />\n"; # Spit out some control panel links $filters = array('hideMinor' => 'rcshowhideminor', 'hideBots' => 'rcshowhidebots', 'hideAnons' => 'rcshowhideanons', 'hideLiu' => 'rcshowhideliu', 'hideOwn' => 'rcshowhidemine', 'hidePatrolled' => 'rcshowhidepatr'); foreach ($this->customFilters as $key => $params) { $filters[$key] = $params['msg']; } // Disable some if needed if (!$user->useNPPatrol()) { unset($filters['hidePatrolled']); } $links = array(); foreach ($filters as $name => $msg) { $links[] = $this->showHideLink($nondefaults, $msg, $name, $values[$name]); } # Namespace filter and put the whole form together. $form .= $wlInfo; $form .= $cutofflinks; $form .= $lang->pipeList($links); $form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector')); $form .= '<hr /><p>'; $form .= Html::namespaceSelector(array('selected' => $nameSpace, 'all' => '', 'label' => $this->msg('namespace')->text()), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . ' '; $form .= Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $invert, array('title' => $this->msg('tooltip-invert')->text())) . ' '; $form .= Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $associated, array('title' => $this->msg('tooltip-namespace_association')->text())) . ' '; $form .= Xml::submitButton($this->msg('allpagessubmit')->text()) . '</p>'; $form .= Html::hidden('days', $values['days']); foreach ($filters as $key => $msg) { if ($values[$key]) { $form .= Html::hidden($key, 1); } } $form .= Xml::closeElement('form'); $form .= Xml::closeElement('fieldset'); $output->addHTML($form); # If there's nothing to show, stop here if ($numRows == 0) { $output->addWikiMsg('watchnochange'); return; } /* End bottom header */ /* Do link batch query */ $linkBatch = new LinkBatch(); foreach ($res as $row) { $userNameUnderscored = str_replace(' ', '_', $row->rc_user_text); if ($row->rc_user != 0) { $linkBatch->add(NS_USER, $userNameUnderscored); } $linkBatch->add(NS_USER_TALK, $userNameUnderscored); $linkBatch->add($row->rc_namespace, $row->rc_title); } $linkBatch->execute(); $dbr->dataSeek($res, 0); $list = ChangesList::newFromContext($this->getContext()); $list->setWatchlistDivs(); $s = $list->beginRecentChangesList(); $counter = 1; foreach ($res as $obj) { # Make RC entry $rc = RecentChange::newFromRow($obj); $rc->counter = $counter++; if ($wgShowUpdatedMarker) { $updated = $obj->wl_notificationtimestamp; } else { $updated = false; } if ($wgRCShowWatchingUsers && $user->getOption('shownumberswatching')) { $rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__); } else { $rc->numberofWatchingusers = 0; } $s .= $list->recentChangesLine($rc, $updated, $counter); } $s .= $list->endRecentChangesList(); $output->addHTML($s); }
public function buildRssWatch($par) { // TODO SU (04.07.11 10:35): Globals global $wgUser, $wgOut, $wgRequest, $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifWatchlist, $wgSitename; $skin = RequestContext::getMain()->getSkin(); $specialTitle = SpecialPage::getTitleFor('Watchlist'); $wgOut->setRobotPolicy('noindex,nofollow'); # Anons don't get a watchlist if ($wgUser->isAnon()) { $_user = $wgRequest->getVal('u', ''); $user = User::newFromName($_user); $_hash = $wgRequest->getVal('h', ''); if (!($user && $_hash == md5($_user . $user->getToken() . $user->getId())) || $user->isAnon()) { $oTitle = SpecialPage::getTitleFor('Userlogin'); $sLink = Linker::link($oTitle, wfMessage('loginreqlink')->plain(), array(), array('returnto' => $specialTitle->getLocalUrl())); throw new ErrorPageError('bs-rssstandards-watchnologin', 'watchlistanontext', array($sLink)); } } else { $user = $wgUser; } $wgOut->setPageTitle(wfMessage('bs-rssstandards-watchlist')->plain()); $sub = wfMessage('watchlistfor', $user->getName())->parse(); $sub .= '<br />' . WatchlistEditor::buildTools($user->getSkin()); $wgOut->setSubtitle($sub); if (($mode = WatchlistEditor::getMode($wgRequest, $par)) !== false) { $editor = new WatchlistEditor(); $editor->execute($user, $wgOut, $wgRequest, $mode); return; } $uid = $user->getId(); if (($wgEnotifWatchlist || $wgShowUpdatedMarker) && $wgRequest->getVal('reset') && $wgRequest->wasPosted()) { $user->clearAllNotifications($uid); $wgOut->redirect($specialTitle->getFullUrl()); return; } $defaults = array('days' => floatval($user->getOption('watchlistdays')), 'hideOwn' => (int) $user->getBoolOption('watchlisthideown'), 'hideBots' => (int) $user->getBoolOption('watchlisthidebots'), 'hideMinor' => (int) $user->getBoolOption('watchlisthideminor'), 'namespace' => 'all'); extract($defaults); # Extract variables from the request, falling back to user preferences or # other default values if these don't exist $prefs['days'] = floatval($user->getOption('watchlistdays')); $prefs['hideown'] = $user->getBoolOption('watchlisthideown'); $prefs['hidebots'] = $user->getBoolOption('watchlisthidebots'); $prefs['hideminor'] = $user->getBoolOption('watchlisthideminor'); # Get query variables $days = $wgRequest->getVal('days', $prefs['days']); $hideOwn = $wgRequest->getBool('hideOwn', $prefs['hideown']); $hideBots = $wgRequest->getBool('hideBots', $prefs['hidebots']); $hideMinor = $wgRequest->getBool('hideMinor', $prefs['hideminor']); # Get namespace value, if supplied, and prepare a WHERE fragment $nameSpace = $wgRequest->getIntOrNull('namespace'); if (!is_null($nameSpace)) { $nameSpace = intval($nameSpace); $nameSpaceClause = " AND rc_namespace = {$nameSpace}"; } else { $nameSpace = ''; $nameSpaceClause = ''; } $dbr = wfGetDB(DB_SLAVE, 'watchlist'); list($page, $watchlist, $recentchanges) = $dbr->tableNamesN('page', 'watchlist', 'recentchanges'); $watchlistCount = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_user' => $uid), __METHOD__); // Adjust for page X, talk:page X, which are both stored separately, // but treated together $nitems = floor($watchlistCount / 2); if (is_null($days) || !is_numeric($days)) { $big = 1000; /* The magical big */ if ($nitems > $big) { # Set default cutoff shorter $days = $defaults['days'] = 12.0 / 24.0; # 12 hours... } else { $days = $defaults['days']; # default cutoff for shortlisters } } else { $days = floatval($days); } // Dump everything here $nondefaults = array(); wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults); wfAppendToArrayIfNotDefault('hideOwn', (int) $hideOwn, $defaults, $nondefaults); wfAppendToArrayIfNotDefault('hideBots', (int) $hideBots, $defaults, $nondefaults); wfAppendToArrayIfNotDefault('hideMinor', (int) $hideMinor, $defaults, $nondefaults); wfAppendToArrayIfNotDefault('namespace', $nameSpace, $defaults, $nondefaults); $hookSql = ""; if (!wfRunHooks('BeforeWatchlist', array($nondefaults, $user, &$hookSql))) { return; } /*if ( $nitems == 0 ) { $wgOut->addWikiMsg( 'nowatchlist' ); return; }*/ if ($days <= 0) { $andcutoff = ''; } else { $andcutoff = "AND rc_timestamp > '" . $dbr->timestamp(time() - intval($days * 86400)) . "'"; } # If the watchlist is relatively short, it's simplest to zip # down its entirety and then sort the results. # If it's relatively long, it may be worth our while to zip # through the time-sorted page list checking for watched items. # Up estimate of watched items by 15% to compensate for talk pages... # Toggles $andHideOwn = $hideOwn ? "AND (rc_user <> {$uid})" : ''; $andHideBots = $hideBots ? "AND (rc_bot = 0)" : ''; $andHideMinor = $hideMinor ? 'AND rc_minor = 0' : ''; # Toggle watchlist content (all recent edits or just the latest) if ($user->getOption('extendwatchlist')) { $andLatest = ''; $limitWatchlist = 'LIMIT ' . intval($user->getOption('wllimit')); } else { # Top log Ids for a page are not stored $andLatest = 'AND (rc_this_oldid=page_latest OR rc_type=' . RC_LOG . ') '; $limitWatchlist = ''; } if ($wgShowUpdatedMarker) { $wltsfield = ", {$watchlist}.wl_notificationtimestamp "; } else { $wltsfield = ''; } $sql = "SELECT {$recentchanges}.* {$wltsfield}\n\t FROM {$watchlist},{$recentchanges}\n\t LEFT JOIN {$page} ON rc_cur_id=page_id\n\t WHERE wl_user={$uid}\n\t AND wl_namespace=rc_namespace\n\t AND wl_title=rc_title\n\t\t\t{$andcutoff}\n\t\t\t{$andLatest}\n\t\t\t{$andHideOwn}\n\t\t\t{$andHideBots}\n\t\t\t{$andHideMinor}\n\t\t\t{$nameSpaceClause}\n\t\t\t{$hookSql}\n\t ORDER BY rc_timestamp DESC\n\t\t\t{$limitWatchlist}"; $res = $dbr->query($sql, __METHOD__); $numRows = $dbr->numRows($res); /*# If there's nothing to show, stop here if( $numRows == 0 ) { $wgOut->addWikiMsg( 'watchnochange' ); return; }*/ /* End bottom header */ if ($numRows > 0) { /* Do link batch query */ $linkBatch = new LinkBatch(); while ($row = $dbr->fetchObject($res)) { $userNameUnderscored = str_replace(' ', '_', $row->rc_user_text); if ($row->rc_user != 0) { $linkBatch->add(NS_USER, $userNameUnderscored); } $linkBatch->add(NS_USER_TALK, $userNameUnderscored); } $linkBatch->execute(); $dbr->dataSeek($res, 0); } $list = ChangesList::newFromContext($skin->getContext()); //Thanks to Bartosz Dziewoński (https://gerrit.wikimedia.org/r/#/c/94082/) $channel = RSSCreator::createChannel(SpecialPage::getTitleFor('Watchlist') . ' (' . $user->getName() . ')', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], wfMessage('bs-rssstandards-desc-watch')->plain()); $html = $list->beginRecentChangesList(); $counter = 1; $items = array(); while ($obj = $dbr->fetchObject($res)) { $title = Title::newFromText($obj->rc_title, $obj->rc_namespace); $items[] = array('title' => $title->getPrefixedText(), 'link' => $title->getFullURL(), 'date' => wfTimestamp(TS_UNIX, $obj->rc_timestamp), 'comments' => $title->getTalkPage()->getFullURL()); # Make RC entry $rc = RecentChange::newFromRow($obj); $rc->counter = $counter++; if ($wgShowUpdatedMarker) { $updated = $obj->wl_notificationtimestamp; } else { $updated = false; } if ($wgRCShowWatchingUsers && $user->getOption('shownumberswatching')) { $rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__); } else { $rc->numberofWatchingusers = 0; } $rc->mAttribs['rc_timestamp'] = 0; $html .= $list->recentChangesLine($rc, false); } $html .= $list->endRecentChangesList(); $lines = array(); preg_match_all('%<li.*?>(.*?)</li>%', $html, $lines, PREG_SET_ORDER); foreach ($lines as $key => $line) { $item = $items[$key]; $entry = RSSItemCreator::createItem($item['title'], $item['link'], RSSCreator::xmlEncode($line[1])); if ($entry == false) { wfDebugLog('BS::RSSStandards::buildRssWatch', 'Invalid item: ' . var_export($item, true)); continue; } $entry->setPubDate($item['date']); $entry->setComments($item['comments']); $channel->addItem($entry); } $dbr->freeResult($res); return $channel->buildOutput(); }
private function buildQuickWatchlist() { global $wgShowUpdatedMarker, $wgRCShowWatchingUsers; $user = $this->getUser(); // Building the request $dbr = wfGetDB(DB_SLAVE, 'watchlist'); $tables = array('recentchanges', 'watchlist'); $fields = array($dbr->tableName('recentchanges') . '.*'); if ($wgShowUpdatedMarker) { $fields[] = 'wl_notificationtimestamp'; } $conds = array(); $conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG; $limitWatchlist = 0; $usePage = true; $join_conds = array('watchlist' => array('INNER JOIN', "wl_user='******' AND wl_namespace=rc_namespace AND wl_title=rc_title")); $options = array('LIMIT' => 5, 'ORDER BY' => 'rc_timestamp DESC'); $rollbacker = $user->isAllowed('rollback'); if ($usePage || $rollbacker) { $tables[] = 'page'; $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id'); if ($rollbacker) { $fields[] = 'page_latest'; } } ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, ''); $res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds); $numRows = $dbr->numRows($res); $s = '<div class="ms-info-wl">' . wfMessage('ms-watchlist')->parse() . '</div>'; if ($numRows == 0) { $s .= '<p class="ms-wl-empty">' . wfMessage('watchnochange')->parse() . '</p>'; } else { /* Do link batch query */ $linkBatch = new LinkBatch(); foreach ($res as $row) { $userNameUnderscored = str_replace(' ', '_', $row->rc_user_text); if ($row->rc_user != 0) { $linkBatch->add(NS_USER, $userNameUnderscored); } $linkBatch->add(NS_USER_TALK, $userNameUnderscored); $linkBatch->add($row->rc_namespace, $row->rc_title); } $linkBatch->execute(); $dbr->dataSeek($res, 0); $list = ChangesList::newFromContext($this->getContext()); $list->setWatchlistDivs(); $s .= $list->beginRecentChangesList(); $counter = 1; foreach ($res as $obj) { # Make RC entry $rc = RecentChange::newFromRow($obj); $rc->counter = $counter++; // Updated markers are always shown $updated = $obj->wl_notificationtimestamp; // We don't display the count of watching users $rc->numberofWatchingusers = 0; $s .= $list->recentChangesLine($rc, $updated, $counter); } $s .= $list->endRecentChangesList(); } return $s; }