Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler Class Reference

Service for embedding Kartographer mapframes for GlobeCoordinateValues. More...

Public Member Functions

 __construct (Parser $parser)
 
 getHtml (GlobeCoordinateValue $value, Language $language)
 
 getPreviewHtml (GlobeCoordinateValue $value, Language $language)
 Get HTML for a Kartographer map, that can be injected into a MediaWiki page on demand (for live previews). More...
 
 getParserOutput (array $values, Language $language)
 Get a ParserOutput with metadata for all the given GlobeCoordinateValues. More...
 

Private Member Functions

 getCacheKey (GlobeCoordinateValue $value, Language $language)
 
 getMapframeInitJS ( $mapPreviewId, array $rlModules, array $kartographerLiveData)
 Get a <script> code block that initializes a mapframe. More...
 
 getMWConfigJS (array $kartographerLiveData)
 Get JavaScript code to update/init "wgKartographerLiveData" with the given data. More...
 
 getWikiText (GlobeCoordinateValue $value)
 Get the mapframe wikitext for a given GlobeCoordinateValue. More...
 
 formatNumber (float $number)
 

Private Attributes

 $parser
 
 $cache
 

Detailed Description

Service for embedding Kartographer mapframes for GlobeCoordinateValues.

Use getParserOutput with ALL GlobeCoordinateValues on a page to get metadata needed to display the mapframes properly. Use getHtml for getting the HTML for a specific GlobeCoordinateValue.

Author
Marius Hoch

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::__construct ( Parser  $parser)
Parameters
Parser$parser

Member Function Documentation

◆ formatNumber()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::formatNumber ( float  $number)
private
Parameters
float$number
Returns
string

◆ getCacheKey()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getCacheKey ( GlobeCoordinateValue  $value,
Language  $language 
)
private
Parameters
GlobeCoordinateValue$value
Language$language
Returns
string

◆ getHtml()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getHtml ( GlobeCoordinateValue  $value,
Language  $language 
)
Parameters
GlobeCoordinateValue$value
Language$language
Exceptions
InvalidArgumentException
Returns
string|bool Html, false if the given value could not be rendered

◆ getMapframeInitJS()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getMapframeInitJS (   $mapPreviewId,
array  $rlModules,
array  $kartographerLiveData 
)
private

Get a <script> code block that initializes a mapframe.

Parameters
string$mapPreviewIdId of the container containing the map
string[]$rlModulesRL modules to load
array$kartographerLiveData
Returns
string HTML

◆ getMWConfigJS()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getMWConfigJS ( array  $kartographerLiveData)
private

Get JavaScript code to update/init "wgKartographerLiveData" with the given data.

Parameters
array$kartographerLiveData
Returns
string JavaScript code

◆ getParserOutput()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getParserOutput ( array  $values,
Language  $language 
)

Get a ParserOutput with metadata for all the given GlobeCoordinateValues.

ATTENTION: This ParserOutput will generally only contain metadata, for getting the html for a certain GlobeCoordinateValue, please use self::getHtml()

Parameters
GlobeCoordinateValue[]$values
Language$language
Returns
ParserOutput

◆ getPreviewHtml()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getPreviewHtml ( GlobeCoordinateValue  $value,
Language  $language 
)

Get HTML for a Kartographer map, that can be injected into a MediaWiki page on demand (for live previews).

Parameters
GlobeCoordinateValue$value
Language$language
Exceptions
InvalidArgumentException
Returns
string|bool Html, false if the given value could not be rendered

◆ getWikiText()

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::getWikiText ( GlobeCoordinateValue  $value)
private

Get the mapframe wikitext for a given GlobeCoordinateValue.

Parameters
GlobeCoordinateValue$value
Returns
string wikitext

Member Data Documentation

◆ $cache

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::$cache
private

◆ $parser

Wikibase\Lib\Formatters\CachingKartographerEmbeddingHandler::$parser
private

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