diff options
Diffstat (limited to 'www/wiki/extensions/Maps/src/Presentation/MapHtmlBuilder.php')
-rw-r--r-- | www/wiki/extensions/Maps/src/Presentation/MapHtmlBuilder.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/www/wiki/extensions/Maps/src/Presentation/MapHtmlBuilder.php b/www/wiki/extensions/Maps/src/Presentation/MapHtmlBuilder.php new file mode 100644 index 00000000..aa47e558 --- /dev/null +++ b/www/wiki/extensions/Maps/src/Presentation/MapHtmlBuilder.php @@ -0,0 +1,37 @@ +<?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: #cccccc; overflow: hidden;", + 'class' => 'maps-map maps-' . $serviceName + ], + wfMessage( 'maps-loading-map' )->inContentLanguage()->escaped() . + Html::element( + 'div', + [ 'style' => 'display:none', 'class' => 'mapdata' ], + FormatJson::encode( $params ) + ) + ); + } + +} |