MediaWiki
master
|
The text processing backend for CommentFormatter. More...
Public Member Functions | |
__construct (LinkRenderer $linkRenderer, LinkBatchFactory $linkBatchFactory, LinkCache $linkCache, RepoGroup $repoGroup, Language $userLang, Language $contLang, TitleParser $titleParser, NamespaceInfo $namespaceInfo, HookContainer $hookContainer) | |
finalize ( $comments) | |
Execute pending batch queries and replace markers in the specified string(s) with actual links. More... | |
preprocess (string $comment, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false, $enableSectionLinks=true) | |
Convert a comment to HTML, but replace links with markers which are resolved later. More... | |
preprocessUnsafe ( $comment, LinkTarget $selfLinkTarget=null, $samePage=false, $wikiId=false, $enableSectionLinks=true) | |
Convert a comment in pseudo-HTML format to HTML, replacing links with markers. More... | |
Private Member Functions | |
addFileLink (LinkTarget $target, $html) | |
Link to a file, returning a marker. More... | |
addLinkMarker ( $callback) | |
Add a deferred link to the list and return its marker. More... | |
addPageLink (LinkTarget $target, $text, $wikiId) | |
Link to a LinkTarget. More... | |
doSectionLinks ( $comment, $selfLinkTarget=null, $samePage=false, $wikiId=false) | |
Converts C-style comments in edit summaries into section links. More... | |
doWikiLinks ( $comment, $selfLinkTarget=null, $samePage=false, $wikiId=false) | |
Formats wiki links and media links in text; all other wiki formatting is ignored. More... | |
flushLinkBatches () | |
Execute any pending link batch or file batch. More... | |
makeSectionLink (LinkTarget $target, $text, $wikiId) | |
Make a section link. More... | |
preprocessInternal ( $comment, $unsafe, $selfLinkTarget, $samePage, $wikiId, $enableSectionLinks) | |
Private Attributes | |
Language | $contLang |
array | $fileBatch |
Input to RepoGroup::findFiles() More... | |
File[] | $files = [] |
Resolved File objects indexed by DB key. More... | |
HookRunner | $hookRunner |
LinkBatch null | $linkBatch |
LinkBatchFactory | $linkBatchFactory |
LinkCache | $linkCache |
LinkRenderer | $linkRenderer |
callable[] | $links = [] |
NamespaceInfo | $namespaceInfo |
RepoGroup | $repoGroup |
TitleParser | $titleParser |
Language | $userLang |
The text processing backend for CommentFormatter.
CommentParser objects should be discarded after the comment batch is complete, in order to reduce memory usage.
Definition at line 32 of file CommentParser.php.
MediaWiki\CommentFormatter\CommentParser::__construct | ( | LinkRenderer | $linkRenderer, |
LinkBatchFactory | $linkBatchFactory, | ||
LinkCache | $linkCache, | ||
RepoGroup | $repoGroup, | ||
Language | $userLang, | ||
Language | $contLang, | ||
TitleParser | $titleParser, | ||
NamespaceInfo | $namespaceInfo, | ||
HookContainer | $hookContainer | ||
) |
LinkRenderer | $linkRenderer | |
LinkBatchFactory | $linkBatchFactory | |
LinkCache | $linkCache | |
RepoGroup | $repoGroup | |
Language | $userLang | |
Language | $contLang | |
TitleParser | $titleParser | |
NamespaceInfo | $namespaceInfo | |
HookContainer | $hookContainer |
Definition at line 76 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\$contLang, MediaWiki\CommentFormatter\CommentParser\$linkBatchFactory, MediaWiki\CommentFormatter\CommentParser\$linkCache, MediaWiki\CommentFormatter\CommentParser\$linkRenderer, MediaWiki\CommentFormatter\CommentParser\$namespaceInfo, MediaWiki\CommentFormatter\CommentParser\$repoGroup, MediaWiki\CommentFormatter\CommentParser\$titleParser, and MediaWiki\CommentFormatter\CommentParser\$userLang.
|
private |
Link to a file, returning a marker.
LinkTarget | $target | The name of the file. |
string | $html | The inner HTML of the link |
Definition at line 505 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\addLinkMarker(), MediaWiki\Linker\LinkTarget\getDBkey(), and Linker\makeMediaLinkFile().
Referenced by MediaWiki\CommentFormatter\CommentParser\doWikiLinks().
|
private |
Add a deferred link to the list and return its marker.
callable | $callback |
Definition at line 444 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\addFileLink(), and MediaWiki\CommentFormatter\CommentParser\addPageLink().
|
private |
Link to a LinkTarget.
Return either HTML or a marker depending on whether existence checks are deferred.
LinkTarget | $target | |
string | $text | |
string | false | null | $wikiId |
Definition at line 462 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\addLinkMarker(), MediaWiki\Linker\LinkTarget\getDBkey(), WikiMap\getForeignURL(), MediaWiki\Linker\LinkTarget\getFragment(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\isExternal(), Linker\makeExternalLink(), and Title\newFromLinkTarget().
Referenced by MediaWiki\CommentFormatter\CommentParser\doWikiLinks().
|
private |
Converts C-style comments in edit summaries into section links.
Too many things are called "comments", so these are mostly now called section links rather than autocomments.
We look for all comments, match any text before and after the comment, add a separator where needed and format the comment itself with CSS.
string | $comment | Comment text |
LinkTarget | null | $selfLinkTarget | An optional LinkTarget object used to links to sections |
bool | $samePage | Whether section links should refer to local page |
string | false | null | $wikiId | Id of the wiki to link to (if not the local wiki), as used by WikiMap. |
Definition at line 197 of file CommentParser.php.
References Title\castFromLinkTarget(), Parser\guessSectionNameFromStrippedText(), MediaWiki\CommentFormatter\CommentParser\makeSectionLink(), NS_MAIN, and wfMessage().
Referenced by MediaWiki\CommentFormatter\CommentParser\preprocessInternal().
|
private |
Formats wiki links and media links in text; all other wiki formatting is ignored.
string | $comment | Text to format links in. WARNING! Since the output of this function is html, $comment must be sanitized for use as html. You probably want to pass $comment through Sanitizer::escapeHtmlAllowEntities() before calling this function. as used by WikiMap. |
LinkTarget | null | $selfLinkTarget | An optional LinkTarget object used to links to sections |
bool | $samePage | Whether section links should refer to local page |
string | false | null | $wikiId | Id of the wiki to link to (if not the local wiki), as used by WikiMap. |
Definition at line 331 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\addFileLink(), MediaWiki\CommentFormatter\CommentParser\addPageLink(), Linker\normalizeSubpageLink(), NS_FILE, NS_MEDIA, and Linker\splitTrail().
Referenced by MediaWiki\CommentFormatter\CommentParser\preprocessInternal().
MediaWiki\CommentFormatter\CommentParser::finalize | ( | $comments | ) |
Execute pending batch queries and replace markers in the specified string(s) with actual links.
string | string[] | $comments |
Definition at line 140 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\flushLinkBatches().
|
private |
Execute any pending link batch or file batch.
Definition at line 521 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\finalize().
|
private |
Make a section link.
These don't need to go into the LinkBatch, since the link class does not depend on whether the link is known.
LinkTarget | $target | |
string | $text | |
string | false | null | $wikiId | Id of the wiki to link to (if not the local wiki), as used by WikiMap. |
Definition at line 293 of file CommentParser.php.
References MediaWiki\Linker\LinkTarget\getDBkey(), WikiMap\getForeignURL(), MediaWiki\Linker\LinkTarget\getFragment(), MediaWiki\Linker\LinkTarget\getNamespace(), MediaWiki\Linker\LinkTarget\isExternal(), and Linker\makeExternalLink().
Referenced by MediaWiki\CommentFormatter\CommentParser\doSectionLinks().
MediaWiki\CommentFormatter\CommentParser::preprocess | ( | string | $comment, |
LinkTarget | $selfLinkTarget = null , |
||
$samePage = false , |
|||
$wikiId = false , |
|||
$enableSectionLinks = true |
|||
) |
Convert a comment to HTML, but replace links with markers which are resolved later.
string | $comment | |
LinkTarget | null | $selfLinkTarget | |
bool | $samePage | |
string | false | null | $wikiId | |
bool | $enableSectionLinks |
Definition at line 109 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\preprocessInternal().
Referenced by MediaWiki\CommentFormatter\CommentFormatter\preprocessRevComment().
|
private |
string | $comment | |
bool | $unsafe | |
LinkTarget | null | $selfLinkTarget | |
bool | $samePage | |
string | false | null | $wikiId | |
bool | $enableSectionLinks |
Definition at line 165 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\doSectionLinks(), MediaWiki\CommentFormatter\CommentParser\doWikiLinks(), and Sanitizer\escapeHtmlAllowEntities().
Referenced by MediaWiki\CommentFormatter\CommentParser\preprocess(), and MediaWiki\CommentFormatter\CommentParser\preprocessUnsafe().
MediaWiki\CommentFormatter\CommentParser::preprocessUnsafe | ( | $comment, | |
LinkTarget | $selfLinkTarget = null , |
||
$samePage = false , |
|||
$wikiId = false , |
|||
$enableSectionLinks = true |
|||
) |
Convert a comment in pseudo-HTML format to HTML, replacing links with markers.
string | $comment | |
LinkTarget | null | $selfLinkTarget | |
bool | $samePage | |
string | false | null | $wikiId | |
bool | $enableSectionLinks |
Definition at line 126 of file CommentParser.php.
References MediaWiki\CommentFormatter\CommentParser\preprocessInternal().
|
private |
Definition at line 42 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Input to RepoGroup::findFiles()
Definition at line 58 of file CommentParser.php.
|
private |
Resolved File objects indexed by DB key.
Definition at line 60 of file CommentParser.php.
|
private |
Definition at line 48 of file CommentParser.php.
|
private |
Definition at line 55 of file CommentParser.php.
|
private |
Definition at line 36 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Definition at line 50 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Definition at line 34 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Definition at line 53 of file CommentParser.php.
|
private |
Definition at line 46 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Definition at line 38 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Definition at line 44 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().
|
private |
Definition at line 40 of file CommentParser.php.
Referenced by MediaWiki\CommentFormatter\CommentParser\__construct().