Merge "Add final tests for the Status class"
[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 class OldChangesList extends ChangesList {
23 /**
24 * Format a line using the old system (aka without any javascript).
25 *
26 * @param RecentChange $rc Passed by reference
27 * @param bool $watched (default false)
28 * @param int $linenumber (default null)
29 *
30 * @return string|bool
31 */
32 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
33 global $wgRCShowChangedSize;
34 wfProfileIn( __METHOD__ );
35
36 # Should patrol-related stuff be shown?
37 $unpatrolled = $this->showAsUnpatrolled( $rc );
38
39 $dateheader = ''; // $s now contains only <li>...</li>, for hooks' convenience.
40 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
41
42 $s = '';
43 $classes = array();
44 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
45 if ( $linenumber ) {
46 if ( $linenumber & 1 ) {
47 $classes[] = 'mw-line-odd';
48 } else {
49 $classes[] = 'mw-line-even';
50 }
51 }
52
53 // Indicate watched status on the line to allow for more
54 // comprehensive styling.
55 $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
56 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
57
58 // Moved pages (very very old, not supported anymore)
59 if ( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
60 // Log entries
61 } elseif ( $rc->mAttribs['rc_log_type'] ) {
62 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
63 $this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
64 // Log entries (old format) or log targets, and special pages
65 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
66 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
67 if ( $name == 'Log' ) {
68 $this->insertLog( $s, $rc->getTitle(), $subpage );
69 }
70 // Regular entries
71 } else {
72 $this->insertDiffHist( $s, $rc, $unpatrolled );
73 # M, N, b and ! (minor, new, bot and unpatrolled)
74 $s .= $this->recentChangesFlags(
75 array(
76 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
77 'minor' => $rc->mAttribs['rc_minor'],
78 'unpatrolled' => $unpatrolled,
79 'bot' => $rc->mAttribs['rc_bot']
80 ),
81 ''
82 );
83 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
84 }
85 # Edit/log timestamp
86 $this->insertTimestamp( $s, $rc );
87 # Bytes added or removed
88 if ( $wgRCShowChangedSize ) {
89 $cd = $this->formatCharacterDifference( $rc );
90 if ( $cd !== '' ) {
91 $s .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
92 }
93 }
94
95 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
96 $s .= $this->insertLogEntry( $rc );
97 } else {
98 # User tool links
99 $this->insertUserRelatedLinks( $s, $rc );
100 # LTR/RTL direction mark
101 $s .= $this->getLanguage()->getDirMark();
102 $s .= $this->insertComment( $rc );
103 }
104
105 # Tags
106 $this->insertTags( $s, $rc, $classes );
107 # Rollback
108 $this->insertRollback( $s, $rc );
109 # For subclasses
110 $this->insertExtra( $s, $rc, $classes );
111
112 # How many users watch this page
113 if ( $rc->numberofWatchingusers > 0 ) {
114 $s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
115 }
116
117 if ( $this->watchlist ) {
118 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
119 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
120 }
121
122 if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc, &$classes ) ) ) {
123 wfProfileOut( __METHOD__ );
124
125 return false;
126 }
127
128 wfProfileOut( __METHOD__ );
129
130 return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $s . "</li>\n";
131 }
132 }