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