MediaWiki  1.33.0
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  // Avoid PHP 7.1 warning from passing $this by reference
57  $list = $this;
58  if ( !Hooks::run( 'OldChangesListRecentChangesLine',
59  [ &$list, &$html, $rc, &$classes, &$attribs ] )
60  ) {
61  return false;
62  }
63  $attribs = array_filter( $attribs,
64  [ Sanitizer::class, 'isReservedDataAttribute' ],
65  ARRAY_FILTER_USE_KEY
66  );
67 
68  $dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
69  $this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
70 
72  $attribs['class'] = implode( ' ', $classes );
73 
74  return $dateheader . Html::rawElement( 'li', $attribs, $html ) . "\n";
75  }
76 
84  private function formatChangeLine( RecentChange $rc, array &$classes, $watched ) {
85  $html = '';
86  $unpatrolled = $this->showAsUnpatrolled( $rc );
87 
88  if ( $rc->mAttribs['rc_log_type'] ) {
89  $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
90  $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'] );
91  $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
92  'bot' => $rc->mAttribs['rc_bot'] ], '' );
93  if ( $flags !== '' ) {
94  $html .= ' ' . $flags;
95  }
96  // Log entries (old format) or log targets, and special pages
97  } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
98  list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
99  resolveAlias( $rc->mAttribs['rc_title'] );
100  if ( $name == 'Log' ) {
101  $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
102  }
103  // Regular entries
104  } else {
105  $this->insertDiffHist( $html, $rc );
106  # M, N, b and ! (minor, new, bot and unpatrolled)
107  $html .= $this->recentChangesFlags(
108  [
109  'newpage' => $rc->mAttribs['rc_type'] == RC_NEW,
110  'minor' => $rc->mAttribs['rc_minor'],
111  'unpatrolled' => $unpatrolled,
112  'bot' => $rc->mAttribs['rc_bot']
113  ],
114  ''
115  );
116  $html .= $this->getArticleLink( $rc, $unpatrolled, $watched );
117  }
118  # Edit/log timestamp
119  $this->insertTimestamp( $html, $rc );
120  # Bytes added or removed
121  if ( $this->getConfig()->get( 'RCShowChangedSize' ) ) {
122  $cd = $this->formatCharacterDifference( $rc );
123  if ( $cd !== '' ) {
124  $html .= $cd . ' <span class="mw-changeslist-separator"></span> ';
125  }
126  }
127 
128  if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
129  $html .= $this->insertLogEntry( $rc );
130  } elseif ( $this->isCategorizationWithoutRevision( $rc ) ) {
131  $html .= $this->insertComment( $rc );
132  } else {
133  # User tool links
134  $this->insertUserRelatedLinks( $html, $rc );
135  # LTR/RTL direction mark
136  $html .= $this->getLanguage()->getDirMark();
137  $html .= $this->insertComment( $rc );
138  }
139 
140  # Tags
141  $this->insertTags( $html, $rc, $classes );
142  # Rollback
143  $this->insertRollback( $html, $rc );
144  # For subclasses
145  $this->insertExtra( $html, $rc, $classes );
146 
147  # How many users watch this page
148  if ( $rc->numberofWatchingusers > 0 ) {
149  $html .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
150  }
151 
152  $html = Html::rawElement( 'span', [
153  'class' => 'mw-changeslist-line-inner',
154  'data-target-page' => $rc->getTitle(), // Used for reliable determination of the affiliated page
155  ], $html );
156  if ( is_callable( $this->changeLinePrefixer ) ) {
157  $prefix = call_user_func( $this->changeLinePrefixer, $rc, $this, false );
158  $html = Html::rawElement( 'span', [ 'class' => 'mw-changeslist-line-prefix' ], $prefix ) . $html;
159  }
160 
161  return $html;
162  }
163 }
ContextSource\getConfig
getConfig()
Definition: ContextSource.php:63
ChangesList\insertComment
insertComment( $rc)
Insert a formatted comment.
Definition: ChangesList.php:615
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:69
RC_LOG
const RC_LOG
Definition: Defines.php:144
ChangesList\insertLog
insertLog(&$s, $title, $logtype)
Definition: ChangesList.php:450
ChangesList\getHighlightsContainerDiv
getHighlightsContainerDiv()
Get the container for highlights that are used in the new StructuredFilters system.
Definition: ChangesList.php:122
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:82
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:371
php
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:35
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
ChangesList\insertDateHeader
insertDateHeader(&$s, $rc_timestamp)
Definition: ChangesList.php:432
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:53
$html
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:1985
ChangesList\insertLogEntry
insertLogEntry( $rc)
Insert a formatted action.
Definition: ChangesList.php:601
$attribs
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:1985
ChangesList\insertTags
insertTags(&$s, &$rc, &$classes)
Definition: ChangesList.php:733
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
ChangesList\insertUserRelatedLinks
insertUserRelatedLinks(&$s, &$rc)
Insert links to user page, user talk page and eventually a blocking link.
Definition: ChangesList.php:578
list
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
ChangesList\getArticleLink
getArticleLink(&$rc, $unpatrolled, $watched)
Definition: ChangesList.php:515
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
ChangesList\getDataAttributes
getDataAttributes(RecentChange $rc)
Get recommended data attributes for a change line.
Definition: ChangesList.php:817
OldChangesList
Definition: OldChangesList.php:25
ChangesList\insertTimestamp
insertTimestamp(&$s, $rc)
Insert time timestamp string from $rc into $s.
Definition: ChangesList.php:568
ChangesList\numberofWatchingusers
numberofWatchingusers( $count)
Returns the string which indicates the number of watching users.
Definition: ChangesList.php:635
ChangesList\showAsUnpatrolled
showAsUnpatrolled(RecentChange $rc)
Definition: ChangesList.php:763
RC_NEW
const RC_NEW
Definition: Defines.php:143
ChangesList\getHTMLClasses
getHTMLClasses( $rc, $watched)
Get an array of default HTML class attributes for the change.
Definition: ChangesList.php:197
ChangesList\recentChangesFlags
recentChangesFlags( $flags, $nothing="\u{00A0}")
Returns the appropriate flags for new page, minor change and patrolling.
Definition: ChangesList.php:178
ChangesList\insertDiffHist
insertDiffHist(&$s, &$rc, $unpatrolled=null)
Definition: ChangesList.php:463
OldChangesList\formatChangeLine
formatChangeLine(RecentChange $rc, array &$classes, $watched)
Definition: OldChangesList.php:84
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:807
ChangesList
Definition: ChangesList.php:28
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:23
RecentChange\getTitle
& getTitle()
Definition: RecentChange.php:331
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
ChangesList\insertExtra
insertExtra(&$s, &$rc, &$classes)
Definition: ChangesList.php:759
ChangesList\insertRollback
insertRollback(&$s, &$rc)
Insert a rollback link.
Definition: ChangesList.php:694