2013-10-17 00:51:49 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Generate a list of changes using the good old system (no javascript).
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2014-02-05 11:02:29 +00:00
|
|
|
|
2018-08-12 09:08:58 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2013-10-17 00:51:49 +00:00
|
|
|
class OldChangesList extends ChangesList {
|
2014-08-28 11:36:26 +00:00
|
|
|
|
2013-10-17 00:51:49 +00:00
|
|
|
/**
|
|
|
|
|
* Format a line using the old system (aka without any javascript).
|
|
|
|
|
*
|
2017-08-11 00:23:16 +00:00
|
|
|
* @param RecentChange &$rc Passed by reference
|
2013-10-17 00:51:49 +00:00
|
|
|
* @param bool $watched (default false)
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param int|null $linenumber (default null)
|
2013-10-17 00:51:49 +00:00
|
|
|
*
|
|
|
|
|
* @return string|bool
|
|
|
|
|
*/
|
|
|
|
|
public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
|
2015-09-28 16:01:10 +00:00
|
|
|
$classes = $this->getHTMLClasses( $rc, $watched );
|
2017-02-20 22:44:19 +00:00
|
|
|
// use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
|
2013-10-17 00:51:49 +00:00
|
|
|
if ( $linenumber ) {
|
|
|
|
|
if ( $linenumber & 1 ) {
|
|
|
|
|
$classes[] = 'mw-line-odd';
|
|
|
|
|
} else {
|
|
|
|
|
$classes[] = 'mw-line-even';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-06 16:40:52 +00:00
|
|
|
$html = $this->formatChangeLine( $rc, $classes, $watched );
|
2014-08-28 11:36:26 +00:00
|
|
|
|
|
|
|
|
if ( $this->watchlist ) {
|
|
|
|
|
$classes[] = Sanitizer::escapeClass( 'watchlist-' .
|
|
|
|
|
$rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-10 05:31:32 +00:00
|
|
|
$attribs = $this->getDataAttributes( $rc );
|
|
|
|
|
|
2020-05-13 03:47:27 +00:00
|
|
|
if ( !$this->getHookRunner()->onOldChangesListRecentChangesLine(
|
|
|
|
|
$this, $html, $rc, $classes, $attribs )
|
2017-02-10 05:31:32 +00:00
|
|
|
) {
|
2014-08-28 11:36:26 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2018-09-29 00:24:13 +00:00
|
|
|
$attribs = array_filter( $attribs,
|
|
|
|
|
[ Sanitizer::class, 'isReservedDataAttribute' ],
|
|
|
|
|
ARRAY_FILTER_USE_KEY
|
|
|
|
|
);
|
2014-08-28 11:36:26 +00:00
|
|
|
|
|
|
|
|
$dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
|
|
|
|
|
$this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
|
|
|
|
|
|
2018-06-25 21:25:19 +00:00
|
|
|
$html = $this->getHighlightsContainerDiv() . $html;
|
2017-02-10 05:31:32 +00:00
|
|
|
$attribs['class'] = implode( ' ', $classes );
|
|
|
|
|
|
2020-06-27 01:13:01 +00:00
|
|
|
return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
|
2014-08-28 11:36:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param RecentChange $rc
|
2014-09-06 16:40:52 +00:00
|
|
|
* @param string[] &$classes
|
2014-12-10 05:09:35 +00:00
|
|
|
* @param bool $watched
|
2014-08-28 11:36:26 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2014-09-06 16:40:52 +00:00
|
|
|
private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
|
2014-08-28 11:36:26 +00:00
|
|
|
$html = '';
|
Option to associate a rev id to a RC log entry, allowing unpatrolled status
This provides a mechanism to associate a revision id to an action.
For example in core, it makes sense for moves and uploads, which both
generate null revisions (also protections, but it isn't interesting if one
has patrolling in mind).
Crucially, in that case an unpatrolled status is allowed for the RC item.
So if the performer of the action is not autopatrolled, it will be displayed
as unpatrolled, and if the performer is autopatrolled, it will record an
autopatrol action.
When one associates a rev id to a type of action, one should also implement
a mechanism to patrol said action, since getting the diff for the associated
revision is not user friendly and works only if RC patrol is enabled.
This is done for uploads in If71af58719a4461f12d125455b7bef07164525ca (with
a new file patrol) and for moves in Ie0fa417feaf930c096b69521fc54d57aecd6cd51
(within RC patrol).
Extensions might possess other such actions that could benefit from patrolling.
Bug: T122089
Change-Id: I694424eca32b69e277f89d4c15183870983d0993
2015-11-07 19:24:33 +00:00
|
|
|
$unpatrolled = $this->showAsUnpatrolled( $rc );
|
2014-08-28 11:36:26 +00:00
|
|
|
|
2014-06-05 00:54:02 +00:00
|
|
|
if ( $rc->mAttribs['rc_log_type'] ) {
|
2013-10-17 00:51:49 +00:00
|
|
|
$logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
|
2019-03-26 23:58:19 +00:00
|
|
|
$this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false );
|
2017-08-11 13:53:17 +00:00
|
|
|
$flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
|
2016-02-17 09:09:32 +00:00
|
|
|
'bot' => $rc->mAttribs['rc_bot'] ], '' );
|
Option to associate a rev id to a RC log entry, allowing unpatrolled status
This provides a mechanism to associate a revision id to an action.
For example in core, it makes sense for moves and uploads, which both
generate null revisions (also protections, but it isn't interesting if one
has patrolling in mind).
Crucially, in that case an unpatrolled status is allowed for the RC item.
So if the performer of the action is not autopatrolled, it will be displayed
as unpatrolled, and if the performer is autopatrolled, it will record an
autopatrol action.
When one associates a rev id to a type of action, one should also implement
a mechanism to patrol said action, since getting the diff for the associated
revision is not user friendly and works only if RC patrol is enabled.
This is done for uploads in If71af58719a4461f12d125455b7bef07164525ca (with
a new file patrol) and for moves in Ie0fa417feaf930c096b69521fc54d57aecd6cd51
(within RC patrol).
Extensions might possess other such actions that could benefit from patrolling.
Bug: T122089
Change-Id: I694424eca32b69e277f89d4c15183870983d0993
2015-11-07 19:24:33 +00:00
|
|
|
if ( $flags !== '' ) {
|
|
|
|
|
$html .= ' ' . $flags;
|
|
|
|
|
}
|
2013-10-17 00:51:49 +00:00
|
|
|
// Log entries (old format) or log targets, and special pages
|
|
|
|
|
} elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
|
2018-08-12 09:08:58 +00:00
|
|
|
list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
|
|
|
|
|
resolveAlias( $rc->mAttribs['rc_title'] );
|
2013-10-17 00:51:49 +00:00
|
|
|
if ( $name == 'Log' ) {
|
2019-03-26 23:58:19 +00:00
|
|
|
$this->insertLog( $html, $rc->getTitle(), $htmlubpage, false );
|
2013-10-17 00:51:49 +00:00
|
|
|
}
|
|
|
|
|
// Regular entries
|
|
|
|
|
} else {
|
2016-02-11 14:40:42 +00:00
|
|
|
$this->insertDiffHist( $html, $rc );
|
2013-10-17 00:51:49 +00:00
|
|
|
# M, N, b and ! (minor, new, bot and unpatrolled)
|
2014-08-28 11:36:26 +00:00
|
|
|
$html .= $this->recentChangesFlags(
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2013-10-17 00:51:49 +00:00
|
|
|
'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
|
|
|
|
|
'minor' => $rc->mAttribs['rc_minor'],
|
|
|
|
|
'unpatrolled' => $unpatrolled,
|
|
|
|
|
'bot' => $rc->mAttribs['rc_bot']
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2013-10-17 00:51:49 +00:00
|
|
|
''
|
|
|
|
|
);
|
2015-10-19 08:33:54 +00:00
|
|
|
$html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
|
2013-10-17 00:51:49 +00:00
|
|
|
}
|
|
|
|
|
# Edit/log timestamp
|
2014-08-28 11:36:26 +00:00
|
|
|
$this->insertTimestamp( $html, $rc );
|
2013-10-17 00:51:49 +00:00
|
|
|
# Bytes added or removed
|
2014-08-22 20:01:08 +00:00
|
|
|
if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
|
2013-10-17 00:51:49 +00:00
|
|
|
$cd = $this->formatCharacterDifference( $rc );
|
|
|
|
|
if ( $cd !== '' ) {
|
2018-11-21 22:55:48 +00:00
|
|
|
$html .= $cd . ' <span class="mw-changeslist-separator"></span> ';
|
2013-10-17 00:51:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
|
2014-08-28 11:36:26 +00:00
|
|
|
$html .= $this->insertLogEntry( $rc );
|
2015-08-24 17:40:06 +00:00
|
|
|
} elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
|
|
|
|
|
$html .= $this->insertComment( $rc );
|
2013-10-17 00:51:49 +00:00
|
|
|
} else {
|
|
|
|
|
# User tool links
|
2014-08-28 11:36:26 +00:00
|
|
|
$this->insertUserRelatedLinks( $html, $rc );
|
2013-10-17 00:51:49 +00:00
|
|
|
# LTR/RTL direction mark
|
2014-08-28 11:36:26 +00:00
|
|
|
$html .= $this->getLanguage()->getDirMark();
|
|
|
|
|
$html .= $this->insertComment( $rc );
|
2013-10-17 00:51:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Tags
|
2014-08-28 11:36:26 +00:00
|
|
|
$this->insertTags( $html, $rc, $classes );
|
2013-10-17 00:51:49 +00:00
|
|
|
# Rollback
|
2014-08-28 11:36:26 +00:00
|
|
|
$this->insertRollback( $html, $rc );
|
2013-10-17 00:51:49 +00:00
|
|
|
# For subclasses
|
2014-08-28 11:36:26 +00:00
|
|
|
$this->insertExtra( $html, $rc, $classes );
|
2013-10-17 00:51:49 +00:00
|
|
|
|
|
|
|
|
# How many users watch this page
|
|
|
|
|
if ( $rc->numberofWatchingusers > 0 ) {
|
2014-08-28 11:36:26 +00:00
|
|
|
$html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
|
2013-10-17 00:51:49 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-11 00:59:58 +00:00
|
|
|
$html = Html::rawElement( 'span', [
|
|
|
|
|
'class' => 'mw-changeslist-line-inner',
|
|
|
|
|
'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
|
|
|
|
|
], $html );
|
|
|
|
|
if ( is_callable( $this->changeLinePrefixer ) ) {
|
|
|
|
|
$prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false );
|
|
|
|
|
$html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-28 11:36:26 +00:00
|
|
|
return $html;
|
2013-10-17 00:51:49 +00:00
|
|
|
}
|
|
|
|
|
}
|