MediaWiki  1.23.2
MediaWikiPageLinkRenderer Class Reference

A service for generating links from page titles. More...

Inheritance diagram for MediaWikiPageLinkRenderer:
Collaboration diagram for MediaWikiPageLinkRenderer:

Public Member Functions

 __construct (TitleFormatter $formatter, $baseUrl=null)
 
 getPageUrl (TitleValue $page, $params=array())
 Returns the (partial) URL for the given page (including any section identifier). More...
 
 renderHtmlLink (TitleValue $page, $text=null)
 Returns an HTML link to the given page, using the given surface text. More...
 
 renderWikitextLink (TitleValue $page, $text=null)
 Returns a wikitext link to the given page, using the given surface text. More...
 

Protected Attributes

string $baseUrl
 
TitleFormatter $formatter
 

Detailed Description

A service for generating links from page titles.

See also
https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue

Definition at line 30 of file MediaWikiPageLinkRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWikiPageLinkRenderer::__construct ( TitleFormatter  $formatter,
  $baseUrl = null 
)
Note
$formatter and $baseUrl are currently not used for generating links, since we still rely on the Linker class to generate the actual HTML. Once this is reversed so that Linker becomes a legacy interface to HtmlPageLinkRenderer, we will be using them, so it seems prudent to already declare the dependency and inject them.
Parameters
TitleFormatter$formatterformatter for generating the target title string
string$baseUrl(currently unused, pending refactoring of Linker). Defaults to $wgArticlePath.

Definition at line 51 of file MediaWikiPageLinkRenderer.php.

References $baseUrl, $formatter, and $GLOBALS.

Member Function Documentation

◆ getPageUrl()

MediaWikiPageLinkRenderer::getPageUrl ( TitleValue  $page,
  $params = array() 
)

Returns the (partial) URL for the given page (including any section identifier).

Parameters
TitleValue$pageThe link's target
array$paramsany additional URL parameters.
Returns
string

Implements PageLinkRenderer.

Definition at line 68 of file MediaWikiPageLinkRenderer.php.

References $name, $params, TitleValue\getFragment(), wfArrayToCgi(), and wfUrlencode().

◆ renderHtmlLink()

MediaWikiPageLinkRenderer::renderHtmlLink ( TitleValue  $page,
  $text = null 
)

Returns an HTML link to the given page, using the given surface text.

Parameters
TitleValue$pageThe link's target
string$textThe link's surface text (will be derived from $page if not given).
Returns
string

Implements PageLinkRenderer.

Definition at line 99 of file MediaWikiPageLinkRenderer.php.

References $link, $title, Linker\link(), and Title\newFromTitleValue().

◆ renderWikitextLink()

MediaWikiPageLinkRenderer::renderWikitextLink ( TitleValue  $page,
  $text = null 
)

Returns a wikitext link to the given page, using the given surface text.

Parameters
TitleValue$pageThe link's target
string$textThe link's surface text (will be derived from $page if not given).
Returns
string

Implements PageLinkRenderer.

Definition at line 120 of file MediaWikiPageLinkRenderer.php.

References $name, and wfEscapeWikiText().

Member Data Documentation

◆ $baseUrl

string MediaWikiPageLinkRenderer::$baseUrl
protected

Definition at line 38 of file MediaWikiPageLinkRenderer.php.

Referenced by __construct().

◆ $formatter

TitleFormatter MediaWikiPageLinkRenderer::$formatter
protected

Definition at line 34 of file MediaWikiPageLinkRenderer.php.

Referenced by __construct().


The documentation for this class was generated from the following file: