embedGoogleMapHtmlBuilder.php
1.52 KB
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
44
45
46
<?php
/**
* @version $Id: Embed Google Map v2.0.1 2015-03-28 16:06 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2015 Petteri Kivimki. All rights reserved.
* @author Petteri Kivimki
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
abstract class EmbedGoogleMapHtmlBuilder {
abstract public function buildHtml(&$params);
protected function getUrl(&$params, $baseUrl) {
$url = "";
if($params->isLink() == 0 && $params->isGoogleMapsEngine() == 1) {
$url = $params->getAddress();
} else if($params->isGoogleMapsEngine() == 0) {
$url = $params->getAddress();
$alternatives = array("/edit", "/viewer");
$url = str_replace($alternatives,'/embed', $url);
} else {
$url = $baseUrl;
}
if($params->getHttps() == 0) {
$url = str_replace('http://','https://', $url);
}
return $url;
}
protected function getIFrameBegin(&$params) {
$width="width='".$params->getWidth()."'";
$height="height='".$params->getHeight()."'";
$style="style='border: ".$params->getBorder()."px ".$params->getBorderStyle()." ".$params->getBorderColor()."'";
return "\n<iframe $width $height $style ";
}
protected function getLinkHtml($url, $label) {
return "<div><a href='$url' target='new'>$label</a></div>\n";
}
}
?>