Skip to content

Commit

Permalink
Add new link position parameter
Browse files Browse the repository at this point in the history
- The parameter lets the user define whether the link is placed above or under the map.
  • Loading branch information
petkivim committed Aug 17, 2019
1 parent f6adeb1 commit 3261fb4
Show file tree
Hide file tree
Showing 23 changed files with 116 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.2.0 - 2019-08-17
- Add link position parameter.

## 2.1.2 - 2019-03-10
- Fix compatibility issue with Google Recaptcha when asynchronous loading of
Google Maps is enabled (#62).
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Embed Google Map is a plugin for embedding one or more Google Maps to Joomla art
* Hide/show the info label. Supported by Google Maps Classic only.
* Define the border width, border style and border color.
* Add link to the full size map. Supported by Google Maps and Google Maps Classic only.
* Define the link label. Supported by Google Maps and Google Maps Classic only.
* Define the link label and location (above or below the map). Supported by Google Maps and Google Maps Classic only.
* Support for HTTP and HTTPS.
* Embed maps created in Google Maps Engine.
* Multilingual features for front-end:
Expand All @@ -38,7 +38,7 @@ Embed Google Map is a plugin for embedding one or more Google Maps to Joomla art
* {google_map}address|zoom:10|lang:it{/google_map}
* {google_map}address|lang:system{/google_map}
* {google_map}address|width:200|height:200|border:1|border_style:solid|border_color:#000000{/google_map}
* {google_map}address|width:200|height:200|link:yes|link_label:Label{/google_map}
* {google_map}address|width:200|height:200|link:yes|link_label:Label|link_position:top{/google_map}
* {google_map}address|link:yes{/google_map}
* {google_map}address|type:satellite{/google_map}
* {google_map}address|show_info:yes|info_label:Label{/google_map}
Expand Down Expand Up @@ -82,6 +82,7 @@ Google Maps and Google Maps Classic do not require an API key, but for Google Ma
* zoom level
* language - By default, visitors will see a map in their own language which is defined by the locale of their browser. The setting takes effect only when a map is opened through the additional link to Google Maps
* add link
* link position
* link label
* height
* width
Expand All @@ -96,6 +97,7 @@ Google Maps and Google Maps Classic do not require an API key, but for Google Ma
* zoom level
* language
* add link
* link position
* link label
* link to full screen
* show info
Expand Down
2 changes: 1 addition & 1 deletion src/embedGoogleMapBuilderFactory.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down
4 changes: 2 additions & 2 deletions src/embedGoogleMapClassicHtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down Expand Up @@ -51,7 +51,7 @@ public function buildHtml(&$params) {
} else {
$url .= $output;
}
$html .= parent::getLinkHtml($url, $params->getLinkLabel());
$html = parent::addLinkToHtml($html, $url, $params->getLinkLabel(), $params->getLinkPosition());
}
return $html;
}
Expand Down
4 changes: 2 additions & 2 deletions src/embedGoogleMapEmbedAPIHtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down Expand Up @@ -40,7 +40,7 @@ public function buildHtml(&$params) {
$url = str_replace('/maps/embed/v1', '/maps', $url);
$url = str_replace('language=', 'hl=', $url);
}
$html .= parent::getLinkHtml($url, $params->getLinkLabel());
$html = parent::addLinkToHtml($html, $url, $params->getLinkLabel(), $params->getLinkPosition());
}
return $html;
}
Expand Down
7 changes: 6 additions & 1 deletion src/embedGoogleMapHtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down Expand Up @@ -61,6 +61,11 @@ protected function getLinkHtml($url, $label) {
return "<div><a href='$url' target='new'>$label</a></div>\n";
}

protected function addLinkToHtml($html, $url, $label, $linkPosition) {
$linkHtml = $this->getLinkHtml($url, $label);
return strcmp(strtolower($linkPosition), 'top') === 0 ? $linkHtml . $html : $html . $linkHtml;
}

