summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Maps/src/Presentation/MapHtmlBuilder.php
blob: 7d74ad3450c93f7e295e337fac459450f67a35b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

declare( strict_types = 1 );

namespace Maps\Presentation;

use FormatJson;
use Html;

class MapHtmlBuilder {

	public function getMapHTML( array $params, string $mapName, string $serviceName ): string {
		if ( is_int( $params['height'] ) ) {
			$params['height'] = (string)$params['height'] . 'px';
		}

		if ( is_int( $params['width'] ) ) {
			$params['width'] = (string)$params['width'] . 'px';
		}

		return Html::rawElement(
			'div',
			[
				'id' => $mapName,
				'style' => "width: {$params['width']}; height: {$params['height']}; background-color: #eeeeee; overflow: hidden;",
				'class' => 'maps-map maps-' . $serviceName
			],
			Html::element(
				'div',
				[
					'class' => 'maps-loading-message'
				],
				wfMessage( 'maps-loading-map' )->inContentLanguage()->text()
			)
			. Html::element(
				'div',
				[ 'style' => 'display:none', 'class' => 'mapdata' ],
				FormatJson::encode( $params )
			)
		);
	}

}