3 * Base implementations for deletable items.
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
21 * @ingroup RevisionDelete
25 * List for revision table items
27 * This will check both the 'revision' table for live revisions and the
28 * 'archive' table for traditionally-deleted revisions that have an
31 * See RevDelRevisionItem and RevDelArchivedRevisionItem for items.
33 class RevDelRevisionList
extends RevDelList
{
36 public function getType() {
40 public static function getRelationType() {
44 public static function getRestriction() {
45 return 'deleterevision';
48 public static function getRevdelConstant() {
49 return Revision
::DELETED_TEXT
;
52 public static function suggestTarget( $target, array $ids ) {
53 $rev = Revision
::newFromId( $ids[0] );
54 return $rev ?
$rev->getTitle() : $target;
58 * @param DatabaseBase $db
61 public function doQuery( $db ) {
62 $ids = array_map( 'intval', $this->ids
);
64 array( 'revision', 'page', 'user' ),
65 array_merge( Revision
::selectFields(), Revision
::selectUserFields() ),
67 'rev_page' => $this->title
->getArticleID(),
71 array( 'ORDER BY' => 'rev_id DESC' ),
73 'page' => Revision
::pageJoinCond(),
74 'user' => Revision
::userJoinCond() )
77 if ( $live->numRows() >= count( $ids ) ) {
78 // All requested revisions are live, keeps things simple!
82 // Check if any requested revisions are available fully deleted.
83 $archived = $db->select( array( 'archive' ), Revision
::selectArchiveFields(),
88 array( 'ORDER BY' => 'ar_rev_id DESC' )
91 if ( $archived->numRows() == 0 ) {
93 } elseif ( $live->numRows() == 0 ) {
96 // Combine the two! Whee
98 foreach ( $live as $row ) {
99 $rows[$row->rev_id
] = $row;
101 foreach ( $archived as $row ) {
102 $rows[$row->ar_rev_id
] = $row;
105 return new FakeResultWrapper( array_values( $rows ) );
109 public function newItem( $row ) {
110 if ( isset( $row->rev_id
) ) {
111 return new RevDelRevisionItem( $this, $row );
112 } elseif ( isset( $row->ar_rev_id
) ) {
113 return new RevDelArchivedRevisionItem( $this, $row );
115 // This shouldn't happen. :)
116 throw new MWException( 'Invalid row type in RevDelRevisionList' );
120 public function getCurrent() {
121 if ( is_null( $this->currentRevId
) ) {
122 $dbw = wfGetDB( DB_MASTER
);
123 $this->currentRevId
= $dbw->selectField(
124 'page', 'page_latest', $this->title
->pageCond(), __METHOD__
);
126 return $this->currentRevId
;
129 public function getSuppressBit() {
130 return Revision
::DELETED_RESTRICTED
;
133 public function doPreCommitUpdates() {
134 $this->title
->invalidateCache();
135 return Status
::newGood();
138 public function doPostCommitUpdates() {
139 $this->title
->purgeSquid();
140 // Extensions that require referencing previous revisions may need this
141 wfRunHooks( 'ArticleRevisionVisibilitySet', array( &$this->title
) );
142 return Status
::newGood();
147 * Item class for a live revision table row
149 class RevDelRevisionItem
extends RevDelItem
{
152 public function __construct( $list, $row ) {
153 parent
::__construct( $list, $row );
154 $this->revision
= new Revision( $row );
157 public function getIdField() {
161 public function getTimestampField() {
162 return 'rev_timestamp';
165 public function getAuthorIdField() {
169 public function getAuthorNameField() {
170 return 'rev_user_text';
173 public function canView() {
174 return $this->revision
->userCan( Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
177 public function canViewContent() {
178 return $this->revision
->userCan( Revision
::DELETED_TEXT
, $this->list->getUser() );
181 public function getBits() {
182 return $this->revision
->getVisibility();
185 public function setBits( $bits ) {
186 $dbw = wfGetDB( DB_MASTER
);
187 // Update revision table
188 $dbw->update( 'revision',
189 array( 'rev_deleted' => $bits ),
191 'rev_id' => $this->revision
->getId(),
192 'rev_page' => $this->revision
->getPage(),
193 'rev_deleted' => $this->getBits()
197 if ( !$dbw->affectedRows() ) {
201 // Update recentchanges table
202 $dbw->update( 'recentchanges',
204 'rc_deleted' => $bits,
208 'rc_this_oldid' => $this->revision
->getId(), // condition
209 // non-unique timestamp index
210 'rc_timestamp' => $dbw->timestamp( $this->revision
->getTimestamp() ),
217 public function isDeleted() {
218 return $this->revision
->isDeleted( Revision
::DELETED_TEXT
);
221 public function isHideCurrentOp( $newBits ) {
222 return ( $newBits & Revision
::DELETED_TEXT
)
223 && $this->list->getCurrent() == $this->getId();
227 * Get the HTML link to the revision text.
228 * Overridden by RevDelArchiveItem.
231 protected function getRevisionLink() {
232 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
233 $this->revision
->getTimestamp(), $this->list->getUser() ) );
235 if ( $this->isDeleted() && !$this->canViewContent() ) {
238 return Linker
::linkKnown(
243 'oldid' => $this->revision
->getId(),
250 * Get the HTML link to the diff.
251 * Overridden by RevDelArchiveItem
254 protected function getDiffLink() {
255 if ( $this->isDeleted() && !$this->canViewContent() ) {
256 return $this->list->msg( 'diff' )->escaped();
258 return Linker
::linkKnown(
260 $this->list->msg( 'diff' )->escaped(),
263 'diff' => $this->revision
->getId(),
271 public function getHTML() {
272 $difflink = $this->list->msg( 'parentheses' )
273 ->rawParams( $this->getDiffLink() )->escaped();
274 $revlink = $this->getRevisionLink();
275 $userlink = Linker
::revUserLink( $this->revision
);
276 $comment = Linker
::revComment( $this->revision
);
277 if ( $this->isDeleted() ) {
278 $revlink = "<span class=\"history-deleted\">$revlink</span>";
280 return "<li>$difflink $revlink $userlink $comment</li>";
283 public function getApiData( ApiResult
$result ) {
284 $rev = $this->revision
;
285 $user = $this->list->getUser();
287 'id' => $rev->getId(),
288 'timestamp' => wfTimestamp( TS_ISO_8601
, $rev->getTimestamp() ),
290 $ret +
= $rev->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
291 $ret +
= $rev->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
292 $ret +
= $rev->isDeleted( Revision
::DELETED_TEXT
) ?
array( 'texthidden' => '' ) : array();
293 if ( $rev->userCan( Revision
::DELETED_USER
, $user ) ) {
295 'userid' => $rev->getUser( Revision
::FOR_THIS_USER
),
296 'user' => $rev->getUserText( Revision
::FOR_THIS_USER
),
299 if ( $rev->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
301 'comment' => $rev->getComment( Revision
::FOR_THIS_USER
),
309 * List for archive table items, i.e. revisions deleted via action=delete
311 class RevDelArchiveList
extends RevDelRevisionList
{
312 public function getType() {
316 public static function getRelationType() {
317 return 'ar_timestamp';
321 * @param DatabaseBase $db
324 public function doQuery( $db ) {
325 $timestamps = array();
326 foreach ( $this->ids
as $id ) {
327 $timestamps[] = $db->timestamp( $id );
329 return $db->select( 'archive', Revision
::selectArchiveFields(),
331 'ar_namespace' => $this->title
->getNamespace(),
332 'ar_title' => $this->title
->getDBkey(),
333 'ar_timestamp' => $timestamps
336 array( 'ORDER BY' => 'ar_timestamp DESC' )
340 public function newItem( $row ) {
341 return new RevDelArchiveItem( $this, $row );
344 public function doPreCommitUpdates() {
345 return Status
::newGood();
348 public function doPostCommitUpdates() {
349 return Status
::newGood();
354 * Item class for a archive table row
356 class RevDelArchiveItem
extends RevDelRevisionItem
{
357 public function __construct( $list, $row ) {
358 RevDelItem
::__construct( $list, $row );
359 $this->revision
= Revision
::newFromArchiveRow( $row,
360 array( 'page' => $this->list->title
->getArticleID() ) );
363 public function getIdField() {
364 return 'ar_timestamp';
367 public function getTimestampField() {
368 return 'ar_timestamp';
371 public function getAuthorIdField() {
375 public function getAuthorNameField() {
376 return 'ar_user_text';
379 public function getId() {
380 # Convert DB timestamp to MW timestamp
381 return $this->revision
->getTimestamp();
384 public function setBits( $bits ) {
385 $dbw = wfGetDB( DB_MASTER
);
386 $dbw->update( 'archive',
387 array( 'ar_deleted' => $bits ),
389 'ar_namespace' => $this->list->title
->getNamespace(),
390 'ar_title' => $this->list->title
->getDBkey(),
391 // use timestamp for index
392 'ar_timestamp' => $this->row
->ar_timestamp
,
393 'ar_rev_id' => $this->row
->ar_rev_id
,
394 'ar_deleted' => $this->getBits()
397 return (bool)$dbw->affectedRows();
400 protected function getRevisionLink() {
401 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
402 $this->revision
->getTimestamp(), $this->list->getUser() ) );
404 if ( $this->isDeleted() && !$this->canViewContent() ) {
409 SpecialPage
::getTitleFor( 'Undelete' ),
413 'target' => $this->list->title
->getPrefixedText(),
414 'timestamp' => $this->revision
->getTimestamp()
419 protected function getDiffLink() {
420 if ( $this->isDeleted() && !$this->canViewContent() ) {
421 return $this->list->msg( 'diff' )->escaped();
425 SpecialPage
::getTitleFor( 'Undelete' ),
426 $this->list->msg( 'diff' )->escaped(),
429 'target' => $this->list->title
->getPrefixedText(),
431 'timestamp' => $this->revision
->getTimestamp()
438 * Item class for a archive table row by ar_rev_id -- actually
439 * used via RevDelRevisionList.
441 class RevDelArchivedRevisionItem
extends RevDelArchiveItem
{
442 public function __construct( $list, $row ) {
443 RevDelItem
::__construct( $list, $row );
445 $this->revision
= Revision
::newFromArchiveRow( $row,
446 array( 'page' => $this->list->title
->getArticleID() ) );
449 public function getIdField() {
453 public function getId() {
454 return $this->revision
->getId();
457 public function setBits( $bits ) {
458 $dbw = wfGetDB( DB_MASTER
);
459 $dbw->update( 'archive',
460 array( 'ar_deleted' => $bits ),
461 array( 'ar_rev_id' => $this->row
->ar_rev_id
,
462 'ar_deleted' => $this->getBits()
465 return (bool)$dbw->affectedRows();
470 * List for oldimage table items
472 class RevDelFileList
extends RevDelList
{
473 public function getType() {
477 public static function getRelationType() {
478 return 'oi_archive_name';
481 public static function getRestriction() {
482 return 'deleterevision';
485 public static function getRevdelConstant() {
486 return File
::DELETED_FILE
;
489 var $storeBatch, $deleteBatch, $cleanupBatch;
492 * @param DatabaseBase $db
495 public function doQuery( $db ) {
496 $archiveNames = array();
497 foreach ( $this->ids
as $timestamp ) {
498 $archiveNames[] = $timestamp . '!' . $this->title
->getDBkey();
502 OldLocalFile
::selectFields(),
504 'oi_name' => $this->title
->getDBkey(),
505 'oi_archive_name' => $archiveNames
508 array( 'ORDER BY' => 'oi_timestamp DESC' )
512 public function newItem( $row ) {
513 return new RevDelFileItem( $this, $row );
516 public function clearFileOps() {
517 $this->deleteBatch
= array();
518 $this->storeBatch
= array();
519 $this->cleanupBatch
= array();
522 public function doPreCommitUpdates() {
523 $status = Status
::newGood();
524 $repo = RepoGroup
::singleton()->getLocalRepo();
525 if ( $this->storeBatch
) {
526 $status->merge( $repo->storeBatch( $this->storeBatch
, FileRepo
::OVERWRITE_SAME
) );
528 if ( !$status->isOK() ) {
531 if ( $this->deleteBatch
) {
532 $status->merge( $repo->deleteBatch( $this->deleteBatch
) );
534 if ( !$status->isOK() ) {
535 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
536 // modified (but destined for rollback) causes data loss
539 if ( $this->cleanupBatch
) {
540 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch
) );
545 public function doPostCommitUpdates() {
547 $file = wfLocalFile( $this->title
);
549 $file->purgeDescription();
550 $purgeUrls = array();
551 foreach ( $this->ids
as $timestamp ) {
552 $archiveName = $timestamp . '!' . $this->title
->getDBkey();
553 $file->purgeOldThumbnails( $archiveName );
554 $purgeUrls[] = $file->getArchiveUrl( $archiveName );
557 // purge full images from cache
558 SquidUpdate
::purge( $purgeUrls );
560 return Status
::newGood();
563 public function getSuppressBit() {
564 return File
::DELETED_RESTRICTED
;
569 * Item class for an oldimage table row
571 class RevDelFileItem
extends RevDelItem
{
578 public function __construct( $list, $row ) {
579 parent
::__construct( $list, $row );
580 $this->file
= RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
583 public function getIdField() {
584 return 'oi_archive_name';
587 public function getTimestampField() {
588 return 'oi_timestamp';
591 public function getAuthorIdField() {
595 public function getAuthorNameField() {
596 return 'oi_user_text';
599 public function getId() {
600 $parts = explode( '!', $this->row
->oi_archive_name
);
604 public function canView() {
605 return $this->file
->userCan( File
::DELETED_RESTRICTED
, $this->list->getUser() );
608 public function canViewContent() {
609 return $this->file
->userCan( File
::DELETED_FILE
, $this->list->getUser() );
612 public function getBits() {
613 return $this->file
->getVisibility();
616 public function setBits( $bits ) {
618 # @todo FIXME: Move to LocalFile.php
619 if ( $this->isDeleted() ) {
620 if ( $bits & File
::DELETED_FILE
) {
624 $key = $this->file
->getStorageKey();
625 $srcRel = $this->file
->repo
->getDeletedHashPath( $key ) . $key;
626 $this->list->storeBatch
[] = array(
627 $this->file
->repo
->getVirtualUrl( 'deleted' ) . '/' . $srcRel,
629 $this->file
->getRel()
631 $this->list->cleanupBatch
[] = $key;
633 } elseif ( $bits & File
::DELETED_FILE
) {
635 $key = $this->file
->getStorageKey();
636 $dstRel = $this->file
->repo
->getDeletedHashPath( $key ) . $key;
637 $this->list->deleteBatch
[] = array( $this->file
->getRel(), $dstRel );
640 # Do the database operations
641 $dbw = wfGetDB( DB_MASTER
);
642 $dbw->update( 'oldimage',
643 array( 'oi_deleted' => $bits ),
645 'oi_name' => $this->row
->oi_name
,
646 'oi_timestamp' => $this->row
->oi_timestamp
,
647 'oi_deleted' => $this->getBits()
651 return (bool)$dbw->affectedRows();
654 public function isDeleted() {
655 return $this->file
->isDeleted( File
::DELETED_FILE
);
659 * Get the link to the file.
660 * Overridden by RevDelArchivedFileItem.
663 protected function getLink() {
664 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
665 $this->file
->getTimestamp(), $this->list->getUser() ) );
667 if ( !$this->isDeleted() ) {
669 return Html
::rawElement( 'a', array( 'href' => $this->file
->getUrl() ), $date );
673 if ( !$this->canViewContent() ) {
676 $link = Linker
::link(
677 SpecialPage
::getTitleFor( 'Revisiondelete' ),
681 'target' => $this->list->title
->getPrefixedText(),
682 'file' => $this->file
->getArchiveName(),
683 'token' => $this->list->getUser()->getEditToken(
684 $this->file
->getArchiveName() )
688 return '<span class="history-deleted">' . $link . '</span>';
692 * Generate a user tool link cluster if the current user is allowed to view it
693 * @return string HTML
695 protected function getUserTools() {
696 if ( $this->file
->userCan( Revision
::DELETED_USER
, $this->list->getUser() ) ) {
697 $uid = $this->file
->getUser( 'id' );
698 $name = $this->file
->getUser( 'text' );
699 $link = Linker
::userLink( $uid, $name ) . Linker
::userToolLinks( $uid, $name );
701 $link = $this->list->msg( 'rev-deleted-user' )->escaped();
703 if ( $this->file
->isDeleted( Revision
::DELETED_USER
) ) {
704 return '<span class="history-deleted">' . $link . '</span>';
710 * Wrap and format the file's comment block, if the current
711 * user is allowed to view it.
713 * @return string HTML
715 protected function getComment() {
716 if ( $this->file
->userCan( File
::DELETED_COMMENT
, $this->list->getUser() ) ) {
717 $block = Linker
::commentBlock( $this->file
->getDescription() );
719 $block = ' ' . $this->list->msg( 'rev-deleted-comment' )->escaped();
721 if ( $this->file
->isDeleted( File
::DELETED_COMMENT
) ) {
722 return "<span class=\"history-deleted\">$block</span>";
727 public function getHTML() {
729 $this->list->msg( 'widthheight' )->numParams(
730 $this->file
->getWidth(), $this->file
->getHeight() )->text() .
731 ' (' . $this->list->msg( 'nbytes' )->numParams( $this->file
->getSize() )->text() . ')';
733 return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
734 $data . ' ' . $this->getComment() . '</li>';
737 public function getApiData( ApiResult
$result ) {
739 $user = $this->list->getUser();
741 'title' => $this->list->title
->getPrefixedText(),
742 'archivename' => $file->getArchiveName(),
743 'timestamp' => wfTimestamp( TS_ISO_8601
, $file->getTimestamp() ),
744 'width' => $file->getWidth(),
745 'height' => $file->getHeight(),
746 'size' => $file->getSize(),
748 $ret +
= $file->isDeleted( Revision
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
749 $ret +
= $file->isDeleted( Revision
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
750 $ret +
= $this->isDeleted() ?
array( 'contenthidden' => '' ) : array();
751 if ( !$this->isDeleted() ) {
753 'url' => $file->getUrl(),
755 } elseif ( $this->canViewContent() ) {
757 'url' => SpecialPage
::getTitleFor( 'Revisiondelete' )->getLinkURL(
759 'target' => $this->list->title
->getPrefixedText(),
760 'file' => $file->getArchiveName(),
761 'token' => $user->getEditToken( $file->getArchiveName() )
763 false, PROTO_RELATIVE
767 if ( $file->userCan( Revision
::DELETED_USER
, $user ) ) {
769 'userid' => $file->user
,
770 'user' => $file->user_text
,
773 if ( $file->userCan( Revision
::DELETED_COMMENT
, $user ) ) {
775 'comment' => $file->description
,
783 * List for filearchive table items
785 class RevDelArchivedFileList
extends RevDelFileList
{
786 public function getType() {
787 return 'filearchive';
790 public static function getRelationType() {
795 * @param DatabaseBase $db
798 public function doQuery( $db ) {
799 $ids = array_map( 'intval', $this->ids
);
802 ArchivedFile
::selectFields(),
804 'fa_name' => $this->title
->getDBkey(),
808 array( 'ORDER BY' => 'fa_id DESC' )
812 public function newItem( $row ) {
813 return new RevDelArchivedFileItem( $this, $row );
818 * Item class for a filearchive table row
820 class RevDelArchivedFileItem
extends RevDelFileItem
{
821 public function __construct( $list, $row ) {
822 RevDelItem
::__construct( $list, $row );
823 $this->file
= ArchivedFile
::newFromRow( $row );
826 public function getIdField() {
830 public function getTimestampField() {
831 return 'fa_timestamp';
834 public function getAuthorIdField() {
838 public function getAuthorNameField() {
839 return 'fa_user_text';
842 public function getId() {
843 return $this->row
->fa_id
;
846 public function setBits( $bits ) {
847 $dbw = wfGetDB( DB_MASTER
);
848 $dbw->update( 'filearchive',
849 array( 'fa_deleted' => $bits ),
851 'fa_id' => $this->row
->fa_id
,
852 'fa_deleted' => $this->getBits(),
856 return (bool)$dbw->affectedRows();
859 protected function getLink() {
860 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
861 $this->file
->getTimestamp(), $this->list->getUser() ) );
864 if ( !$this->canViewContent() ) {
867 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
868 $key = $this->file
->getKey();
869 $link = Linker
::link( $undelete, $date, array(),
871 'target' => $this->list->title
->getPrefixedText(),
873 'token' => $this->list->getUser()->getEditToken( $key )
877 if ( $this->isDeleted() ) {
878 $link = '<span class="history-deleted">' . $link . '</span>';
885 * List for logging table items
887 class RevDelLogList
extends RevDelList
{
888 public function getType() {
892 public static function getRelationType() {
896 public static function getRestriction() {
897 return 'deletelogentry';
900 public static function getRevdelConstant() {
901 return LogPage
::DELETED_ACTION
;
904 public static function suggestTarget( $target, array $ids ) {
905 $result = wfGetDB( DB_SLAVE
)->select( 'logging',
907 array( 'log_id' => $ids ),
911 if ( $result->numRows() == 1 ) {
912 // If there's only one type, the target can be set to include it.
913 return SpecialPage
::getTitleFor( 'Log', $result->current()->log_type
);
915 return SpecialPage
::getTitleFor( 'Log' );
919 * @param DatabaseBase $db
922 public function doQuery( $db ) {
923 $ids = array_map( 'intval', $this->ids
);
924 return $db->select( 'logging', array(
938 array( 'log_id' => $ids ),
940 array( 'ORDER BY' => 'log_id DESC' )
944 public function newItem( $row ) {
945 return new RevDelLogItem( $this, $row );
948 public function getSuppressBit() {
949 return Revision
::DELETED_RESTRICTED
;
952 public function getLogAction() {
956 public function getLogParams( $params ) {
958 implode( ',', $params['ids'] ),
959 "ofield={$params['oldBits']}",
960 "nfield={$params['newBits']}"
966 * Item class for a logging table row
968 class RevDelLogItem
extends RevDelItem
{
969 public function getIdField() {
973 public function getTimestampField() {
974 return 'log_timestamp';
977 public function getAuthorIdField() {
981 public function getAuthorNameField() {
982 return 'log_user_text';
985 public function canView() {
986 return LogEventsList
::userCan( $this->row
, Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
989 public function canViewContent() {
993 public function getBits() {
994 return $this->row
->log_deleted
;
997 public function setBits( $bits ) {
998 $dbw = wfGetDB( DB_MASTER
);
999 $dbw->update( 'recentchanges',
1001 'rc_deleted' => $bits,
1005 'rc_logid' => $this->row
->log_id
,
1006 'rc_timestamp' => $this->row
->log_timestamp
// index
1010 $dbw->update( 'logging',
1011 array( 'log_deleted' => $bits ),
1013 'log_id' => $this->row
->log_id
,
1014 'log_deleted' => $this->getBits()
1018 return (bool)$dbw->affectedRows();
1021 public function getHTML() {
1022 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
1023 $this->row
->log_timestamp
, $this->list->getUser() ) );
1024 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
1025 $formatter = LogFormatter
::newFromRow( $this->row
);
1026 $formatter->setContext( $this->list->getContext() );
1027 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
1029 // Log link for this page
1030 $loglink = Linker
::link(
1031 SpecialPage
::getTitleFor( 'Log' ),
1032 $this->list->msg( 'log' )->escaped(),
1034 array( 'page' => $title->getPrefixedText() )
1036 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
1037 // User links and action text
1038 $action = $formatter->getActionText();
1040 $comment = $this->list->getLanguage()->getDirMark() . Linker
::commentBlock( $this->row
->log_comment
);
1041 if ( LogEventsList
::isDeleted( $this->row
, LogPage
::DELETED_COMMENT
) ) {
1042 $comment = '<span class="history-deleted">' . $comment . '</span>';
1045 return "<li>$loglink $date $action $comment</li>";
1048 public function getApiData( ApiResult
$result ) {
1049 $logEntry = DatabaseLogEntry
::newFromRow( $this->row
);
1050 $user = $this->list->getUser();
1052 'id' => $logEntry->getId(),
1053 'type' => $logEntry->getType(),
1054 'action' => $logEntry->getSubtype(),
1056 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
1057 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
1058 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_ACTION
) ?
array( 'actionhidden' => '' ) : array();
1060 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_ACTION
, $user ) ) {
1061 ApiQueryLogEvents
::addLogParams(
1064 $logEntry->getParameters(),
1065 $logEntry->getType(),
1066 $logEntry->getSubtype(),
1067 $logEntry->getTimestamp(),
1068 $logEntry->isLegacy()
1071 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_USER
, $user ) ) {
1073 'userid' => $this->row
->log_user
,
1074 'user' => $this->row
->log_user_text
,
1077 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_COMMENT
, $user ) ) {
1079 'comment' => $this->row
->log_comment
,