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
24 * Item class for a live revision table row
26 class RevisionItem
extends RevisionItemBase
{
30 /** @var RequestContext */
33 public function __construct( $list, $row ) {
34 parent
::__construct( $list, $row );
35 $this->revision
= new Revision( $row );
36 $this->context
= $list->getContext();
39 public function getIdField() {
43 public function getTimestampField() {
44 return 'rev_timestamp';
47 public function getAuthorIdField() {
51 public function getAuthorNameField() {
52 return 'rev_user_text';
55 public function canView() {
56 return $this->revision
->userCan( Revision
::DELETED_RESTRICTED
, $this->context
->getUser() );
59 public function canViewContent() {
60 return $this->revision
->userCan( Revision
::DELETED_TEXT
, $this->context
->getUser() );
63 public function isDeleted() {
64 return $this->revision
->isDeleted( Revision
::DELETED_TEXT
);
68 * Get the HTML link to the revision text.
69 * @todo Essentially a copy of RevDelRevisionItem::getRevisionLink. That class
70 * should inherit from this one, and implement an appropriate interface instead
71 * of extending RevDelItem
74 protected function getRevisionLink() {
75 $date = $this->list->getLanguage()->userTimeAndDate(
76 $this->revision
->getTimestamp(), $this->list->getUser() );
78 if ( $this->isDeleted() && !$this->canViewContent() ) {
79 return htmlspecialchars( $date );
81 $linkRenderer = $this->getLinkRenderer();
82 return $linkRenderer->makeKnownLink(
87 'oldid' => $this->revision
->getId(),
94 * Get the HTML link to the diff.
95 * @todo Essentially a copy of RevDelRevisionItem::getDiffLink. That class
96 * should inherit from this one, and implement an appropriate interface instead
97 * of extending RevDelItem
100 protected function getDiffLink() {
101 if ( $this->isDeleted() && !$this->canViewContent() ) {
102 return $this->context
->msg( 'diff' )->escaped();
104 $linkRenderer = $this->getLinkRenderer();
105 return $linkRenderer->makeKnownLink(
107 $this->list->msg( 'diff' )->text(),
110 'diff' => $this->revision
->getId(),
119 * @todo Essentially a copy of RevDelRevisionItem::getHTML. That class
120 * should inherit from this one, and implement an appropriate interface instead
121 * of extending RevDelItem
124 public function getHTML() {
125 $difflink = $this->context
->msg( 'parentheses' )
126 ->rawParams( $this->getDiffLink() )->escaped();
127 $revlink = $this->getRevisionLink();
128 $userlink = Linker
::revUserLink( $this->revision
);
129 $comment = Linker
::revComment( $this->revision
);
130 if ( $this->isDeleted() ) {
131 $revlink = "<span class=\"history-deleted\">$revlink</span>";
133 return "<li>$difflink $revlink $userlink $comment</li>";