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
21 use MediaWiki\Html\Html
;
22 use MediaWiki\MediaWikiServices
;
23 use MediaWiki\RevisionList\RevisionItemBase
;
24 use MediaWiki\SpecialPage\SpecialPage
;
25 use MediaWiki\Title\Title
;
28 * Item class for a logging table row with its associated change tags.
30 * @todo Abstract out a base class for this and RevDelLogItem, similar to the
31 * RevisionItem class but specifically for log items.
36 class ChangeTagsLogItem
extends RevisionItemBase
{
37 public function getIdField() {
41 public function getTimestampField() {
42 return 'log_timestamp';
45 public function getAuthorIdField() {
49 public function getAuthorNameField() {
50 return 'log_user_text';
53 public function getAuthorActorField() {
57 public function canView() {
58 return LogEventsList
::userCan(
59 $this->row
, LogPage
::DELETED_RESTRICTED
, $this->list->getAuthority()
63 public function canViewContent() {
68 * @return string Comma-separated list of tags
70 public function getTags() {
71 return $this->row
->ts_tags
;
75 * @return string A HTML <li> element representing this revision, showing
76 * change tags and everything
78 public function getHTML() {
79 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
80 $this->row
->log_timestamp
, $this->list->getUser() ) );
81 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
82 $services = MediaWikiServices
::getInstance();
83 $formatter = $services->getLogFormatterFactory()->newFromRow( $this->row
);
84 $formatter->setContext( $this->list->getContext() );
85 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
87 // Log link for this page
88 $loglink = $services->getLinkRenderer()->makeLink(
89 SpecialPage
::getTitleFor( 'Log' ),
90 $this->list->msg( 'log' )->text(),
92 [ 'page' => $title->getPrefixedText() ]
94 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
95 // User links and action text
96 $action = $formatter->getActionText();
98 $dir = $this->list->getLanguage()->getDir();
99 $comment = Html
::rawElement( 'bdi', [ 'dir' => $dir ], $formatter->getComment() );
101 $content = "$loglink $date $action $comment";
103 $tags = $this->getTags();
105 [ $tagSummary, $classes ] = ChangeTags
::formatSummaryRow(
108 $this->list->getContext()
110 $content .= " $tagSummary";
111 $attribs['class'] = implode( ' ', $classes );
113 return Html
::rawElement( 'li', $attribs, $content );