37 private $linkRenderer;
47 $this->context = $context;
48 $this->messages = $messages;
49 $this->linkRenderer = $linkRenderer;
59 $user = $this->context->getUser();
64 $cacheEntry->unpatrolled = ChangesList::isUnpatrolled( $baseRC, $user );
66 $cacheEntry->watched = $cacheEntry->mAttribs[
'rc_type'] ==
RC_LOG ? false : $watched;
67 $cacheEntry->numberofWatchingusers = $baseRC->numberofWatchingusers;
68 $cacheEntry->watchlistExpiry = $baseRC->watchlistExpiry;
70 $cacheEntry->link = $this->buildCLink( $cacheEntry );
71 $cacheEntry->timestamp = $this->buildTimestamp( $cacheEntry );
75 $showDiffLinks = $this->showDiffLinks( $cacheEntry, $user );
77 $cacheEntry->difflink = $this->buildDiffLink( $cacheEntry, $showDiffLinks );
78 $cacheEntry->curlink = $this->buildCurLink( $cacheEntry, $showDiffLinks );
79 $cacheEntry->lastlink = $this->buildLastLink( $cacheEntry, $showDiffLinks );
82 $cacheEntry->userlink = $this->getUserLink( $cacheEntry );
84 if ( !ChangesList::isDeleted( $cacheEntry, RevisionRecord::DELETED_USER ) ) {
86 $cacheEntry->mAttribs[
'rc_user'],
87 $cacheEntry->mAttribs[
'rc_user_text'],
109 return ChangesList::userCan( $cacheEntry, RevisionRecord::DELETED_TEXT, $performer );
117 private function buildCLink(
RCCacheEntry $cacheEntry ) {
118 $type = $cacheEntry->mAttribs[
'rc_type'];
121 if ( $cacheEntry->unpatrolled &&
$type ==
RC_NEW ) {
122 $clink = $this->linkRenderer->makeKnownLink( $cacheEntry->
getTitle() );
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 $queryParams = $this->buildCurQueryParams( $cacheEntry );
191 $curMessage = $this->getMessage(
'cur' );
194 if ( !$showDiffLinks || in_array( $cacheEntry->mAttribs[
'rc_type'], $logTypes ) ) {
195 $curLink = $curMessage;
197 $curUrl = htmlspecialchars( $cacheEntry->
getTitle()->getLinkURL( $queryParams ) );
198 $curLink =
"<a class=\"mw-changeslist-diff-cur\" href=\"$curUrl\">$curMessage</a>";
209 private function buildDiffQueryParams(
RecentChange $recentChange ) {
211 'curid' => $recentChange->mAttribs[
'rc_cur_id'],
212 'diff' => $recentChange->mAttribs[
'rc_this_oldid'],
213 'oldid' => $recentChange->mAttribs[
'rc_last_oldid']
223 private function buildDiffLink(
RecentChange $cacheEntry, $showDiffLinks ) {
224 $queryParams = $this->buildDiffQueryParams( $cacheEntry );
225 $diffMessage = $this->getMessage(
'diff' );
228 if ( !$showDiffLinks ) {
229 $diffLink = $diffMessage;
230 } elseif ( in_array( $cacheEntry->mAttribs[
'rc_type'], $logTypes ) ) {
231 $diffLink = $diffMessage;
235 if ( $pageTitle ===
null ) {
236 wfDebugLog(
'RCCacheEntryFactory',
'Could not get Title for rc_cur_id: ' . $rcCurId );
239 $diffUrl = htmlspecialchars( $pageTitle->getLinkURL( $queryParams ) );
240 $diffLink =
"<a class=\"mw-changeslist-diff\" href=\"$diffUrl\">$diffMessage</a>";
242 $diffUrl = htmlspecialchars( $cacheEntry->
getTitle()->getLinkURL( $queryParams ) );
243 $diffLink =
"<a class=\"mw-changeslist-diff\" href=\"$diffUrl\">$diffMessage</a>";
257 private function buildLastLink(
RecentChange $cacheEntry, $showDiffLinks ) {
258 $lastOldid = $cacheEntry->mAttribs[
'rc_last_oldid'];
259 $lastMessage = $this->getMessage(
'last' );
260 $type = $cacheEntry->mAttribs[
'rc_type'];
264 if ( !$showDiffLinks || !$lastOldid || in_array(
$type, $logTypes ) ) {
265 $lastLink = $lastMessage;
267 $lastLink = $this->linkRenderer->makeKnownLink(
270 [
'class' =>
'mw-changeslist-diff' ],
271 $this->buildDiffQueryParams( $cacheEntry )
283 private function getUserLink(
RecentChange $cacheEntry ) {
284 if ( ChangesList::isDeleted( $cacheEntry, RevisionRecord::DELETED_USER ) ) {
285 $deletedClass =
'history-deleted';
286 if ( ChangesList::isDeleted( $cacheEntry, RevisionRecord::DELETED_RESTRICTED ) ) {
287 $deletedClass .=
' mw-history-suppressed';
289 $userLink =
' <span class="' . $deletedClass .
'">' .
290 $this->context->msg(
'rev-deleted-user' )->escaped() .
'</span>';
293 $cacheEntry->mAttribs[
'rc_user'],
294 $cacheEntry->mAttribs[
'rc_user_text'],
295 ExternalUserNames::getLocal( $cacheEntry->mAttribs[
'rc_user_text'] )
307 private function getMessage( $key ) {
308 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.
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
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.