MediaWiki  1.34.0
RevisionItem.php
Go to the documentation of this file.
1 <?php
24 
30  protected $revision;
31 
33  protected $context;
34 
35  public function __construct( $list, $row ) {
36  parent::__construct( $list, $row );
37  $this->revision = new Revision( $row );
38  $this->context = $list->getContext();
39  }
40 
41  public function getIdField() {
42  return 'rev_id';
43  }
44 
45  public function getTimestampField() {
46  return 'rev_timestamp';
47  }
48 
49  public function getAuthorIdField() {
50  return 'rev_user';
51  }
52 
53  public function getAuthorNameField() {
54  return 'rev_user_text';
55  }
56 
57  public function canView() {
58  return $this->revision->userCan(
59  RevisionRecord::DELETED_RESTRICTED, $this->context->getUser()
60  );
61  }
62 
63  public function canViewContent() {
64  return $this->revision->userCan(
65  RevisionRecord::DELETED_TEXT, $this->context->getUser()
66  );
67  }
68 
69  public function isDeleted() {
70  return $this->revision->isDeleted( RevisionRecord::DELETED_TEXT );
71  }
72 
80  protected function getRevisionLink() {
81  $date = $this->list->getLanguage()->userTimeAndDate(
82  $this->revision->getTimestamp(), $this->list->getUser() );
83 
84  if ( $this->isDeleted() && !$this->canViewContent() ) {
85  return htmlspecialchars( $date );
86  }
87  $linkRenderer = $this->getLinkRenderer();
88  return $linkRenderer->makeKnownLink(
89  $this->list->title,
90  $date,
91  [],
92  [
93  'oldid' => $this->revision->getId(),
94  'unhide' => 1
95  ]
96  );
97  }
98 
106  protected function getDiffLink() {
107  if ( $this->isDeleted() && !$this->canViewContent() ) {
108  return $this->context->msg( 'diff' )->escaped();
109  } else {
110  $linkRenderer = $this->getLinkRenderer();
111  return $linkRenderer->makeKnownLink(
112  $this->list->title,
113  $this->list->msg( 'diff' )->text(),
114  [],
115  [
116  'diff' => $this->revision->getId(),
117  'oldid' => 'prev',
118  'unhide' => 1
119  ]
120  );
121  }
122  }
123 
130  public function getHTML() {
131  $difflink = $this->context->msg( 'parentheses' )
132  ->rawParams( $this->getDiffLink() )->escaped();
133  $revlink = $this->getRevisionLink();
134  $userlink = Linker::revUserLink( $this->revision );
135  $comment = Linker::revComment( $this->revision );
136  if ( $this->isDeleted() ) {
137  $revlink = "<span class=\"history-deleted\">$revlink</span>";
138  }
139  return "<li>$difflink $revlink $userlink $comment</li>";
140  }
141 }
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:40
Revision\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:46
Linker\revUserLink
static revUserLink( $rev, $isPublic=false)
Generate a user link if the current user is allowed to view it.
Definition: Linker.php:1101
RevisionItemBase
Abstract base class for revision items.
Definition: RevisionItemBase.php:28
RevisionItem\canView
canView()
Returns true if the current user can view the item.
Definition: RevisionItem.php:57
RevisionItem\isDeleted
isDeleted()
Definition: RevisionItem.php:69
Linker\revComment
static revComment(Revision $rev, $local=false, $isPublic=false, $useParentheses=true)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition: Linker.php:1577
RevisionItem\__construct
__construct( $list, $row)
Definition: RevisionItem.php:35
RevisionItem\getAuthorIdField
getAuthorIdField()
Get the DB field name storing user ids.
Definition: RevisionItem.php:49
RevisionItemBase\$list
RevisionListBase $list
The parent.
Definition: RevisionItemBase.php:30
Revision
Definition: Revision.php:40
RevisionItem\canViewContent
canViewContent()
Returns true if the current user can view the item text/file.
Definition: RevisionItem.php:63
RevisionItemBase\getLinkRenderer
getLinkRenderer()
Returns an instance of LinkRenderer.
Definition: RevisionItemBase.php:174
RevisionItem\getAuthorNameField
getAuthorNameField()
Get the DB field name storing user names.
Definition: RevisionItem.php:53
RevisionItem\getIdField
getIdField()
Get the DB field name associated with the ID list.
Definition: RevisionItem.php:41
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:33
RevisionItem\$revision
Revision $revision
Definition: RevisionItem.php:30
RevisionItemBase\$row
$row
The database result row.
Definition: RevisionItemBase.php:33
RevisionItem
Item class for a live revision table row.
Definition: RevisionItem.php:28
RevisionItem\getRevisionLink
getRevisionLink()
Get the HTML link to the revision text.
Definition: RevisionItem.php:80
RevisionItem\getDiffLink
getDiffLink()
Get the HTML link to the diff.
Definition: RevisionItem.php:106
RevisionItem\getTimestampField
getTimestampField()
Get the DB field name storing timestamps.
Definition: RevisionItem.php:45
RevisionItem\$context
RequestContext $context
Definition: RevisionItem.php:33
RevisionItem\getHTML
getHTML()
Definition: RevisionItem.php:130