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 canView() {
51 return $this->revision
->userCan( Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
54 public function canViewContent() {
55 return $this->revision
->userCan( Revision
::DELETED_TEXT
, $this->list->getUser() );
58 public function getBits() {
59 return $this->revision
->getVisibility();
62 public function setBits( $bits ) {
63 $dbw = wfGetDB( DB_MASTER
);
64 // Update revision table
65 $dbw->update( 'revision',
66 array( 'rev_deleted' => $bits ),
68 'rev_id' => $this->revision
->getId(),
69 'rev_page' => $this->revision
->getPage(),
70 'rev_deleted' => $this->getBits() // cas
74 if ( !$dbw->affectedRows() ) {
78 // Update recentchanges table
79 $dbw->update( 'recentchanges',
81 'rc_deleted' => $bits,
85 'rc_this_oldid' => $this->revision
->getId(), // condition
86 // non-unique timestamp index
87 'rc_timestamp' => $dbw->timestamp( $this->revision
->getTimestamp() ),
95 public function isDeleted() {
96 return $this->revision
->isDeleted( Revision
::DELETED_TEXT
);
99 public function isHideCurrentOp( $newBits ) {
100 return ( $newBits & Revision
::DELETED_TEXT
)
101 && $this->list->getCurrent() == $this->getId();
105 * Get the HTML link to the revision text.
106 * Overridden by RevDelArchiveItem.
109 protected function getRevisionLink() {
110 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
111 $this->revision
->getTimestamp(), $this->list->getUser() ) );
113 if ( $this->isDeleted() && !$this->canViewContent() ) {
117 return Linker
::linkKnown(
122 'oldid' => $this->revision
->getId(),
129 * Get the HTML link to the diff.
130 * Overridden by RevDelArchiveItem
133 protected function getDiffLink() {
134 if ( $this->isDeleted() && !$this->canViewContent() ) {
135 return $this->list->msg( 'diff' )->escaped();
137 return Linker
::linkKnown(
139 $this->list->msg( 'diff' )->escaped(),
142 'diff' => $this->revision
->getId(),
151 * @return string A HTML <li> element representing this revision, showing
152 * change tags and everything
154 public function getHTML() {
155 $difflink = $this->list->msg( 'parentheses' )
156 ->rawParams( $this->getDiffLink() )->escaped();
157 $revlink = $this->getRevisionLink();
158 $userlink = Linker
::revUserLink( $this->revision
);
159 $comment = Linker
::revComment( $this->revision
);
160 if ( $this->isDeleted() ) {
161 $revlink = "<span class=\"history-deleted\">$revlink</span>";
163 $content = "$difflink $revlink $userlink $comment";
165 $tags = $this->getTags();
167 list( $tagSummary, $classes ) = ChangeTags
::formatSummaryRow( $tags, 'revisiondelete' );
168 $content .= " $tagSummary";
169 $attribs['class'] = implode( ' ', $classes );
171 return Xml
::tags( 'li', $attribs, $content );
175 * @return string Comma-separated list of tags
177 public function getTags() {
178 return $this->row
->ts_tags
;
181 public function getApiData( ApiResult
$result ) {
182 $rev = $this->revision
;
183 $user = $this->list->getUser();
185 'id' => $rev->getId(),
186 'timestamp' => wfTimestamp( TS_ISO_8601
, $rev->getTimestamp() ),
188 $ret +
= $rev->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
189 $ret +
= $rev->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
190 $ret +
= $rev->isDeleted( Revision
::DELETED_TEXT
) ?
array( 'texthidden' => '' ) : array();
191 if ( $rev->userCan( Revision
::DELETED_USER
, $user ) ) {
193 'userid' => $rev->getUser( Revision
::FOR_THIS_USER
),
194 'user' => $rev->getUserText( Revision
::FOR_THIS_USER
),
197 if ( $rev->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
199 'comment' => $rev->getComment( Revision
::FOR_THIS_USER
),