]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/changetags/ChangeTagsLogItem.php
MediaWiki 1.30.2-scripts2
[autoinstallsdev/mediawiki.git] / includes / changetags / ChangeTagsLogItem.php
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.
7  *
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.
12  *
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
17  *
18  * @file
19  * @ingroup Change tagging
20  */
21
22 use MediaWiki\MediaWikiServices;
23
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
29  */
30 class ChangeTagsLogItem extends RevisionItemBase {
31         public function getIdField() {
32                 return 'log_id';
33         }
34
35         public function getTimestampField() {
36                 return 'log_timestamp';
37         }
38
39         public function getAuthorIdField() {
40                 return 'log_user';
41         }
42
43         public function getAuthorNameField() {
44                 return 'log_user_text';
45         }
46
47         public function canView() {
48                 return LogEventsList::userCan( $this->row, Revision::SUPPRESSED_ALL, $this->list->getUser() );
49         }
50
51         public function canViewContent() {
52                 return true; // none
53         }
54
55         /**
56          * @return string Comma-separated list of tags
57          */
58         public function getTags() {
59                 return $this->row->ts_tags;
60         }
61
62         /**
63          * @return string A HTML <li> element representing this revision, showing
64          * change tags and everything
65          */
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 );
73
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() ]
80                 );
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();
87
88                 if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) {
89                         $comment = '<span class="history-deleted">' . $comment . '</span>';
90                 }
91
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()
100                         );
101                         $content .= " $tagSummary";
102                         $attribs['class'] = implode( ' ', $classes );
103                 }
104                 return Xml::tags( 'li', $attribs, $content );
105         }
106 }