Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
LegacyMapLink
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 render
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace Kartographer\Tag;
4
5use Kartographer\CoordFormatter;
6use Kartographer\PartialWikitextParser;
7use MediaWiki\Html\Html;
8
9/**
10 * The <maplink> tag creates a link that, when clicked, will open a dynamic map in Special:Map page
11 *
12 * @license MIT
13 */
14class LegacyMapLink extends LegacyTagHandler {
15
16    public const TAG = 'maplink';
17
18    /** @inheritDoc */
19    protected function render( PartialWikitextParser $parser, bool $serverMayRenderOverlays ): string {
20        $this->getOutput()->addModules( [ 'ext.kartographer.link' ] );
21
22        $gen = new MapLinkAttributeGenerator( $this->args );
23        $attrs = $gen->prepareAttrs();
24
25        // @todo: Mapbox markers don't support localized numbers yet
26        $text = $this->args->getTextWithFallback();
27        if ( $text === null ) {
28            $formatter = new CoordFormatter( $this->args->lat, $this->args->lon );
29            $text = $formatter->format( $this->parserContext->getTargetLanguage() );
30        } else {
31            $text = $parser->halfParseWikitext( $text );
32        }
33
34        return Html::rawElement( 'a', $attrs, $text );
35    }
36}