51 $samePage =
false, $wikiId =
false
53 return $this->formatInternal( $comment,
true,
false,
false,
54 $selfLinkTarget, $samePage, $wikiId );
72 $samePage =
false, $wikiId =
false, $useParentheses =
true
74 return $this->formatInternal( $comment,
true,
true, $useParentheses,
75 $selfLinkTarget, $samePage, $wikiId );
97 $samePage =
false, $wikiId =
false
99 $parser = $this->parserFactory->create();
101 $samePage, $wikiId,
false );
102 return $parser->
finalize( $preprocessed );
118 $samePage =
false, $wikiId =
false
120 return $this->formatInternal( $comment,
false,
false,
false,
121 $selfLinkTarget, $samePage, $wikiId );
139 private function formatInternal( $comment, $enableSectionLinks, $useBlock, $useParentheses,
140 $selfLinkTarget =
null, $samePage =
false, $wikiId =
false
142 $parser = $this->parserFactory->create();
143 $preprocessed = $parser->
preprocess( $comment, $selfLinkTarget, $samePage, $wikiId,
144 $enableSectionLinks );
145 $output = $parser->
finalize( $preprocessed );
168 $samePage =
false, $wikiId =
false
170 $parser = $this->parserFactory->create();
172 foreach ( $strings as $i => $comment ) {
173 $outputs[$i] = $parser->
preprocess( $comment, $selfLinkTarget, $samePage, $wikiId );
175 return $parser->
finalize( $outputs );
196 $samePage =
false, $wikiId =
false, $useParentheses =
true
198 $parser = $this->parserFactory->create();
200 foreach ( $strings as $i => $comment ) {
202 $parser->
preprocess( $comment, $selfLinkTarget, $samePage, $wikiId ),
205 return $parser->
finalize( $outputs );
232 $useParentheses =
true
234 $parser = $this->parserFactory->create();
235 return $parser->
finalize( $this->preprocessRevComment(
236 $parser, $authority, $revision, $samePage, $isPublic, $useParentheses ) );
257 $useParentheses =
true,
260 $parser = $this->parserFactory->create();
262 foreach ( $revisions as $i => $rev ) {
264 $key = $rev->getId();
269 $outputs[$key] = $this->preprocessRevComment(
270 $parser, $authority, $rev, $samePage, $isPublic, $useParentheses );
272 return $parser->
finalize( $outputs );
312 $samePage =
null, $wikiId =
null, $enableSectionLinks =
null,
313 $useBlock =
null, $useParentheses =
null
316 $parser = $this->parserFactory->create();
317 foreach ( $items as $index => $item ) {
320 $item->selfLinkTarget ?? $selfLinkTarget,
321 $item->samePage ?? $samePage ??
false,
322 $item->wikiId ?? $wikiId ??
false,
323 $enableSectionLinks ??
true
325 if ( $useBlock ??
false ) {
328 $useParentheses ??
true
331 $outputs[$index] = $preprocessed;
333 return $parser->
finalize( $outputs );
346 $formatted, $useParentheses
351 if ( $formatted ==
'' || $formatted ==
'*' ) {
354 if ( $useParentheses ) {
355 $formatted =
wfMessage(
'parentheses' )->rawParams( $formatted )->escaped();
356 $classNames =
'comment';
358 $classNames =
'comment comment--without-parentheses';
360 return " <span class=\"$classNames\">$formatted</span>";
374 private function preprocessRevComment(
380 $useParentheses =
true
382 if ( $revRecord->
getComment( RevisionRecord::RAW ) ===
null ) {
386 RevisionRecord::DELETED_COMMENT,
387 $isPublic ? RevisionRecord::FOR_PUBLIC :
RevisionRecord::FOR_THIS_USER,
390 $comment = $revRecord->
getComment( RevisionRecord::FOR_THIS_USER, $authority );
392 $comment ? $comment->text :
'',
393 $revRecord->getPageAsLinkTarget(),
400 $block =
" <span class=\"comment\">" .
wfMessage(
'rev-deleted-comment' )->escaped() .
"</span>";
402 if ( $revRecord->
isDeleted( RevisionRecord::DELETED_COMMENT ) ) {
403 $class = \Linker::getRevisionDeletedClass( $revRecord );
404 return " <span class=\"$class comment\">$block</span>";