MediaWiki master
ChangeTagsLogItem.php
Go to the documentation of this file.
1<?php
8
18
29
31 public function __construct(
33 $row,
34 private readonly ChangeTagsFormatter $changeTagsFormatter,
35 ) {
36 parent::__construct( $list, $row );
37 }
38
40 public function getIdField() {
41 return 'log_id';
42 }
43
45 public function getTimestampField() {
46 return 'log_timestamp';
47 }
48
50 public function getAuthorIdField() {
51 return 'log_user';
52 }
53
55 public function getAuthorNameField() {
56 return 'log_user_text';
57 }
58
60 public function getAuthorActorField() {
61 return 'log_actor';
62 }
63
65 public function canView() {
66 return LogEventsList::userCan(
67 $this->row, LogPage::DELETED_RESTRICTED, $this->list->getAuthority()
68 );
69 }
70
72 public function canViewContent() {
73 return true; // none
74 }
75
79 public function getTags() {
80 return $this->row->ts_tags;
81 }
82
87 public function getHTML() {
88 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
89 $this->row->log_timestamp, $this->list->getUser() ) );
90 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
92 $formatter = $services->getLogFormatterFactory()->newFromRow( $this->row );
93 $formatter->setContext( $this->list->getContext() );
94 $formatter->setAudience( LogFormatter::FOR_THIS_USER );
95
96 // Log link for this page
97 $loglink = $services->getLinkRenderer()->makeLink(
99 $this->list->msg( 'log' )->text(),
100 [],
101 [ 'page' => $title->getPrefixedText() ]
102 );
103 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
104 // User links and action text
105 $action = $formatter->getActionText();
106
107 $dir = $this->list->getLanguage()->getDir();
108 $comment = Html::rawElement( 'bdi', [ 'dir' => $dir ], $formatter->getComment() );
109
110 $content = "$loglink $date $action $comment";
111 $attribs = [];
112 $tags = $this->getTags();
113 if ( $tags ) {
114 [ $tagSummary, $classes ] = $this->changeTagsFormatter->formatTagsAsSummaryList(
115 $tags,
116 $this->list->getContext(),
117 $this->list->getAuthority()
118 );
119 $content .= " $tagSummary";
120 $attribs['class'] = $classes;
121 }
122 return Html::rawElement( 'li', $attribs, $content );
123 }
124}
125
127class_alias( ChangeTagsLogItem::class, 'ChangeTagsLogItem' );
Formats change tags for display in HTML and use filter dropdown menus.
Item class for a logging table row with its associated change tags.
getAuthorActorField()
Get the DB field name storing actor ids.Override this function. 1.31 string|false
canViewContent()
Returns true if the current user can view the item text/file.bool
__construct(RevisionListBase $list, $row, private readonly ChangeTagsFormatter $changeTagsFormatter,)
getIdField()
Get the DB field name associated with the ID list.Override this function. string|null
getAuthorNameField()
Get the DB field name storing user names.Override this function. string|false
getAuthorIdField()
Get the DB field name storing user ids.Override this function. string|false
getTimestampField()
Get the DB field name storing timestamps.Override this function. string|false
canView()
Returns true if the current user can view the item.bool
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
This class is a collection of static functions that serve two purposes:
Definition Html.php:44
Implements the default log formatting.
Class to simplify the use of log pages.
Definition LogPage.php:34
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Abstract base class for revision items.
stdClass $row
The database result row.
List for revision table items for a single page.
Parent class for all special pages.
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,...
Represents a title within MediaWiki.
Definition Title.php:69