Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 38
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChangeTagsLogItem
0.00% covered (danger)
0.00%
0 / 38
0.00% covered (danger)
0.00%
0 / 9
110
0.00% covered (danger)
0.00%
0 / 1
 getIdField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTimestampField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorIdField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorNameField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthorActorField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 canView
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 canViewContent
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTags
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHTML
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 1
6
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
22use MediaWiki\Html\Html;
23use MediaWiki\MediaWikiServices;
24use MediaWiki\RevisionList\RevisionItemBase;
25use MediaWiki\SpecialPage\SpecialPage;
26use MediaWiki\Title\Title;
27
28/**
29 * 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.
32 * @since 1.25
33 */
34class ChangeTagsLogItem extends RevisionItemBase {
35    public function getIdField() {
36        return 'log_id';
37    }
38
39    public function getTimestampField() {
40        return 'log_timestamp';
41    }
42
43    public function getAuthorIdField() {
44        return 'log_user';
45    }
46
47    public function getAuthorNameField() {
48        return 'log_user_text';
49    }
50
51    public function getAuthorActorField() {
52        return 'log_actor';
53    }
54
55    public function canView() {
56        return LogEventsList::userCan(
57            $this->row, LogPage::DELETED_RESTRICTED, $this->list->getAuthority()
58        );
59    }
60
61    public function canViewContent() {
62        return true; // none
63    }
64
65    /**
66     * @return string Comma-separated list of tags
67     */
68    public function getTags() {
69        return $this->row->ts_tags;
70    }
71
72    /**
73     * @return string A HTML <li> element representing this revision, showing
74     * change tags and everything
75     */
76    public function getHTML() {
77        $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
78            $this->row->log_timestamp, $this->list->getUser() ) );
79        $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
80        $formatter = LogFormatter::newFromRow( $this->row );
81        $formatter->setContext( $this->list->getContext() );
82        $formatter->setAudience( LogFormatter::FOR_THIS_USER );
83
84        // Log link for this page
85        $loglink = MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
86            SpecialPage::getTitleFor( 'Log' ),
87            $this->list->msg( 'log' )->text(),
88            [],
89            [ 'page' => $title->getPrefixedText() ]
90        );
91        $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
92        // User links and action text
93        $action = $formatter->getActionText();
94
95        $comment = $this->list->getLanguage()->getDirMark() .
96            $formatter->getComment();
97
98        $content = "$loglink $date $action $comment";
99        $attribs = [];
100        $tags = $this->getTags();
101        if ( $tags ) {
102            [ $tagSummary, $classes ] = ChangeTags::formatSummaryRow(
103                $tags,
104                'edittags',
105                $this->list->getContext()
106            );
107            $content .= " $tagSummary";
108            $attribs['class'] = implode( ' ', $classes );
109        }
110        return Html::rawElement( 'li', $attribs, $content );
111    }
112}