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
19 * @ingroup Change tagging
22 use MediaWiki\MediaWikiServices
;
23 use MediaWiki\Storage\RevisionRecord
;
26 * Item class for a logging table row with its associated change tags.
27 * @todo Abstract out a base class for this and RevDelLogItem, similar to the
28 * RevisionItem class but specifically for log items.
31 class ChangeTagsLogItem
extends RevisionItemBase
{
32 public function getIdField() {
36 public function getTimestampField() {
37 return 'log_timestamp';
40 public function getAuthorIdField() {
44 public function getAuthorNameField() {
45 return 'log_user_text';
48 public function getAuthorActorField() {
52 public function canView() {
53 return LogEventsList
::userCan(
54 $this->row
, RevisionRecord
::SUPPRESSED_ALL
, $this->list->getUser()
58 public function canViewContent() {
63 * @return string Comma-separated list of tags
65 public function getTags() {
66 return $this->row
->ts_tags
;
70 * @return string A HTML <li> element representing this revision, showing
71 * change tags and everything
73 public function getHTML() {
74 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
75 $this->row
->log_timestamp
, $this->list->getUser() ) );
76 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
77 $formatter = LogFormatter
::newFromRow( $this->row
);
78 $formatter->setContext( $this->list->getContext() );
79 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
81 // Log link for this page
82 $loglink = MediaWikiServices
::getInstance()->getLinkRenderer()->makeLink(
83 SpecialPage
::getTitleFor( 'Log' ),
84 $this->list->msg( 'log' )->text(),
86 [ 'page' => $title->getPrefixedText() ]
88 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
89 // User links and action text
90 $action = $formatter->getActionText();
92 $comment = $this->list->getLanguage()->getDirMark() .
93 $formatter->getComment();
95 if ( LogEventsList
::isDeleted( $this->row
, LogPage
::DELETED_COMMENT
) ) {
96 $comment = '<span class="history-deleted">' . $comment . '</span>';
99 $content = "$loglink $date $action $comment";
101 $tags = $this->getTags();
103 list( $tagSummary, $classes ) = ChangeTags
::formatSummaryRow(
106 $this->list->getContext()
108 $content .= " $tagSummary";
109 $attribs['class'] = implode( ' ', $classes );
111 return Xml
::tags( 'li', $attribs, $content );