RevDelArchiveItem.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  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.
  7. *
  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.
  12. *
  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
  17. *
  18. * @file
  19. * @ingroup RevisionDelete
  20. */
  21. /**
  22. * Item class for a archive table row
  23. */
  24. class RevDelArchiveItem extends RevDelRevisionItem {
  25. public function __construct( $list, $row ) {
  26. RevDelItem::__construct( $list, $row );
  27. $this->revision = Revision::newFromArchiveRow( $row,
  28. [ 'page' => $this->list->title->getArticleID() ] );
  29. }
  30. public function getIdField() {
  31. return 'ar_timestamp';
  32. }
  33. public function getTimestampField() {
  34. return 'ar_timestamp';
  35. }
  36. public function getAuthorIdField() {
  37. return 'ar_user';
  38. }
  39. public function getAuthorNameField() {
  40. return 'ar_user_text';
  41. }
  42. public function getAuthorActorField() {
  43. return 'ar_actor';
  44. }
  45. public function getId() {
  46. # Convert DB timestamp to MW timestamp
  47. return $this->revision->getTimestamp();
  48. }
  49. public function setBits( $bits ) {
  50. $dbw = wfGetDB( DB_MASTER );
  51. $dbw->update( 'archive',
  52. [ 'ar_deleted' => $bits ],
  53. [
  54. 'ar_namespace' => $this->list->title->getNamespace(),
  55. 'ar_title' => $this->list->title->getDBkey(),
  56. // use timestamp for index
  57. 'ar_timestamp' => $this->row->ar_timestamp,
  58. 'ar_rev_id' => $this->row->ar_rev_id,
  59. 'ar_deleted' => $this->getBits()
  60. ],
  61. __METHOD__ );
  62. return (bool)$dbw->affectedRows();
  63. }
  64. protected function getRevisionLink() {
  65. $date = $this->list->getLanguage()->userTimeAndDate(
  66. $this->revision->getTimestamp(), $this->list->getUser() );
  67. if ( $this->isDeleted() && !$this->canViewContent() ) {
  68. return htmlspecialchars( $date );
  69. }
  70. return $this->getLinkRenderer()->makeLink(
  71. SpecialPage::getTitleFor( 'Undelete' ),
  72. $date,
  73. [],
  74. [
  75. 'target' => $this->list->title->getPrefixedText(),
  76. 'timestamp' => $this->revision->getTimestamp()
  77. ]
  78. );
  79. }
  80. protected function getDiffLink() {
  81. if ( $this->isDeleted() && !$this->canViewContent() ) {
  82. return $this->list->msg( 'diff' )->escaped();
  83. }
  84. return $this->getLinkRenderer()->makeLink(
  85. SpecialPage::getTitleFor( 'Undelete' ),
  86. $this->list->msg( 'diff' )->text(),
  87. [],
  88. [
  89. 'target' => $this->list->title->getPrefixedText(),
  90. 'diff' => 'prev',
  91. 'timestamp' => $this->revision->getTimestamp()
  92. ]
  93. );
  94. }
  95. }