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