MediaWiki REL1_37
OldChangesList.php
Go to the documentation of this file.
1<?php
24
26
37 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
38 $classes = $this->getHTMLClasses( $rc, $watched );
39 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
40 if ( $linenumber ) {
41 if ( $linenumber & 1 ) {
42 $classes[] = 'mw-line-odd';
43 } else {
44 $classes[] = 'mw-line-even';
45 }
46 }
47
48 $html = $this->formatChangeLine( $rc, $classes, $watched );
49
50 if ( $this->watchlist ) {
51 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
52 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
53 }
54
55 $attribs = $this->getDataAttributes( $rc );
56
57 if ( !$this->getHookRunner()->onOldChangesListRecentChangesLine(
58 $this, $html, $rc, $classes, $attribs )
59 ) {
60 return false;
61 }
62 $attribs = array_filter( $attribs,
63 [ Sanitizer::class, 'isReservedDataAttribute' ],
64 ARRAY_FILTER_USE_KEY
65 );
66
67 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
68 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
69
70 $html = $this->getHighlightsContainerDiv() . $html;
71 $attribs['class'] = $classes;
72
73 return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
74 }
75
83 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
84 $html = '';
85 $unpatrolled = $this->showAsUnpatrolled( $rc );
86
87 if ( $rc->mAttribs['rc_log_type'] ) {
88 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
89 $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false );
90 $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
91 'bot' => $rc->mAttribs['rc_bot'] ], '' );
92 if ( $flags !== '' ) {
93 $html .= ' ' . $flags;
94 }
95 // Log entries (old format) or log targets, and special pages
96 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
97 list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
98 resolveAlias( $rc->mAttribs['rc_title'] );
99 if ( $name == 'Log' ) {
100 $this->insertLog( $html, $rc->getTitle(), $htmlubpage, false );
101 }
102 // Regular entries
103 } else {
104 $this->insertDiffHist( $html, $rc );
105 # M, N, b and ! (minor, new, bot and unpatrolled)
106 $html .= $this->recentChangesFlags(
107 [
108 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
109 'minor' => $rc->mAttribs['rc_minor'],
110 'unpatrolled' => $unpatrolled,
111 'bot' => $rc->mAttribs['rc_bot']
112 ],
113 ''
114 );
115 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
116 }
117 # Edit/log timestamp
118 $this->insertTimestamp( $html, $rc );
119 # Bytes added or removed
120 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
121 $cd = $this->formatCharacterDifference( $rc );
122 if ( $cd !== '' ) {
123 $html .= $cd . ' <span class="mw-changeslist-separator"></span> ';
124 }
125 }
126
127 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
128 $html .= $this->insertLogEntry( $rc );
129 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
130 $html .= $this->insertComment( $rc );
131 } else {
132 # User tool links
133 $this->insertUserRelatedLinks( $html, $rc );
134 # LTR/RTL direction mark
135 $html .= $this->getLanguage()->getDirMark();
136 $html .= $this->insertComment( $rc );
137 }
138
139 # Tags
140 $this->insertTags( $html, $rc, $classes );
141 # Rollback
142 $this->insertRollback( $html, $rc );
143 # For subclasses
144 $this->insertExtra( $html, $rc, $classes );
145
146 # How many users watch this page
147 if ( $rc->numberofWatchingusers > 0 ) {
148 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
149 }
150
151 $html = Html::rawElement( 'span', [
152 'class' => 'mw-changeslist-line-inner',
153 'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
154 ], $html );
155 if ( is_callable( $this->changeLinePrefixer ) ) {
156 $prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false );
157 $html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
158 }
159
160 return $html;
161 }
162}
const RC_NEW
Definition Defines.php:116
const NS_SPECIAL
Definition Defines.php:53
const RC_LOG
Definition Defines.php:117
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,...