Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChangeTagsRevisionItem
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
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 / 21
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\ChangeTags;
8
9use MediaWiki\Html\Html;
10use MediaWiki\Linker\Linker;
11use MediaWiki\MediaWikiServices;
12use MediaWiki\RevisionList\RevisionItem;
13use MediaWiki\RevisionList\RevisionListBase;
14
15/**
16 * Item class for a live revision table row with its associated change tags.
17 *
18 * @since 1.25
19 * @ingroup ChangeTags
20 */
21class ChangeTagsRevisionItem extends RevisionItem {
22
23    /** @inheritDoc */
24    public function __construct(
25        RevisionListBase $list,
26        $row,
27        private readonly ChangeTagsFormatter $changeTagsFormatter,
28    ) {
29        parent::__construct( $list, $row );
30    }
31
32    /**
33     * @return string Comma-separated list of tags
34     */
35    public function getTags() {
36        return $this->row->ts_tags;
37    }
38
39    /**
40     * @return string A HTML <li> element representing this revision, showing
41     * change tags and everything
42     */
43    public function getHTML() {
44        $difflink = $this->list->msg( 'parentheses' )
45            ->rawParams( $this->getDiffLink() )->escaped();
46        $revlink = $this->getRevisionLink();
47        $userlink = Linker::revUserLink( $this->getRevisionRecord() );
48        $comment = MediaWikiServices::getInstance()->getCommentFormatter()
49            ->formatRevision( $this->getRevisionRecord(), $this->list->getAuthority() );
50        if ( $this->isDeleted() ) {
51            $class = Linker::getRevisionDeletedClass( $this->getRevisionRecord() );
52            $revlink = "<span class=\"$class\">$revlink</span>";
53        }
54
55        $content = "$difflink $revlink $userlink $comment";
56        $attribs = [];
57        $tags = $this->getTags();
58        if ( $tags ) {
59            [ $tagSummary, $classes ] = $this->changeTagsFormatter->formatTagsAsSummaryList(
60                $tags,
61                $this->list->getContext(),
62                $this->list->getAuthority()
63            );
64            $content .= " $tagSummary";
65            $attribs['class'] = $classes;
66        }
67        return Html::rawElement( 'li', $attribs, $content );
68    }
69}
70
71/** @deprecated class alias since 1.44 */
72class_alias( ChangeTagsRevisionItem::class, 'ChangeTagsRevisionItem' );