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