MediaWiki master
|
Class that generates HTML for internal links. More...
Public Member Functions | |
__construct (TitleFormatter $titleFormatter, LinkCache $linkCache, SpecialPageFactory $specialPageFactory, HookContainer $hookContainer, ServiceOptions $options) | |
getExpandURLs () | |
getForceArticlePath () | |
getLinkClasses ( $target) | |
Returns CSS classes to add to a known link. | |
isForComment () | |
True when the links will be rendered in an edit summary or log comment. | |
makeBrokenLink ( $target, $text=null, array $extraAttribs=[], array $query=[]) | |
Make a link that's styled as if the target page doesn't exist (a "red link"). | |
makeExternalLink (string $url, $text, LinkTarget $title, $linktype='', $attribs=[]) | |
Make an external link. | |
makeKnownLink ( $target, $text=null, array $extraAttribs=[], array $query=[]) | |
Make a link that's styled as if the target page exists (usually a "blue link", although the styling might depend on e.g. | |
makeLink ( $target, $text=null, array $extraAttribs=[], array $query=[]) | |
Render a wikilink. | |
makePreloadedLink ( $target, $text=null, $classes='', array $extraAttribs=[], array $query=[]) | |
Make a link that's styled as if the target page exists (a "blue link"), with a specified class attribute. | |
makeRedirectHeader (Language $lang, Title $target, bool $forceKnown=false) | |
Return the HTML for the top of a redirect page. | |
normalizeTarget ( $target) | |
Normalizes the provided target. | |
setExpandURLs ( $expand) | |
Whether/how to expand URLs. | |
setForceArticlePath ( $force) | |
Whether to force the link to use the article path ($wgArticlePath) even if a query string is present, resulting in URLs like /wiki/Main_Page?action=foobar. | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
Class that generates HTML for internal links.
See the Linker class for other kinds of links.
Definition at line 47 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::__construct | ( | TitleFormatter | $titleFormatter, |
LinkCache | $linkCache, | ||
SpecialPageFactory | $specialPageFactory, | ||
HookContainer | $hookContainer, | ||
ServiceOptions | $options ) |
TitleFormatter | $titleFormatter | |
LinkCache | $linkCache | |
SpecialPageFactory | $specialPageFactory | |
HookContainer | $hookContainer | |
ServiceOptions | $options |
Definition at line 101 of file LinkRenderer.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), and MediaWiki\Config\ServiceOptions\get().
MediaWiki\Linker\LinkRenderer::getExpandURLs | ( | ) |
Definition at line 149 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::getForceArticlePath | ( | ) |
MediaWiki\Linker\LinkRenderer::getLinkClasses | ( | $target | ) |
Returns CSS classes to add to a known link.
Note that most CSS classes set on wikilinks are actually handled elsewhere (e.g. in makeKnownLink() or in LinkHolderArray).
LinkTarget | PageReference | $target | Page that will be visited when the user clicks on the link. |
Definition at line 593 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::isForComment | ( | ) |
True when the links will be rendered in an edit summary or log comment.
Definition at line 158 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::makeBrokenLink | ( | $target, | |
$text = null, | |||
array | $extraAttribs = [], | ||
array | $query = [] ) |
Make a link that's styled as if the target page doesn't exist (a "red link").
LinkTarget | PageReference | $target | Page that will be visited when the user clicks on the link. |
string | HtmlArmor | null | $text | Text that the user can click on to visit the link. |
array | $extraAttribs | Attributes you would like to add to the tag. For example, if you would like to add title="Text when hovering!", you would set this to [ 'title' => 'Text when hovering!' ] |
array | $query | Parameters you would like to add to the URL. For example, if you would like to add ?redirect=no&debug=1, you would set this to [ 'redirect' => 'no', 'debug' => '1' ] |
Definition at line 321 of file LinkRenderer.php.
References $url, NS_SPECIAL, and wfMessage().
MediaWiki\Linker\LinkRenderer::makeExternalLink | ( | string | $url, |
$text, | |||
LinkTarget | $title, | ||
$linktype = '', | |||
$attribs = [] ) |
Make an external link.
string | $url | URL to link to |
string | HtmlArmor | Message | $text | Text of link; will be escaped if a string. |
LinkTarget | $title | LinkTarget object used for title specific link attributes |
string | $linktype | Type of external link. Gets added to the classes |
array | $attribs | Array of extra attributes to |
Definition at line 381 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::makeKnownLink | ( | $target, | |
$text = null, | |||
array | $extraAttribs = [], | ||
array | $query = [] ) |
Make a link that's styled as if the target page exists (usually a "blue link", although the styling might depend on e.g.
whether the target is a redirect).
This will result in a DB lookup if the title wasn't cached yet. If you want to avoid that, and don't care about matching the exact styling of links within page content, you can use makePreloadedLink() instead.
LinkTarget | PageReference | $target | Page that will be visited when the user clicks on the link. |
string | HtmlArmor | null | $text | Text that the user can click on to visit the link. |
array | $extraAttribs | Attributes you would like to add to the tag. For example, if you would like to add title="Text when hovering!", you would set this to [ 'title' => 'Text when hovering!' ] |
array | $query | Parameters you would like to add to the URL. For example, if you would like to add ?redirect=no&debug=1, you would set this to [ 'redirect' => 'no', 'debug' => '1' ] |
Definition at line 275 of file LinkRenderer.php.
Referenced by MediaWiki\Pager\PagerTools\__construct(), and TraditionalImageGallery\getCaptionHtml().
MediaWiki\Linker\LinkRenderer::makeLink | ( | $target, | |
$text = null, | |||
array | $extraAttribs = [], | ||
array | $query = [] ) |
Render a wikilink.
Will call makeKnownLink() or makeBrokenLink() as appropriate.
LinkTarget | PageReference | $target | Page that will be visited when the user clicks on the link. |
string | HtmlArmor | null | $text | Text that the user can click on to visit the link. |
array | $extraAttribs | Attributes you would like to add to the tag. For example, if you would like to add title="Text when hovering!", you would set this to [ 'title' => 'Text when hovering!' ] |
array | $query | Parameters you would like to add to the URL. For example, if you would like to add ?redirect=no&debug=1, you would set this to [ 'redirect' => 'no', 'debug' => '1' ] |
Definition at line 181 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::makePreloadedLink | ( | $target, | |
$text = null, | |||
$classes = '', | |||
array | $extraAttribs = [], | ||
array | $query = [] ) |
Make a link that's styled as if the target page exists (a "blue link"), with a specified class attribute.
Usually you should use makeLink() or makeKnownLink() instead, which will select the CSS classes automatically. Use this method if the exact styling doesn't matter and you want to ensure no extra DB lookup happens, e.g. for links generated by the skin.
LinkTarget | PageReference | $target | Page that will be visited when the user clicks on the link. |
string | HtmlArmor | null | $text | Text that the user can click on to visit the link. |
string | $classes | CSS classes to add |
array | $extraAttribs | Attributes you would like to add to the tag. For example, if you would like to add title="Text when hovering!", you would set this to [ 'title' => 'Text when hovering!' ] |
array | $query | Parameters you would like to add to the URL. For example, if you would like to add ?redirect=no&debug=1, you would set this to [ 'redirect' => 'no', 'debug' => '1' ] |
Definition at line 226 of file LinkRenderer.php.
References $url.
MediaWiki\Linker\LinkRenderer::makeRedirectHeader | ( | Language | $lang, |
Title | $target, | ||
bool | $forceKnown = false ) |
Return the HTML for the top of a redirect page.
Chances are you should just be using the ParserOutput from WikitextContent::getParserOutput (which will have this header added automatically) instead of calling this for redirects.
If creating your own redirect-alike, please use return value of this method to set the 'core:redirect-header' extension data field in your ParserOutput, rather than concatenating HTML directly. See WikitextContentHandler::fillParserOutput().
Language | $lang | |
Title | $target | Destination to redirect |
bool | $forceKnown | Should the image be shown as a bluelink regardless of existence? |
Definition at line 441 of file LinkRenderer.php.
References MediaWiki\Title\Title\getFullText(), MediaWiki\Title\Title\isRedirect(), and wfMessage().
Referenced by Article\getRedirectHeaderHtml().
MediaWiki\Linker\LinkRenderer::normalizeTarget | ( | $target | ) |
Normalizes the provided target.
LinkTarget | PageReference | $target | Page that will be visited when the user clicks on the link. |
Definition at line 541 of file LinkRenderer.php.
References NS_SPECIAL.
MediaWiki\Linker\LinkRenderer::setExpandURLs | ( | $expand | ) |
Whether/how to expand URLs.
string | bool | int | $expand | A PROTO_* constant or false for no expansion |
Definition at line 141 of file LinkRenderer.php.
MediaWiki\Linker\LinkRenderer::setForceArticlePath | ( | $force | ) |
Whether to force the link to use the article path ($wgArticlePath) even if a query string is present, resulting in URLs like /wiki/Main_Page?action=foobar.
bool | $force |
Definition at line 123 of file LinkRenderer.php.
const MediaWiki\Linker\LinkRenderer::CONSTRUCTOR_OPTIONS |
Definition at line 49 of file LinkRenderer.php.
Referenced by MediaWiki\Linker\LinkRendererFactory\create().