MediaWiki
1.42.1
CommentBatch.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\CommentFormatter
;
4
5
use
MediaWiki\Linker\LinkTarget
;
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;
29
private
$enableSectionLinks;
30
36
public
function
__construct
(
CommentFormatter
$formatter ) {
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
) {
97
$this->
useParentheses
= $useParentheses;
98
return
$this;
99
}
100
109
public
function
selfLinkTarget
(
LinkTarget
$selfLinkTarget ) {
110
$this->
selfLinkTarget
= $selfLinkTarget;
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
This class provides a fluent interface for formatting a batch of comments.
Definition
CommentBatch.php:13
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\useParentheses
useParentheses( $useParentheses=true)
Wrap each comment with parentheses.
Definition
CommentBatch.php:96
MediaWiki\CommentFormatter\CommentBatch\execute
execute()
Format the comments and produce an array of HTML fragments.
Definition
CommentBatch.php:182
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\selfLinkTarget
selfLinkTarget(LinkTarget $selfLinkTarget)
Set the title to be used for self links in the comments.
Definition
CommentBatch.php:109
MediaWiki\CommentFormatter\CommentBatch\comments
comments( $comments)
Set the comments to be formatted.
Definition
CommentBatch.php:50
MediaWiki\CommentFormatter\CommentBatch\__construct
__construct(CommentFormatter $formatter)
Definition
CommentBatch.php:36
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\strings
strings(array $strings)
Specify the comments to be formatted as an array of strings.
Definition
CommentBatch.php:65
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\CommentFormatter\CommentBatch\samePage
samePage( $samePage=true)
Set the same-page option.
Definition
CommentBatch.php:156
MediaWiki\CommentFormatter\CommentFormatter
This is the main service interface for converting single-line comments from various DB comment fields...
Definition
CommentFormatter.php:17
MediaWiki\CommentFormatter\StringCommentIterator
An adaptor which converts an array of strings to an iterator of CommentItem objects.
Definition
StringCommentIterator.php:13
MediaWiki\Linker\LinkTarget
Represents the target of a wiki link.
Definition
LinkTarget.php:32
MediaWiki\CommentFormatter
Definition
CommentBatch.php:3
includes
CommentFormatter
CommentBatch.php
Generated on Thu Jun 27 2024 15:58:31 for MediaWiki by
1.10.0