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
;
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.
30 class ChangeTagsLogItem
extends RevisionItemBase
{
31 public function getIdField() {
35 public function getTimestampField() {
36 return 'log_timestamp';
39 public function getAuthorIdField() {
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() {
56 * @return string Comma-separated list of tags
58 public function getTags() {
59 return $this->row
->ts_tags
;
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(),
79 [ 'page' => $title->getPrefixedText() ]
81 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
82 // User links and action text
83 $action = $formatter->getActionText();
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";
94 $tags = $this->getTags();
96 list( $tagSummary, $classes ) = ChangeTags
::formatSummaryRow(
99 $this->list->getContext()
101 $content .= " $tagSummary";
102 $attribs['class'] = implode( ' ', $classes );
104 return Xml
::tags( 'li', $attribs, $content );