Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / changes / OldChangesList.php
1 <?php
2 /**
3 * Generate a list of changes using the good old system (no javascript).
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 */
22
23 class OldChangesList extends ChangesList {
24
25 /**
26 * Format a line using the old system (aka without any javascript).
27 *
28 * @param RecentChange $rc Passed by reference
29 * @param bool $watched (default false)
30 * @param int $linenumber (default null)
31 *
32 * @return string|bool
33 */
34 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
35
36 $classes = $this->getHTMLClasses( $rc, $watched );
37 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
38 if ( $linenumber ) {
39 if ( $linenumber & 1 ) {
40 $classes[] = 'mw-line-odd';
41 } else {
42 $classes[] = 'mw-line-even';
43 }
44 }
45
46 $html = $this->formatChangeLine( $rc, $classes, $watched );
47
48 if ( $this->watchlist ) {
49 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
50 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
51 }
52
53 // Avoid PHP 7.1 warning from passing $this by reference
54 $list = $this;
55 if ( !Hooks::run( 'OldChangesListRecentChangesLine', [ &$list, &$html, $rc, &$classes ] ) ) {
56 return false;
57 }
58
59 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
60 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
61
62 return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $html . "</li>\n";
63 }
64
65 /**
66 * @param RecentChange $rc
67 * @param string[] &$classes
68 * @param bool $watched
69 *
70 * @return string
71 */
72 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
73 $html = '';
74 $unpatrolled = $this->showAsUnpatrolled( $rc );
75
76 if ( $rc->mAttribs['rc_log_type'] ) {
77 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
78 $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'] );
79 $flags = $this->recentChangesFlags( [ 'unpatrolled' =>$unpatrolled,
80 'bot' => $rc->mAttribs['rc_bot'] ], '' );
81 if ( $flags !== '' ) {
82 $html .= ' ' . $flags;
83 }
84 // Log entries (old format) or log targets, and special pages
85 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
86 list( $name, $htmlubpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
87 if ( $name == 'Log' ) {
88 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
89 }
90 // Regular entries
91 } else {
92 $this->insertDiffHist( $html, $rc );
93 # M, N, b and ! (minor, new, bot and unpatrolled)
94 $html .= $this->recentChangesFlags(
95 [
96 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
97 'minor' => $rc->mAttribs['rc_minor'],
98 'unpatrolled' => $unpatrolled,
99 'bot' => $rc->mAttribs['rc_bot']
100 ],
101 ''
102 );
103 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
104 }
105 # Edit/log timestamp
106 $this->insertTimestamp( $html, $rc );
107 # Bytes added or removed
108 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
109 $cd = $this->formatCharacterDifference( $rc );
110 if ( $cd !== '' ) {
111 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
112 }
113 }
114
115 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
116 $html .= $this->insertLogEntry( $rc );
117 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
118 $html .= $this->insertComment( $rc );
119 } else {
120 # User tool links
121 $this->insertUserRelatedLinks( $html, $rc );
122 # LTR/RTL direction mark
123 $html .= $this->getLanguage()->getDirMark();
124 $html .= $this->insertComment( $rc );
125 }
126
127 # Tags
128 $this->insertTags( $html, $rc, $classes );
129 # Rollback
130 $this->insertRollback( $html, $rc );
131 # For subclasses
132 $this->insertExtra( $html, $rc, $classes );
133
134 # How many users watch this page
135 if ( $rc->numberofWatchingusers > 0 ) {
136 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
137 }
138
139 return $html;
140 }
141 }