MediaWiki  master
OldChangesList.php
Go to the documentation of this file.
1 <?php
24 
25 class OldChangesList extends ChangesList {
26 
36  public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
37  $classes = $this->getHTMLClasses( $rc, $watched );
38  // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
39  if ( $linenumber ) {
40  if ( $linenumber & 1 ) {
41  $classes[] = 'mw-line-odd';
42  } else {
43  $classes[] = 'mw-line-even';
44  }
45  }
46 
47  $html = $this->formatChangeLine( $rc, $classes, $watched );
48 
49  if ( $this->watchlist ) {
50  $classes[] = Sanitizer::escapeClass( 'watchlist-' .
51  $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
52  }
53 
54  $attribs = $this->getDataAttributes( $rc );
55 
56  if ( !$this->getHookRunner()->onOldChangesListRecentChangesLine(
57  $this, $html, $rc, $classes, $attribs )
58  ) {
59  return false;
60  }
61  $attribs = array_filter( $attribs,
62  [ Sanitizer::class, 'isReservedDataAttribute' ],
63  ARRAY_FILTER_USE_KEY
64  );
65 
66  $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
67  $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
68 
69  $html = $this->getHighlightsContainerDiv() . $html;
70  $attribs['class'] = implode( ' ', $classes );
71 
72  return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
73  }
74 
82  private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
83  $html = '';
84  $unpatrolled = $this->showAsUnpatrolled( $rc );
85 
86  if ( $rc->mAttribs['rc_log_type'] ) {
87  $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
88  $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false );
89  $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
90  'bot' => $rc->mAttribs['rc_bot'] ], '' );
91  if ( $flags !== '' ) {
92  $html .= ' ' . $flags;
93  }
94  // Log entries (old format) or log targets, and special pages
95  } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
96  list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
97  resolveAlias( $rc->mAttribs['rc_title'] );
98  if ( $name == 'Log' ) {
99  $this->insertLog( $html, $rc->getTitle(), $htmlubpage, false );
100  }
101  // Regular entries
102  } else {
103  $this->insertDiffHist( $html, $rc );
104  # M, N, b and ! (minor, new, bot and unpatrolled)
105  $html .= $this->recentChangesFlags(
106  [
107  'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
108  'minor' => $rc->mAttribs['rc_minor'],
109  'unpatrolled' => $unpatrolled,
110  'bot' => $rc->mAttribs['rc_bot']
111  ],
112  ''
113  );
114  $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
115  }
116  # Edit/log timestamp
117  $this->insertTimestamp( $html, $rc );
118  # Bytes added or removed
119  if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
120  $cd = $this->formatCharacterDifference( $rc );
121  if ( $cd !== '' ) {
122  $html .= $cd . ' <span class="mw-changeslist-separator"></span> ';
123  }
124  }
125 
126  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
127  $html .= $this->insertLogEntry( $rc );
128  } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
129  $html .= $this->insertComment( $rc );
130  } else {
131  # User tool links
132  $this->insertUserRelatedLinks( $html, $rc );
133  # LTR/RTL direction mark
134  $html .= $this->getLanguage()->getDirMark();
135  $html .= $this->insertComment( $rc );
136  }
137 
138  # Tags
139  $this->insertTags( $html, $rc, $classes );
140  # Rollback
141  $this->insertRollback( $html, $rc );
142  # For subclasses
143  $this->insertExtra( $html, $rc, $classes );
144 
145  # How many users watch this page
146  if ( $rc->numberofWatchingusers > 0 ) {
147  $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
148  }
149 
150  $html = Html::rawElement( 'span', [
151  'class' => 'mw-changeslist-line-inner',
152  'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
153  ], $html );
154  if ( is_callable( $this->changeLinePrefixer ) ) {
155  $prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false );
156  $html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
157  }
158 
159  return $html;
160  }
161 }
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:63
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:652
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:149
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:71
RC_LOG
const RC_LOG
Definition: Defines.php:133
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:129
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:90
Sanitizer\escapeClass
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:1260
OldChangesList\recentChangesLine
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line using the old system (aka without any javascript).
Definition: OldChangesList.php:36
ChangesList\formatCharacterDifference
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
Definition: ChangesList.php:386
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
ChangesList\insertLog
insertLog(&$s, $title, $logtype, $useParentheses=true)
Definition: ChangesList.php:475
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:456
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:58
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:636
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:785
ChangesList\insertUserRelatedLinks
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
Definition: ChangesList.php:613
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Definition: ChangesList.php:547
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:869
OldChangesList
Definition: OldChangesList.php:25
ChangesList\insertTimestamp
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
Definition: ChangesList.php:603
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:672
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:815
RC_NEW
const RC_NEW
Definition: Defines.php:132
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:205
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:186
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:495
OldChangesList\formatChangeLine
formatChangeLine(RecentChange $rc, array &$classes, $watched)
Definition: OldChangesList.php:82
ChangesList\isCategorizationWithoutRevision
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
Definition: ChangesList.php:859
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
ChangesList
Definition: ChangesList.php:33
RecentChange\getTitle
& getTitle()
Definition: RecentChange.php:285
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:811
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:736