MediaWiki REL1_31
OldChangesList.php
Go to the documentation of this file.
1<?php
24
34 public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
35 $classes = $this->getHTMLClasses( $rc, $watched );
36 // use mw-line-even/mw-line-odd class only if linenumber is given (feature from T16468)
37 if ( $linenumber ) {
38 if ( $linenumber & 1 ) {
39 $classes[] = 'mw-line-odd';
40 } else {
41 $classes[] = 'mw-line-even';
42 }
43 }
44
45 $html = $this->formatChangeLine( $rc, $classes, $watched );
46
47 if ( $this->watchlist ) {
48 $classes[] = Sanitizer::escapeClass( 'watchlist-' .
49 $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
50 }
51
52 $attribs = $this->getDataAttributes( $rc );
53
54 // Avoid PHP 7.1 warning from passing $this by reference
55 $list = $this;
56 if ( !Hooks::run( 'OldChangesListRecentChangesLine',
57 [ &$list, &$html, $rc, &$classes, &$attribs ] )
58 ) {
59 return false;
60 }
61 $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
62
63 $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
64 $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
65
66 $attribs['class'] = implode( ' ', $classes );
67
68 return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
69 }
70
78 private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
79 $html = '';
80 $unpatrolled = $this->showAsUnpatrolled( $rc );
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 $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
86 'bot' => $rc->mAttribs['rc_bot'] ], '' );
87 if ( $flags !== '' ) {
88 $html .= ' ' . $flags;
89 }
90 // Log entries (old format) or log targets, and special pages
91 } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
92 list( $name, $htmlubpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
93 if ( $name == 'Log' ) {
94 $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
95 }
96 // Regular entries
97 } else {
98 $this->insertDiffHist( $html, $rc );
99 # M, N, b and ! (minor, new, bot and unpatrolled)
100 $html .= $this->recentChangesFlags(
101 [
102 'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
103 'minor' => $rc->mAttribs['rc_minor'],
104 'unpatrolled' => $unpatrolled,
105 'bot' => $rc->mAttribs['rc_bot']
106 ],
107 ''
108 );
109 $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
110 }
111 # Edit/log timestamp
112 $this->insertTimestamp( $html, $rc );
113 # Bytes added or removed
114 if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
115 $cd = $this->formatCharacterDifference( $rc );
116 if ( $cd !== '' ) {
117 $html .= $cd . ' <span class="mw-changeslist-separator">. .</span> ';
118 }
119 }
120
121 if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
122 $html .= $this->insertLogEntry( $rc );
123 } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
124 $html .= $this->insertComment( $rc );
125 } else {
126 # User tool links
127 $this->insertUserRelatedLinks( $html, $rc );
128 # LTR/RTL direction mark
129 $html .= $this->getLanguage()->getDirMark();
130 $html .= $this->insertComment( $rc );
131 }
132
133 # Tags
134 $this->insertTags( $html, $rc, $classes );
135 # Rollback
136 $this->insertRollback( $html, $rc );
137 # For subclasses
138 $this->insertExtra( $html, $rc, $classes );
139
140 # How many users watch this page
141 if ( $rc->numberofWatchingusers > 0 ) {
142 $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
143 }
144
145 $html = Html::rawElement( 'span', [
146 'class' => 'mw-changeslist-line-inner',
147 'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
148 ], $html );
149 if ( is_callable( $this->changeLinePrefixer ) ) {
150 $prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false );
151 $html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
152 }
153
154 return $html;
155 }
156}
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
recentChangesFlags( $flags, $nothing='&#160;')
Returns the appropriate flags for new page, minor change and patrolling.
formatCharacterDifference(RecentChange $old, RecentChange $new=null)
Format the character difference of one or several changes.
insertDateHeader(&$s, $rc_timestamp)
insertRollback(&$s, &$rc)
Inserts a rollback link.
showAsUnpatrolled(RecentChange $rc)
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
insertLog(&$s, $title, $logtype)
getArticleLink(&$rc, $unpatrolled, $watched)
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
insertLogEntry( $rc)
Insert a formatted action.
insertTags(&$s, &$rc, &$classes)
insertComment( $rc)
Insert a formatted comment.
insertExtra(&$s, &$rc, &$classes)
isCategorizationWithoutRevision( $rcObj)
Determines whether a revision is linked to this change; this may not be the case when the categorizat...
insertDiffHist(&$s, &$rc, $unpatrolled=null)
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
formatChangeLine(RecentChange $rc, array &$classes, $watched)
recentChangesLine(&$rc, $watched=false, $linenumber=null)
Format a line using the old system (aka without any javascript).
Utility class for creating new RC entries.
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
const RC_NEW
Definition Defines.php:153
const NS_SPECIAL
Definition Defines.php:63
const RC_LOG
Definition Defines.php:154
the array() calling protocol came about after MediaWiki 1.4rc1.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:2013
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:2014
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37