File manager - Edit - /home/jardides/www/Jardi-design/j37/plugins/pagebuilderck/googlemap/googlemap.php
Back
<?php /** * @copyright Copyright (C) 2015 Cédric KEIFLIN alias ced1870 * http://www.template-creator.com * http://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 JPlugin { 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 = JFactory::getDocument(); $doc->addScript("https://maps.googleapis.com/maps/api/js?key=" . $apikey); // load the language files of the plugin $this->loadLanguage(); // create the menu item $menuitem = new stdClass(); $menuitem->type = $this->type; $menuitem->title = JText::_($this->context . '_MENUITEM_TITLE'); $menuitem->description = JText::_($this->context . '_MENUITEM_DESC'); $menuitem->image = JUri::root(true) . '/plugins/pagebuilderck/googlemap/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 onPagebuilderckLoadItemContentGooglemap() { // 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="googlemapck inner"> <img style="display:block;margin: 0 auto;" src="<?php echo JUri::root(true); ?>/plugins/pagebuilderck/googlemap/assets/images/google_map_exemple.jpg" 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 : ''; $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 = JFactory::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: \'' . $params->get('markertitle', '') . '\' }); if (\'' . $content . '\') { var infowindow = new google.maps.InfoWindow({ content: \'' . $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; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings