40 private $linkRenderer;
50 $this->context = $context;
51 $this->messages = $messages;
52 $this->linkRenderer = $linkRenderer;
62 $user = $this->context->getUser();
67 $cacheEntry->unpatrolled = ChangesList::isUnpatrolled( $baseRC, $user );
69 $cacheEntry->watched = $cacheEntry->mAttribs[
'rc_type'] ==
RC_LOG ? false : $watched;
70 $cacheEntry->numberofWatchingusers = $baseRC->numberofWatchingusers;
71 $cacheEntry->watchlistExpiry = $baseRC->watchlistExpiry;
73 $cacheEntry->link = $this->buildCLink( $cacheEntry );
74 $cacheEntry->timestamp = $this->buildTimestamp( $cacheEntry );
78 $showDiffLinks = $this->showDiffLinks( $cacheEntry, $user );
80 $cacheEntry->difflink = $this->buildDiffLink( $cacheEntry, $showDiffLinks );
81 $cacheEntry->curlink = $this->buildCurLink( $cacheEntry, $showDiffLinks );
82 $cacheEntry->lastlink = $this->buildLastLink( $cacheEntry, $showDiffLinks );
85 $cacheEntry->userlink = $this->getUserLink( $cacheEntry );
87 if ( !ChangesList::isDeleted( $cacheEntry, RevisionRecord::DELETED_USER ) ) {
88 $cacheEntry->usertalklink = Linker::userToolLinks(
89 $cacheEntry->mAttribs[
'rc_user'],
90 $cacheEntry->mAttribs[
'rc_user_text'],
112 return ChangesList::userCan( $cacheEntry, RevisionRecord::DELETED_TEXT, $performer );
120 private function buildCLink(
RCCacheEntry $cacheEntry ) {
121 $type = $cacheEntry->mAttribs[
'rc_type'];
125 $logType = $cacheEntry->mAttribs[
'rc_log_type'];
128 $clink = $this->getLogLink( $logType );
130 wfDebugLog(
'recentchanges',
'Unexpected log entry with no log type in recent changes' );
131 $clink = $this->linkRenderer->makeLink( $cacheEntry->
getTitle() );
134 } elseif ( $cacheEntry->mAttribs[
'rc_namespace'] ==
NS_SPECIAL ) {
135 wfDebugLog(
'recentchanges',
'Unexpected special page in recentchanges' );
139 $clink = $this->linkRenderer->makeKnownLink( $cacheEntry->
getTitle() );
145 private function getLogLink( $logType ) {
147 $logpage =
new LogPage( $logType );
148 $logname = $logpage->getName()->text();
150 $logLink = $this->context->msg(
'parentheses' )
152 $this->linkRenderer->makeKnownLink( $logtitle, $logname )
163 private function buildTimestamp(
RecentChange $cacheEntry ) {
164 return $this->context->getLanguage()->userTime(
165 $cacheEntry->mAttribs[
'rc_timestamp'],
166 $this->context->getUser()
175 private function buildCurQueryParams(
RecentChange $recentChange ) {
177 'curid' => $recentChange->mAttribs[
'rc_cur_id'],
179 'oldid' => $recentChange->mAttribs[
'rc_this_oldid']
189 private function buildCurLink(
RecentChange $cacheEntry, $showDiffLinks ) {
190 $curMessage = $this->getMessage(
'cur' );
192 if ( $cacheEntry->mAttribs[
'rc_this_oldid'] == $cacheEntry->
getAttribute(
'page_latest' ) ) {
193 $showDiffLinks =
false;
196 if ( !$showDiffLinks || in_array( $cacheEntry->mAttribs[
'rc_type'], $logTypes ) ) {
197 $curLink = $curMessage;
199 $queryParams = $this->buildCurQueryParams( $cacheEntry );
200 $curUrl = htmlspecialchars( $cacheEntry->
getTitle()->getLinkURL( $queryParams ) );
201 $curLink =
"<a class=\"mw-changeslist-diff-cur\" href=\"$curUrl\">$curMessage</a>";
212 private function buildDiffQueryParams(
RecentChange $recentChange ) {
214 'curid' => $recentChange->mAttribs[
'rc_cur_id'],
215 'diff' => $recentChange->mAttribs[
'rc_this_oldid'],
216 'oldid' => $recentChange->mAttribs[
'rc_last_oldid']
226 private function buildDiffLink(
RecentChange $cacheEntry, $showDiffLinks ) {
227 $queryParams = $this->buildDiffQueryParams( $cacheEntry );
228 $diffMessage = $this->getMessage(
'diff' );
231 if ( !$showDiffLinks ) {
232 $diffLink = $diffMessage;
233 } elseif ( in_array( $cacheEntry->mAttribs[
'rc_type'], $logTypes ) ) {
234 $diffLink = $diffMessage;
237 $pageTitle = Title::newFromID( $rcCurId );
238 if ( $pageTitle ===
null ) {
239 wfDebugLog(
'RCCacheEntryFactory',
'Could not get Title for rc_cur_id: ' . $rcCurId );
242 $diffUrl = htmlspecialchars( $pageTitle->getLinkURL( $queryParams ) );
243 $diffLink =
"<a class=\"mw-changeslist-diff\" href=\"$diffUrl\">$diffMessage</a>";
245 $diffUrl = htmlspecialchars( $cacheEntry->
getTitle()->getLinkURL( $queryParams ) );
246 $diffLink =
"<a class=\"mw-changeslist-diff\" href=\"$diffUrl\">$diffMessage</a>";
260 private function buildLastLink(
RecentChange $cacheEntry, $showDiffLinks ) {
261 $lastOldid = $cacheEntry->mAttribs[
'rc_last_oldid'];
262 $lastMessage = $this->getMessage(
'last' );
263 $type = $cacheEntry->mAttribs[
'rc_type'];
267 if ( !$showDiffLinks || !$lastOldid || in_array(
$type, $logTypes ) ) {
268 $lastLink = $lastMessage;
270 $lastLink = $this->linkRenderer->makeKnownLink(
273 [
'class' =>
'mw-changeslist-diff' ],
274 $this->buildDiffQueryParams( $cacheEntry )
286 private function getUserLink(
RecentChange $cacheEntry ) {
287 if ( ChangesList::isDeleted( $cacheEntry, RevisionRecord::DELETED_USER ) ) {
288 $deletedClass =
'history-deleted';
289 if ( ChangesList::isDeleted( $cacheEntry, RevisionRecord::DELETED_RESTRICTED ) ) {
290 $deletedClass .=
' mw-history-suppressed';
292 $userLink =
' <span class="' . $deletedClass .
'">' .
293 $this->context->msg(
'rev-deleted-user' )->escaped() .
'</span>';
295 $userLink = Linker::userLink(
296 $cacheEntry->mAttribs[
'rc_user'],
297 $cacheEntry->mAttribs[
'rc_user_text'],
298 ExternalUserNames::getLocal( $cacheEntry->mAttribs[
'rc_user_text'] ),
300 'data-mw-revid' => $cacheEntry->mAttribs[
'rc_this_oldid']
313 private function getMessage( $key ) {
314 return $this->messages[$key];
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Class to simplify the use of log pages.
newFromRecentChange(RecentChange $baseRC, $watched)
__construct(IContextSource $context, $messages, LinkRenderer $linkRenderer)
static newFromParent( $rc)
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Interface for objects which can provide a MediaWiki context on request.