| Server IP : 46.105.57.169 / Your IP : 216.73.216.144 Web Server : Apache System : Linux webd003.cluster120.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : maitricfuz ( 93378) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/m/a/i/maitricfuz/www/new-saint-martin/plugins/pagebuilderck/googlemap/ |
Upload File : |
<?php
/**
* @copyright Copyright (C) 2015 Cédric KEIFLIN alias ced1870
* https://www.template-creator.com
* https://www.joomlack.fr
* @license GNU/GPL
* */
// https://developers.google.com/maps/tutorials/customizing/
defined('_JEXEC') or die('Restricted access');
jimport('joomla.event.plugin');
class plgPagebuilderckGooglemap extends \Joomla\CMS\Plugin\CMSPlugin {
private $context = 'PLG_PAGEBUILDERCK_GOOGLEMAP';
private $type = 'googlemap';
function __construct(&$subject, $params) {
parent::__construct($subject, $params);
}
/*
* Construct the Menu Item to drag into the interface
*
* Return Object with item data
*/
public function onPagebuilderckAddItemToMenu() {
// load the google map API (must be unique in the page)
$apikey = $this->params->get('gmapapikey', '');
$doc = \Joomla\CMS\Factory::getDocument();
$doc->addScript("https://maps.googleapis.com/maps/api/js?key=" . $apikey);
PagebuilderckFrontHelper::addStyleDeclaration('.googlemapmarkertitleck, .googlemapmarkercontentck {display: none;}');
// load the language files of the plugin
$this->loadLanguage();
// create the menu item
$menuitem = new stdClass();
$menuitem->type = $this->type;
$menuitem->group = 'other';
$menuitem->title = \Joomla\CMS\Language\Text::_($this->context . '_MENUITEM_TITLE');
$menuitem->description = \Joomla\CMS\Language\Text::_($this->context . '_MENUITEM_DESC');
$menuitem->image = \Joomla\CMS\Uri\Uri::root(true) . '/plugins/pagebuilderck/googlemap/assets/images/map.svg';
return $menuitem;
}
/*
* Display the html code for the item to be used into the interface
*
* Return String the html code
*/
public function onPagebuilderckLoadItemContentGooglemap() {
// ckstyle and inner classes are needed to get the styles from the interface
$input = \Joomla\CMS\Factory::getApplication()->input;
$id = $input->get('ckid', '', 'string');
?>
<div id="<?php echo $id; ?>" class="cktype" data-type="<?php echo $this->type ?>">
<div class="ckstyle">
</div>
<div class="googlemapck inner">
<img style="display:block;margin: 0 auto;" src="<?php echo \Joomla\CMS\Uri\Uri::root(true); ?>/plugins/pagebuilderck/googlemap/assets/images/google_map_example.svg" width="100%" height="auto" />
<div class="googlemapmarkertitleck"></div>
<div class="googlemapmarkercontentck"></div>
</div>
</div>
<?php
}
/*
* Display the html code for the item to be used into the interface
*
* Return String the html code
*/
public function onPagebuilderckLoadItemOptionsGooglemap() {
// load the language files of the plugin
$this->loadLanguage();
// load the interface for the options
$tpl = JPATH_SITE . '/plugins/pagebuilderck/googlemap/layouts/edit_googlemap.php';
return $tpl;
}
/*
* Display the html code for the item to be used into the frontend page
* @param string the item object from simple_html_dom
*
* Return String the html code
*/
public function onPagebuilderckRenderItemGooglemap($item) {
// load the helper to help us to use the parameters
include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/pagebuilderckfront.php';
// ckstyle and inner classes are needed to get the styles from the interface
$ckstyle = $item->find('.ckstyle');
$styles = count($ckstyle) ? $ckstyle[0]->innertext : '';
// get the content of the marker
$content = $item->find('.googlemapmarkercontentck');
$content = count($content) ? $content[0]->innertext : '';
// get the title of the marker
$title = $item->find('.googlemapmarkertitleck');
$title = count($title) ? $title[0]->innertext : '';
$mapattrs = $item->find('.tab_map'); // this is the tab id in the interface which contains the map options
$params = PagebuilderckFrontHelper::createParamsFromElement($mapattrs);
// load the google map API (must be unique in the page)
$apikey = $this->params->get('gmapapikey', '');
$doc = \Joomla\CMS\Factory::getDocument();
$doc->addScript("https://maps.googleapis.com/maps/api/js?key=" . $apikey);
$html = '<style>
#googlemapwrapper'.$item->attr['id'].' {
width: ' . $params->get('mapwidth', '500px') .';
height: ' . $params->get('mapheight', '400px') .';
overflow: hidden;
}
</style>
<div class="ckstyle">
'. $styles . '
</div>
<div id="googlemapwrapper'.$item->attr['id'].'" class="googlemapck inner">
<div id="googlemap'.$item->attr['id'].'" style="height:100%;width:100%;"></div>
</div>
<script>
function ck_map'.$item->attr['id'].'_initialize() {
var mapCanvas = document.getElementById("googlemap'.$item->attr['id'].'");
var mapOptions = {
center: new google.maps.LatLng(' . $params->get('latitude', '44.5403') . ', ' . $params->get('longitude', '-78.5463') . '),
zoom: ' . (int) $params->get('mapzoom', 8) . ',
scrollwheel: ' . $params->get('scroll', 'true') . ',
styles: ' . ($params->get('snazzymaps', '') ? htmlspecialchars_decode($params->get('snazzymaps', '')) : '[]') .',
mapTypeId: ' . $params->get('maptype', 'google.maps.MapTypeId.ROADMAP') . '
}
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(' . $params->get('latitude', '44.5403') . ', ' . $params->get('longitude', '-78.5463') . '),
title: \'' . $title . '\'
});
if (\'' . !empty($content) . '\') {
var infowindow = new google.maps.InfoWindow({
content: \'' . addslashes(str_replace(array("\r\n", "\r", "\n"), "<br style=\"display:none;\"/>", trim($content))) . '\'
});
marker.addListener(\'' . $params->get('markershowon', '') . '\', function() {
infowindow.open(map, marker);
});
}
}
google.maps.event.addDomListener(window, "load", ck_map'.$item->attr['id'].'_initialize());
</script>';
return $html;
}
}