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.
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.
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
19 * @ingroup RevisionDelete
23 * Item class for a live revision table row
25 class RevDelRevisionItem
extends RevDelItem
{
29 public function __construct( $list, $row ) {
30 parent
::__construct( $list, $row );
31 $this->revision
= new Revision( $row );
34 public function getIdField() {
38 public function getTimestampField() {
39 return 'rev_timestamp';
42 public function getAuthorIdField() {
46 public function getAuthorNameField() {
47 return 'rev_user_text';
50 public function getAuthorActorField() {
54 public function canView() {
55 return $this->revision
->userCan( Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
58 public function canViewContent() {
59 return $this->revision
->userCan( Revision
::DELETED_TEXT
, $this->list->getUser() );
62 public function getBits() {
63 return $this->revision
->getVisibility();
66 public function setBits( $bits ) {
67 $dbw = wfGetDB( DB_MASTER
);
68 // Update revision table
69 $dbw->update( 'revision',
70 [ 'rev_deleted' => $bits ],
72 'rev_id' => $this->revision
->getId(),
73 'rev_page' => $this->revision
->getPage(),
74 'rev_deleted' => $this->getBits() // cas
78 if ( !$dbw->affectedRows() ) {
82 // Update recentchanges table
83 $dbw->update( 'recentchanges',
85 'rc_deleted' => $bits,
86 'rc_patrolled' => RecentChange
::PRC_PATROLLED
89 'rc_this_oldid' => $this->revision
->getId(), // condition
90 // non-unique timestamp index
91 'rc_timestamp' => $dbw->timestamp( $this->revision
->getTimestamp() ),
99 public function isDeleted() {
100 return $this->revision
->isDeleted( Revision
::DELETED_TEXT
);
103 public function isHideCurrentOp( $newBits ) {
104 return ( $newBits & Revision
::DELETED_TEXT
)
105 && $this->list->getCurrent() == $this->getId();
109 * Get the HTML link to the revision text.
110 * Overridden by RevDelArchiveItem.
113 protected function getRevisionLink() {
114 $date = $this->list->getLanguage()->userTimeAndDate(
115 $this->revision
->getTimestamp(), $this->list->getUser() );
117 if ( $this->isDeleted() && !$this->canViewContent() ) {
118 return htmlspecialchars( $date );
121 return $this->getLinkRenderer()->makeKnownLink(
126 'oldid' => $this->revision
->getId(),
133 * Get the HTML link to the diff.
134 * Overridden by RevDelArchiveItem
137 protected function getDiffLink() {
138 if ( $this->isDeleted() && !$this->canViewContent() ) {
139 return $this->list->msg( 'diff' )->escaped();
141 return $this->getLinkRenderer()->makeKnownLink(
143 $this->list->msg( 'diff' )->text(),
146 'diff' => $this->revision
->getId(),
155 * @return string A HTML <li> element representing this revision, showing
156 * change tags and everything
158 public function getHTML() {
159 $difflink = $this->list->msg( 'parentheses' )
160 ->rawParams( $this->getDiffLink() )->escaped();
161 $revlink = $this->getRevisionLink();
162 $userlink = Linker
::revUserLink( $this->revision
);
163 $comment = Linker
::revComment( $this->revision
);
164 if ( $this->isDeleted() ) {
165 $revlink = "<span class=\"history-deleted\">$revlink</span>";
167 $content = "$difflink $revlink $userlink $comment";
169 $tags = $this->getTags();
171 list( $tagSummary, $classes ) = ChangeTags
::formatSummaryRow(
174 $this->list->getContext()
176 $content .= " $tagSummary";
177 $attribs['class'] = implode( ' ', $classes );
179 return Xml
::tags( 'li', $attribs, $content );
183 * @return string Comma-separated list of tags
185 public function getTags() {
186 return $this->row
->ts_tags
;
189 public function getApiData( ApiResult
$result ) {
190 $rev = $this->revision
;
191 $user = $this->list->getUser();
193 'id' => $rev->getId(),
194 'timestamp' => wfTimestamp( TS_ISO_8601
, $rev->getTimestamp() ),
195 'userhidden' => (bool)$rev->isDeleted( Revision
::DELETED_USER
),
196 'commenthidden' => (bool)$rev->isDeleted( Revision
::DELETED_COMMENT
),
197 'texthidden' => (bool)$rev->isDeleted( Revision
::DELETED_TEXT
),
199 if ( $rev->userCan( Revision
::DELETED_USER
, $user ) ) {
201 'userid' => $rev->getUser( Revision
::FOR_THIS_USER
),
202 'user' => $rev->getUserText( Revision
::FOR_THIS_USER
),
205 if ( $rev->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
207 'comment' => $rev->getComment( Revision
::FOR_THIS_USER
),