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