Merge "Make HashBagOStuff::lock() compatible with BagOStuff::lock"
[mediawiki.git] / includes / changes / OldChangesList.php
blob4ce564d1e444b8401822db828841f9519cd44e8e
1 <?php
2 /**
3 * Generate a list of changes using the good old system (no javascript).
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.
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.
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
20 * @file
23 class OldChangesList extends ChangesList {
25 /**
26 * Format a line using the old system (aka without any javascript).
28 * @param RecentChange $rc Passed by reference
29 * @param bool $watched (default false)
30 * @param int $linenumber (default null)
32 * @return string|bool
34 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
36 $classes = array();
37 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
38 if ( $linenumber ) {
39 if ( $linenumber & 1 ) {
40 $classes[] = 'mw-line-odd';
41 } else {
42 $classes[] = 'mw-line-even';
46 // Indicate watched status on the line to allow for more
47 // comprehensive styling.
48 $classes[] = $watched && $rc->mAttribs['rc_timestamp'] >= $watched
49 ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
51 $html = $this->formatChangeLine( $rc, $classes, $watched );
53 if ( $this->watchlist ) {
54 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
55 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
58 if ( !Hooks::run( 'OldChangesListRecentChangesLine', array( &$this, &$html, $rc, &$classes ) ) ) {
59 return false;
62 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
63 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
65 return "$dateheader<li class=\"" . implode( ' ', $classes ) . "\">" . $html . "</li>\n";
68 /**
69 * @param RecentChange $rc
70 * @param string[] &$classes
71 * @param bool $watched
73 * @return string
75 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
76 $html = '';
78 if ( $rc->mAttribs['rc_log_type'] ) {
79 $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
80 $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'] );
81 // Log entries (old format) or log targets, and special pages
82 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
83 list( $name, $htmlubpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
84 if ( $name == 'Log' ) {
85 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
87 // Regular entries
88 } else {
89 $unpatrolled = $this->showAsUnpatrolled( $rc );
91 $this->insertDiffHist( $html, $rc, $unpatrolled );
92 # M, N, b and ! (minor, new, bot and unpatrolled)
93 $html .= $this->recentChangesFlags(
94 array(
95 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
96 'minor' => $rc->mAttribs['rc_minor'],
97 'unpatrolled' => $unpatrolled,
98 'bot' => $rc->mAttribs['rc_bot']
102 $this->insertArticleLink( $html, $rc, $unpatrolled, $watched );
104 # Edit/log timestamp
105 $this->insertTimestamp( $html, $rc );
106 # Bytes added or removed
107 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
108 $cd = $this->formatCharacterDifference( $rc );
109 if ( $cd !== '' ) {
110 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
114 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
115 $html .= $this->insertLogEntry( $rc );
116 } else {
117 # User tool links
118 $this->insertUserRelatedLinks( $html, $rc );
119 # LTR/RTL direction mark
120 $html .= $this->getLanguage()->getDirMark();
121 $html .= $this->insertComment( $rc );
124 # Tags
125 $this->insertTags( $html, $rc, $classes );
126 # Rollback
127 $this->insertRollback( $html, $rc );
128 # For subclasses
129 $this->insertExtra( $html, $rc, $classes );
131 # How many users watch this page
132 if ( $rc->numberofWatchingusers > 0 ) {
133 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
136 return $html;