MediaWiki  1.34.0
TemplatesOnThisPageFormatter Class Reference

Handles formatting for the "templates used on this page" lists. More...

Collaboration diagram for TemplatesOnThisPageFormatter:

Public Member Functions

 __construct (IContextSource $context, LinkRenderer $linkRenderer)
 
 format (array $templates, $type=false, $more=null)
 Make an HTML list of templates, and then add a "More..." link at the bottom. More...
 

Private Member Functions

 buildEditLink (LinkTarget $titleObj)
 Return a link to the edit page, with the text saying "view source" if the user can't edit the page. More...
 
 formatTemplate (LinkTarget $target)
 Builds an item for an individual template. More...
 
 getRestrictionsText (array $restrictions)
 If the page is protected, get the relevant text for those restrictions. More...
 

Private Attributes

IContextSource $context
 
LinkRenderer $linkRenderer
 

Detailed Description

Handles formatting for the "templates used on this page" lists.

Formerly known as Linker::formatTemplates()

Since
1.28

Definition at line 31 of file TemplatesOnThisPageFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

TemplatesOnThisPageFormatter::__construct ( IContextSource  $context,
LinkRenderer  $linkRenderer 
)
Parameters
IContextSource$context
LinkRenderer$linkRenderer

Definition at line 47 of file TemplatesOnThisPageFormatter.php.

References $context, and $linkRenderer.

Member Function Documentation

◆ buildEditLink()

TemplatesOnThisPageFormatter::buildEditLink ( LinkTarget  $titleObj)
private

Return a link to the edit page, with the text saying "view source" if the user can't edit the page.

Parameters
LinkTarget$titleObj
Returns
string

Definition at line 165 of file TemplatesOnThisPageFormatter.php.

References getPermissionManager().

Referenced by formatTemplate().

◆ format()

TemplatesOnThisPageFormatter::format ( array  $templates,
  $type = false,
  $more = null 
)

Make an HTML list of templates, and then add a "More..." link at the bottom.

If $more is null, do not add a "More..." link. If $more is a LinkTarget, make a link to that title and use it. If $more is a string, directly paste it in as the link (escaping needs to be done manually).

Parameters
LinkTarget[]$templates
string | bool$type'preview' if a preview, 'section' if a section edit, false if neither
LinkTarget | string | null$moreAn escaped link for "More..." of the templates
Returns
string HTML output

Definition at line 63 of file TemplatesOnThisPageFormatter.php.

References $type, and formatTemplate().

◆ formatTemplate()

TemplatesOnThisPageFormatter::formatTemplate ( LinkTarget  $target)
private

Builds an item for an individual template.

Parameters
LinkTarget$target
Returns
string

Definition at line 110 of file TemplatesOnThisPageFormatter.php.

References buildEditLink(), getRestrictionsText(), and Title\newFromLinkTarget().

Referenced by format().

◆ getRestrictionsText()

TemplatesOnThisPageFormatter::getRestrictionsText ( array  $restrictions)
private

If the page is protected, get the relevant text for those restrictions.

Parameters
array$restrictions
Returns
string

Definition at line 129 of file TemplatesOnThisPageFormatter.php.

Referenced by formatTemplate().

Member Data Documentation

◆ $context

IContextSource TemplatesOnThisPageFormatter::$context
private

Definition at line 36 of file TemplatesOnThisPageFormatter.php.

Referenced by __construct().

◆ $linkRenderer

LinkRenderer TemplatesOnThisPageFormatter::$linkRenderer
private

Definition at line 41 of file TemplatesOnThisPageFormatter.php.

Referenced by __construct().


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