3 * Generate a list of changes using the good old system (no javascript).
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 use MediaWiki\MediaWikiServices
;
25 class OldChangesList
extends ChangesList
{
28 * Format a line using the old system (aka without any javascript).
30 * @param RecentChange &$rc Passed by reference
31 * @param bool $watched (default false)
32 * @param int|null $linenumber (default null)
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)
40 if ( $linenumber & 1 ) {
41 $classes[] = 'mw-line-odd';
43 $classes[] = 'mw-line-even';
47 $html = $this->formatChangeLine( $rc, $classes, $watched );
49 if ( $this->watchlist
) {
50 $classes[] = Sanitizer
::escapeClass( 'watchlist-' .
51 $rc->mAttribs
['rc_namespace'] . '-' . $rc->mAttribs
['rc_title'] );
54 $attribs = $this->getDataAttributes( $rc );
56 // Avoid PHP 7.1 warning from passing $this by reference
58 if ( !Hooks
::run( 'OldChangesListRecentChangesLine',
59 [ &$list, &$html, $rc, &$classes, &$attribs ] )
63 $attribs = array_filter( $attribs,
64 [ Sanitizer
::class, 'isReservedDataAttribute' ],
68 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
69 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
71 $html = $this->getHighlightsContainerDiv() . $html;
72 $attribs['class'] = implode( ' ', $classes );
74 return $dateheader . Html
::rawElement( 'li', $attribs, $html ) . "\n";
78 * @param RecentChange $rc
79 * @param string[] &$classes
80 * @param bool $watched
84 private function formatChangeLine( RecentChange
$rc, array &$classes, $watched ) {
86 $unpatrolled = $this->showAsUnpatrolled( $rc );
88 if ( $rc->mAttribs
['rc_log_type'] ) {
89 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc->mAttribs
['rc_log_type'] );
90 $this->insertLog( $html, $logtitle, $rc->mAttribs
['rc_log_type'] );
91 $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
92 'bot' => $rc->mAttribs
['rc_bot'] ], '' );
93 if ( $flags !== '' ) {
94 $html .= ' ' . $flags;
96 // Log entries (old format) or log targets, and special pages
97 } elseif ( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
98 list( $name, $htmlubpage ) = MediaWikiServices
::getInstance()->getSpecialPageFactory()->
99 resolveAlias( $rc->mAttribs
['rc_title'] );
100 if ( $name == 'Log' ) {
101 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
105 $this->insertDiffHist( $html, $rc );
106 # M, N, b and ! (minor, new, bot and unpatrolled)
107 $html .= $this->recentChangesFlags(
109 'newpage' => $rc->mAttribs
['rc_type'] == RC_NEW
,
110 'minor' => $rc->mAttribs
['rc_minor'],
111 'unpatrolled' => $unpatrolled,
112 'bot' => $rc->mAttribs
['rc_bot']
116 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
119 $this->insertTimestamp( $html, $rc );
120 # Bytes added or removed
121 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
122 $cd = $this->formatCharacterDifference( $rc );
124 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
128 if ( $rc->mAttribs
['rc_type'] == RC_LOG
) {
129 $html .= $this->insertLogEntry( $rc );
130 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
131 $html .= $this->insertComment( $rc );
134 $this->insertUserRelatedLinks( $html, $rc );
135 # LTR/RTL direction mark
136 $html .= $this->getLanguage()->getDirMark();
137 $html .= $this->insertComment( $rc );
141 $this->insertTags( $html, $rc, $classes );
143 $this->insertRollback( $html, $rc );
145 $this->insertExtra( $html, $rc, $classes );
147 # How many users watch this page
148 if ( $rc->numberofWatchingusers
> 0 ) {
149 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers
);
152 $html = Html
::rawElement( 'span', [
153 'class' => 'mw-changeslist-line-inner',
154 'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
156 if ( is_callable( $this->changeLinePrefixer
) ) {
157 $prefix = call_user_func( $this->changeLinePrefixer
, $rc, $this, false );
158 $html = Html
::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;