MediaWiki master
OldChangesList.php
Go to the documentation of this file.
1<?php
22
28
35
46 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
47 $classes = $this->getHTMLClasses( $rc, $watched );
48 / use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
49 if ( $linenumber ) {
50 if ( $linenumber & 1 ) {
51 $classes[] = 'mw-line-odd';
52 } else {
53 $classes[] = 'mw-line-even';
54 }
55 }
56
57 $html = $this->formatChangeLine( $rc, $classes, $watched );
58
59 if ( $this->watchlist ) {
60 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
61 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
62 }
63
64 $attribs = $this->getDataAttributes( $rc );
65
66 if ( !$this->getHookRunner()->onOldChangesListRecentChangesLine(
67 $this, $html, $rc, $classes, $attribs )
68 ) {
69 return false;
70 }
71 $attribs = array_filter( $attribs,
72 [ Sanitizer::class, 'isReservedDataAttribute' ],
73 ARRAY_FILTER_USE_KEY
74 );
75
76 $dateheader = ''; / $html now contains only <li>...</li>, for hooks' convenience.
77 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
78
79 $html = $this->getHighlightsContainerDiv() . $html;
80 $attribs['class'] = $classes;
81
82 return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
83 }
84
92 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
93 $html = '';
94 $unpatrolled = $this->showAsUnpatrolled( $rc );
95
96 if ( $rc->mAttribs['rc_log_type'] ) {
97 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
98 $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false );
99 $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
100 'bot' => $rc->mAttribs['rc_bot'] ], '' );
101 if ( $flags !== '' ) {
102 $html .= ' ' . $flags;
103 }
104 / Log entries (old format) or log targets, and special pages
105 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
106 [ $name, $htmlubpage ] = MediaWikiServices::getInstance()->getSpecialPageFactory()->
107 resolveAlias( $rc->mAttribs['rc_title'] );
108 if ( $name == 'Log' ) {
109 $this->insertLog( $html, $rc->getTitle(), $htmlubpage, false );
110 }
111 / Regular entries
112 } else {
113 $this->insertDiffHist( $html, $rc );
114 # M, N, b and ! (minor, new, bot and unpatrolled)
115 $html .= $this->recentChangesFlags(
116 [
117 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
118 'minor' => $rc->mAttribs['rc_minor'],
119 'unpatrolled' => $unpatrolled,
120 'bot' => $rc->mAttribs['rc_bot']
121 ],
122 ''
123 );
124 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
125 }
126 # Edit/log timestamp
127 $this->insertTimestamp( $html, $rc );
128 # Bytes added or removed
129 if ( $this->getConfig()->get( MainConfigNames::RCShowChangedSize ) ) {
130 $cd = $this->formatCharacterDifference( $rc );
131 if ( $cd !== '' ) {
132 $html .= $cd . ' <span class="mw-changeslist-separator"></span> ';
133 }
134 }
135
136 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
137 $html .= $this->insertLogEntry( $rc );
138 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
139 $html .= $this->insertComment( $rc );
140 } else {
141 # User tool links
142 $this->insertUserRelatedLinks( $html, $rc );
143 $html .= $this->insertComment( $rc );
144 }
145
146 # Tags
147 $this->insertTags( $html, $rc, $classes );
148 # Rollback
149 $this->insertRollback( $html, $rc );
150 # For subclasses
151 $this->insertExtra( $html, $rc, $classes );
152
153 # How many users watch this page
154 if ( $rc->numberofWatchingusers > 0 ) {
155 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
156 }
157
158 $html = Html::rawElement( 'span', [
159 'class' => 'mw-changeslist-line-inner',
160 'data-target-page' => $rc->getTitle(), / Used for reliable determination of the affiliated page
161 ], $html );
162 if ( is_callable( $this->changeLinePrefixer ) ) {
163 $prefix = ( $this->changeLinePrefixer )( $rc, $this, false );
164 $html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
165 }
166
167 return $html;
168 }
169}
170
172class_alias( OldChangesList::class, 'OldChangesList' );
const RC_NEW
Definition Defines.php:118
const NS_SPECIAL
Definition Defines.php:54
const RC_LOG
Definition Defines.php:119
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
A class containing constants representing the names of configuration variables.
const RCShowChangedSize
Name constant for the RCShowChangedSize setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
HTML sanitizer for MediaWiki.
Definition Sanitizer.php:46
Base class for lists of recent changes shown on special pages.
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.
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
insertLogEntry( $rc)
Insert a formatted action.
getArticleLink(&$rc, $unpatrolled, $watched)
Get the HTML link to the changed page, possibly with a prefix from hook handlers, and a suffix for te...
insertLog(&$s, $title, $logtype, $useParentheses=true)
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
insertComment( $rc)
Insert a formatted comment.
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
insertDiffHist(&$s, &$rc, $unpatrolled=null)
insertRollback(&$s, &$rc)
Insert a rollback link.
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
formatCharacterDifference(RecentChange $old, ?RecentChange $new=null)
Format the character difference of one or several changes.
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Generate a list of changes using the good old system (no javascript).
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line using the old system (aka without any javascript).
Utility class for creating and reading rows in the recentchanges table.
Parent class for all special pages.
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,...

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant