MediaWiki REL1_30
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.
 

Private Member Functions

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

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 30 of file TemplatesOnThisPageFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 46 of file TemplatesOnThisPageFormatter.php.

References $context, and $linkRenderer.

Member Function Documentation

◆ buildEditLink()

TemplatesOnThisPageFormatter::buildEditLink ( Title $titleObj)
private

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

Parameters
Title$titleObj
Returns
string

Definition at line 168 of file TemplatesOnThisPageFormatter.php.

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 62 of file TemplatesOnThisPageFormatter.php.

References $batch, $template, $type, LinkBatch\addObj(), and formatTemplate().

◆ formatTemplate()

TemplatesOnThisPageFormatter::formatTemplate ( LinkTarget $target)
private

Builds an item for an individual template.

Parameters
LinkTarget$target
Returns
string

Definition at line 113 of file TemplatesOnThisPageFormatter.php.

References buildEditLink(), and getRestrictionsText().

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 132 of file TemplatesOnThisPageFormatter.php.

Referenced by formatTemplate().

Member Data Documentation

◆ $context

IContextSource TemplatesOnThisPageFormatter::$context
private

Definition at line 35 of file TemplatesOnThisPageFormatter.php.

Referenced by __construct().

◆ $linkRenderer

LinkRenderer TemplatesOnThisPageFormatter::$linkRenderer
private

Definition at line 40 of file TemplatesOnThisPageFormatter.php.

Referenced by __construct().


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