Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / includes / changetags / ChangeTagsLogItem.php
blobb78efafa65fef9ee45e1235641d4daa330fbadba
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup Change tagging
22 use MediaWiki\MediaWikiServices;
24 /**
25 * Item class for a logging table row with its associated change tags.
26 * @todo Abstract out a base class for this and RevDelLogItem, similar to the
27 * RevisionItem class but specifically for log items.
28 * @since 1.25
30 class ChangeTagsLogItem extends RevisionItemBase {
31 public function getIdField() {
32 return 'log_id';
35 public function getTimestampField() {
36 return 'log_timestamp';
39 public function getAuthorIdField() {
40 return 'log_user';
43 public function getAuthorNameField() {
44 return 'log_user_text';
47 public function canView() {
48 return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
51 public function canViewContent() {
52 return true; // none
55 /**
56 * @return string Comma-separated list of tags
58 public function getTags() {
59 return $this->row->ts_tags;
62 /**
63 * @return string A HTML <li> element representing this revision, showing
64 * change tags and everything
66 public function getHTML() {
67 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
68 $this->row->log_timestamp, $this->list->getUser() ) );
69 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
70 $formatter = LogFormatter::newFromRow( $this->row );
71 $formatter->setContext( $this->list->getContext() );
72 $formatter->setAudience( LogFormatter::FOR_THIS_USER );
74 // Log link for this page
75 $loglink = MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
76 SpecialPage::getTitleFor( 'Log' ),
77 $this->list->msg( 'log' )->text(),
78 [],
79 [ 'page' => $title->getPrefixedText() ]
81 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
82 // User links and action text
83 $action = $formatter->getActionText();
84 // Comment
85 $comment = $this->list->getLanguage()->getDirMark() .
86 $formatter->getComment();
88 if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) {
89 $comment = '<span class="history-deleted">' . $comment . '</span>';
92 $content = "$loglink $date $action $comment";
93 $attribs = [];
94 $tags = $this->getTags();
95 if ( $tags ) {
96 list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
97 $tags,
98 'edittags',
99 $this->list->getContext()
101 $content .= " $tagSummary";
102 $attribs['class'] = implode( ' ', $classes );
104 return Xml::tags( 'li', $attribs, $content );