File manager - Edit - /home/jardides/www/Jardi-design/old/plugins/pagebuilderck/openstreetmap/openstreetmap.php
Back
<?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 JPlugin { 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 = JFactory::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 = JText::_($this->context . '_MENUITEM_TITLE'); $menuitem->description = JText::_($this->context . '_MENUITEM_DESC'); $menuitem->image = JUri::root(true) . '/plugins/pagebuilderck/openstreetmap/assets/images/map.png'; 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 = JFactory::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 JUri::root(true); ?>/plugins/pagebuilderck/openstreetmap/assets/images/openstreetmap_exemple.jpg" 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 = JFactory::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; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings