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