3 * Holders of revision list for a single page
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 use MediaWiki\Storage\RevisionRecord
;
26 * Item class for a live revision table row
28 class RevisionItem
extends RevisionItemBase
{
32 /** @var RequestContext */
35 public function __construct( $list, $row ) {
36 parent
::__construct( $list, $row );
37 $this->revision
= new Revision( $row );
38 $this->context
= $list->getContext();
41 public function getIdField() {
45 public function getTimestampField() {
46 return 'rev_timestamp';
49 public function getAuthorIdField() {
53 public function getAuthorNameField() {
54 return 'rev_user_text';
57 public function canView() {
58 return $this->revision
->userCan(
59 RevisionRecord
::DELETED_RESTRICTED
, $this->context
->getUser()
63 public function canViewContent() {
64 return $this->revision
->userCan(
65 RevisionRecord
::DELETED_TEXT
, $this->context
->getUser()
69 public function isDeleted() {
70 return $this->revision
->isDeleted( RevisionRecord
::DELETED_TEXT
);
74 * Get the HTML link to the revision text.
75 * @todo Essentially a copy of RevDelRevisionItem::getRevisionLink. That class
76 * should inherit from this one, and implement an appropriate interface instead
77 * of extending RevDelItem
80 protected function getRevisionLink() {
81 $date = $this->list->getLanguage()->userTimeAndDate(
82 $this->revision
->getTimestamp(), $this->list->getUser() );
84 if ( $this->isDeleted() && !$this->canViewContent() ) {
85 return htmlspecialchars( $date );
87 $linkRenderer = $this->getLinkRenderer();
88 return $linkRenderer->makeKnownLink(
93 'oldid' => $this->revision
->getId(),
100 * Get the HTML link to the diff.
101 * @todo Essentially a copy of RevDelRevisionItem::getDiffLink. That class
102 * should inherit from this one, and implement an appropriate interface instead
103 * of extending RevDelItem
106 protected function getDiffLink() {
107 if ( $this->isDeleted() && !$this->canViewContent() ) {
108 return $this->context
->msg( 'diff' )->escaped();
110 $linkRenderer = $this->getLinkRenderer();
111 return $linkRenderer->makeKnownLink(
113 $this->list->msg( 'diff' )->text(),
116 'diff' => $this->revision
->getId(),
125 * @todo Essentially a copy of RevDelRevisionItem::getHTML. That class
126 * should inherit from this one, and implement an appropriate interface instead
127 * of extending RevDelItem
130 public function getHTML() {
131 $difflink = $this->context
->msg( 'parentheses' )
132 ->rawParams( $this->getDiffLink() )->escaped();
133 $revlink = $this->getRevisionLink();
134 $userlink = Linker
::revUserLink( $this->revision
);
135 $comment = Linker
::revComment( $this->revision
);
136 if ( $this->isDeleted() ) {
137 $revlink = "<span class=\"history-deleted\">$revlink</span>";
139 return "<li>$difflink $revlink $userlink $comment</li>";