MediaWiki REL1_35
OldChangesList.php
Go to the documentation of this file.
1<?php
24
26
36 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
37 $classes = $this->getHTMLClasses( $rc, $watched );
38 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
39 if ( $linenumber ) {
40 if ( $linenumber & 1 ) {
41 $classes[] = 'mw-line-odd';
42 } else {
43 $classes[] = 'mw-line-even';
44 }
45 }
46
47 $html = $this->formatChangeLine( $rc, $classes, $watched );
48
49 if ( $this->watchlist ) {
50 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
51 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
52 }
53
54 $attribs = $this->getDataAttributes( $rc );
55
56 if ( !$this->getHookRunner()->onOldChangesListRecentChangesLine(
57 $this, $html, $rc, $classes, $attribs )
58 ) {
59 return false;
60 }
61 $attribs = array_filter( $attribs,
62 [ Sanitizer::class, 'isReservedDataAttribute' ],
63 ARRAY_FILTER_USE_KEY
64 );
65
66 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
67 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
68
69 $html = $this->getHighlightsContainerDiv() . $html;
70 $attribs['class'] = implode( ' ', $classes );
71
72 return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
73 }
74
82 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
83 $html = '';
84 $unpatrolled = $this->showAsUnpatrolled( $rc );
85
86 if ( $rc->mAttribs['rc_log_type'] ) {
87 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
88 $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false );
89 $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
90 'bot' => $rc->mAttribs['rc_bot'] ], '' );
91 if ( $flags !== '' ) {
92 $html .= ' ' . $flags;
93 }
94 // Log entries (old format) or log targets, and special pages
95 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
96 list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
97 resolveAlias( $rc->mAttribs['rc_title'] );
98 if ( $name == 'Log' ) {
99 $this->insertLog( $html, $rc->getTitle(), $htmlubpage, false );
100 }
101 // Regular entries
102 } else {
103 $this->insertDiffHist( $html, $rc );
104 # M, N, b and ! (minor, new, bot and unpatrolled)
105 $html .= $this->recentChangesFlags(
106 [
107 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
108 'minor' => $rc->mAttribs['rc_minor'],
109 'unpatrolled' => $unpatrolled,
110 'bot' => $rc->mAttribs['rc_bot']
111 ],
112 ''
113 );
114 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
115 }
116 # Edit/log timestamp
117 $this->insertTimestamp( $html, $rc );
118 # Bytes added or removed
119 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
120 $cd = $this->formatCharacterDifference( $rc );
121 if ( $cd !== '' ) {
122 $html .= $cd . ' <span class="mw-changeslist-separator"></span> ';
123 }
124 }
125
126 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
127 $html .= $this->insertLogEntry( $rc );
128 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
129 $html .= $this->insertComment( $rc );
130 } else {
131 # User tool links
132 $this->insertUserRelatedLinks( $html, $rc );
133 # LTR/RTL direction mark
134 $html .= $this->getLanguage()->getDirMark();
135 $html .= $this->insertComment( $rc );
136 }
137
138 # Tags
139 $this->insertTags( $html, $rc, $classes );
140 # Rollback
141 $this->insertRollback( $html, $rc );
142 # For subclasses
143 $this->insertExtra( $html, $rc, $classes );
144
145 # How many users watch this page
146 if ( $rc->numberofWatchingusers > 0 ) {
147 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
148 }
149
150 $html = Html::rawElement( 'span', [
151 'class' => 'mw-changeslist-line-inner',
152 'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
153 ], $html );
154 if ( is_callable( $this->changeLinePrefixer ) ) {
155 $prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false );
156 $html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
157 }
158
159 return $html;
160 }
161}
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
insertDateHeader(&$s, $rc_timestamp)
insertRollback(&$s, &$rc)
Insert a rollback link.
showAsUnpatrolled(RecentChange $rc)
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
getArticleLink(&$rc, $unpatrolled, $watched)
Get the HTML link to the changed page, possibly with a prefix from hook handlers, and a suffix for te...
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
insertLogEntry( $rc)
Insert a formatted action.
insertLog(&$s, $title, $logtype, $useParentheses=true)
insertTags(&$s, &$rc, &$classes)
insertComment( $rc)
Insert a formatted comment.
insertExtra(&$s, &$rc, &$classes)
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
insertDiffHist(&$s, &$rc, $unpatrolled=null)
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
MediaWikiServices is the service locator for the application scope of MediaWiki.
formatChangeLine(RecentChange $rc, array &$classes, $watched)
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line using the old system (aka without any javascript).
Utility class for creating new RC entries.
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,...
const RC_NEW
Definition Defines.php:133
const NS_SPECIAL
Definition Defines.php:59
const RC_LOG
Definition Defines.php:134