Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.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 /**
23 * Item class for a logging table row with its associated change tags.
24 * @todo Abstract out a base class for this and RevDelLogItem, similar to the
25 * RevisionItem class but specifically for log items.
26 * @since 1.25
27 */
28 class ChangeTagsLogItem extends RevisionItemBase {
29 public function getIdField() {
30 return 'log_id';
31 }
32
33 public function getTimestampField() {
34 return 'log_timestamp';
35 }
36
37 public function getAuthorIdField() {
38 return 'log_user';
39 }
40
41 public function getAuthorNameField() {
42 return 'log_user_text';
43 }
44
45 public function canView() {
46 return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
47 }
48
49 public function canViewContent() {
50 return true; // none
51 }
52
53 /**
54 * @return string Comma-separated list of tags
55 */
56 public function getTags() {
57 return $this->row->ts_tags;
58 }
59
60 /**
61 * @return string A HTML <li> element representing this revision, showing
62 * change tags and everything
63 */
64 public function getHTML() {
65 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
66 $this->row->log_timestamp, $this->list->getUser() ) );
67 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
68 $formatter = LogFormatter::newFromRow( $this->row );
69 $formatter->setContext( $this->list->getContext() );
70 $formatter->setAudience( LogFormatter::FOR_THIS_USER );
71
72 // Log link for this page
73 $loglink = Linker::link(
74 SpecialPage::getTitleFor( 'Log' ),
75 $this->list->msg( 'log' )->escaped(),
76 [],
77 [ 'page' => $title->getPrefixedText() ]
78 );
79 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
80 // User links and action text
81 $action = $formatter->getActionText();
82 // Comment
83 $comment = $this->list->getLanguage()->getDirMark() .
84 $formatter->getComment();
85
86 if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) {
87 $comment = '<span class="history-deleted">' . $comment . '</span>';
88 }
89
90 $content = "$loglink $date $action $comment";
91 $attribs = [];
92 $tags = $this->getTags();
93 if ( $tags ) {
94 list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
95 $tags,
96 'edittags',
97 $this->list->getContext()
98 );
99 $content .= " $tagSummary";
100 $attribs['class'] = implode( ' ', $classes );
101 }
102 return Xml::tags( 'li', $attribs, $content );
103 }
104 }