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 ) {
36 $classes = $this->getHTMLClasses( $rc, $watched );
37 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
39 if ( $linenumber & 1 ) {
40 $classes[] = 'mw-line-odd';
42 $classes[] = 'mw-line-even';
46 $html = $this->formatChangeLine( $rc, $classes, $watched );
48 if ( $this->watchlist
) {
49 $classes[] = Sanitizer
::escapeClass( 'watchlist-' .
50 $rc->mAttribs
['rc_namespace'] . '-' . $rc->mAttribs
['rc_title'] );
53 $attribs = $this->getDataAttributes( $rc );
55 // Avoid PHP 7.1 warning from passing $this by reference
57 if ( !Hooks
::run( 'OldChangesListRecentChangesLine',
58 [ &$list, &$html, $rc, &$classes, &$attribs ] )
62 $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer
::class, 'isReservedDataAttribute' ] );
64 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
65 $this->insertDateHeader( $dateheader, $rc->mAttribs
['rc_timestamp'] );
67 $attribs['class'] = implode( ' ', $classes );
69 return $dateheader . Html
::rawElement( 'li', $attribs, $html ) . "\n";
73 * @param RecentChange $rc
74 * @param string[] &$classes
75 * @param bool $watched
79 private function formatChangeLine( RecentChange
$rc, array &$classes, $watched ) {
81 $unpatrolled = $this->showAsUnpatrolled( $rc );
83 if ( $rc->mAttribs
['rc_log_type'] ) {
84 $logtitle = SpecialPage
::getTitleFor( 'Log', $rc->mAttribs
['rc_log_type'] );
85 $this->insertLog( $html, $logtitle, $rc->mAttribs
['rc_log_type'] );
86 $flags = $this->recentChangesFlags( [ 'unpatrolled' =>$unpatrolled,
87 'bot' => $rc->mAttribs
['rc_bot'] ], '' );
88 if ( $flags !== '' ) {
89 $html .= ' ' . $flags;
91 // Log entries (old format) or log targets, and special pages
92 } elseif ( $rc->mAttribs
['rc_namespace'] == NS_SPECIAL
) {
93 list( $name, $htmlubpage ) = SpecialPageFactory
::resolveAlias( $rc->mAttribs
['rc_title'] );
94 if ( $name == 'Log' ) {
95 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
99 $this->insertDiffHist( $html, $rc );
100 # M, N, b and ! (minor, new, bot and unpatrolled)
101 $html .= $this->recentChangesFlags(
103 'newpage' => $rc->mAttribs
['rc_type'] == RC_NEW
,
104 'minor' => $rc->mAttribs
['rc_minor'],
105 'unpatrolled' => $unpatrolled,
106 'bot' => $rc->mAttribs
['rc_bot']
110 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
113 $this->insertTimestamp( $html, $rc );
114 # Bytes added or removed
115 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
116 $cd = $this->formatCharacterDifference( $rc );
118 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
122 if ( $rc->mAttribs
['rc_type'] == RC_LOG
) {
123 $html .= $this->insertLogEntry( $rc );
124 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
125 $html .= $this->insertComment( $rc );
128 $this->insertUserRelatedLinks( $html, $rc );
129 # LTR/RTL direction mark
130 $html .= $this->getLanguage()->getDirMark();
131 $html .= $this->insertComment( $rc );
135 $this->insertTags( $html, $rc, $classes );
137 $this->insertRollback( $html, $rc );
139 $this->insertExtra( $html, $rc, $classes );
141 # How many users watch this page
142 if ( $rc->numberofWatchingusers
> 0 ) {
143 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers
);