Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChangeTagsRevisionItem
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 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 / 21
0.00% covered (danger)
0.00%
0 / 1
12
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 */
20
21use MediaWiki\Html\Html;
22use MediaWiki\Linker\Linker;
23use MediaWiki\MediaWikiServices;
24use MediaWiki\RevisionList\RevisionItem;
25
26/**
27 * Item class for a live revision table row with its associated change tags.
28 *
29 * @since 1.25
30 * @ingroup ChangeTags
31 */
32class ChangeTagsRevisionItem extends RevisionItem {
33    /**
34     * @return string Comma-separated list of tags
35     */
36    public function getTags() {
37        return $this->row->ts_tags;
38    }
39
40    /**
41     * @return string A HTML <li> element representing this revision, showing
42     * change tags and everything
43     */
44    public function getHTML() {
45        $difflink = $this->list->msg( 'parentheses' )
46            ->rawParams( $this->getDiffLink() )->escaped();
47        $revlink = $this->getRevisionLink();
48        $userlink = Linker::revUserLink( $this->getRevisionRecord() );
49        $comment = MediaWikiServices::getInstance()->getCommentFormatter()
50            ->formatRevision( $this->getRevisionRecord(), $this->list->getAuthority() );
51        if ( $this->isDeleted() ) {
52            $class = Linker::getRevisionDeletedClass( $this->getRevisionRecord() );
53            $revlink = "<span class=\"$class\">$revlink</span>";
54        }
55
56        $content = "$difflink $revlink $userlink $comment";
57        $attribs = [];
58        $tags = $this->getTags();
59        if ( $tags ) {
60            [ $tagSummary, $classes ] = ChangeTags::formatSummaryRow(
61                $tags,
62                'edittags',
63                $this->list->getContext()
64            );
65            $content .= " $tagSummary";
66            $attribs['class'] = implode( ' ', $classes );
67        }
68        return Html::rawElement( 'li', $attribs, $content );
69    }
70}