Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / includes / changes / OldChangesList.php
blob8eb06ced032274f0ca806cee26a3e84076032f35
1 <?php
2 /**
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
20 * @file
23 class OldChangesList extends ChangesList {
25 /**
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)
32 * @return string|bool
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 bug 14468)
38 if ( $linenumber ) {
39 if ( $linenumber & 1 ) {
40 $classes[] = 'mw-line-odd';
41 } else {
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 if ( !Hooks::run( 'OldChangesListRecentChangesLine', [ &$this, &$html, $rc, &$classes ] ) ) {
54 return false;
57 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
58 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
60 return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $html . "</li>\n";
63 /**
64 * @param RecentChange $rc
65 * @param string[] &$classes
66 * @param bool $watched
68 * @return string
70 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
71 $html = '';
72 $unpatrolled = $this->showAsUnpatrolled( $rc );
74 if ( $rc->mAttribs['rc_log_type'] ) {
75 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
76 $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'] );
77 $flags = $this->recentChangesFlags( [ 'unpatrolled' =>$unpatrolled,
78 'bot' => $rc->mAttribs['rc_bot'] ], '' );
79 if ( $flags !== '' ) {
80 $html .= ' ' . $flags;
82 // Log entries (old format) or log targets, and special pages
83 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
84 list( $name, $htmlubpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
85 if ( $name == 'Log' ) {
86 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
88 // Regular entries
89 } else {
90 $this->insertDiffHist( $html, $rc );
91 # M, N, b and ! (minor, new, bot and unpatrolled)
92 $html .= $this->recentChangesFlags(
94 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
95 'minor' => $rc->mAttribs['rc_minor'],
96 'unpatrolled' => $unpatrolled,
97 'bot' => $rc->mAttribs['rc_bot']
101 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
103 # Edit/log timestamp
104 $this->insertTimestamp( $html, $rc );
105 # Bytes added or removed
106 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
107 $cd = $this->formatCharacterDifference( $rc );
108 if ( $cd !== '' ) {
109 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
113 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
114 $html .= $this->insertLogEntry( $rc );
115 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
116 $html .= $this->insertComment( $rc );
117 } else {
118 # User tool links
119 $this->insertUserRelatedLinks( $html, $rc );
120 # LTR/RTL direction mark
121 $html .= $this->getLanguage()->getDirMark();
122 $html .= $this->insertComment( $rc );
125 # Tags
126 $this->insertTags( $html, $rc, $classes );
127 # Rollback
128 $this->insertRollback( $html, $rc );
129 # For subclasses
130 $this->insertExtra( $html, $rc, $classes );
132 # How many users watch this page
133 if ( $rc->numberofWatchingusers > 0 ) {
134 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
137 return $html;