private function addLoadAsyncScript($delayMs) {
$document = JFactory::getDocument();

Expand Down
4 changes: 2 additions & 2 deletions src/embedGoogleMapNewHtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down Expand Up @@ -36,7 +36,7 @@ public function buildHtml(&$params) {
} else if ($params->isLink() == 1) {
$url = str_replace('/maps', '/maps/preview', $url);
}
$html .= parent::getLinkHtml($url, $params->getLinkLabel());
$html = parent::addLinkToHtml($html, $url, $params->getLinkLabel(), $params->getLinkPosition());
}
return $html;
}
Expand Down
12 changes: 11 additions & 1 deletion src/embedGoogleMapParameters.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.1.2 2019-08-17 08:50 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand All @@ -15,6 +15,7 @@ class EmbedGoogleMapParameters {
private $zoomLevel = 14;
private $language = "en";
private $addLink = 1;
private $linkPosition = "bottom";
private $linkLabel = "";
private $linkFull = 1;
private $showInfo = 0;
Expand Down Expand Up @@ -89,6 +90,14 @@ public function getAddLink() {
return $this->addLink;
}

public function setLinkPosition($value) {
$this->linkPosition = $value;
}

public function getLinkPosition() {
return $this->linkPosition;
}

public function setLinkLabel($value) {
$this->linkLabel = $value;
}
Expand Down Expand Up @@ -219,6 +228,7 @@ public function toString() {
$str .= "zoomLevel:\t\t$this->zoomLevel\n";
$str .= "language:\t\t\"$this->language\"\n";
$str .= "addLink:\t\t$this->addLink\n";
$str .= "linkPosition:\t\t$this->linkPosition\n";
$str .= "linkLabel:\t\t\"$this->linkLabel\"\n";
$str .= "linkFull:\t\t$this->linkFull\n";
$str .= "showInfo:\t\t$this->showInfo\n";
Expand Down
11 changes: 10 additions & 1 deletion src/embedGoogleMapParser.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down Expand Up @@ -61,6 +61,15 @@ public function parse($string, &$params) {
$params->setAddLink(1);
}
}
if (strstr(strtolower($phrase), 'link_position:')) {
$tpm1 = explode(':', $phrase);
$tmp1 = trim($tpm1[1], '"');
if (strcmp(strtolower($tmp1), 'top') == 0) {
$params->setLinkPosition("top");
} else {
$params->setLinkPosition("bottom");
}
}
if (strstr(strtolower($phrase), 'link_label:')) {
$tpm1 = explode(':', $phrase);
$params->setLinkLabel(trim($tpm1[1], '"'));
Expand Down
3 changes: 2 additions & 1 deletion src/embed_google_map.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @version $Id: Embed Google Map v2.1.2 2019-03-10 12:48 $
* @version $Id: Embed Google Map v2.2.0 2019-08-17 09:10 $
* @package Joomla 1.6
* @copyright Copyright (C) 2014-2019 Petteri Kivimäki. All rights reserved.
* @author Petteri Kivimäki
Expand Down Expand Up @@ -38,6 +38,7 @@ function onContentPrepare($context, &$row, &$params, $limitstart) {
$plgParams->setZoomLevel($this->params->def('zoom', 14));
$plgParams->setLanguage($this->params->def('language', '-'));
$plgParams->setAddLink($this->params->def('add_link', 1));
$plgParams->setLinkPosition($this->params->def('link_position', 'bottom'));
$plgParams->setLinkLabel($this->params->def('link_label', 'View Larger Map'));
$plgParams->setLinkFull($this->params->def('link_full', 1));
$plgParams->setShowInfo($this->params->def('show_info', 0));
Expand Down
13 changes: 11 additions & 2 deletions src/embed_google_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<extension version="1.6" type="plugin" group="content" method="upgrade">
<name>PLG_EMBED_GOOGLE_MAP</name>
<author>Petteri Kivimäki</author>
<creationDate>10 March 2019</creationDate>
<creationDate>17 August 2019</creationDate>
<copyright>(C)2012-2019 Petteri Kivimäki</copyright>
<license>http://www.gnu.org/copyright/gpl.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<version>2.1.2</version>
<version>2.2.0</version>
<description>PLG_EMBED_GOOGLE_MAP_DESC</description>
<files>
<filename plugin="embed_google_map">embed_google_map.php</filename>
Expand Down Expand Up @@ -165,6 +165,15 @@
<option value="1">PLG_EMBED_GOOGLE_MAP_SW_NO</option>
</field>

<field name="link_position" type="radio"
default="bottom"
description="PLG_EMBED_GOOGLE_MAP_DESC_LINK_POSITION"
label="PLG_EMBED_GOOGLE_MAP_LBL_LINK_POSITION"
>
<option value="top">PLG_EMBED_GOOGLE_MAP_LINK_POSITION_TOP</option>
<option value="bottom">PLG_EMBED_GOOGLE_MAP_LINK_POSITION_BOTTOM</option>
</field>

<field name="link_label" type="text"
default="View Larger Map"
size="60"
Expand Down
6 changes: 5 additions & 1 deletion src/en-GB.plg_content_embed_google_map.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PLG_EMBED_GOOGLE_MAP="Content - Embed Google Map"
PLG_EMBED_GOOGLE_MAP_XML_DESCRIPTION="This plugin embeds Google Map to articles."

PLG_EMBED_GOOGLE_MAP_DESC="<h3>Embed Google Map Joomla Plugin</h3><p>Thank you for installing Embed Google Map for Joomla.</p><p>Embed Google Map makes it possible to embed Google Maps to Joomla articles.</p><p>The plugin supports Google Maps, Google Maps Classic and Google Maps Embed API. The version to be used can be set by using the Version setting (supported values: new, classic, embed). Google Maps and Google Maps Classic do not require an API key, but for Google Maps Embed API an API key is required instead. Not all the parameters are supported by all the versions. Please see the supported parameters below.</p><p>Google Maps<br />* map type (normal, satellite)<br />* zoom level<br />* language - By default, visitors will see a map in their own language which is defined by the locale of their browser. The setting takes effect only when a map is opened through the additional link to Google Maps<br />* add link<br />* link label<br />* height<br />* width<br />* border<br />* border style<br />* border color<br />* HTTPS</p><p>Google Maps Classic (deprecated)<br />* map type (normal, satellite, hybrid, terrain)<br />* zoom level<br />* language<br />* add link<br />* link label<br />* link to full screen<br />* show info<br />* info label<br />* height<br />* width<br />* border<br />* border style<br />* border color<br />* HTTPS</p><p>Google Maps Embed API<br />* map type (normal, satellite)<br />* zoom level<br />* language<br />* height<br />* width<br />* border<br />* border style<br />* border color<br />* HTTPS</p><p>Syntax:<br />{google_map}address{/google_map}<br />{google_map}address|version:classic{/google_map}<br />{google_map}address|zoom:10{/google_map}<br />{google_map}address|zoom:10|lang:it{/google_map}<br />{google_map}address|width:200|height:200|border:1|border_style:solid|border_color:#000000{/google_map}<br />{google_map}address|width:200|height:200|link:yes|link_label:Label|link_full:yes{/google_map}<br />{google_map}address|link:yes{/google_map}<br />{google_map}address|type:satellite{/google_map}<br />{google_map}address|show_info:no{/google_map}<br />{google_map}address|show_info:yes|info_label:Label{/google_map}<br />{google_map}address|https:yes{/google_map}<br />*{google_map}latitude,longitude{/google_map}<br /><br />* latitude,longitude = coordinates in decimal degrees</p>"
PLG_EMBED_GOOGLE_MAP_DESC="<h3>Embed Google Map Joomla Plugin</h3><p>Thank you for installing Embed Google Map for Joomla.</p><p>Embed Google Map makes it possible to embed Google Maps to Joomla articles.</p><p>The plugin supports Google Maps, Google Maps Classic and Google Maps Embed API. The version to be used can be set by using the Version setting (supported values: new, classic, embed). Google Maps and Google Maps Classic do not require an API key, but for Google Maps Embed API an API key is required instead. Not all the parameters are supported by all the versions. Please see the supported parameters below.</p><p>Google Maps<br />* map type (normal, satellite)<br />* zoom level<br />* language - By default, visitors will see a map in their own language which is defined by the locale of their browser. The setting takes effect only when a map is opened through the additional link to Google Maps<br />* add link<br />* link position<br />* link label<br />* height<br />* width<br />* border<br />* border style<br />* border color<br />* HTTPS</p><p>Google Maps Classic (deprecated)<br />* map type (normal, satellite, hybrid, terrain)<br />* zoom level<br />* language<br />* add link<br />* link position<br />* link label<br />* link to full screen<br />* show info<br />* info label<br />* height<br />* width<br />* border<br />* border style<br />* border color<br />* HTTPS</p><p>Google Maps Embed API<br />* map type (normal, satellite)<br />* zoom level<br />* language<br />* height<br />* width<br />* border<br />* border style<br />* border color<br />* HTTPS</p><p>Syntax:<br />{google_map}address{/google_map}<br />{google_map}address|version:classic{/google_map}<br />{google_map}address|zoom:10{/google_map}<br />{google_map}address|zoom:10|lang:it{/google_map}<br />{google_map}address|width:200|height:200|border:1|border_style:solid|border_color:#000000{/google_map}<br />{google_map}address|width:200|height:200|link:yes|link_label:Label|link_full:yes{/google_map}<br />{google_map}address|link:yes{/google_map}<br />{google_map}address|type:satellite{/google_map}<br />{google_map}address|show_info:no{/google_map}<br />{google_map}address|show_info:yes|info_label:Label{/google_map}<br />{google_map}address|https:yes{/google_map}<br />*{google_map}latitude,longitude{/google_map}<br /><br />* latitude,longitude = coordinates in decimal degrees</p>"
PLG_EMBED_GOOGLE_MAP_DESC_VERSION="Google Maps version."
PLG_EMBED_GOOGLE_MAP_LBL_VERSION="Version"
PLG_EMBED_GOOGLE_MAP_DESC_MAP_TYPE="Map type. Google Maps Classic supports normal, hybrid, satellite and terrain. Google Maps and Google Maps Embed API version support only normal and satellite."
Expand All @@ -16,6 +16,10 @@ PLG_EMBED_GOOGLE_MAP_SW_YES="Yes"
PLG_EMBED_GOOGLE_MAP_SW_NO="No"
PLG_EMBED_GOOGLE_MAP_DESC_LINK_LABEL="Link label."
PLG_EMBED_GOOGLE_MAP_LBL_LINK_LABEL="Link label"
PLG_EMBED_GOOGLE_MAP_DESC_LINK_POSITION="Is the link located below (bottom) or above (top) the map?"
PLG_EMBED_GOOGLE_MAP_LBL_LINK_POSITION="Link position"
PLG_EMBED_GOOGLE_MAP_LINK_POSITION_BOTTOM="Bottom"
PLG_EMBED_GOOGLE_MAP_LINK_POSITION_TOP="Top"
PLG_EMBED_GOOGLE_MAP_DESC_LINK_FULL="Open link in full screen mode. Supported by Google Maps Classic only."
PLG_EMBED_GOOGLE_MAP_LBL_LINK_FULL="Link to full screen"
PLG_EMBED_GOOGLE_MAP_DESC_SHOW_INFO="Show info label. Supported by Google Maps Classic only."
Expand Down
Loading

0 comments on commit 3261fb4

Please sign in to comment.