loadLanguage(); } public function _setPhocaMapsPluginNumber() { $this->_plgPhocaMapsNr = (int)$this->_plgPhocaMapsNr + 1; } public function _setPhocaMapsPluginLoadedBootstrap() { $this->_loadedBootstrap = (int)$this->_loadedBootstrap + 1; } public function onContentPrepare($context, &$article, &$params, $page = 0) { // Don't run this plugin when the content is being indexed if ($context == 'com_finder.indexer') { return true; } //$layout = new FileLayout('test', null, []); //$layout->addIncludePaths([JPATH_SITE . '/plugins/content/phocamaps/layouts']); $app = Factory::getApplication(); $view = $app->input->get('view'); if ($view == 'tag') { return; } $param['display_map_description'] = $this->params->get('display_map_description', 0); $param['display_auto_location'] = $this->params->get('display_auto_location', 0); // Start Plugin $regex_one = '/({phocamaps\s*)(.*?)(})/si'; $regex_all = '/{phocamaps\s*.*?}/si'; $matches = array(); $count_matches = preg_match_all($regex_all,$article->text,$matches,PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER); $lang = Factory::getLanguage(); $lang->load('com_phocamaps.sys'); $lang->load('com_phocamaps'); // Start if count_matches if ($count_matches != 0) { if (!ComponentHelper::isEnabled('com_phocamaps', true)) { Text::_('PLG_CONTENT_PHOCAMAPS_PLUGIN_REQUIRE_COMPONENT'); return true; } $document = Factory::getDocument(); $db = Factory::getDBO(); //$menu = &JSite::getMenu(); //$plugin = &JPluginHelper::getPlugin('content', 'phocamaps'); //$paramsP = new JParameter( $plugin->params ); $paramsP = $this->params; require_once( JPATH_ROOT.'/components/com_phocamaps/helpers/route.php' ); require_once( JPATH_ADMINISTRATOR.'/components/com_phocamaps/helpers/phocamapspath.php' ); require_once( JPATH_ADMINISTRATOR.'/components/com_phocamaps/helpers/phocamaps.php' ); require_once( JPATH_ADMINISTRATOR.'/components/com_phocamaps/helpers/phocamapsmap.php' ); require_once( JPATH_ADMINISTRATOR.'/components/com_phocamaps/helpers/phocamapsmaposm.php' ); //$component = 'com_phocamaps'; //$table =& JTable::getInstance('component'); //$table->loadByOption( $component ); //$paramsC = new JParameter( $table->params ); $component = 'com_phocamaps'; $paramsC = ComponentHelper::getParams($component) ; $tmpl = array(); HTMLHelper::_('jquery.framework', false); $document->addStyleSheet(URI::base(true).'/media/com_phocamaps/css/phocamaps.css'); $document->addStyleSheet(URI::base(true).'/media/plg_content_phocamaps/css/default.css'); $allIds = array(); for($i = 0; $i < $count_matches; $i++) { // MUST BE HERE - defined for each instance $tmpl['enable_kml'] = $paramsC->get( 'enable_kml', 0 ); $tmpl['display_print_route'] = $paramsC->get( 'display_print_route', 1 ); $tmpl['close_opened_window'] = $paramsC->get( 'close_opened_window', 0 ); $tmpl['map_type'] = $paramsC->get( 'map_type', 2 ); $tmpl['osm_map_type'] = $paramsC->get( 'osm_map_type', 'osm' ); $tmpl['osm_search'] = $paramsC->get( 'osm_search', 0 ); $tmpl['osm_easyprint'] = $paramsC->get( 'osm_easyprint', 0 ); $this->_setPhocaMapsPluginNumber(); // Only loaded when the type is really map not a link - see below view=map YES, view=link NO //$id = 'PlgPM'.(int)$this->_plgPhocaMapsNr; //$allIds[] = $id; $view = ''; $idMap = ''; $text = ''; //$lang = ''; // Get plugin parameters $phocaMaps = $matches[0][$i][0]; preg_match($regex_one,$phocaMaps,$phocaMaps_parts); $parts = explode("|", $phocaMaps_parts[2]); $values_replace = array ("/^'/", "/'$/", "/^'/", "/'$/", "/
/"); foreach($parts as $key => $value) { $values = explode("=", $value, 2); foreach ($values_replace as $key2 => $values2) { $values = preg_replace($values2, '', $values); } // Get plugin parameters from article if($values[0]=='view') {$view = $values[1];} else if($values[0]=='id') {$idMap = $values[1];} else if($values[0]=='text') {$text = $values[1];} //else if($values[0]=='lang') {$lang = $values[1];} else if($values[0]=='kmlfile') {$tmpl['enable_kml'] = $values[1];} else if($values[0]=='printroute') {$tmpl['display_print_route'] = $values[1];} else if($values[0]=='maptype') {$tmpl['map_type'] = $values[1];} else if($values[0]=='osmmaptype') {$tmpl['osm_map_type'] = $values[1];} else if($values[0]=='iframesrc') {$tmpl['iframesrc'] = $values[1];} else if($values[0]=='iframewidth') {$tmpl['iframewidth'] = $values[1];} else if($values[0]=='iframeheight') {$tmpl['iframeheight'] = $values[1];} } $output = ''; switch($view) { // - - - - - - - - - - - - - - - - // Map // - - - - - - - - - - - - - - - - case 'map': $id = 'PlgPM' . (int)$this->_plgPhocaMapsNr; // Javascript for all Google Maps if ($tmpl['map_type'] == 1) { $allIds[] = $id; } $query = 'SELECT a.*' .' FROM #__phocamaps_map AS a' .' WHERE a.id = '.(int) $idMap; $db->setQuery($query); $mapp = $db->loadObject(); if (empty($mapp)) { echo '
'. Text::_('PLG_CONTENT_PHOCAMAPS_PLUGIN_ERROR') . ' - '. Text::_('PLG_CONTENT_PHOCAMAPS_MAP_NOT_EXISTS') . ' (ID = '.$idMap.')
'; return false; } $query = 'SELECT a.*, i.id as iconid, i.url as iurl, i.urls as iurls, i.object as iobject, i.objects as iobjects, i.objectshape as iobjectshape' .' FROM #__phocamaps_marker AS a' .' LEFT JOIN #__phocamaps_map AS c ON c.id = a.catid ' .' LEFT JOIN #__phocamaps_icon AS i ON i.id = a.iconext ' .' WHERE c.id = '.(int) $idMap .' AND a.published = 1' .' ORDER BY a.ordering ASC'; $db->setQuery($query); $markerp = $db->loadObjectList(); // Parameters $tmpl['apikey'] = $paramsC->get( 'google_maps_api_key', '' ); $tmpl['displayphocainfo'] = $paramsC->get( 'display_phoca_info', 1 ); $tmpl['displaymapdescription'] = $paramsP->get( 'display_map_description', 0 ); // - - - - - - - - - - - - - - - // RENDER // - - - - - - - - - - - - - - - // Display Description $tmpl['description'] = ''; if (isset($mapp->description) && $mapp->description != '' && $param['display_map_description'] == 1) { $tmpl['description'] = '
'.$mapp->description.'
'; } // Check Width and Height $tmpl['fullwidth'] = 0; if (!isset($mapp->width)) { $mapp->width = '100%'; } if (isset($mapp->width) && (int)$mapp->width < 1) { $tmpl['fullwidth'] = 1; } if (!isset($mapp->height) || (isset($mapp->height) && (int)$mapp->height < 1)) { $mapp->height = '50vh'; } if (!isset($mapp->zoom) || (isset($mapp->zoom) && (int)$mapp->zoom < 1)) { $mapp->zoom = 2; } if (is_numeric($mapp->width)) { $mapp->width = $mapp->width . 'px'; } if (is_numeric($mapp->height)) { $mapp->height = $mapp->height . 'px'; } // Map Langugage $tmpl['params'] = ''; if (!isset($mapp->lang) || (isset($mapp->lang) && $mapp->lang == '')) { //$tmpl['params'] = '{other_params:"sensor=false"}'; $tmpl['params'] = ''; $tmpl['paramssearch'] = ''; $tmpl['lang'] = ''; } else { //$tmpl['params'] = '{other_params:"sensor=false&language='.$mapp->lang.'"}'; $tmpl['params'] = '{other_params:"language='.$mapp->lang.'"}'; $tmpl['paramssearch'] = '{"language":"'.$mapp->lang.'"}'; $tmpl['lang'] = $mapp->lang; } // Design $tmpl['border'] = ''; if (isset($mapp->border)) { switch ($mapp->border) { case 1: $tmpl['border'] = '-grey'; break; case 2: $tmpl['border'] = '-greywb'; break; case 3: $tmpl['border'] = '-greyrc'; break; case 4: $tmpl['border'] = '-black'; break; } } // Plugin - no border $tmpl['stylesite'] = 'margin:0;padding:0;margin-top:10px;'; $tmpl['stylesitewidth'] = ''; if ($tmpl['fullwidth'] == 1) { $tmpl['stylesitewidth'] = 'style="width:100%"'; } // Parameters if (isset($mapp->continuouszoom) && (int)$mapp->continuouszoom == 1) { $mapp->continuouszoom = 1; } else { $mapp->continuouszoom = 0; } if (isset($mapp->doubleclickzoom) && (int)$mapp->doubleclickzoom == 1) { $mapp->disabledoubleclickzoom = 0; } else { $mapp->disabledoubleclickzoom = 1; } if (isset($mapp->scrollwheelzoom) && (int)$mapp->scrollwheelzoom == 1) { $mapp->scrollwheelzoom = 1; } else { $mapp->scrollwheelzoom = 0; } // Since 1.1.0 zoomcontrol is alias for navigationcontrol if (empty($mapp->zoomcontrol)) { $mapp->zoomcontrol = 0; } if (empty($mapp->scalecontrol)) { $mapp->scalecontrol = 0; } if (empty($mapp->typecontrol)) { $mapp->typecontrol = 0; } if (empty($mapp->typecontrolposition)) { $mapp->typecontrolposition = 0; } if (empty($mapp->typeid)) { $mapp->typeid = 0; } // Display Direction $tmpl['displaydir'] = 0; if (isset($mapp->displayroute) && $mapp->displayroute == 1) { if (isset($markerp) && !empty($markerp)) { $tmpl['displaydir'] = 1; } } // KML Support $tmpl['load_kml'] = FALSE; if($tmpl['enable_kml'] == 1) { jimport( 'joomla.filesystem.folder' ); jimport( 'joomla.filesystem.file' ); $path = PhocaMapsPath::getPath(); if (isset($mapp->kmlfile) && File::exists($path->kml_abs . $mapp->kmlfile)) { $tmpl['load_kml'] = $path->kml_rel_full . $mapp->kmlfile; } } $output .= '
'; if ((!isset($mapp->longitude)) || (!isset($mapp->latitude)) || (isset($mapp->longitude) && $mapp->longitude == '') || (isset($mapp->latitude) && $mapp->latitude == '')) { $output .= '

' . Text::_('COM_PHOCAMAPS_MAP_ERROR_FRONT') . '

'; } else { ######################### # ALL MAPS - Google Maps, OpenStreetMap ######################### $output .= $tmpl['description']; // Map Box if ($tmpl['border'] == '') { $output .= '
'; if ($tmpl['fullwidth'] == 1) { $output .= '
'; } else { $output .= '
'; } $output .= '
'; } else { $output .= '
'; if ($tmpl['fullwidth'] == 1) { $output .= '
'; } else { $output .= '
'; } $output .= '
'; //echo '
'; } ########################### # GOOGLE MAPS ########################### if ($tmpl['map_type'] == 1) { //$id = ''; $map = new PhocaMapsMap($id); //$map->loadAPI(); //$map->loadAPI('jsapi',$paramsC->get( 'load_api_ssl',0)); //$map->loadAPI($article->id);//must be loaded at the end $map->loadGeoXMLJS(); $map->loadBase64JS(); // Direction if ($tmpl['displaydir']) { $countMarker = count($markerp); $form = ''; if ((int)$countMarker > 1) { $form .= ' ' . Text::_('PLG_CONTENT_PHOCAMAPS_TO').': '; } else if ((int)$countMarker == 1) { foreach ($markerp as $key => $markerV) { if ((isset($markerV->longitude) && $markerV->longitude != '') && (isset($markerV->latitude) && $markerV->latitude != '')) { $form .= ''; } } } if ($form != '') { /*$output .= '
'; $output .= Text::_('PLG_CONTENT_PHOCAMAPS_FROM_ADDRESS').': '; $output .= $form; $output .= '
'; $output .= '
'; if ($tmpl['display_print_route'] == 1) { $output .= ''; } $output .= '
';*/ $output .= '
'; $output .= '
'; $output .= Text::_('PLG_CONTENT_PHOCAMAPS_FROM_ADDRESS').': '; $output .= $form; $output .= ' '; $output .= '
'; $output .= '
'; if ($tmpl['display_print_route'] == 1) { $output .= ''; } $output .= '
'; } } // $id is not used anymore as this is added in methods of Phoca Maps Class // e.g. 'phocaMap' will be not 'phocaMap'.$id as the id will be set in methods $output .= $map->startJScData(); $output .= $map->addAjaxAPI('maps', '3', $tmpl['params']); $output .= $map->addAjaxAPI('search', '1', $tmpl['paramssearch']); $output .= $map->createMap('phocaMap', 'mapPhocaMap', 'phocaLatLng', 'phocaOptions','tstPhocaMap', 'tstIntPhocaMap', FALSE, FALSE, $tmpl['displaydir']); $output .= $map->cancelEventFunction(); $output .= $map->checkMapFunction(); $output .= $map->startMapFunction(); $output .= $map->setLatLng( $mapp->latitude, $mapp->longitude ); $output .= $map->startMapOptions(); $output .= $map->setMapOption('zoom', $mapp->zoom).','."\n"; $output .= $map->setCenterOpt().','."\n"; $output .= $map->setTypeControlOpt($mapp->typecontrol, $mapp->typecontrolposition).','."\n"; $output .= $map->setNavigationControlOpt($mapp->zoomcontrol).','."\n"; $output .= $map->setMapOption('scaleControl', $mapp->scalecontrol, TRUE ).','."\n"; //$output .= $map->setMapOption('scrollwheel', $mapp->scrollwheelzoom, TRUE).','."\n"; if ($mapp->gesturehandling != '') { $output .= $map->setMapOption('gestureHandling', '"' . $mapp->gesturehandling . '"').','."\n"; } else { $output .= $map->setMapOption('scrollwheel', $mapp->scrollwheelzoom, TRUE).','."\n"; } $output .= $map->setMapOption('disableDoubleClickZoom', $mapp->disabledoubleclickzoom).','."\n"; // $output .= $map->setMapOption('googleBar', $mapp->googlebar).','."\n";// Not ready yet // $output .= $map->setMapOption('continuousZoom', $mapp->continuouszoom).','."\n";// Not ready yet if (isset($mapp->map_styles)) { $output .= $map->setMapOption('styles', $mapp->map_styles).','."\n"; } $output .= $map->setMapTypeOpt($mapp->typeid)."\n"; if (isset($mapp->custom_options)) { $output .= $map->endMapOptions($mapp->custom_options); } else { $output .= $map->endMapOptions(); } if ($tmpl['close_opened_window'] == 1) { $output .= $map->setCloseOpenedWindow(); } $output .= $map->setMap(); // Markers jimport('joomla.filter.output'); if (isset($markerp) && !empty($markerp)) { $iconArray = array(); // add information about created icons to array and check it so no duplicity icons js code will be created foreach ($markerp as $key => $markerV) { if ((isset($markerV->longitude) && $markerV->longitude != '') && (isset($markerV->latitude) && $markerV->latitude != '')) { //$hStyle = 'font-size:120%;margin: 5px 0px;font-weight:bold;'; //$text = '
' . addslashes($markerV->title) . '
'; // template // $text = '
' . addslashes($markerV->title) . '
'; // Try to correct images in description $markerV->description = PhocaMapsHelper::fixImagePath($markerV->description); $markerV->description = str_replace('@', '@', $markerV->description); //$markerV->description = str_replace("/", '/', $markerV->description); $markerV->description = str_replace("'", ''', $markerV->description); //$markerV->description = str_replace('"', '"', $markerV->description); //$markerV->description = htmlentities($markerV->description); // template /* $text .= '
'. PhocaMapsHelper::strTrimAll(addslashes($markerV->description)).'
'; if ($markerV->displaygps == 1) { $text .= '
' .'' .'' .'
'. Text::_('PLG_CONTENT_PHOCAMAPS_GPS') . ': '.PhocaMapsHelper::strTrimAll(addslashes($markerV->gpslatitude)).'
'.PhocaMapsHelper::strTrimAll(addslashes($markerV->gpslongitude)).'
'; }*/ // Get marker text from tmpl so it can be overriden by template override $text = str_replace(array("\r", "\n", "\t"), '', $this->getTemplateOutput($markerV, "marker")); if(empty($markerV->icon)) { $markerV->icon = 0; } if(empty($markerV->title)){ $markerV->title = ''; } if(empty($markerV->description)){ $markerV->description = ''; } $iconOutput = $map->setMarkerIcon($markerV->icon, $markerV->iconext, $markerV->iurl, $markerV->iobject, $markerV->iurls, $markerV->iobjects, $markerV->iobjectshape); $output .= $map->outputMarkerJs($iconOutput['js'], $markerV->icon, $markerV->iconext); $output .= $map->setMarker($markerV->id,$markerV->title,$markerV->description,$markerV->latitude, $markerV->longitude, $iconOutput['icon'], $iconOutput['iconid'], $text, $markerV->contentwidth, $markerV->contentheight, $markerV->markerwindow, $iconOutput['iconshadow'], $iconOutput['iconshape'], $tmpl['close_opened_window']); } } $output .= $map->setMarkerClusterer(); } if ($tmpl['load_kml']) { $output .= $map->setKMLFile($tmpl['load_kml']); } if ($tmpl['displaydir']) { $output .= $map->setDirectionDisplayService('phocaDir'); } if(isset($mapp->scrollwheelzoom) && $mapp->scrollwheelzoom != 0){ $output .= $map->setListener(); } if ((int)$mapp->autolocation == 1) { $output .= $map->setAutolocation(); } // Set own custom JS which can be overriden by template $output .= $this->getTemplateOutput(["mapId"=>$this->_plgPhocaMapsNr], "custom_js"); $output .= $map->endMapFunction(); if ($tmpl['displaydir']) { $output .= $map->setDirectionFunction($tmpl['display_print_route'], $mapp->id, $mapp->alias, $tmpl['lang']); } //if ((int)$this->_plgPhocaMapsNr < 2) { //$output .= $map->setInitializeFunction();// will be set at bottom for all items - Add init for all maps $output .= $map->setInitializeFunctionSpecificMap(); //} $output .= $map->endJScData(); ########################### END GOOGLE MAPS ########################### # OPENSTREETMAP ########################### } else { //OSM tracks if ($tmpl['map_type'] == 2) { $tmpl['fitbounds'] = $mapp->fitbounds_osm; $textarea = $mapp->trackfiles_osm; $textarea = str_replace(array("\r\n", "\n", "\r"),'',$textarea); $tracks = explode(",",$textarea); $textarea = $mapp->trackcolors_osm; $textarea = str_replace(array("\r\n", "\n", "\r"),'',$textarea); //$colors = explode(",",$textarea); $colors = array_map('trim', explode(',', $textarea)); $tracksA = array(); foreach ($tracks as $k => $v) { $v = trim($v); $ext = pathinfo($v,PATHINFO_EXTENSION); if (($ext != 'gpx') && ($ext != 'kml')) { $v = ''; } else { //if no path specified add default path (hardcoded to /phocamapskml for now) if (strpos($v,'/') === false) { $v = 'phocamapskml/'.$v; } $v = trim($v,'/'); $tracksA[$k] = array(); $tracksA[$k]['file'] = File::exists(JPATH_ROOT.'/'.$v) ? URI::base().$v : ''; $tracksA[$k]['color'] = isset($colors[$k]) ? $colors[$k] : ''; } } $tmpl['tracks'] = $tracksA; } else { $tmpl['tracks'] = array(); } $map = new PhocaMapsMapOsm($id); $map->osmmaptype = $tmpl['osm_map_type']; $map->loadAPI(); $map->loadCoordinatesJS(); $map->createMap($mapp->latitude, $mapp->longitude, $mapp->zoom); $map->setMapType(); // Markers jimport('joomla.filter.output'); $iM = 0; if (isset($markerp) && !empty($markerp)) { $iconArray = array(); // add information about created icons to array and check it so no duplicity icons js code will be created foreach ($markerp as $key => $markerV) { if ((isset($markerV->longitude) && $markerV->longitude != '') && (isset($markerV->latitude) && $markerV->latitude != '')) { if ($iM == 0) { // Get info about first marker to use it in routing plan $firstMarker = $markerV; } $hStyle = 'font-size:120%;margin: 5px 0px;font-weight:bold;'; $text = '
' . addslashes($markerV->title) . '
'; // Try to correct images in description $markerV->description = PhocaMapsHelper::fixImagePath($markerV->description); $markerV->description = str_replace('@', '@', $markerV->description); $text .= '
'. PhocaMapsHelper::strTrimAll(addslashes($markerV->description)).'
'; if ($markerV->displaygps == 1) { $text .= '
' .'' .'' .'
'. Text::_('COM_PHOCAMAPS_GPS') . ': '.PhocaMapsHelper::strTrimAll(addslashes($markerV->gpslatitude)).'
'.PhocaMapsHelper::strTrimAll(addslashes($markerV->gpslongitude)).'
'; } if(empty($markerV->icon)) { $markerV->icon = 0; } if(empty($markerV->title)){ $markerV->title = ''; } if(empty($markerV->description)){ $markerV->description = ''; } $map->setMarker($id . 'm'.$markerV->id, $markerV->title, $markerV->description, $markerV->latitude, $markerV->longitude, $text, $markerV->contentwidth, $markerV->contentheight, $markerV->markerwindow, $tmpl['close_opened_window']); $markerIconOptions = array(); if (isset($markerV->osm_icon) && $markerV->osm_icon != '') { $markerIconOptions = $map->setMarkerIcon($id . 'm'.$markerV->id, $markerV->osm_icon, $markerV->osm_marker_color, $markerV->osm_icon_color, $markerV->osm_icon_prefix, $markerV->osm_icon_spin, $markerV->osm_icon_class); } if ($iM == 0) { // Get info about first marker to use it in routing plan // so we get the same icons for markers in Options like the first marker has $firstMarker->markericonoptions = $markerIconOptions; } $iM++; } } $map->setMarkerClusterer(); } $map->renderFullScreenControl(); $map->renderCurrentPosition(); if ($tmpl['osm_search'] == 1) { $map->renderSearch('', 'topleft'); } // Get Lat and Lng TO (first marker) $lat = $lng = 0; $mId = ''; $markerIconOptions = array(); if (isset($firstMarker->latitude)) { $lat = $firstMarker->latitude; } if (isset($firstMarker->longitude)) { $lng = $firstMarker->longitude; } if (isset($firstMarker->id)) { $mId = $id . 'm'.$firstMarker->id; } if (isset($firstMarker->markericonoptions)) { $markerIconOptions = $firstMarker->markericonoptions; } $map->renderRouting(0,0,$lat,$lng, $mId, $markerIconOptions, $mapp->lang); if ($tmpl['osm_easyprint'] == 1) { $map->renderEasyPrint(); } if (!empty($tmpl['tracks'])) { foreach ($tmpl['tracks'] as $ky=>$trk) { $fitbounds = $ky==0 ? $tmpl['fitbounds'] : false; if (isset($trk['file'])) { $map->renderTrack($trk['file'], $trk['color'], $fitbounds); } } } $map->renderMap(); ########################### END OPENSTREETMAP } } $output .= '
'; $output .= ''; // END RENDER // - - - - - - - - - - - - - - - break; // - - - - - - - - - - - - - - - - // Link // - - - - - - - - - - - - - - - - case 'link': if ((int)$idMap > 0) { $query = 'SELECT a.*,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug' .' FROM #__phocamaps_map AS a' .' WHERE a.id = '.(int) $idMap; $db->setQuery($query); $mapp = $db->loadObject(); if (empty($mapp)) { echo '
'. Text::_('PLG_CONTENT_PHOCAMAPS_PLUGIN_ERROR') . ' - '. Text::_('PLG_CONTENT_PHOCAMAPS_MAP_NOT_EXISTS') . ' (ID = '.$idMap.')
'; return false; } $query = 'SELECT a.id' .' FROM #__phocamaps_marker AS a' .' LEFT JOIN #__phocamaps_map AS c ON c.id = a.catid ' .' WHERE c.id = '.(int) $idMap .' AND a.published = 1'; $db->setQuery($query); $markerp = $db->loadObjectList(); $linkMap = PhocaMapsHelperRoute::getMapRoute( $mapp->id, $mapp->alias); if ($text =='') { $text = Text::_('PLG_CONTENT_PHOCAMAPS_LINK_TO_MAP'); } // Parameters $tmpl['detailwindow'] = $paramsP->get( 'detail_window', 0 ); $tmpl['mbbordercolor'] = $paramsP->get( 'modal_box_border_color', '#6b6b6b' ); $tmpl['mbborderwidth'] = $paramsP->get( 'modal_box_border_width', 2 ); $tmpl['mboverlaycolor'] = $paramsP->get( 'modal_box_overlay_color', '#000000' ); $tmpl['mboverlayopacity'] = $paramsP->get( 'modal_box_overlay_opacity', 0.3 ); if ($mapp->width > 0) { $tmpl['windowwidth'] = (int)$mapp->width + 20; } else { $tmpl['windowwidth'] = 640; } if ($mapp->width > 0) { $tmpl['windowheight'] = (int)$mapp->height + 20; } else { $tmpl['windowheight'] = 360; } //Route if (isset($mapp->displayroute) && $mapp->displayroute == 1) { if (isset($markerp) && !empty($markerp)) { $tmpl['windowheight'] = (int)$tmpl['windowheight'] + 40; } } if ($tmpl['detailwindow'] == 1) { $button = new CMSObject(); $button->set('name', 'phocamaps'); $button->set('methodname', 'js-button'); $button->set('options', "window.open(this.href,'win2','width=".$tmpl['windowwidth'].",height=".$tmpl['windowheight'].",menubar=no,resizable=yes'); return false;"); $output .= ''.$text.''; } else if ($tmpl['detailwindow'] == 0) { // Button HTMLHelper::_('behavior.modal', 'a.modal-button'); $cssSbox = " #sbox-window {background-color:".$tmpl['mbbordercolor'].";padding:".$tmpl['mbborderwidth']."px} \n" ." #sbox-overlay {background-color:".$tmpl['mboverlaycolor'].";} \n"; $document->addCustomTag( "\n"); $button = new CMSObject(); $button->set('name', 'phocamaps'); $button->set('modal', true); $button->set('methodname', 'modal-button'); $button->set('options', "{handler: 'iframe', size: {x: ".$tmpl['windowwidth'].", y: ".$tmpl['windowheight']."}, overlayOpacity: ".$tmpl['mboverlayopacity'].", classWindow: 'phocamaps-plugin-window', classOverlay: 'phocamaps-plugin-overlay'}"); $output .= ''.$text.''; } else if ($tmpl['detailwindow'] == 2) { // Bootstrap Modal $item = 'phPlgMapsModalDetail' . $this->_plgPhocaMapsNr; if($this->_loadedBootstrap == 0) { HTMLHelper::_('script', 'media/plg_content_phocamaps/js/main.js', array('version' => 'auto')); Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.modal'); $output .= ''; $this->_setPhocaMapsPluginLoadedBootstrap(); } $output .= ''.$text.''; } } break; case 'iframe': $output = ''; $width = isset($tmpl['iframewidth']) && $tmpl['iframewidth'] != '' ? $tmpl['iframewidth'] : '100%'; $height = isset($tmpl['iframeheight']) && $tmpl['iframeheight'] != '' ? $tmpl['iframeheight'] : '450'; if (isset($tmpl['iframesrc']) && $tmpl['iframesrc'] != '') { $output = ''; } break; } $article->text = preg_replace($regex_all, $output, $article->text, 1); } // end foreach // Add init for all Google Maps $iDi = ''; if (!empty($allIds)) { $jsI = ''."\n"; $mapA = new PhocaMapsMap($iDi); $jsI .= $mapA->loadAPI($iDi, $mapp->lang); $article->text = $article->text . $jsI; } }// end if count_matches return true; } public function getTemplateOutput($data, $tmpl = "default") { ob_start(); $getTemplatePath = PluginHelper::getLayoutPath('content', $this->plg_name, $tmpl); include($getTemplatePath); return ob_get_clean(); } } ?>