Self-revert r105872, there's a deeper issue here
[lhc/web/wiklou.git] / includes / revisiondelete / RevisionDelete.php
1 <?php
2 /**
3 * List for revision table items
4 *
5 * This will check both the 'revision' table for live revisions and the
6 * 'archive' table for traditionally-deleted revisions that have an
7 * ar_rev_id saved.
8 *
9 * See RevDel_RevisionItem and RevDel_ArchivedRevisionItem for items.
10 */
11 class RevDel_RevisionList extends RevDel_List {
12 var $currentRevId;
13
14 public function getType() {
15 return 'revision';
16 }
17
18 public static function getRelationType() {
19 return 'rev_id';
20 }
21
22 /**
23 * @param $db DatabaseBase
24 * @return mixed
25 */
26 public function doQuery( $db ) {
27 $ids = array_map( 'intval', $this->ids );
28 $live = $db->select(
29 array( 'revision', 'page', 'user' ),
30 array_merge( Revision::selectFields(), Revision::selectUserFields() ),
31 array(
32 'rev_page' => $this->title->getArticleID(),
33 'rev_id' => $ids,
34 ),
35 __METHOD__,
36 array( 'ORDER BY' => 'rev_id DESC' ),
37 array(
38 'page' => Revision::pageJoinCond(),
39 'user' => Revision::userJoinCond() )
40 );
41
42 if ( $live->numRows() >= count( $ids ) ) {
43 // All requested revisions are live, keeps things simple!
44 return $live;
45 }
46
47 // Check if any requested revisions are available fully deleted.
48 $archived = $db->select( array( 'archive' ), '*',
49 array(
50 'ar_rev_id' => $ids
51 ),
52 __METHOD__,
53 array( 'ORDER BY' => 'ar_rev_id DESC' )
54 );
55
56 if ( $archived->numRows() == 0 ) {
57 return $live;
58 } elseif ( $live->numRows() == 0 ) {
59 return $archived;
60 } else {
61 // Combine the two! Whee
62 $rows = array();
63 foreach ( $live as $row ) {
64 $rows[$row->rev_id] = $row;
65 }
66 foreach ( $archived as $row ) {
67 $rows[$row->ar_rev_id] = $row;
68 }
69 krsort( $rows );
70 return new FakeResultWrapper( array_values( $rows ) );
71 }
72 }
73
74 public function newItem( $row ) {
75 if ( isset( $row->rev_id ) ) {
76 return new RevDel_RevisionItem( $this, $row );
77 } elseif ( isset( $row->ar_rev_id ) ) {
78 return new RevDel_ArchivedRevisionItem( $this, $row );
79 } else {
80 // This shouldn't happen. :)
81 throw new MWException( 'Invalid row type in RevDel_RevisionList' );
82 }
83 }
84
85 public function getCurrent() {
86 if ( is_null( $this->currentRevId ) ) {
87 $dbw = wfGetDB( DB_MASTER );
88 $this->currentRevId = $dbw->selectField(
89 'page', 'page_latest', $this->title->pageCond(), __METHOD__ );
90 }
91 return $this->currentRevId;
92 }
93
94 public function getSuppressBit() {
95 return Revision::DELETED_RESTRICTED;
96 }
97
98 public function doPreCommitUpdates() {
99 $this->title->invalidateCache();
100 return Status::newGood();
101 }
102
103 public function doPostCommitUpdates() {
104 $this->title->purgeSquid();
105 // Extensions that require referencing previous revisions may need this
106 wfRunHooks( 'ArticleRevisionVisibilitySet', array( &$this->title ) );
107 return Status::newGood();
108 }
109 }
110
111 /**
112 * Item class for a live revision table row
113 */
114 class RevDel_RevisionItem extends RevDel_Item {
115 var $revision;
116
117 public function __construct( $list, $row ) {
118 parent::__construct( $list, $row );
119 $this->revision = new Revision( $row );
120 }
121
122 public function getIdField() {
123 return 'rev_id';
124 }
125
126 public function getTimestampField() {
127 return 'rev_timestamp';
128 }
129
130 public function getAuthorIdField() {
131 return 'rev_user';
132 }
133
134 public function getAuthorNameField() {
135 return 'user_name'; // see Revision::selectUserFields()
136 }
137
138 public function canView() {
139 return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->list->getUser() );
140 }
141
142 public function canViewContent() {
143 return $this->revision->userCan( Revision::DELETED_TEXT, $this->list->getUser() );
144 }
145
146 public function getBits() {
147 return $this->revision->getVisibility();
148 }
149
150 public function setBits( $bits ) {
151 $dbw = wfGetDB( DB_MASTER );
152 // Update revision table
153 $dbw->update( 'revision',
154 array( 'rev_deleted' => $bits ),
155 array(
156 'rev_id' => $this->revision->getId(),
157 'rev_page' => $this->revision->getPage(),
158 'rev_deleted' => $this->getBits()
159 ),
160 __METHOD__
161 );
162 if ( !$dbw->affectedRows() ) {
163 // Concurrent fail!
164 return false;
165 }
166 // Update recentchanges table
167 $dbw->update( 'recentchanges',
168 array(
169 'rc_deleted' => $bits,
170 'rc_patrolled' => 1
171 ),
172 array(
173 'rc_this_oldid' => $this->revision->getId(), // condition
174 // non-unique timestamp index
175 'rc_timestamp' => $dbw->timestamp( $this->revision->getTimestamp() ),
176 ),
177 __METHOD__
178 );
179 return true;
180 }
181
182 public function isDeleted() {
183 return $this->revision->isDeleted( Revision::DELETED_TEXT );
184 }
185
186 public function isHideCurrentOp( $newBits ) {
187 return ( $newBits & Revision::DELETED_TEXT )
188 && $this->list->getCurrent() == $this->getId();
189 }
190
191 /**
192 * Get the HTML link to the revision text.
193 * Overridden by RevDel_ArchiveItem.
194 */
195 protected function getRevisionLink() {
196 $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true );
197 if ( $this->isDeleted() && !$this->canViewContent() ) {
198 return $date;
199 }
200 return Linker::link(
201 $this->list->title,
202 $date,
203 array(),
204 array(
205 'oldid' => $this->revision->getId(),
206 'unhide' => 1
207 )
208 );
209 }
210
211 /**
212 * Get the HTML link to the diff.
213 * Overridden by RevDel_ArchiveItem
214 */
215 protected function getDiffLink() {
216 if ( $this->isDeleted() && !$this->canViewContent() ) {
217 return wfMsgHtml('diff');
218 } else {
219 return
220 Linker::link(
221 $this->list->title,
222 wfMsgHtml('diff'),
223 array(),
224 array(
225 'diff' => $this->revision->getId(),
226 'oldid' => 'prev',
227 'unhide' => 1
228 ),
229 array(
230 'known',
231 'noclasses'
232 )
233 );
234 }
235 }
236
237 public function getHTML() {
238 $difflink = $this->getDiffLink();
239 $revlink = $this->getRevisionLink();
240 $userlink = Linker::revUserLink( $this->revision );
241 $comment = Linker::revComment( $this->revision );
242 if ( $this->isDeleted() ) {
243 $revlink = "<span class=\"history-deleted\">$revlink</span>";
244 }
245 return "<li>($difflink) $revlink $userlink $comment</li>";
246 }
247 }
248
249 /**
250 * List for archive table items, i.e. revisions deleted via action=delete
251 */
252 class RevDel_ArchiveList extends RevDel_RevisionList {
253 public function getType() {
254 return 'archive';
255 }
256
257 public static function getRelationType() {
258 return 'ar_timestamp';
259 }
260
261 /**
262 * @param $db DatabaseBase
263 * @return mixed
264 */
265 public function doQuery( $db ) {
266 $timestamps = array();
267 foreach ( $this->ids as $id ) {
268 $timestamps[] = $db->timestamp( $id );
269 }
270 return $db->select( 'archive', '*',
271 array(
272 'ar_namespace' => $this->title->getNamespace(),
273 'ar_title' => $this->title->getDBkey(),
274 'ar_timestamp' => $timestamps
275 ),
276 __METHOD__,
277 array( 'ORDER BY' => 'ar_timestamp DESC' )
278 );
279 }
280
281 public function newItem( $row ) {
282 return new RevDel_ArchiveItem( $this, $row );
283 }
284
285 public function doPreCommitUpdates() {
286 return Status::newGood();
287 }
288
289 public function doPostCommitUpdates() {
290 return Status::newGood();
291 }
292 }
293
294 /**
295 * Item class for a archive table row
296 */
297 class RevDel_ArchiveItem extends RevDel_RevisionItem {
298 public function __construct( $list, $row ) {
299 RevDel_Item::__construct( $list, $row );
300 $this->revision = Revision::newFromArchiveRow( $row,
301 array( 'page' => $this->list->title->getArticleId() ) );
302 }
303
304 public function getIdField() {
305 return 'ar_timestamp';
306 }
307
308 public function getTimestampField() {
309 return 'ar_timestamp';
310 }
311
312 public function getAuthorIdField() {
313 return 'ar_user';
314 }
315
316 public function getAuthorNameField() {
317 return 'ar_user_text';
318 }
319
320 public function getId() {
321 # Convert DB timestamp to MW timestamp
322 return $this->revision->getTimestamp();
323 }
324
325 public function setBits( $bits ) {
326 $dbw = wfGetDB( DB_MASTER );
327 $dbw->update( 'archive',
328 array( 'ar_deleted' => $bits ),
329 array(
330 'ar_namespace' => $this->list->title->getNamespace(),
331 'ar_title' => $this->list->title->getDBkey(),
332 // use timestamp for index
333 'ar_timestamp' => $this->row->ar_timestamp,
334 'ar_rev_id' => $this->row->ar_rev_id,
335 'ar_deleted' => $this->getBits()
336 ),
337 __METHOD__ );
338 return (bool)$dbw->affectedRows();
339 }
340
341 protected function getRevisionLink() {
342 $undelete = SpecialPage::getTitleFor( 'Undelete' );
343 $date = $this->list->getLanguage()->timeanddate( $this->revision->getTimestamp(), true );
344 if ( $this->isDeleted() && !$this->canViewContent() ) {
345 return $date;
346 }
347 return Linker::link( $undelete, $date, array(),
348 array(
349 'target' => $this->list->title->getPrefixedText(),
350 'timestamp' => $this->revision->getTimestamp()
351 ) );
352 }
353
354 protected function getDiffLink() {
355 if ( $this->isDeleted() && !$this->canViewContent() ) {
356 return wfMsgHtml( 'diff' );
357 }
358 $undelete = SpecialPage::getTitleFor( 'Undelete' );
359 return Linker::link( $undelete, wfMsgHtml('diff'), array(),
360 array(
361 'target' => $this->list->title->getPrefixedText(),
362 'diff' => 'prev',
363 'timestamp' => $this->revision->getTimestamp()
364 ) );
365 }
366 }
367
368
369 /**
370 * Item class for a archive table row by ar_rev_id -- actually
371 * used via RevDel_RevisionList.
372 */
373 class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem {
374 public function __construct( $list, $row ) {
375 RevDel_Item::__construct( $list, $row );
376
377 $this->revision = Revision::newFromArchiveRow( $row,
378 array( 'page' => $this->list->title->getArticleId() ) );
379 }
380
381 public function getIdField() {
382 return 'ar_rev_id';
383 }
384
385 public function getId() {
386 return $this->revision->getId();
387 }
388
389 public function setBits( $bits ) {
390 $dbw = wfGetDB( DB_MASTER );
391 $dbw->update( 'archive',
392 array( 'ar_deleted' => $bits ),
393 array( 'ar_rev_id' => $this->row->ar_rev_id,
394 'ar_deleted' => $this->getBits()
395 ),
396 __METHOD__ );
397 return (bool)$dbw->affectedRows();
398 }
399 }
400
401 /**
402 * List for oldimage table items
403 */
404 class RevDel_FileList extends RevDel_List {
405 public function getType() {
406 return 'oldimage';
407 }
408
409 public static function getRelationType() {
410 return 'oi_archive_name';
411 }
412
413 var $storeBatch, $deleteBatch, $cleanupBatch;
414
415 /**
416 * @param $db DatabaseBase
417 * @return mixed
418 */
419 public function doQuery( $db ) {
420 $archiveNames = array();
421 foreach( $this->ids as $timestamp ) {
422 $archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
423 }
424 return $db->select( 'oldimage', '*',
425 array(
426 'oi_name' => $this->title->getDBkey(),
427 'oi_archive_name' => $archiveNames
428 ),
429 __METHOD__,
430 array( 'ORDER BY' => 'oi_timestamp DESC' )
431 );
432 }
433
434 public function newItem( $row ) {
435 return new RevDel_FileItem( $this, $row );
436 }
437
438 public function clearFileOps() {
439 $this->deleteBatch = array();
440 $this->storeBatch = array();
441 $this->cleanupBatch = array();
442 }
443
444 public function doPreCommitUpdates() {
445 $status = Status::newGood();
446 $repo = RepoGroup::singleton()->getLocalRepo();
447 if ( $this->storeBatch ) {
448 $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
449 }
450 if ( !$status->isOK() ) {
451 return $status;
452 }
453 if ( $this->deleteBatch ) {
454 $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
455 }
456 if ( !$status->isOK() ) {
457 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
458 // modified (but destined for rollback) causes data loss
459 return $status;
460 }
461 if ( $this->cleanupBatch ) {
462 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
463 }
464 return $status;
465 }
466
467 public function doPostCommitUpdates() {
468 $file = wfLocalFile( $this->title );
469 $file->purgeCache();
470 $file->purgeDescription();
471 return Status::newGood();
472 }
473
474 public function getSuppressBit() {
475 return File::DELETED_RESTRICTED;
476 }
477 }
478
479 /**
480 * Item class for an oldimage table row
481 */
482 class RevDel_FileItem extends RevDel_Item {
483
484 /**
485 * @var File
486 */
487 var $file;
488
489 public function __construct( $list, $row ) {
490 parent::__construct( $list, $row );
491 $this->file = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
492 }
493
494 public function getIdField() {
495 return 'oi_archive_name';
496 }
497
498 public function getTimestampField() {
499 return 'oi_timestamp';
500 }
501
502 public function getAuthorIdField() {
503 return 'oi_user';
504 }
505
506 public function getAuthorNameField() {
507 return 'oi_user_text';
508 }
509
510 public function getId() {
511 $parts = explode( '!', $this->row->oi_archive_name );
512 return $parts[0];
513 }
514
515 public function canView() {
516 return $this->file->userCan( File::DELETED_RESTRICTED, $this->list->getUser() );
517 }
518
519 public function canViewContent() {
520 return $this->file->userCan( File::DELETED_FILE, $this->list->getUser() );
521 }
522
523 public function getBits() {
524 return $this->file->getVisibility();
525 }
526
527 public function setBits( $bits ) {
528 # Queue the file op
529 # @todo FIXME: Move to LocalFile.php
530 if ( $this->isDeleted() ) {
531 if ( $bits & File::DELETED_FILE ) {
532 # Still deleted
533 } else {
534 # Newly undeleted
535 $key = $this->file->getStorageKey();
536 $srcRel = $this->file->repo->getDeletedHashPath( $key ) . $key;
537 $this->list->storeBatch[] = array(
538 $this->file->repo->getVirtualUrl( 'deleted' ) . '/' . $srcRel,
539 'public',
540 $this->file->getRel()
541 );
542 $this->list->cleanupBatch[] = $key;
543 }
544 } elseif ( $bits & File::DELETED_FILE ) {
545 # Newly deleted
546 $key = $this->file->getStorageKey();
547 $dstRel = $this->file->repo->getDeletedHashPath( $key ) . $key;
548 $this->list->deleteBatch[] = array( $this->file->getRel(), $dstRel );
549 }
550
551 # Do the database operations
552 $dbw = wfGetDB( DB_MASTER );
553 $dbw->update( 'oldimage',
554 array( 'oi_deleted' => $bits ),
555 array(
556 'oi_name' => $this->row->oi_name,
557 'oi_timestamp' => $this->row->oi_timestamp,
558 'oi_deleted' => $this->getBits()
559 ),
560 __METHOD__
561 );
562 return (bool)$dbw->affectedRows();
563 }
564
565 public function isDeleted() {
566 return $this->file->isDeleted( File::DELETED_FILE );
567 }
568
569 /**
570 * Get the link to the file.
571 * Overridden by RevDel_ArchivedFileItem.
572 */
573 protected function getLink() {
574 $date = $this->list->getLanguage()->timeanddate( $this->file->getTimestamp(), true );
575 if ( $this->isDeleted() ) {
576 # Hidden files...
577 if ( !$this->canViewContent() ) {
578 $link = $date;
579 } else {
580 $revdelete = SpecialPage::getTitleFor( 'Revisiondelete' );
581 $link = Linker::link(
582 $revdelete,
583 $date, array(),
584 array(
585 'target' => $this->list->title->getPrefixedText(),
586 'file' => $this->file->getArchiveName(),
587 'token' => $this->list->getUser()->getEditToken(
588 $this->file->getArchiveName() )
589 )
590 );
591 }
592 return '<span class="history-deleted">' . $link . '</span>';
593 } else {
594 # Regular files...
595 return Xml::element( 'a', array( 'href' => $this->file->getUrl() ), $date );
596 }
597 }
598 /**
599 * Generate a user tool link cluster if the current user is allowed to view it
600 * @return string HTML
601 */
602 protected function getUserTools() {
603 if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) {
604 $link = Linker::userLink( $this->file->user, $this->file->user_text ) .
605 Linker::userToolLinks( $this->file->user, $this->file->user_text );
606 } else {
607 $link = wfMsgHtml( 'rev-deleted-user' );
608 }
609 if( $this->file->isDeleted( Revision::DELETED_USER ) ) {
610 return '<span class="history-deleted">' . $link . '</span>';
611 }
612 return $link;
613 }
614
615 /**
616 * Wrap and format the file's comment block, if the current
617 * user is allowed to view it.
618 *
619 * @return string HTML
620 */
621 protected function getComment() {
622 if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) {
623 $block = Linker::commentBlock( $this->file->description );
624 } else {
625 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
626 }
627 if( $this->file->isDeleted( File::DELETED_COMMENT ) ) {
628 return "<span class=\"history-deleted\">$block</span>";
629 }
630 return $block;
631 }
632
633 public function getHTML() {
634 $data =
635 wfMsg(
636 'widthheight',
637 $this->list->getLanguage()->formatNum( $this->file->getWidth() ),
638 $this->list->getLanguage()->formatNum( $this->file->getHeight() )
639 ) .
640 ' (' .
641 wfMsgExt( 'nbytes', 'parsemag', $this->list->getLanguage()->formatNum( $this->file->getSize() ) ) .
642 ')';
643
644 return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
645 $data . ' ' . $this->getComment(). '</li>';
646 }
647 }
648
649 /**
650 * List for filearchive table items
651 */
652 class RevDel_ArchivedFileList extends RevDel_FileList {
653 public function getType() {
654 return 'filearchive';
655 }
656
657 public static function getRelationType() {
658 return 'fa_id';
659 }
660
661 /**
662 * @param $db DatabaseBase
663 * @return mixed
664 */
665 public function doQuery( $db ) {
666 $ids = array_map( 'intval', $this->ids );
667 return $db->select( 'filearchive', '*',
668 array(
669 'fa_name' => $this->title->getDBkey(),
670 'fa_id' => $ids
671 ),
672 __METHOD__,
673 array( 'ORDER BY' => 'fa_id DESC' )
674 );
675 }
676
677 public function newItem( $row ) {
678 return new RevDel_ArchivedFileItem( $this, $row );
679 }
680 }
681
682 /**
683 * Item class for a filearchive table row
684 */
685 class RevDel_ArchivedFileItem extends RevDel_FileItem {
686 public function __construct( $list, $row ) {
687 RevDel_Item::__construct( $list, $row );
688 $this->file = ArchivedFile::newFromRow( $row );
689 }
690
691 public function getIdField() {
692 return 'fa_id';
693 }
694
695 public function getTimestampField() {
696 return 'fa_timestamp';
697 }
698
699 public function getAuthorIdField() {
700 return 'fa_user';
701 }
702
703 public function getAuthorNameField() {
704 return 'fa_user_text';
705 }
706
707 public function getId() {
708 return $this->row->fa_id;
709 }
710
711 public function setBits( $bits ) {
712 $dbw = wfGetDB( DB_MASTER );
713 $dbw->update( 'filearchive',
714 array( 'fa_deleted' => $bits ),
715 array(
716 'fa_id' => $this->row->fa_id,
717 'fa_deleted' => $this->getBits(),
718 ),
719 __METHOD__
720 );
721 return (bool)$dbw->affectedRows();
722 }
723
724 protected function getLink() {
725 $date = $this->list->getLanguage()->timeanddate( $this->file->getTimestamp(), true );
726 $undelete = SpecialPage::getTitleFor( 'Undelete' );
727 $key = $this->file->getKey();
728 # Hidden files...
729 if( !$this->canViewContent() ) {
730 $link = $date;
731 } else {
732 $link = Linker::link( $undelete, $date, array(),
733 array(
734 'target' => $this->list->title->getPrefixedText(),
735 'file' => $key,
736 'token' => $this->list->getUser()->getEditToken( $key )
737 )
738 );
739 }
740 if( $this->isDeleted() ) {
741 $link = '<span class="history-deleted">' . $link . '</span>';
742 }
743 return $link;
744 }
745 }
746
747 /**
748 * List for logging table items
749 */
750 class RevDel_LogList extends RevDel_List {
751 public function getType() {
752 return 'logging';
753 }
754
755 public static function getRelationType() {
756 return 'log_id';
757 }
758
759 /**
760 * @param $db DatabaseBase
761 * @return mixed
762 */
763 public function doQuery( $db ) {
764 $ids = array_map( 'intval', $this->ids );
765 return $db->select( 'logging', '*',
766 array( 'log_id' => $ids ),
767 __METHOD__,
768 array( 'ORDER BY' => 'log_id DESC' )
769 );
770 }
771
772 public function newItem( $row ) {
773 return new RevDel_LogItem( $this, $row );
774 }
775
776 public function getSuppressBit() {
777 return Revision::DELETED_RESTRICTED;
778 }
779
780 public function getLogAction() {
781 return 'event';
782 }
783
784 public function getLogParams( $params ) {
785 return array(
786 implode( ',', $params['ids'] ),
787 "ofield={$params['oldBits']}",
788 "nfield={$params['newBits']}"
789 );
790 }
791 }
792
793 /**
794 * Item class for a logging table row
795 */
796 class RevDel_LogItem extends RevDel_Item {
797 public function getIdField() {
798 return 'log_id';
799 }
800
801 public function getTimestampField() {
802 return 'log_timestamp';
803 }
804
805 public function getAuthorIdField() {
806 return 'log_user';
807 }
808
809 public function getAuthorNameField() {
810 return 'log_user_text';
811 }
812
813 public function canView() {
814 return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
815 }
816
817 public function canViewContent() {
818 return true; // none
819 }
820
821 public function getBits() {
822 return $this->row->log_deleted;
823 }
824
825 public function setBits( $bits ) {
826 $dbw = wfGetDB( DB_MASTER );
827 $dbw->update( 'recentchanges',
828 array(
829 'rc_deleted' => $bits,
830 'rc_patrolled' => 1
831 ),
832 array(
833 'rc_logid' => $this->row->log_id,
834 'rc_timestamp' => $this->row->log_timestamp // index
835 ),
836 __METHOD__
837 );
838 $dbw->update( 'logging',
839 array( 'log_deleted' => $bits ),
840 array(
841 'log_id' => $this->row->log_id,
842 'log_deleted' => $this->getBits()
843 ),
844 __METHOD__
845 );
846 return (bool)$dbw->affectedRows();
847 }
848
849 public function getHTML() {
850 $date = htmlspecialchars( $this->list->getLanguage()->timeanddate( $this->row->log_timestamp ) );
851 $paramArray = LogPage::extractParams( $this->row->log_params );
852 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
853
854 // Log link for this page
855 $loglink = Linker::link(
856 SpecialPage::getTitleFor( 'Log' ),
857 wfMsgHtml( 'log' ),
858 array(),
859 array( 'page' => $title->getPrefixedText() )
860 );
861 // Action text
862 if( !$this->canView() ) {
863 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
864 } else {
865 $skin = $this->list->getUser()->getSkin();
866 $action = LogPage::actionText( $this->row->log_type, $this->row->log_action,
867 $title, $skin, $paramArray, true, true );
868 if( $this->row->log_deleted & LogPage::DELETED_ACTION )
869 $action = '<span class="history-deleted">' . $action . '</span>';
870 }
871 // User links
872 $userLink = Linker::userLink( $this->row->log_user,
873 User::WhoIs( $this->row->log_user ) );
874 if( LogEventsList::isDeleted($this->row,LogPage::DELETED_USER) ) {
875 $userLink = '<span class="history-deleted">' . $userLink . '</span>';
876 }
877 // Comment
878 $comment = $this->list->getLanguage()->getDirMark() . Linker::commentBlock( $this->row->log_comment );
879 if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) {
880 $comment = '<span class="history-deleted">' . $comment . '</span>';
881 }
882 return "<li>($loglink) $date $userLink $action $comment</li>";
883 }
884 }