MediaWiki  master
CommentBatch.php
Go to the documentation of this file.
1 <?php
2 
4 
6 use Traversable;
7 
13 class CommentBatch {
15  private $formatter;
17  private $comments;
19  private $useBlock;
21  private $useParentheses;
23  private $selfLinkTarget;
25  private $samePage;
27  private $wikiId;
30 
37  $this->formatter = $formatter;
38  }
39 
50  public function comments( $comments ) {
51  $this->comments = $comments;
52  return $this;
53  }
54 
65  public function strings( array $strings ) {
66  $this->comments = new StringCommentIterator( $strings );
67  return $this;
68  }
69 
80  public function useBlock( $useBlock = true ) {
81  $this->useBlock = $useBlock;
82  return $this;
83  }
84 
96  public function useParentheses( $useParentheses = true ) {
98  return $this;
99  }
100 
111  return $this;
112  }
113 
126  public function enableSectionLinks( $enable ) {
127  $this->enableSectionLinks = $enable;
128  return $this;
129  }
130 
139  public function disableSectionLinks() {
140  $this->enableSectionLinks = false;
141  return $this;
142  }
143 
156  public function samePage( $samePage = true ) {
157  $this->samePage = $samePage;
158  return $this;
159  }
160 
172  public function wikiId( $wikiId ) {
173  $this->wikiId = $wikiId;
174  return $this;
175  }
176 
182  public function execute() {
183  return $this->formatter->formatItemsInternal(
184  $this->comments,
185  $this->selfLinkTarget,
186  $this->samePage,
187  $this->wikiId,
188  $this->enableSectionLinks,
189  $this->useBlock,
190  $this->useParentheses
191  );
192  }
193 
194 }
MediaWiki\CommentFormatter\CommentBatch\enableSectionLinks
enableSectionLinks( $enable)
Set the option to enable/disable section links formatted as C-style comments, as used in revision com...
Definition: CommentBatch.php:126
MediaWiki\CommentFormatter\CommentBatch\samePage
samePage( $samePage=true)
Set the same-page option.
Definition: CommentBatch.php:156
MediaWiki\CommentFormatter\CommentBatch\wikiId
wikiId( $wikiId)
ID of the wiki to link to (if not the local wiki), as used by WikiMap.
Definition: CommentBatch.php:172
MediaWiki\CommentFormatter\CommentBatch\$useBlock
bool null $useBlock
Definition: CommentBatch.php:19
MediaWiki\CommentFormatter\CommentBatch\$formatter
CommentFormatter $formatter
Definition: CommentBatch.php:15
MediaWiki\CommentFormatter\CommentBatch\strings
strings(array $strings)
Specify the comments to be formatted as an array of strings.
Definition: CommentBatch.php:65
MediaWiki\CommentFormatter\CommentBatch\$wikiId
string false null $wikiId
Definition: CommentBatch.php:27
MediaWiki\CommentFormatter\CommentFormatter
This is the main service interface for converting single-line comments from various DB comment fields...
Definition: CommentFormatter.php:16
MediaWiki\CommentFormatter\CommentBatch\$enableSectionLinks
bool null $enableSectionLinks
Definition: CommentBatch.php:29
MediaWiki\CommentFormatter\CommentBatch\$comments
iterable< CommentItem > Traversable $comments
Definition: CommentBatch.php:17
MediaWiki\CommentFormatter\CommentBatch
This class provides a fluent interface for formatting a batch of comments.
Definition: CommentBatch.php:13
MediaWiki\CommentFormatter\CommentBatch\useBlock
useBlock( $useBlock=true)
Wrap each comment in standard punctuation and formatting if it's non-empty.
Definition: CommentBatch.php:80
MediaWiki\CommentFormatter\CommentBatch\selfLinkTarget
selfLinkTarget(LinkTarget $selfLinkTarget)
Set the title to be used for self links in the comments.
Definition: CommentBatch.php:109
MediaWiki\CommentFormatter\CommentBatch\$samePage
bool null $samePage
Definition: CommentBatch.php:25
MediaWiki\CommentFormatter\CommentBatch\$useParentheses
bool null $useParentheses
Definition: CommentBatch.php:21
MediaWiki\CommentFormatter\CommentBatch\useParentheses
useParentheses( $useParentheses=true)
Wrap each comment with parentheses.
Definition: CommentBatch.php:96
MediaWiki\CommentFormatter\CommentBatch\$selfLinkTarget
LinkTarget null $selfLinkTarget
Definition: CommentBatch.php:23
MediaWiki\CommentFormatter\CommentBatch\execute
execute()
Format the comments and produce an array of HTML fragments.
Definition: CommentBatch.php:182
MediaWiki\CommentFormatter\CommentBatch\__construct
__construct(CommentFormatter $formatter)
Definition: CommentBatch.php:36
MediaWiki\CommentFormatter
Definition: CommentBatch.php:3
MediaWiki\CommentFormatter\CommentBatch\disableSectionLinks
disableSectionLinks()
Disable section links formatted as C-style comments, as used in revision comments to indicate the sec...
Definition: CommentBatch.php:139
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
MediaWiki\CommentFormatter\CommentBatch\comments
comments( $comments)
Set the comments to be formatted.
Definition: CommentBatch.php:50
MediaWiki\CommentFormatter\StringCommentIterator
An adaptor which converts an array of strings to an iterator of CommentItem objects.
Definition: StringCommentIterator.php:13