| 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/openstreetmap/ |
Upload File : |
<?php
/**
* @copyright Copyright (C) 2015 Cédric KEIFLIN alias ced1870
* https://www.template-creator.com
* https://www.joomlack.fr
* @license GNU/GPL
* */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.event.plugin');
class plgPagebuilderckOpenstreetmap extends \Joomla\CMS\Plugin\CMSPlugin {
private $context = 'PLG_PAGEBUILDERCK_OPENSTREETMAP';
private $type = 'openstreetmap';
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() {
$doc = \Joomla\CMS\Factory::getDocument();
/* get the style for the leaflet map */
$doc->addStyleSheet('https://cdn.jsdelivr.net/leaflet/1/leaflet.css');
/* get the script for the leaflet map */
$doc->addScript('https://cdn.jsdelivr.net/leaflet/1/leaflet.js');
PagebuilderckFrontHelper::addStyleDeclaration('.openstreetmapmarkertitleck, .openstreetmapmarkercontentck {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/openstreetmap/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 onPagebuilderckLoadItemContentOpenstreetmap() {
// 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="openstreetmapck inner">
<img style="display:block;margin: 0 auto;" src="<?php echo \Joomla\CMS\Uri\Uri::root(true); ?>/plugins/pagebuilderck/openstreetmap/assets/images/open_street_map_example.svg" width="100%" height="auto" />
<div class="openstreetmapmarkertitleck"></div>
<div class="openstreetmapmarkercontentck"></div>
</div>
</div>
<?php
}
/*
* Display the html code for the item to be used into the interface
*
* Return String the html code
*/
public function onPagebuilderckLoadItemOptionsOpenstreetmap() {
// load the language files of the plugin
$this->loadLanguage();
// load the interface for the options
$tpl = JPATH_SITE . '/plugins/pagebuilderck/openstreetmap/layouts/edit_openstreetmap.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 onPagebuilderckRenderItemOpenstreetmap($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('.openstreetmapmarkercontentck');
$content = count($content) ? $content[0]->innertext : '';
// get the title of the marker
$title = $item->find('.openstreetmapmarkertitleck');
$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);
// $apikey = $this->params->get('gmapapikey', '');
$doc = \Joomla\CMS\Factory::getDocument();
/* get the style for the leaflet map */
$doc->addStyleSheet('https://cdn.jsdelivr.net/leaflet/1/leaflet.css');
/* get the script for the leaflet map */
$doc->addScript('https://cdn.jsdelivr.net/leaflet/1/leaflet.js');
$html = '<style>
#openstreetmapwrapper'.$item->attr['id'].' {
width: ' . PagebuilderckFrontHelper::testUnit($params->get('mapwidth', '500px')) .';
height: ' . PagebuilderckFrontHelper::testUnit($params->get('mapheight', '400px')) .';
overflow: hidden;
}
</style>
<div class="ckstyle">
'. $styles . '
</div>
<div id="openstreetmapwrapper'.$item->attr['id'].'" class="openstreetmapck inner">
<div id="map'.$item->attr['id'].'" style="height:100%;width:100%;"></div>
</div>
<script>
(function ($) {
var map'.$item->attr['id'].';
$(function () {
// Initialize the map
// This variable map is inside the scope of the jQuery function.
// Now map reference the global map declared in the first line
map'.$item->attr['id'].' = L.map(\'map'.$item->attr['id'].'\').setView([' . $params->get('latitude', '44.5403') . ', ' . $params->get('longitude', '-78.5463') . '], ' . $params->get('mapzoom', 8) . ');
L.tileLayer(\'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
attribution: \'Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>\',
maxZoom: 18
}).addTo(map'.$item->attr['id'].');
markerck = L.marker([' . $params->get('latitude', '44.5403') . ', ' . $params->get('longitude', '-78.5463') . ']).addTo(map'.$item->attr['id'].');
if (\'' . !empty($content) . '\' || \'' . !empty($title) . '\') {
markerck.bindPopup("' . $title . '<br/>' . addslashes(str_replace(array("\r\n", "\r", "\n"), "<br style=\"display:none;\"/>", trim($content))) . '");
if (\'' . $params->get('markershowon', '') . '\' == \'always\') {
markerck.openPopup();
} else {
markerck.on(\'click\', function() { markerck.openPopup() });
}
}
});
})(jQuery);
</script>
';
return $html;
}
}