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