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 class OldChangesList
extends ChangesList
{
26 * Format a line using the old system (aka without any javascript).
28 * @param RecentChange &$rc Passed by reference
29 * @param bool $watched (default false)
30 * @param int $linenumber (default null)
34 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
35 $classes = $this->getHTMLClasses( $rc, $watched );
36 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
38 if ( $linenumber & 1 ) {
39 $classes[] = 'mw-line-odd';
41 $classes[] = 'mw-line-even';
45 $html = $this->formatChangeLine( $rc, $classes, $watched );
47 if ( $this->watchlist
) {
48 $classes[] = Sanitizer
::escapeClass( 'watchlist-' .
49 $rc->mAttribs
['rc_namespace'] . '-' . $rc->mAttribs
['rc_title'] );
52 $attribs = $this->getDataAttributes( $rc );
54 // Avoid PHP 7.1 warning from passing $this by reference
56 if ( !Hooks
::run( 'OldChangesListRecentChangesLine',
57 [ &$list, &$html, $rc, &$classes, &$attribs ] )
61 $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer
::class, 'isReservedDataAttribute' ] );
63 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
64 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
66 $attribs['class'] = implode( ' ', $classes );
68 return $dateheader . Html
::rawElement( 'li', $attribs, $html ) . "\n";
72 * @param RecentChange $rc
73 * @param string[] &$classes
74 * @param bool $watched
78 private function formatChangeLine( RecentChange
$rc, array &$classes, $watched ) {
80 $unpatrolled = $this->showAsUnpatrolled( $rc );
82 if ( $rc->mAttribs
['rc_log_type'] ) {
83 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc->mAttribs
['rc_log_type'] );
84 $this->insertLog( $html, $logtitle, $rc->mAttribs
['rc_log_type'] );
85 $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
86 'bot' => $rc->mAttribs
['rc_bot'] ], '' );
87 if ( $flags !== '' ) {
88 $html .= ' ' . $flags;
90 // Log entries (old format) or log targets, and special pages
91 } elseif ( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
92 list( $name, $htmlubpage ) = SpecialPageFactory
::resolveAlias( $rc->mAttribs
['rc_title'] );
93 if ( $name == 'Log' ) {
94 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
98 $this->insertDiffHist( $html, $rc );
99 # M, N, b and ! (minor, new, bot and unpatrolled)
100 $html .= $this->recentChangesFlags(
102 'newpage' => $rc->mAttribs
['rc_type'] == RC_NEW
,
103 'minor' => $rc->mAttribs
['rc_minor'],
104 'unpatrolled' => $unpatrolled,
105 'bot' => $rc->mAttribs
['rc_bot']
109 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
112 $this->insertTimestamp( $html, $rc );
113 # Bytes added or removed
114 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
115 $cd = $this->formatCharacterDifference( $rc );
117 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
121 if ( $rc->mAttribs
['rc_type'] == RC_LOG
) {
122 $html .= $this->insertLogEntry( $rc );
123 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
124 $html .= $this->insertComment( $rc );
127 $this->insertUserRelatedLinks( $html, $rc );
128 # LTR/RTL direction mark
129 $html .= $this->getLanguage()->getDirMark();
130 $html .= $this->insertComment( $rc );
134 $this->insertTags( $html, $rc, $classes );
136 $this->insertRollback( $html, $rc );
138 $this->insertExtra( $html, $rc, $classes );
140 # How many users watch this page
141 if ( $rc->numberofWatchingusers
> 0 ) {
142 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers
);
145 $html = Html
::rawElement( 'span', [
146 'class' => 'mw-changeslist-line-inner',
147 'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
149 if ( is_callable( $this->changeLinePrefixer
) ) {
150 $prefix = call_user_func( $this->changeLinePrefixer
, $rc, $this, false );
151 $html = Html
::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;