MediaWiki
REL1_39
RevDelLogItem.php
Go to the documentation of this file.
1
<?php
22
use
MediaWiki\MediaWikiServices
;
23
use
MediaWiki\Revision\RevisionRecord
;
24
28
class
RevDelLogItem
extends
RevDelItem
{
29
31
private
$commentStore;
32
38
public
function
__construct
(
39
RevisionListBase
$list
,
40
$row
,
41
CommentStore
$commentStore
42
) {
43
parent::__construct(
$list
,
$row
);
44
$this->commentStore = $commentStore;
45
}
46
47
public
function
getIdField
() {
48
return
'log_id'
;
49
}
50
51
public
function
getTimestampField
() {
52
return
'log_timestamp'
;
53
}
54
55
public
function
getAuthorIdField
() {
56
return
'log_user'
;
57
}
58
59
public
function
getAuthorNameField
() {
60
return
'log_user_text'
;
61
}
62
63
public
function
getAuthorActorField
() {
64
return
'log_actor'
;
65
}
66
67
public
function
canView
() {
68
return
LogEventsList::userCan(
69
$this->row, RevisionRecord::DELETED_RESTRICTED, $this->list->getAuthority()
70
);
71
}
72
73
public
function
canViewContent
() {
74
return
true
;
// none
75
}
76
77
public
function
getBits
() {
78
return
(
int
)$this->row->log_deleted;
79
}
80
81
public
function
setBits
( $bits ) {
82
$dbw =
wfGetDB
(
DB_PRIMARY
);
83
84
$dbw->update(
'logging'
,
85
[
'log_deleted'
=> $bits ],
86
[
87
'log_id'
=> $this->row->log_id,
88
'log_deleted'
=> $this->getBits()
// cas
89
],
90
__METHOD__
91
);
92
93
if
( !$dbw->affectedRows() ) {
94
// Concurrent fail!
95
return
false
;
96
}
97
98
$dbw->update(
'recentchanges'
,
99
[
100
'rc_deleted'
=> $bits,
101
'rc_patrolled'
=> RecentChange::PRC_AUTOPATROLLED
102
],
103
[
104
'rc_logid'
=> $this->row->log_id,
105
'rc_timestamp'
=> $this->row->log_timestamp
// index
106
],
107
__METHOD__
108
);
109
110
return
true
;
111
}
112
113
public
function
getHTML
() {
114
$date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
115
$this->row->log_timestamp, $this->list->getUser() ) );
116
$title
= Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
117
$formatter = LogFormatter::newFromRow( $this->row );
118
$formatter->setContext( $this->list->getContext() );
119
$formatter->setAudience( LogFormatter::FOR_THIS_USER );
120
121
// Log link for this page
122
$loglink = $this->
getLinkRenderer
()->makeLink(
123
SpecialPage::getTitleFor
(
'Log'
),
124
$this->list->msg(
'log'
)->text(),
125
[],
126
[
'page'
=>
$title
->getPrefixedText() ]
127
);
128
$loglink = $this->list->msg(
'parentheses'
)->rawParams( $loglink )->escaped();
129
// User links and action text
130
$action = $formatter->getActionText();
131
132
$commentRaw = $this->commentStore->getComment(
'log_comment'
, $this->row )->text;
133
$commentFormatter = MediaWikiServices::getInstance()->getCommentFormatter();
134
$dirMark = $this->list->getLanguage()->getDirMark();
135
$comment = $dirMark . $commentFormatter->formatBlock( $commentRaw );
136
137
if
( LogEventsList::isDeleted( $this->row,
LogPage::DELETED_COMMENT
) ) {
138
$comment =
'<span class="history-deleted">'
. $comment .
'</span>'
;
139
}
140
141
$content
=
"$loglink $date $action $comment"
;
142
$attribs = [];
143
if
( $this->row->ts_tags ) {
144
list( $tagSummary, $classes ) =
ChangeTags::formatSummaryRow
(
145
$this->row->ts_tags,
146
'revisiondelete'
,
147
$this->list->getContext()
148
);
149
$content
.=
" $tagSummary"
;
150
$attribs[
'class'
] = implode(
' '
, $classes );
151
}
152
return
Xml::tags(
'li'
, $attribs,
$content
);
153
}
154
155
public
function
getApiData
(
ApiResult
$result ) {
156
$logEntry = DatabaseLogEntry::newFromRow( $this->row );
157
$user = $this->list->getAuthority();
158
$ret = [
159
'id'
=> $logEntry->getId(),
160
'type'
=> $logEntry->getType(),
161
'action'
=> $logEntry->getSubtype(),
162
'userhidden'
=> (bool)$logEntry->isDeleted(
LogPage::DELETED_USER
),
163
'commenthidden'
=> (bool)$logEntry->isDeleted(
LogPage::DELETED_COMMENT
),
164
'actionhidden'
=> (bool)$logEntry->isDeleted(
LogPage::DELETED_ACTION
),
165
];
166
167
if
( LogEventsList::userCan( $this->row,
LogPage::DELETED_ACTION
, $user ) ) {
168
$ret[
'params'
] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
169
}
170
if
( LogEventsList::userCan( $this->row,
LogPage::DELETED_USER
, $user ) ) {
171
$ret += [
172
'userid'
=> $this->row->log_user ?? 0,
173
'user'
=> $this->row->log_user_text,
174
];
175
}
176
if
( LogEventsList::userCan( $this->row,
LogPage::DELETED_COMMENT
, $user ) ) {
177
$ret += [
178
'comment'
=> $this->commentStore->getComment(
'log_comment'
, $this->row )->text,
179
];
180
}
181
182
return
$ret;
183
}
184
}
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition
GlobalFunctions.php:1942
ApiResult
This class represents the result of the API operations.
Definition
ApiResult.php:35
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, MessageLocalizer $localizer=null)
Creates HTML for the given tags.
Definition
ChangeTags.php:193
CommentStore
Handle database storage of comments such as edit summaries and log reasons.
Definition
CommentStore.php:42
LogPage\DELETED_USER
const DELETED_USER
Definition
LogPage.php:42
LogPage\DELETED_COMMENT
const DELETED_COMMENT
Definition
LogPage.php:41
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition
LogPage.php:40
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
Definition
MediaWikiServices.php:212
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition
RevisionRecord.php:47
RevDelItem
Abstract base class for deletable items.
Definition
RevDelItem.php:25
RevDelLogItem
Item class for a logging table row.
Definition
RevDelLogItem.php:28
RevDelLogItem\getAuthorActorField
getAuthorActorField()
Get the DB field name storing actor ids.
Definition
RevDelLogItem.php:63
RevDelLogItem\__construct
__construct(RevisionListBase $list, $row, CommentStore $commentStore)
Definition
RevDelLogItem.php:38
RevDelLogItem\getIdField
getIdField()
Get the DB field name associated with the ID list.
Definition
RevDelLogItem.php:47
RevDelLogItem\getBits
getBits()
Get the current deletion bitfield value.
Definition
RevDelLogItem.php:77
RevDelLogItem\getAuthorNameField
getAuthorNameField()
Get the DB field name storing user names.
Definition
RevDelLogItem.php:59
RevDelLogItem\setBits
setBits( $bits)
Set the visibility of the item.
Definition
RevDelLogItem.php:81
RevDelLogItem\canViewContent
canViewContent()
Returns true if the current user can view the item text/file.
Definition
RevDelLogItem.php:73
RevDelLogItem\getHTML
getHTML()
Get the HTML of the list item.
Definition
RevDelLogItem.php:113
RevDelLogItem\canView
canView()
Returns true if the current user can view the item.
Definition
RevDelLogItem.php:67
RevDelLogItem\getAuthorIdField
getAuthorIdField()
Get the DB field name storing user ids.
Definition
RevDelLogItem.php:55
RevDelLogItem\getApiData
getApiData(ApiResult $result)
Get the return information about the revision for the API.
Definition
RevDelLogItem.php:155
RevDelLogItem\getTimestampField
getTimestampField()
Get the DB field name storing timestamps.
Definition
RevDelLogItem.php:51
RevisionItemBase\$row
stdClass $row
The database result row.
Definition
RevisionItemBase.php:34
RevisionItemBase\$list
RevisionListBase $list
The parent.
Definition
RevisionItemBase.php:31
RevisionItemBase\getLinkRenderer
getLinkRenderer()
Returns an instance of LinkRenderer.
Definition
RevisionItemBase.php:178
RevisionListBase
List for revision table items for a single page.
Definition
RevisionListBase.php:30
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:132
DB_PRIMARY
const DB_PRIMARY
Definition
defines.php:28
$content
$content
Definition
router.php:76
$title
$title
Definition
testCompression.php:38
includes
revisiondelete
RevDelLogItem.php
Generated on Fri Dec 20 2024 15:35:12 for MediaWiki by
1.10.0