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