' . $LANG_MAPS_1['info_global_map'] . '
');
- }
+ }
$T->set_var('header', '');
$T->set_var('footer', '');
//address from global map
$T->set_var('address', addslashes($A['geo']));
- $lat = str_replace(",",".",$A['lat']);
- $lng = str_replace(",",".",$A['lng']);
+ $lat = str_replace(",", ".", $A['lat']);
+ $lng = str_replace(",", ".", $A['lng']);
$T->set_var('lat', $lat);
$T->set_var('lng', $lng);
-
- if ($zoom == '' ) $T->set_var('zoom', $_MAPS_CONF['global_zoom']); else $T->set_var('zoom', $zoom);
+
+ if ($zoom == '') $T->set_var('zoom', $_MAPS_CONF['global_zoom']); else $T->set_var('zoom', $zoom);
$T->set_var('map_type', $_MAPS_CONF['global_type']);
$T->set_var('map_width', $_MAPS_CONF['global_width']);
$T->set_var('map_height', $_MAPS_CONF['global_height']);
-
- $nRows = DB_numRows($res);
+
+ $nRows = DB_numRows($res);
$jsmarkers = 'var markers = [];';
-
+
//Global map
-
+
$res_maps = DB_query("SELECT * FROM {$_TABLES['maps_maps']} WHERE 1=1 ORDER BY mid ASC");
//Check if there at least 1 map
- $nRows_maps = DB_numRows($res_maps);
+ $nRows_maps = DB_numRows($res_maps);
+
+ //markers
- //markers
-
//Select color and label for each marker
- for ( $i=0; $i < $nRows_maps; $i++ ) {
+ for ($i = 0; $i < $nRows_maps; $i++) {
$maps[$i] = DB_fetchArray($res_maps);
- if ((($A['active'] == 0) || ($A['hidden'] == 1)) && !SEC_hasRights('maps.admin')) {
+ if ((($A['active'] == 0) || ($A['hidden'] == 1)) && !SEC_hasRights('maps.admin')) {
continue;
}
$item = $maps[$i]['mid'];
@@ -1748,543 +1761,544 @@ function MAPS_getGlobalMap ( $zoom='', $address='', $pagelist=false ) {
$label_color = '#000000';
}
$sql = "SELECT * FROM {$_TABLES['maps_markers']} WHERE mid=$item";
- $jsmarkers .= MAPS_getMarkers($sql,$primary_color,$stroke_color,$marker_label, $label_color, 1, $maps[$i]['name'],0, $maps[$i]);
+ $jsmarkers .= MAPS_getMarkers($sql, $primary_color, $stroke_color, $marker_label, $label_color, 1, $maps[$i]['name'], 0, $maps[$i]);
}
-
- if ($_MAPS_CONF['use_cluster'] == 0 ) {
- $T->set_var('markerclusterer', '');
- } else {
- $T->set_var('markerclusterer', "");
- $jsmarkers .= LB . ' var markerCluster0 = new MarkerClusterer(map0, markers);' . LB;
- }
-
- $T->set_var('markers', $jsmarkers);
-
- //Ads
- $ads = MAPS_getAds (0);
- $T->set_var('ads', $ads);
+
+ if ($_MAPS_CONF['use_cluster'] == 0) {
+ $T->set_var('markerclusterer', '');
+ } else {
+ $T->set_var('markerclusterer', "");
+ $jsmarkers .= LB . ' var markerCluster0 = new MarkerClusterer(map0, markers);' . LB;
+ }
+
+ $T->set_var('markers', $jsmarkers);
+
+ //Ads
+ $ads = MAPS_getAds(0);
+ $T->set_var('ads', $ads);
$T->set_var('edit_button', '');
- $T->parse('output','page');
- $retval .= $T->finish($T->get_var('output'));
-
+ $T->parse('output', 'page');
+ $retval = $T->finish($T->get_var('output'));
+
hitMap(0);
-
+
return $retval;
} else {
- echo COM_refresh($_MAPS_CONF['site_url'] . '/index.php');
+ echo COM_redirect($_MAPS_CONF['site_url'] . '/index.php');
}
-
+
}
-function MAPS_getMarkers ($sql, $primaryColor, $strokecolor, $label, $label_color, $global, $mapname='', $mapid='', $map = array() )
-{
+function MAPS_getMarkers($sql, $primaryColor, $strokecolor, $label, $label_color, $global, $mapname = '', $mapid = '', $map = array())
+{
global $_TABLES, $LANG_MAPS_1, $_MAPS_CONF, $_CONF;
- $map2 = $map;
-
+ $map2 = $map;
- $markers = '' . LB;
-
- if($sql != '') {
- $res_markers = DB_query($sql);
-
- $nRows = DB_numRows($res_markers);
- for ( $i=0; $i < $nRows; $i++ ) {
- $marker = DB_fetchArray($res_markers);
- if (SEC_hasAccess2($marker)) {
- $markers .= MAPS_renderMarker($marker, $primaryColor, $strokecolor, $label, $label_color,
- $mapname, $marker_fields[$marker['mkid']], '', $mapid, true, $map2 );
- }
- }
- } else {
-
- }
-
- return $markers;
+ $markers = '' . LB;
+
+ if ($sql != '') {
+ $res_markers = DB_query($sql);
+
+ $nRows = DB_numRows($res_markers);
+
+ for ($i = 0; $i < $nRows; $i++) {
+ $marker = DB_fetchArray($res_markers);
+ if (SEC_hasAccess2($marker)) {
+ $markers .= MAPS_renderMarker($marker, $primaryColor, $strokecolor, $label, $label_color,
+ $mapname, '', '', $mapid, true, $map2);
+ }
+ }
+ } else {
+
+ }
+
+ return $markers;
}
// $infos display or not infowindow
-function MAPS_renderMarker ($marker, $primaryColor, $strokecolor, $label, $label_color, $mapname='', $field_tab, $category='', $mapid=0, $infos=true, $map3)
+function MAPS_renderMarker($marker, $primaryColor, $strokecolor, $label, $label_color, $mapname = '', $field_tab, $category = '', $mapid = 0, $infos = true, $map3)
{
global $_CONF, $_MAPS_CONF, $LANG_MAPS_1, $_TABLES, $_USER;
-
- $use_icon = $map3['mmk_default']; // 0 false, 1 true
- $icon_id = $map3['mmk_icon'];
+
+ $use_icon = $map3['mmk_default']; // 0 false, 1 true
+ $icon_id = $map3['mmk_icon'];
//$category is not in use maps plugin v1.3
-
- $mkid = $marker['mkid'];
+
+ $mkid = $marker['mkid'];
$marker['name'] = stripslashes($marker['name']);
-
- if (!MAPS_checkMarkervalidity($marker)) return;
-
- if ( ($marker['hidden'] == 1 && !SEC_hasRights('maps.admin') || $marker['active'] == 0) ) return;
- if ( $marker['hidden'] == 1 && SEC_hasRights('maps.admin') ) $marker['name'] = $LANG_MAPS_1['marker_hidden'] . ' ' . $marker['name'];
-
- //custom marker priority on marker
+
+ if (!MAPS_checkMarkervalidity($marker)) return;
+
+ if (($marker['hidden'] == 1 && !SEC_hasRights('maps.admin') || $marker['active'] == 0)) return;
+ if ($marker['hidden'] == 1 && SEC_hasRights('maps.admin')) $marker['name'] = $LANG_MAPS_1['marker_hidden'] . ' ' . $marker['name'];
+
+ //custom marker priority on marker
if ($marker['mk_default'] == 0) {
-
- //custom icon
- if ($marker['mk_icon'] > 0) {
- // icon use an image
- $icon = DB_getItem($_TABLES['maps_map_icons'],'icon_image',"icon_id={$marker['mk_icon']}");
- $image_path = $_MAPS_CONF['path_icons_images'] . $icon;
- list($width, $height, $type, $attr)= getimagesize($image_path);
- if (file_exists($image_path) && $width != '' & $height != '') {
- // Creating a new marker
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+
+ //custom icon
+ if ($marker['mk_icon'] > 0) {
+ // icon use an image
+ $icon = DB_getItem($_TABLES['maps_map_icons'], 'icon_image', "icon_id={$marker['mk_icon']}");
+ $image_path = $_MAPS_CONF['path_icons_images'] . $icon;
+ list($width, $height, $type, $attr) = getimagesize($image_path);
+ if (file_exists($image_path) && $width != '' & $height != '') {
+ // Creating a new marker
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
- title: "' . $marker['name'] . '",
+ title: "' . $marker['name'] . '",
animation: google.maps.Animation.DROP,
icon: "' . $_MAPS_CONF['images_icons_url'] . $icon . '"
- });' . LB ;
- } else {
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+ });' . LB;
+ } else {
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
animation: google.maps.Animation.DROP,
- title: "' . $marker['name'] . '"
- });' . LB ;
- }
+ title: "' . $marker['name'] . '"
+ });' . LB;
+ }
} else {
//Use custom colors
- $primaryColor = substr ( $marker['mk_pcolor'] ,1, 6 );
- $strokecolor = substr ( $marker['mk_scolor'] ,1, 6 );
- if ($marker['mk_label_color'] == 1) {
- $label_color = 'FFFFFF';
- } else {
- $label_color = '000000';
- }
- $label = $marker['mk_label'];
+ $primaryColor = substr($marker['mk_pcolor'], 1, 6);
+ $strokecolor = substr($marker['mk_scolor'], 1, 6);
+ if ($marker['mk_label_color'] == 1) {
+ $label_color = 'FFFFFF';
+ } else {
+ $label_color = '000000';
+ }
+ $label = $marker['mk_label'];
- // Creating a new marker
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+ // Creating a new marker
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
- title: "' . $marker['name'] . '",
+ title: "' . $marker['name'] . '",
animation: google.maps.Animation.DROP,
- icon: "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' . $label . '|' . $primaryColor . '|' . $label_color . '"
- });' . LB ;
- }
- } else if ($use_icon == '0' && $icon_id != '0') {
- // icon use an image
- $icon = DB_getItem($_TABLES['maps_map_icons'],'icon_image',"icon_id={$icon_id}");
- $image_path = $_MAPS_CONF['path_icons_images'] . $icon;
- list($width, $height, $type, $attr)= getimagesize($image_path);
- if (file_exists($image_path) && $width != '' & $height != '') {
- // Creating a new marker
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+ icon: "//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' . $label . '|' . $primaryColor . '|' . $label_color . '"
+ });' . LB;
+ }
+ } else if ($use_icon == '0' && $icon_id != '0') {
+ // icon use an image
+ $icon = DB_getItem($_TABLES['maps_map_icons'], 'icon_image', "icon_id={$icon_id}");
+ $image_path = $_MAPS_CONF['path_icons_images'] . $icon;
+ list($width, $height, $type, $attr) = getimagesize($image_path);
+ if (file_exists($image_path) && $width != '' & $height != '') {
+ // Creating a new marker
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
- title: "' . $marker['name'] . '",
+ title: "' . $marker['name'] . '",
animation: google.maps.Animation.DROP,
icon: "' . $_MAPS_CONF['images_icons_url'] . $icon . '"
- });' . LB ;
- } else {
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+ });' . LB;
+ } else {
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
animation: google.maps.Animation.DROP,
- title: "' . $marker['name'] . '"
- });' . LB ;
- }
- } else if ($use_icon == '0') {
- // icon use custom colors
- // Creating a new marker
- $primaryColor = substr ( $primaryColor ,1, 6 );
- $strokecolor = substr ( $strokecolor ,1, 6 );
+ title: "' . $marker['name'] . '"
+ });' . LB;
+ }
+ } else if ($use_icon == '0') {
+ // icon use custom colors
+ // Creating a new marker
+ $primaryColor = substr($primaryColor, 1, 6);
+ $strokecolor = substr($strokecolor, 1, 6);
- $label_color = substr ( $label_color ,1, 6 );
+ $label_color = substr($label_color, 1, 6);
- //https://developers.google.com/chart/image/docs/gallery/dynamic_icons
- ($primaryColor != '') ? $icon = LB . 'icon: "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' . $label . '|' . $primaryColor . '|' . $label_color . '"' : $icon = '';
-
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+ //https://developers.google.com/chart/image/docs/gallery/dynamic_icons
+ ($primaryColor != '') ? $icon = LB . 'icon: "//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' . $label . '|' . $primaryColor . '|' . $label_color . '"' : $icon = '';
+
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
animation: google.maps.Animation.DROP,
- title: "' . $marker['name'] . '", ' . $icon . '
- });' . LB ;
- } else {
- // Creating a new marker
- $primaryColor = substr ( $primaryColor ,1, 6 );
- $strokecolor = substr ( $strokecolor ,1, 6 );
+ title: "' . $marker['name'] . '", ' . $icon . '
+ });' . LB;
+ } else {
+ // Creating a new marker
+ $primaryColor = substr($primaryColor, 1, 6);
+ $strokecolor = substr($strokecolor, 1, 6);
- $label_color = substr ( $label_color ,1, 6 );
+ $label_color = substr($label_color, 1, 6);
- //https://developers.google.com/chart/image/docs/gallery/dynamic_icons
- ($primaryColor != '') ? $icon = LB . 'icon: "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' . $label . '|' . $primaryColor . '|' . $label_color . '"' : $icon = '';
-
- $markers .= LB . ' var marker' . $marker['mkid'] .' = new google.maps.Marker({
- position: new google.maps.LatLng('. $marker['lat']. ', '. $marker['lng'] .'),
+ //https://developers.google.com/chart/image/docs/gallery/dynamic_icons
+ ($primaryColor != '') ? $icon = LB . 'icon: "//chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' . $label . '|' . $primaryColor . '|' . $label_color . '"' : $icon = '';
+
+ $markers = LB . ' var marker' . $marker['mkid'] . ' = new google.maps.Marker({
+ position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
map:map' . $mapid . ',
animation: google.maps.Animation.DROP,
- title: "' . $marker['name'] . '", ' . $icon . '
- });' . LB ;
+ title: "' . $marker['name'] . '", ' . $icon . '
+ });' . LB;
}
-
+
// Content for infowindow
- if ( $mapid >= 0 && is_numeric($mapid) ) {
- $presentation = '';
- if (file_exists($_CONF['path_data'] . 'maps_data/templates/presentation_tab.thtml')) {
- $template = COM_newTemplate($_CONF['path_data'] . 'maps_data/templates');
- } else {
- $template = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
- }
- $template->set_file(array('presentation' => 'presentation_tab.thtml'));
-
- //Limited marker
- $limited = '';
- if ( $marker['validity'] == 1 && SEC_hasRights('maps.admin') && ( strtotime($marker['validity_end']) > time() || strtotime($marker['validity_start']) < time() ) ) $limited = ' ' . preg_replace( "/\r|\n/", "", nl2br(mb_substr ( $marker['description'] ,0, 150 ))) . $dots . '
' : '';
- $template->set_var('description', PLG_replaceTags(stripslashes($description)));
-
- //Ressources
- $ressources = '';
- $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
-
- foreach ($arr as $value) {
- //For custom presentation_tab.thtml
- $template->set_var('item_'. $value . '_label', $_MAPS_CONF['item_'. $value]);
- $template->set_var('item_'. $value, PLG_replaceTags(stripslashes($marker['item_'. $value])));
- if ($_MAPS_CONF['item_'. $value] != '' && $marker['item_'. $value] != '') {
- $ressources .= '' . PLG_replaceTags($marker['item_'. $value]) . '
';
- }
- }
- $template->set_var('ressources', $ressources);
-
- //Read more
- $read_more_url = '';
- $lang_read_more = $LANG_MAPS_1['read_more'];
-
- if ($marker['url'] == '') {
- $read_more_url = $_MAPS_CONF['site_url'] .'/markers.php?mode=show&mkid=' . $marker['mkid'] . '&mid=' . $marker['mid'];
- } else {
- $read_more_url = $_CONF['site_url'] . '/' . $marker['url'];
- $funcname = 'MAPS_ReadMore_' . $marker['type'];
- if (function_exists( $funcname ) ) $lang_read_more = $funcname();
- }
-
- $template->set_var('read_more', '' . preg_replace("/\r|\n/", "", nl2br(mb_substr($marker['description'], 0, 150))) . $dots . '
' : '';
+ $template->set_var('description', PLG_replaceTags(stripslashes($description)));
+
+ //Ressources
+ $ressources = '';
+ $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+ foreach ($arr as $value) {
+ //For custom presentation_tab.thtml
+ $template->set_var('item_' . $value . '_label', $_MAPS_CONF['item_' . $value]);
+ $template->set_var('item_' . $value, PLG_replaceTags(stripslashes($marker['item_' . $value])));
+ if ($_MAPS_CONF['item_' . $value] != '' && $marker['item_' . $value] != '') {
+ $ressources .= '' . PLG_replaceTags($marker['item_' . $value]) . '
';
+ }
+ }
+ $template->set_var('ressources', $ressources);
+
+ //Read more
+ $read_more_url = '';
+ $lang_read_more = $LANG_MAPS_1['read_more'];
+
+ if ($marker['url'] == '') {
+ $read_more_url = $_MAPS_CONF['site_url'] . '/markers.php?mode=show&mkid=' . $marker['mkid'] . '&mid=' . $marker['mid'];
+ } else {
+ $read_more_url = $_CONF['site_url'] . '/' . $marker['url'];
+ $funcname = 'MAPS_ReadMore_' . $marker['type'];
+ if (function_exists($funcname)) $lang_read_more = $funcname();
+ }
+
+ $template->set_var('read_more', '' . preg_replace( "/\r|\n/", "", nl2br(mb_substr ( $marker['description'] ,0, 150 ))) . $dots . '
' : '';
- $template->set_var('description', $description);
-
- //Read more
- $template->set_var('read_more', '' . preg_replace("/\r|\n/", "", nl2br(mb_substr($marker['description'], 0, 150))) . $dots . '
' : '';
+ $template->set_var('description', $description);
+
+ //Read more
+ $template->set_var('read_more', '
+ if (DB_numRows($res_map) < 1) {
+ COM_redirect($_MAPS_CONF['site_url'] . '/index.php');
+ }
+
+ $A = DB_fetchArray($res_map);
+
+ // Ensure user has the rights to access this map
+ if (!SEC_hasAccess2($A)) return;
+
+ $primaryColor = $A['primary_color'];
+ $strokecolor = $A['stroke_color'];
+ if ($A['label_color'] == 1) {
+ $label_color = '#FFFFFF';
+ } else {
+ $label_color = '#000000';
+ }
+ $label = $A['label'];
+
+ //marker info
+ $markers = '' . LB;
+ $sql = "SELECT * FROM {$_TABLES['maps_markers']} WHERE mkid=$mkid LIMIT 1";
+ $res_markers = DB_query($sql);
+ $marker = DB_fetchArray($res_markers);
+
+ //check marker validity
+ if (!MAPS_checkMarkervalidity($marker)) return $LANG_MAPS_1['marker_limited'];
+
+ if (!defined('MAPS_PAGE_TITLE')) define('MAPS_PAGE_TITLE', stripslashes($marker['name']));
+
+ $markers = MAPS_renderMarker($marker, $primaryColor, $strokecolor, $label, $label_color, $A['name'], '', '', $mkid, true, $A);
+
+ $T = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
+
+ if ($autotag == 0) {
+ $T->set_file('page', 'map.thtml');
+ } else {
+ $T->set_file('page', 'map_autotag.thtml');
+ }
+ $T->set_var('mid', $mkid);
+ $T->set_var('name', '');
+ $T->set_var('description', '');
+ $T->set_var('header', '');
+ $T->set_var('footer', '');
+
+ //address from marker
+ $T->set_var('address', addslashes($marker['address']));
+ $lat = str_replace(",", ".", $marker['lat']);
+ $lng = str_replace(",", ".", $marker['lng']);
+ $T->set_var('lat', $lat);
+ $T->set_var('lng', $lng);
+ $T->set_var('zoom', $_MAPS_CONF['detail_zoom']);
+
+ $T->set_var('map_type', $_MAPS_CONF['global_type']);
+ $T->set_var('map_width', $_MAPS_CONF['global_width']);
+
+ $T->set_var('map_height', $_MAPS_CONF['map_height_geotag']);
+
+ //directions
+ $gid = $marker['mkid'];
+ $T->set_var('gid', $gid);
+ $value = htmlentities($LANG_MAPS_1['value_directions'], ENT_QUOTES);
+
+ $T->set_var('directions_input', '
' . $LANG_MAPS_1['need_directions'] . '
-
+
');
-
- $T->set_var('current_address', addslashes($marker['address']));
-
- //markers
- $jsmarkers = 'var markers = [];';
- $jsmarkers .= $markers;
- if ($_MAPS_CONF['use_cluster'] == 0 ) {
- $T->set_var('markerclusterer', '');
- } else {
- $T->set_var('markerclusterer', "");
- $jsmarkers .= LB . ' var markerCluster = new MarkerClusterer(map' . $mkid . ', markers);' . LB;
+ $T->set_var('current_address', addslashes($marker['address']));
- }
-
- $T->set_var('markers', $jsmarkers);
-
- //Ads
- $ads = MAPS_getAds ($mkid);
- $T->set_var('ads', $ads);
+ //markers
+ $jsmarkers = 'var markers = [];';
+ $jsmarkers .= $markers;
+ if ($_MAPS_CONF['use_cluster'] == 0) {
+ $T->set_var('markerclusterer', '');
+ } else {
+ $T->set_var('markerclusterer', "");
- //Todo edit button
- $T->set_var('edit_button', '');
+ $jsmarkers .= LB . ' var markerCluster = new MarkerClusterer(map' . $mkid . ', markers);' . LB;
- $T->parse('output','page');
- $retval .= $T->finish($T->get_var('output'));
- } else {
- //Selected markers
+ }
+
+ $T->set_var('markers', $jsmarkers);
+
+ //Ads
+ $ads = MAPS_getAds($mkid);
+ $T->set_var('ads', $ads);
+
+ //Todo edit button
+ $T->set_var('edit_button', '');
+
+ $T->parse('output', 'page');
+ $retval .= $T->finish($T->get_var('output'));
+ } else {
+ //Selected markers
$randid = rand();
- $markers = '' . LB;
-
- foreach ($mkid as $mkinfos) {
+ $markers = '' . LB;
- //check marker validity
- if( !MAPS_checkMarkervalidity($mkinfos) ) continue;
+ foreach ($mkid as $mkinfos) {
- if ( !defined('MAPS_PAGE_TITLE') ) define( 'MAPS_PAGE_TITLE', '');
-
- $primaryColor = $mkinfos['primary_color'];
- $strokecolor = $mkinfos['stroke_color'];
- if ($mkinfos['label_color'] == 1) {
- $label_color = '#FFFFFF';
- } else {
- $label_color = '#000000';
- }
- $label = $mkinfos['label'];
-
- $markers .= MAPS_renderMarker ($mkinfos, $primaryColor, $strokecolor, $label, $label_color, $mkinfos['mapname'], '', '', $randid, true, $mkinfos);
- }
+ //check marker validity
+ if (!MAPS_checkMarkervalidity($mkinfos)) continue;
- $T = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
-
- if ($autotag==0) {
- $T->set_file('page', 'map.thtml');
- } else {
- $T->set_file('page', 'map_autotag.thtml');
- }
- $T->set_var('mid', $randid);
- $T->set_var('name', '');
- $T->set_var('description', '');
- $T->set_var('header', '');
- $T->set_var('footer', '');
- $T->set_var('address', '');
- $T->set_var('lat', $lat);
- $T->set_var('lng', $lng);
- $T->set_var('zoom', $mapzoom);
-
- $T->set_var('map_type', $_MAPS_CONF['global_type']);
- $T->set_var('map_width', $mapwidth);
-
- $T->set_var('map_height', $mapheight);
-
- //directions
- $T->set_var('gid', '');
- $value = htmlentities($LANG_MAPS_1['value_directions'], ENT_QUOTES);
-
- $T->set_var('directions_input', '');
-
- $T->set_var('current_address', '');
-
- //markers
- $jsmarkers = 'var markers = [];';
- $jsmarkers .= $markers;
- if ($_MAPS_CONF['use_cluster'] == 0 ) {
- $T->set_var('markerclusterer', '');
- } else {
- $T->set_var('markerclusterer', "");
+ if (!defined('MAPS_PAGE_TITLE')) define('MAPS_PAGE_TITLE', '');
- $jsmarkers .= LB . ' var markerCluster = new MarkerClusterer(map' . $randid . ', markers);' . LB;
+ $primaryColor = $mkinfos['primary_color'];
+ $strokecolor = $mkinfos['stroke_color'];
+ if ($mkinfos['label_color'] == 1) {
+ $label_color = '#FFFFFF';
+ } else {
+ $label_color = '#000000';
+ }
+ $label = $mkinfos['label'];
- }
-
- $T->set_var('markers', $jsmarkers);
-
- //Ads
- $ads = MAPS_getAds ($randid);
- $T->set_var('ads', $ads);
+ $markers .= MAPS_renderMarker($mkinfos, $primaryColor, $strokecolor, $label, $label_color, $mkinfos['mapname'], '', '', $randid, true, $mkinfos);
+ }
+
+ $T = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
+
+ if ($autotag == 0) {
+ $T->set_file('page', 'map.thtml');
+ } else {
+ $T->set_file('page', 'map_autotag.thtml');
+ }
+ $T->set_var('mid', $randid);
+ $T->set_var('name', '');
+ $T->set_var('description', '');
+ $T->set_var('header', '');
+ $T->set_var('footer', '');
+ $T->set_var('address', '');
+ $T->set_var('lat', $lat);
+ $T->set_var('lng', $lng);
+ $T->set_var('zoom', $mapzoom);
+
+ $T->set_var('map_type', $_MAPS_CONF['global_type']);
+ $T->set_var('map_width', $mapwidth);
+
+ $T->set_var('map_height', $mapheight);
+
+ //directions
+ $T->set_var('gid', '');
+ $value = htmlentities($LANG_MAPS_1['value_directions'], ENT_QUOTES);
+
+ $T->set_var('directions_input', '');
+
+ $T->set_var('current_address', '');
+
+ //markers
+ $jsmarkers = 'var markers = [];';
+ $jsmarkers .= $markers;
+ if ($_MAPS_CONF['use_cluster'] == 0) {
+ $T->set_var('markerclusterer', '');
+ } else {
+ $T->set_var('markerclusterer', "");
- //Edit button
- $T->set_var('edit_button', '');
+ $jsmarkers .= LB . ' var markerCluster = new MarkerClusterer(map' . $randid . ', markers);' . LB;
+
+ }
+
+ $T->set_var('markers', $jsmarkers);
+
+ //Ads
+ $ads = MAPS_getAds($randid);
+ $T->set_var('ads', $ads);
+
+ //Edit button
+ $T->set_var('edit_button', '');
+
+ $T->parse('output', 'page');
+ $retval .= $T->finish($T->get_var('output'));
+ }
- $T->parse('output','page');
- $retval .= $T->finish($T->get_var('output'));
- }
-
return $retval;
-
+
}
/**
-*
-* Checks that the current user has the rights to moderate the
-* plugin, returns true if this is the case, false otherwise
-*
-* @return boolean Returns true if moderator
-*
-*/
+ * Checks that the current user has the rights to moderate the
+ * plugin, returns true if this is the case, false otherwise
+ *
+ * @return boolean Returns true if moderator
+ */
function plugin_ismoderator_maps()
{
return SEC_hasRights('maps.admin');
}
/**
-*
-* Counts the items that are submitted
-*
-*/
+ * Counts the items that are submitted
+
+ */
function plugin_submissioncount_maps()
{
global $_TABLES;
@@ -2293,49 +2307,47 @@ function plugin_submissioncount_maps()
}
/**
-* Shows marker submission form or diverts to marker editor if admin calls in
-*
-*/
-function plugin_submit_maps($marker='')
+ * Shows marker submission form or diverts to marker editor if admin calls in
+
+ */
+function plugin_submit_maps($marker = '')
{
global $_CONF, $_MAPS_CONF, $LANG12, $LANG_MAPS_1, $LANG_LOGIN, $_SCRIPTS;
if (SEC_hasRights('maps.admin')) {
- echo COM_refresh ($_CONF['site_admin_url'] . '/plugins/maps/marker_edit.php');
- exit;
- }
-
- //set default for geocoder
- $marker['lat'] = '37.4217913';
- $marker['lng'] = '-122.08371390000002';
-
- COM_clearSpeedlimit ($_CONF['speedlimit'], 'submit');
+ COM_redirect($_CONF['site_admin_url'] . '/plugins/maps/marker_edit.php');
+ }
+
+ //set default for geocoder
+ $marker['lat'] = '37.4217913';
+ $marker['lng'] = '-122.08371390000002';
+
+ COM_clearSpeedlimit($_CONF['speedlimit'], 'submit');
if ($_MAPS_CONF['marker_submission'] == 0) {
return $LANG_MAPS_1['submission_disabled'];
}
-
+
// Ensure user has the rights to access this page
- // TODO use geeklog built-in login form
-
+ // TODO use geeklog built-in login form
+
if (COM_isAnonUser() && (($_CONF['loginrequired'] == 1) || ($_MAPS_CONF['maps_login_required'] == 1) || ($_MAPS_CONF['submit_login_required'] == 1))) {
- $display .= COM_siteHeader('');
- $display .= MAPS_user_menu();
- $display .= COM_startBlock ($LANG_LOGIN[1], '',
- COM_getBlockTemplate ('_msg_block', 'header'));
+ $display = MAPS_user_menu();
+ $display .= COM_startBlock($LANG_LOGIN[1], '',
+ COM_getBlockTemplate('_msg_block', 'header'));
$login = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
- $login->set_file (array ('login'=>'submitloginrequired.thtml'));
- $login->set_var ( 'xhtml', XHTML );
- $login->set_var ('login_message', $LANG_LOGIN[2]);
- $login->set_var ('site_url', $_CONF['site_url']);
- $login->set_var ('site_admin_url', $_CONF['site_admin_url']);
- $login->set_var ('layout_url', $_CONF['layout_url']);
- $login->set_var ('lang_login', $LANG_LOGIN[3]);
- $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
- $login->parse ('output', 'login');
- $display .= $login->finish ($login->get_var('output'));
- $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
- $display .= COM_siteFooter();
+ $login->set_file(array('login' => 'submitloginrequired.thtml'));
+ $login->set_var('xhtml', XHTML);
+ $login->set_var('login_message', $LANG_LOGIN[2]);
+ $login->set_var('site_url', $_CONF['site_url']);
+ $login->set_var('site_admin_url', $_CONF['site_admin_url']);
+ $login->set_var('layout_url', $_CONF['layout_url']);
+ $login->set_var('lang_login', $LANG_LOGIN[3]);
+ $login->set_var('lang_newuser', $LANG_LOGIN[4]);
+ $login->parse('output', 'login');
+ $display .= $login->finish($login->get_var('output'));
+ $display .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
+ $display = COM_createHTMLDocument($display);
COM_output($display);
exit;
}
@@ -2350,9 +2362,9 @@ function plugin_submit_maps($marker='')
$template->set_var('lang_preview', $LANG12[32]);
$template->set_var('lang_save', $LANG12[8]);
-
+
$template->set_var('arrow', '

');
-
+
//informations
$template->set_var('informations', $LANG_MAPS_1['informations']);
$template->set_var('name_label', $LANG_MAPS_1['marker_name_label']);
@@ -2369,10 +2381,11 @@ function plugin_submit_maps($marker='')
$template->set_var('mid', $marker['mid']);
$map_options = MAPS_recurseMaps($marker['mid']);
if ($map_options == '') {
- $display .= COM_startBlock($LANG_MAPS_1['error'],'','blockheader-message.thtml');
+ $display = COM_startBlock($LANG_MAPS_1['error'], '', 'blockheader-message.thtml');
$display .= $LANG_MAPS_1['maps_empty'];
$display .= COM_endBlock('blockfooter-message.thtml');
- return ;
+
+ return;
}
$template->set_var('map_options', $map_options);
$template->set_var('created_label', $LANG_MAPS_1['marker_created']);
@@ -2387,98 +2400,98 @@ function plugin_submit_maps($marker='')
$template->set_var('presentation_tab', $LANG_MAPS_1['presentation_tab']);
$template->set_var('description_label', $LANG_MAPS_1['description_label']);
$template->set_var('description', $marker['description']);
-
+
$template->set_var('street_label', $LANG_MAPS_1['street_label']);
if ($_MAPS_CONF['street'] == 1) {
- $template->set_var('street', '
');
+ $template->set_var('street', '
');
} else {
- $template->set_var('street', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('street', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('code_label', $LANG_MAPS_1['code_label']);
if ($_MAPS_CONF['code'] == 1) {
- $template->set_var('code', '
');
+ $template->set_var('code', '
');
} else {
- $template->set_var('code', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('code', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('city_label', $LANG_MAPS_1['city_label']);
if ($_MAPS_CONF['city'] == 1) {
- $template->set_var('city', '
');
+ $template->set_var('city', '
');
} else {
- $template->set_var('city', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('city', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('state_label', $LANG_MAPS_1['state_label']);
if ($_MAPS_CONF['state'] == 1) {
- $template->set_var('state', '
');
+ $template->set_var('state', '
');
} else {
- $template->set_var('state', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('state', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('country_label', $LANG_MAPS_1['country_label']);
if ($_MAPS_CONF['country'] == 1) {
- $template->set_var('country', '
');
+ $template->set_var('country', '
');
} else {
- $template->set_var('country', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('country', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('tel_label', $LANG_MAPS_1['tel_label']);
if ($_MAPS_CONF['tel'] == 1) {
- $template->set_var('tel', '
');
+ $template->set_var('tel', '
');
} else {
- $template->set_var('tel', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('tel', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('fax_label', $LANG_MAPS_1['fax_label']);
if ($_MAPS_CONF['fax'] == 1) {
- $template->set_var('fax', '
');
+ $template->set_var('fax', '
');
} else {
- $template->set_var('fax', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('fax', $LANG_MAPS_1['not_use_see_config']);
}
-
+
$template->set_var('web_label', $LANG_MAPS_1['web_label']);
if ($_MAPS_CONF['web'] == 1) {
- $template->set_var('web', '
');
+ $template->set_var('web', '
');
} else {
- $template->set_var('web', $LANG_MAPS_1['not_use_see_config']);
+ $template->set_var('web', $LANG_MAPS_1['not_use_see_config']);
}
//Tab ressources
$template->set_var('ressources_tab', $LANG_MAPS_1['ressources_tab']);
$template->set_var('max_char', $LANG_MAPS_1['max_char']);
-
+
$arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
- $ressources ='';
+ $ressources = '';
foreach ($arr as $value) {
- if ($_MAPS_CONF['item_'. $value] == '') {
- $template->set_var('item_'. $value . '_label', '');
- $template->set_var('item_'. $value, '');
+ if ($_MAPS_CONF['item_' . $value] == '') {
+ $template->set_var('item_' . $value . '_label', '');
+ $template->set_var('item_' . $value, '');
$ressources .= '';
} else {
- $template->set_var('item_'. $value . '_label', $_MAPS_CONF['item_'. $value]);
- $template->set_var('item_'. $value, $marker['item_'. $value]);
- $ressources .= '
' . $_MAPS_CONF['item_'. $value] . '
';
+ $template->set_var('item_' . $value . '_label', $_MAPS_CONF['item_' . $value]);
+ $template->set_var('item_' . $value, $marker['item_' . $value]);
+ $ressources .= '
' . $_MAPS_CONF['item_' . $value] . '
';
}
}
if ($ressources == '') {
$ressources = $LANG_MAPS_1['empty_ressources'];
}
$template->set_var('ressources', $ressources);
-
+
//Form validation
$template->set_var('save_button', $LANG_MAPS_1['save_button']);
$template->set_var('delete_button', $LANG_MAPS_1['delete_button']);
$template->set_var('lang_save', $LANG12[8]);
if (is_numeric($marker['mkid'])) {
- $template->set_var('mkid', '
');
+ $template->set_var('mkid', '
');
} else {
$template->set_var('mkid', '');
}
-
- $_SCRIPTS->setJavaScriptLibrary('jquery');
-
- $js = LB . '
+
+ $_SCRIPTS->setJavaScriptLibrary('jquery');
+
+ $js = LB . '
' . LB. LB;
-
- $_SCRIPTS->setJavaScript($js, false);
-
+ ' . LB . LB;
+
+ $_SCRIPTS->setJavaScript($js, false);
+
return $template->parse('output', 'form');
}
/**
-* Check marker submission form for missing fields
-* and Saves a marker submission
-*
-* @param array $A Data for that submission
-* @return string HTML redirect
-*
-*/
+ * Check marker submission form for missing fields
+ * and Saves a marker submission
+ *
+ * @param array $A Data for that submission
+ * @return string HTML redirect
+ */
function plugin_savesubmission_maps($A)
{
global $_TABLES, $_USER, $LANG_MAPS_1, $_MAPS_CONF;
- $retval = '';
-
// check for missing fields
if (empty($A['name']) || empty($A['address'])) {
COM_resetSpeedlimit($type = 'submit');
- $retval = COM_siteHeader ('menu')
- . COM_startBlock($LANG_MAPS_1['error'],'','blockheader-message.thtml')
+ $retval = COM_siteHeader('menu')
+ . COM_startBlock($LANG_MAPS_1['error'], '', 'blockheader-message.thtml')
. $LANG_MAPS_1['missing_field']
. COM_endBlock('blockfooter-message.thtml')
. plugin_submit_maps($A)
- . COM_siteFooter ();
+ . COM_siteFooter();
return $retval;
}
@@ -2608,163 +2618,162 @@ function plugin_savesubmission_maps($A)
if ($_MAPS_CONF['marker_submission'] == 1) {
if ($A['from'] > $A['to']) {
- $display .= COM_startBlock($LANG_MAPS_1['error'],'','blockheader-message.thtml');
+ $display = COM_startBlock($LANG_MAPS_1['error'], '', 'blockheader-message.thtml');
$display .= $LANG_MAPS_1['date_issue'];
$display .= COM_endBlock('blockfooter-message.thtml');
$A['validity_start'] = $A['from'];
$A['validity_end'] = $A['to'];
$display .= getMarkerForm($A);
- break;
+
+ return COM_createHTMLDocument($display);
}
-
+
// prepare strings for insertion
$A['created'] = date("YmdHis");
$A['modified'] = date("YmdHis");
$A['from'] = date("Ymd");
$A['to'] = date("Ymd");
-
+
// lat, lng can only contain numbers and a decimal
if (empty($A['lat']) || empty($A['lng'])) {
$address = $A['address'];
// Updated to mysql 5.1
- // $coords = MAPS_getCoords($address, &$lat, &$lng);
- $coords = MAPS_getCoords($address, $lat, $lng);
+ // $coords = MAPS_getCoords($address, &$lat, &$lng);
+ $coords = MAPS_getCoords($address, $lat, $lng);
} else {
- $lat = addslashes ($A['lat']);
- $lng = addslashes ($A['lng']);
+ $lat = addslashes($A['lat']);
+ $lng = addslashes($A['lng']);
}
-
+
// Convert array values to numeric permission values
if (is_array($A['perm_owner']) OR is_array($A['perm_group']) OR is_array($A['perm_members']) OR is_array($A['perm_anon'])) {
- list($A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']) = SEC_getPermissionValues($A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
+ list($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) = SEC_getPermissionValues($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
}
- $mkid = addslashes (COM_makeSid ());
-
- $A['name'] = addslashes ($A['name']);
- $A['description'] = addslashes ($A['description']);
- $A['address'] = addslashes ($A['address']);
- $A['mid'] = addslashes ($A['mid']);
- $A['remark'] = addslashes ($A['remark']);
- $A['street'] = addslashes ($A['street']);
- $A['city'] = addslashes ($A['city']);
- $A['code'] = addslashes ($A['code']);
- $A['state'] = addslashes ($A['state']);
- $A['country'] = addslashes ($A['country']);
- $A['tel'] = addslashes ($A['tel']);
- $A['fax'] = addslashes ($A['fax']);
- $A['web'] = addslashes ($A['web']);
- $A['item_1'] = addslashes ($A['item_1']);
- $A['item_2'] = addslashes ($A['item_2']);
- $A['item_3'] = addslashes ($A['item_3']);
- $A['item_4'] = addslashes ($A['item_4']);
- $A['item_5'] = addslashes ($A['item_5']);
- $A['item_6'] = addslashes ($A['item_6']);
- $A['item_7'] = addslashes ($A['item_7']);
- $A['item_8'] = addslashes ($A['item_8']);
- $A['item_9'] = addslashes ($A['item_9']);
- $A['item_10'] = addslashes ($A['item_10']);
-
+ $mkid = addslashes(COM_makeSid());
+
+ $A['name'] = addslashes($A['name']);
+ $A['description'] = addslashes($A['description']);
+ $A['address'] = addslashes($A['address']);
+ $A['mid'] = addslashes($A['mid']);
+ $A['remark'] = addslashes($A['remark']);
+ $A['street'] = addslashes($A['street']);
+ $A['city'] = addslashes($A['city']);
+ $A['code'] = addslashes($A['code']);
+ $A['state'] = addslashes($A['state']);
+ $A['country'] = addslashes($A['country']);
+ $A['tel'] = addslashes($A['tel']);
+ $A['fax'] = addslashes($A['fax']);
+ $A['web'] = addslashes($A['web']);
+ $A['item_1'] = addslashes($A['item_1']);
+ $A['item_2'] = addslashes($A['item_2']);
+ $A['item_3'] = addslashes($A['item_3']);
+ $A['item_4'] = addslashes($A['item_4']);
+ $A['item_5'] = addslashes($A['item_5']);
+ $A['item_6'] = addslashes($A['item_6']);
+ $A['item_7'] = addslashes($A['item_7']);
+ $A['item_8'] = addslashes($A['item_8']);
+ $A['item_9'] = addslashes($A['item_9']);
+ $A['item_10'] = addslashes($A['item_10']);
+
$sql = "'{$mkid}', '{$A['name']}', "
- . "'{$A['description']}', "
- . "'{$A['created']}', "
- . "'{$A['modified']}', "
- . "'0', "
- . "'0', "
- . "'{$A['from']}', "
- . "'{$A['to']}', "
- . "'1', "
- . "'0', "
- . "'{$A['address']}', "
- . "'{$lat}', "
- . "'{$lng}', "
- . "'{$A['mid']}', "
- . "'{$A['remark']}', "
- . "'{$A['street']}', "
- . "'{$A['city']}', "
- . "'{$A['code']}', "
- . "'{$A['state']}', "
- . "'{$A['country']}', "
- . "'{$A['tel']}', "
- . "'{$A['fax']}', "
- . "'{$A['web']}', "
- . "'{$A['item_1']}', "
- . "'{$A['item_2']}', "
- . "'{$A['item_3']}', "
- . "'{$A['item_4']}', "
- . "'{$A['item_5']}', "
- . "'{$A['item_6']}', "
- . "'{$A['item_7']}', "
- . "'{$A['item_8']}', "
- . "'{$A['item_9']}', "
- . "'{$A['item_10']}', "
- . "'{$_USER['uid']}', "
- . "'{$A['group_id']}', "
- . "'{$_MAPS_CONF['default_permissions'][0]}', "
- . "'{$_MAPS_CONF['default_permissions'][1]}', "
- . "'{$_MAPS_CONF['default_permissions'][2]}', "
- . "'{$_MAPS_CONF['default_permissions'][3]}', "
- . "'1', "
- . "'1'";
-
- DB_save ($_TABLES['maps_submission'],
- 'mkid, name, description, created, modified, payed, validity, validity_start, validity_end, active, hidden, address, lat, lng, mid, remark, street, city, code, state, country, tel, fax, web, item_1, item_2, item_3, item_4, item_5, item_6, item_7, item_8, item_9, item_10, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon, submission, mk_default',
- "{$sql}");
-
+ . "'{$A['description']}', "
+ . "'{$A['created']}', "
+ . "'{$A['modified']}', "
+ . "'0', "
+ . "'0', "
+ . "'{$A['from']}', "
+ . "'{$A['to']}', "
+ . "'1', "
+ . "'0', "
+ . "'{$A['address']}', "
+ . "'{$lat}', "
+ . "'{$lng}', "
+ . "'{$A['mid']}', "
+ . "'{$A['remark']}', "
+ . "'{$A['street']}', "
+ . "'{$A['city']}', "
+ . "'{$A['code']}', "
+ . "'{$A['state']}', "
+ . "'{$A['country']}', "
+ . "'{$A['tel']}', "
+ . "'{$A['fax']}', "
+ . "'{$A['web']}', "
+ . "'{$A['item_1']}', "
+ . "'{$A['item_2']}', "
+ . "'{$A['item_3']}', "
+ . "'{$A['item_4']}', "
+ . "'{$A['item_5']}', "
+ . "'{$A['item_6']}', "
+ . "'{$A['item_7']}', "
+ . "'{$A['item_8']}', "
+ . "'{$A['item_9']}', "
+ . "'{$A['item_10']}', "
+ . "'{$_USER['uid']}', "
+ . "'{$A['group_id']}', "
+ . "'{$_MAPS_CONF['default_permissions'][0]}', "
+ . "'{$_MAPS_CONF['default_permissions'][1]}', "
+ . "'{$_MAPS_CONF['default_permissions'][2]}', "
+ . "'{$_MAPS_CONF['default_permissions'][3]}', "
+ . "'1', "
+ . "'1'";
+
+ DB_save($_TABLES['maps_submission'],
+ 'mkid, name, description, created, modified, payed, validity, validity_start, validity_end, active, hidden, address, lat, lng, mid, remark, street, city, code, state, country, tel, fax, web, item_1, item_2, item_3, item_4, item_5, item_6, item_7, item_8, item_9, item_10, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon, submission, mk_default',
+ "{$sql}");
+
if (DB_error()) {
- return COM_refresh($_MAPS_CONF['site_url'] . '/index.php?msg=3');
+ return COM_redirect($_MAPS_CONF['site_url'] . '/index.php?msg=3');
} else {
//Send notification to admin
- MAPS_sendNotification ($A);
- return COM_refresh($_MAPS_CONF['site_url'] . '/index.php?msg=1');
+ MAPS_sendNotification($A);
+
+ return COM_redirect($_MAPS_CONF['site_url'] . '/index.php?msg=1');
}
} else {
- return COM_refresh($_MAPS_CONF['site_url'] . '/index.php?msg=2');
+ return COM_redirect($_MAPS_CONF['site_url'] . '/index.php?msg=2');
}
}
/**
-* Send an email notification for a new submission.
-*
-* @param array $A submission data
-*
-*/
-function MAPS_sendNotification ($data, $modification = false)
+ * Send an email notification for a new submission.
+ *
+ * @param array $A submission data
+ */
+function MAPS_sendNotification($data, $modification = false)
{
global $_CONF, $_MAPS_CONF, $LANG_MAPS_EMAIL, $LANG08, $_TABLES;
- $name = stripslashes ($data['name']);
+ $name = stripslashes($data['name']);
$description = stripslashes($data['description']);
$map = DB_getItem($_TABLES['maps_maps'], 'name', "mid = '{$data['mid']}'");
($modification) ? $action = $LANG_MAPS_EMAIL['marker_modification'] : $action = $LANG_MAPS_EMAIL['new_marker'];
- $mailbody = "$action\n\n"
- . "{$LANG_MAPS_EMAIL['name']} $name\n"
- . "{$LANG_MAPS_EMAIL['description']} $description\n\n"
- . "{$LANG_MAPS_EMAIL['on_map']} $map\n\n";
+ $mailbody = "$action\n\n"
+ . "{$LANG_MAPS_EMAIL['name']} $name\n"
+ . "{$LANG_MAPS_EMAIL['description']} $description\n\n"
+ . "{$LANG_MAPS_EMAIL['on_map']} $map\n\n";
- ($modification) ? $mailbody .= $_MAPS_CONF['site_url'] . '/markers.php?mode=show&mkid=' . $data['mkid'] . '&mid=' . $data['mid'] : $mailbody .= "{$LANG_MAPS_EMAIL['submissions']} >> {$_CONF['site_admin_url']}/moderation.php>\n\n";
+ ($modification) ? $mailbody .= $_MAPS_CONF['site_url'] . '/markers.php?mode=show&mkid=' . $data['mkid'] . '&mid=' . $data['mid'] : $mailbody .= "{$LANG_MAPS_EMAIL['submissions']} >> {$_CONF['site_admin_url']}/moderation.php>\n\n";
- ($modification) ? $mailsubject = $_CONF['site_name'] . ' ' . $LANG_MAPS_EMAIL['marker_modification'] : $mailsubject = $_CONF['site_name'] . ' ' . $LANG_MAPS_EMAIL['marker_submissions'];
+ ($modification) ? $mailsubject = $_CONF['site_name'] . ' ' . $LANG_MAPS_EMAIL['marker_modification'] : $mailsubject = $_CONF['site_name'] . ' ' . $LANG_MAPS_EMAIL['marker_submissions'];
$mailbody .= "\n------------------------------\n";
$mailbody .= "\n$LANG08[34]\n";
$mailbody .= "\n------------------------------\n";
- COM_mail ($_CONF['site_mail'], $mailsubject, $mailbody);
+ COM_mail($_CONF['site_mail'], $mailsubject, $mailbody);
}
/**
-* returns list of moderation values
-*
-* The array returned contains (in order): the row 'id' label, main plugin
-* table, moderation fields (comma seperated), and plugin submission table
-*
-* @return array Returns array of useful moderation values
-*
-*/
+ * returns list of moderation values
+ * The array returned contains (in order): the row 'id' label, main plugin
+ * table, moderation fields (comma seperated), and plugin submission table
+ *
+ * @return array Returns array of useful moderation values
+ */
function plugin_moderationvalues_maps()
{
global $_TABLES;
@@ -2773,8 +2782,8 @@ function plugin_moderationvalues_maps()
}
/**
-* Returns SQL & Language texts to moderation.php
-*/
+ * Returns SQL & Language texts to moderation.php
+ */
function plugin_itemlist_maps()
{
global $_TABLES, $LANG_MAPS_1;
@@ -2783,8 +2792,8 @@ function plugin_itemlist_maps()
$plugin = new Plugin();
$plugin->submissionlabel = $LANG_MAPS_1['markers_submissions'];
$plugin->submissionhelpfile = 'http://geeklog.fr/wiki/plugins:maps#moderation';
- $plugin->getsubmissionssql = "SELECT mkid AS id, name, created, address FROM "
- . $_TABLES['maps_submission'];
+ $plugin->getsubmissionssql = "SELECT mkid AS id, name, created, address FROM "
+ . $_TABLES['maps_submission'];
$plugin->addSubmissionHeading($LANG_MAPS_1['name']);
$plugin->addSubmissionHeading($LANG_MAPS_1['created']);
$plugin->addSubmissionHeading($LANG_MAPS_1['address']);
@@ -2794,52 +2803,49 @@ function plugin_itemlist_maps()
}
/**
-* Performs plugin exclusive work for items approved by moderation
-*
-* While moderation.php handles the actual move from maps_submission
-* to maps_markers tables, within the function we handle all other approval
-* relate tasks
-*
-* @param string $id Identifying string
-* @return string Any wanted HTML output
-*
-*/
+ * Performs plugin exclusive work for items approved by moderation
+ * While moderation.php handles the actual move from maps_submission
+ * to maps_markers tables, within the function we handle all other approval
+ * relate tasks
+ *
+ * @param string $id Identifying string
+ * @return string Any wanted HTML output
+ */
function plugin_moderationapprove_maps($id)
{
global $_TABLES, $_USER, $_CONF;
- $result = DB_query("SELECT * FROM " . $_TABLES['groups']
- . " WHERE grp_name = 'Maps Admin'");
- $group = DB_fetchArray($result);
-
+ $result = DB_query("SELECT * FROM " . $_TABLES['groups']
+ . " WHERE grp_name = 'Maps Admin'");
+ $group = DB_fetchArray($result);
+
$sql = "UPDATE " . $_TABLES['maps_markers'] . " SET active = 1, submission = 0, group_id = " . $group['grp_id'] . " WHERE mkid = '$id'";
$result = DB_query($sql);
if (DB_error()) {
- return 'Error';
+ return 'Error';
}
+
return '';
}
/**
-* Performs plugin exclusive work for items deleted by moderation
-*
-* While moderation.php handles the actual removal from
submission
-* table, within this function we handle all other deletion
-* relate tasks
-*
-* @param string $id Identifying string
-* @return string Any wanted HTML output
-*
-*/
+ * Performs plugin exclusive work for items deleted by moderation
+ * While moderation.php handles the actual removal from submission
+ * table, within this function we handle all other deletion
+ * relate tasks
+ *
+ * @param string $id Identifying string
+ * @return string Any wanted HTML output
+ */
function plugin_moderationdelete_maps($id)
{
global $_TABLES;
}
-function hitMap ($map)
+function hitMap($map)
{
global $_TABLES;
// increment hit counter for map
@@ -2850,16 +2856,16 @@ function hitMap ($map)
}
}
-function hitMarker ($mkid)
+function hitMarker($mkid)
{
global $_TABLES;
-
- // increment hit counter for marker
+
+ // increment hit counter for marker
DB_query("UPDATE {$_TABLES['maps_markers']} SET hits = hits + 1 WHERE mkid = '$mkid'");
}
-function updateMap ($map)
+function updateMap($map)
{
global $_TABLES;
// update modification date for a map
@@ -2868,197 +2874,195 @@ function updateMap ($map)
}
/**
-* Returns the user option for this plugin
-*
-* Adds the plugin to the user menu
-*
-* Universal Plugin: modify/uncomment use it
-*
-* @return array Array containing (plugin name, plugin user url, 0)
-*
-*/
-function plugin_getuseroption_maps()
+ * Returns the user option for this plugin
+ * Adds the plugin to the user menu
+ * Universal Plugin: modify/uncomment use it
+ *
+ * @return array Array containing (plugin name, plugin user url, 0)
+ */
+function plugin_getuseroption_maps()
{
global $_MAPS_CONF, $LANG_MAPS_1;
-
- if ($_MAPS_CONF['marker_submission']==1) return array($LANG_MAPS_1['my_markers'], $_MAPS_CONF['site_url'] . '/markers.php', 0);
+
+ if ($_MAPS_CONF['marker_submission'] == 1) return array($LANG_MAPS_1['my_markers'], $_MAPS_CONF['site_url'] . '/markers.php', 0);
}
-function MAPS_message ($message, $title='')
+function MAPS_message($message, $title = '')
{
global $LANG_MAPS_MESSAGE;
-
+
$retval = '';
if (!empty($message)) {
- $retval = COM_startBlock(($title == '')? $LANG_MAPS_MESSAGE['message'] : $title, '', 'blockheader-message.thtml');
+ $retval = COM_startBlock(($title == '') ? $LANG_MAPS_MESSAGE['message'] : $title, '', 'blockheader-message.thtml');
$retval .= stripslashes($message);
$retval .= COM_endBlock('blockfooter-message.thtml');
}
+
return $retval;
}
-function MAPS_ViewMarkerInfos ($mkid)
+function MAPS_ViewMarkerInfos($mkid)
{
global $LANG_MAPS_1, $_TABLES, $_CONF, $_MAPS_CONF, $_USER;
-
+
if ($mkid == '') return;
-
+
$sql = "SELECT * FROM {$_TABLES['maps_markers']} WHERE mkid=$mkid LIMIT 1";
$res_markers = DB_query($sql);
$marker = DB_fetchArray($res_markers);
-
- if(!MAPS_checkMarkervalidity($marker)) return;
-
+
+ if (!MAPS_checkMarkervalidity($marker)) return;
+
// Presentation tab
$presentation = '';
$template = new Template($_CONF['path'] . 'plugins/maps/templates');
$template->set_file(array('presentation' => 'marker.thtml'));
-
- //Limited marker
- $limited = '';
- if ( $marker['validity'] == 1 && SEC_hasRights('maps.admin') && ( strtotime($marker['validity_end']) > time() || strtotime($marker['validity_start']) < time() ) ) $limited = ' Limited';
-
+
+ //Limited marker
+ $limited = '';
+ if ($marker['validity'] == 1 && SEC_hasRights('maps.admin') && (strtotime($marker['validity_end']) > time() || strtotime($marker['validity_start']) < time())) $limited = ' Limited';
+
$template->set_var('name', '' . stripslashes($marker['name']) . ' ' . $limited);
-
- //ressources tab
+
+ //ressources tab
$ressources = '';
$arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
-
+
//payed marker
- if ( $_MAPS_CONF['monetize'] == 0 ) {
+ if ($_MAPS_CONF['monetize'] == 0) {
if ($marker['description'] != '') {
- $description = nl2br(stripslashes($marker['description']));
- $description = str_replace("\n", "", $description);
- $description = str_replace("\r", "", $description);
- $template->set_var('description', '' . $description . '
');
+ $description = nl2br(stripslashes($marker['description']));
+ $description = str_replace("\n", "", $description);
+ $description = str_replace("\r", "", $description);
+ $template->set_var('description', '' . $description . '
');
} else {
- $template->set_var('description', '');
+ $template->set_var('description', '');
}
if ($_MAPS_CONF['street'] == 1 && $marker['street'] != '') {
- $template->set_var('street', '' . $LANG_MAPS_1['street_label'] . ' ' . stripslashes($marker['street']) . '
');
+ $template->set_var('street', '' . $LANG_MAPS_1['street_label'] . ' ' . stripslashes($marker['street']) . '
');
} else {
- $template->set_var('street', '');
+ $template->set_var('street', '');
}
-
+
if ($_MAPS_CONF['code'] == 1 && $marker['code'] != '') {
- $template->set_var('code', '' . $LANG_MAPS_1['code_label'] . ' ' . $marker['code']);
+ $template->set_var('code', '' . $LANG_MAPS_1['code_label'] . ' ' . $marker['code']);
} else {
- $template->set_var('code', '');
+ $template->set_var('code', '');
}
-
+
if ($_MAPS_CONF['city'] == 1 && $marker['city'] != '') {
- $template->set_var('city', '' . $LANG_MAPS_1['city_label'] . ' ' . stripslashes($marker['city']));
+ $template->set_var('city', '' . $LANG_MAPS_1['city_label'] . ' ' . stripslashes($marker['city']));
} else {
- $template->set_var('city', '');
+ $template->set_var('city', '');
}
-
+
if ($_MAPS_CONF['state'] == 1 && $marker['state'] != '') {
- $template->set_var('state', '' . $LANG_MAPS_1['state_label'] . ' ' . $marker['state'] . '
');
+ $template->set_var('state', '' . $LANG_MAPS_1['state_label'] . ' ' . $marker['state'] . '
');
} else {
- $template->set_var('state', '');
+ $template->set_var('state', '');
}
-
+
if ($_MAPS_CONF['country'] == 1 && $marker['country'] != '') {
- $template->set_var('country', '' . $LANG_MAPS_1['country_label'] . ' ' . stripslashes($marker['country']) . '
');
+ $template->set_var('country', '' . $LANG_MAPS_1['country_label'] . ' ' . stripslashes($marker['country']) . '
');
} else {
- $template->set_var('country', '');
+ $template->set_var('country', '');
}
-
+
if ($_MAPS_CONF['tel'] == 1 && $marker['tel'] != '') {
- $template->set_var('tel', '' . $LANG_MAPS_1['tel_label'] . ' ' . $marker['tel'] . '
');
+ $template->set_var('tel', '' . $LANG_MAPS_1['tel_label'] . ' ' . $marker['tel'] . '
');
} else {
- $template->set_var('tel', '');
+ $template->set_var('tel', '');
}
-
+
if ($_MAPS_CONF['fax'] == 1 && $marker['fax'] != '') {
- $template->set_var('fax', '' . $LANG_MAPS_1['fax_label'] . ' ' . $marker['fax'] . '
');
+ $template->set_var('fax', '' . $LANG_MAPS_1['fax_label'] . ' ' . $marker['fax'] . '
');
} else {
- $template->set_var('fax', '');
+ $template->set_var('fax', '');
}
-
+
if ($_MAPS_CONF['web'] == 1 && $marker['web'] != '') {
- $template->set_var('web', '' . $LANG_MAPS_1['web_label'] . ' ' . MAPS_convertLinkToUrl($marker['web']) . '
');
+ $template->set_var('web', '' . $LANG_MAPS_1['web_label'] . ' ' . MAPS_convertLinkToUrl($marker['web']) . '
');
} else {
- $template->set_var('web', '');
+ $template->set_var('web', '');
}
-
+
//Ressources tab
foreach ($arr as &$value) {
- if ($_MAPS_CONF['item_'. $value] == '') {
+ if ($_MAPS_CONF['item_' . $value] == '') {
$ressources .= '';
} else {
- if ($marker['item_'. $value] != ''){
- $content = str_replace(array("\r\n", "\n", "\r", " "), '', addslashes($marker['item_'. $value]));
- $ressources .= '' . $_MAPS_CONF['item_'. $value] . '
' . stripslashes($content) . '
';
- }
+ if ($marker['item_' . $value] != '') {
+ $content = str_replace(array("\r\n", "\n", "\r", " "), '', addslashes($marker['item_' . $value]));
+ $ressources .= '' . $_MAPS_CONF['item_' . $value] . '
' . stripslashes($content) . '
';
+ }
}
}
- } elseif (($marker['payed'] == 1 ) && ($_MAPS_CONF['monetize'] == 1)) {
+ } elseif (($marker['payed'] == 1) && ($_MAPS_CONF['monetize'] == 1)) {
if ($marker['description'] != '') {
- $template->set_var('description', '' . stripslashes($marker['description']) . '
');
+ $template->set_var('description', '' . stripslashes($marker['description']) . '
');
} else {
- $template->set_var('description', '');
+ $template->set_var('description', '');
}
if ($_MAPS_CONF['street'] == 1 && $marker['street'] != '') {
- $template->set_var('street', stripslashes($marker['street']) . ' ');
+ $template->set_var('street', stripslashes($marker['street']) . ' ');
} else {
- $template->set_var('street', '');
+ $template->set_var('street', '');
}
if ($_MAPS_CONF['code'] == 1 && $marker['code'] != '') {
- $template->set_var('code', $marker['code'] . ' ');
+ $template->set_var('code', $marker['code'] . ' ');
} else {
- $template->set_var('code', '');
+ $template->set_var('code', '');
}
if ($_MAPS_CONF['city'] == 1 && $marker['city'] != '') {
- $template->set_var('city', stripslashes($marker['city']) . ' ');
+ $template->set_var('city', stripslashes($marker['city']) . ' ');
} else {
- $template->set_var('city', '');
+ $template->set_var('city', '');
}
if ($_MAPS_CONF['state'] == 1 && $marker['state'] != '') {
- $template->set_var('state', $marker['state'] . ' ');
+ $template->set_var('state', $marker['state'] . ' ');
} else {
- $template->set_var('state', '');
+ $template->set_var('state', '');
}
if ($_MAPS_CONF['country'] == 1 && $marker['country'] != '') {
- $template->set_var('country', stripslashes($marker['country']) . ' ');
- } else {
- $template->set_var('country', '');
- }
- if ($count == 0) {
- $template->set_var('space', '');
+ $template->set_var('country', stripslashes($marker['country']) . ' ');
} else {
- $template->set_var('space', '
' . '
');
+ $template->set_var('country', '');
}
+// if ($count == 0) {
+ $template->set_var('space', '');
+// } else {
+// $template->set_var('space', '
' . '
');
+// }
if ($_MAPS_CONF['tel'] == 1 && $marker['tel'] != '') {
- $template->set_var('tel', '' . $LANG_MAPS_1['tel_label'] . ' ' . $marker['tel'] . '
');
+ $template->set_var('tel', '' . $LANG_MAPS_1['tel_label'] . ' ' . $marker['tel'] . '
');
} else {
- $template->set_var('tel', '');
+ $template->set_var('tel', '');
}
if ($_MAPS_CONF['fax'] == 1 && $marker['fax'] != '') {
- $template->set_var('fax', '' . $LANG_MAPS_1['fax_label'] . ' ' . $marker['fax'] . '
');
+ $template->set_var('fax', '' . $LANG_MAPS_1['fax_label'] . ' ' . $marker['fax'] . '
');
} else {
- $template->set_var('fax', '');
+ $template->set_var('fax', '');
}
if ($_MAPS_CONF['web'] == 1 && $marker['web'] != '') {
- $template->set_var('web', '' . $LANG_MAPS_1['web_label'] . ' ' . $marker['web'] . '
');
+ $template->set_var('web', '' . $LANG_MAPS_1['web_label'] . ' ' . $marker['web'] . '
');
} else {
- $template->set_var('web', '');
+ $template->set_var('web', '');
}
//Ressources tab
foreach ($arr as &$value) {
- if ($_MAPS_CONF['item_'. $value] == '') {
+ if ($_MAPS_CONF['item_' . $value] == '') {
$ressources .= '';
} else {
- if ($marker['item_'. $value] != '') {
- $content = str_replace(array("\r\n", "\n", "\r", " "), '', addslashes($marker['item_'. $value]));
- $ressources .= '' . $_MAPS_CONF['item_'. $value] . '
' . stripslashes($content) . '
';
- }
+ if ($marker['item_' . $value] != '') {
+ $content = str_replace(array("\r\n", "\n", "\r", " "), '', addslashes($marker['item_' . $value]));
+ $ressources .= '' . $_MAPS_CONF['item_' . $value] . '
' . stripslashes($content) . '
';
+ }
}
}
} else {
if ($marker['description'] != '') {
- $template->set_var('description', '' . stripslashes($marker['description']) . '
');
+ $template->set_var('description', '' . stripslashes($marker['description']) . '
');
} else {
$template->set_var('description', '');
}
@@ -3074,330 +3078,371 @@ function MAPS_ViewMarkerInfos ($mkid)
//Ressources tab
$ressources = '';
}
-
+
$template->set_var('ressources', $ressources);
-
+
//Edit link
if (SEC_hasRights('maps.admin') || $_USER['uid'] == $marker['owner_id']) {
- $template->set_var('edit', ' | ' . $LANG_MAPS_1['edit_button'] . '');
+ $template->set_var('edit', ' | ' . $LANG_MAPS_1['edit_button'] . '');
} else {
$template->set_var('edit', '');
}
//Map
$mapname = DB_getItem($_TABLES['maps_maps'], 'name', "mid={$marker['mid']}");
- $template->set_var('map', ' | ' . $LANG_MAPS_1['from_map'] . ' ' . stripslashes($mapname) . '');
-
- //Owner
- $profile_url = $_CONF['site_url']
- . '/users.php?mode=profile&uid=' . $marker['owner_id'];
+ $template->set_var('map', ' | ' . $LANG_MAPS_1['from_map'] . ' ' . stripslashes($mapname) . '');
+
+ //Owner
+ $profile_url = $_CONF['site_url']
+ . '/users.php?mode=profile&uid=' . $marker['owner_id'];
$profile = COM_createLink(COM_getDisplayName($marker['owner_id']), $profile_url);
- $template->set_var('owner', $LANG_MAPS_1['from_owner'] . ' ' . $profile);
-
+ $template->set_var('owner', $LANG_MAPS_1['from_owner'] . ' ' . $profile);
+
//Update
$update = COM_getUserDateTimeFormat($marker['modified']);
$template->set_var('update', '
' . $LANG_MAPS_1['last_modification'] . ' ' . $update[0] . ' ' . ' | ' . $marker['hits'] . ' ' . $LANG_MAPS_1['hits']);
-
+
//Report
- $template->set_var('report', '' .$LANG_MAPS_1['report'] . '');
-
- //Print
- $template->set_var('print', '' .$LANG_MAPS_1['print'] . ' | ');
-
- //directions
- $gid = $marker['mkid'];
- $template->set_var('directions_table_result', '
- ');
+ $template->set_var('report', '' . $LANG_MAPS_1['report'] . '');
+
+ //Print
+ $template->set_var('print', '' . $LANG_MAPS_1['print'] . ' | ');
+
+ //directions
+ $gid = $marker['mkid'];
+ $template->set_var('directions_table_result', '
+ ');
$presentation .= $template->parse('output', 'presentation');
- $retval .= $presentation;
-
- hitMarker ($mkid);
-
- return $retval;
+ $retval = $presentation;
+
+ hitMarker($mkid);
+
+ return $retval;
}
-function MAPS_convertLinkToUrl ($url, $lenght=35) {
-
- global $_CONF;
-
- if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
- $newurl = "http://" . $url;
+function MAPS_convertLinkToUrl($url, $lenght = 35)
+{
+
+ global $_CONF;
+
+ if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
+ $newurl = "//" . $url;
} else {
- $newurl = $url;
- }
-
- //name
- $parse = parse_url($newurl);
- ($parse['host'] != '' ) ? $name = $parse['host'] : $name = $url;
-
- //Target
- (strpos($newurl,$_CONF['site_url']) !== false) ? $target = '' : $target = '_blank';
-
- // convert link to url
+ $newurl = $url;
+ }
+
+ //name
+ $parse = parse_url($newurl);
+ ($parse['host'] != '') ? $name = $parse['host'] : $name = $url;
+
+ //Target
+ (strpos($newurl, $_CONF['site_url']) !== false) ? $target = '' : $target = '_blank';
+
+ // convert link to url
$link = preg_replace("/((http:\/\/|https:\/\/)[^ |<)
- ]+)/e", "''. ((strlen(\"$name\")>=" . $lenght . " ? substr(\"$name\",0," . $lenght . ").'... ':\"$name\")).' '", $newurl );
-
- return $link ;
+ ]+)/e", "''. ((strlen(\"$name\")>=" . $lenght . " ? substr(\"$name\",0," . $lenght . ").'... ':\"$name\")).' '", $newurl);
+
+ return $link;
}
/**
-* List all markers that the user has access to
-*
-* @retun string HTML for the list
-*
-*/
+ * List all markers that the user has access to
+ *
+ * @retun string HTML for the list
+ */
function MAPS_ListMarkers($mid = '')
{
global $_CONF, $_MAPS_CONF, $_TABLES, $_IMAGE_TYPE, $LANG_ADMIN, $LANG_MAPS_1;
if ($mid == '') return;
$mid = addslashes($mid);
-
+
require_once $_CONF['path_system'] . 'lib-admin.php';
$retval = '';
-
- if (DB_count($_TABLES['maps_markers']) == 0){
- return $retval = '';
+
+ if (DB_count($_TABLES['maps_markers']) == 0) {
+ return $retval = '';
}
$header_arr = array( // display 'text' and use table field 'field'
array('text' => $LANG_MAPS_1['name'], 'field' => 'name', 'sort' => true),
array('text' => $LANG_MAPS_1['code'], 'field' => 'code', 'sort' => true),
- array('text' => $LANG_MAPS_1['city'], 'field' => 'city', 'sort' => true)
+ array('text' => $LANG_MAPS_1['city'], 'field' => 'city', 'sort' => true),
);
$defsort_arr = array('field' => 'code', 'direction' => 'asc');
$text_arr = array(
'has_extras' => true,
- 'form_url' => $_MAPS_CONF['site_url'] . '/index.php?mode=markers&mid=' . $mid
+ 'form_url' => $_MAPS_CONF['site_url'] . '/index.php?mode=markers&mid=' . $mid,
);
-
- if ($mid == 0) {
- $sql = "SELECT
+
+ if ($mid == 0) {
+ $sql = "SELECT
*
FROM {$_TABLES['maps_markers']}
WHERE active = 1 AND hidden = 0
";
- $map_name = $LANG_MAPS_1['global_map'];
- } else {
- $sql = "SELECT
+ $map_name = $LANG_MAPS_1['global_map'];
+ } else {
+ $sql = "SELECT
*
FROM {$_TABLES['maps_markers']}
WHERE mid = {$mid} AND active = 1 AND hidden = 0
";
- $map_name = DB_getItem($_TABLES['maps_maps'],'name', "mid = {$mid}");
- }
+ $map_name = DB_getItem($_TABLES['maps_maps'], 'name', "mid = {$mid}");
+ }
$query_arr = array(
'table' => 'maps_markers',
'sql' => $sql,
- 'query_fields' => array('name','code','city'),
- 'default_filter' => COM_getPermSQL ('AND', 0, 2)
+ 'query_fields' => array('name', 'code', 'city'),
+ 'default_filter' => COM_getPermSQL('AND', 0, 2),
);
$retval .= '
- ' . $LANG_MAPS_1['viewing_markers'] . ' ' . $map_name . '
';
+ ' . $LANG_MAPS_1['viewing_markers'] . ' ' . $map_name . '';
$retval .= '' . ADMIN_list('markers', 'MAPS_getListField_markersList',
- $header_arr, $text_arr, $query_arr, $defsort_arr) . '
';
+ $header_arr, $text_arr, $query_arr, $defsort_arr) . ' ';
return $retval;
}
/**
-* Get an individual field for the markers screen.
-*
-* @param string $fieldname Name of field (from the array, not the db)
-* @param mixed $fieldvalue Value of the field
-* @param array $A Array of all fields from the database
-* @param array $icon_arr System icon array
-* @param object $EntryList This entry list object
-* @return string HTML for field display in the table
-*/
+ * Get an individual field for the markers screen.
+ *
+ * @param string $fieldname Name of field (from the array, not the db)
+ * @param mixed $fieldvalue Value of the field
+ * @param array $A Array of all fields from the database
+ * @param array $icon_arr System icon array
+ * @param object $EntryList This entry list object
+ * @return string HTML for field display in the table
+ */
function MAPS_getListField_markersList($fieldname, $fieldvalue, $A, $icon_arr)
{
global $_CONF, $_MAPS_CONF, $LANG_ADMIN, $LANG_MAPS_1, $LANG_STATIC, $_TABLES;
- switch($fieldname) {
+ switch ($fieldname) {
case "name":
- $map_title = ucwords(strtolower(stripslashes ($A['name'])));
+ $map_title = ucwords(strtolower(stripslashes($A['name'])));
$url = $_MAPS_CONF['site_url'] .
- '/markers.php?mode=show&mkid=' . $A['mkid'] . '&mid=' . $A['mid'];
+ '/markers.php?mode=show&mkid=' . $A['mkid'] . '&mid=' . $A['mid'];
$retval = COM_createLink($map_title, $url);
break;
- case "city":
- $city = ucwords(strtolower(stripslashes ($A['city'])));
+ case "city":
+ $city = ucwords(strtolower(stripslashes($A['city'])));
$retval = $city;
break;
default:
$retval = stripslashes($fieldvalue);
break;
}
+
return $retval;
}
-function MAPS_setGeoLocation ()
+function MAPS_setGeoLocation()
{
global $_CONF, $_TABLES, $_MAPS_CONF;
-
- $sql = "SELECT info.location
+
+ $sql = "SELECT info.location
FROM {$_TABLES['userinfo']} AS info
WHERE info.location <> ''
";
-
- $locations = DB_query($sql);
-
- $nRows = DB_numRows($locations);
-
- for ( $i=0; $i < $nRows; $i++ ) {
+
+ $locations = DB_query($sql);
+
+ $nRows = DB_numRows($locations);
+
+ for ($i = 0; $i < $nRows; $i++) {
$geo = DB_fetchArray($locations);
- MAPS_getDBCoords($gid, $geo['location'], $lat, $lng) ;
- }
-
- return;
+ MAPS_getDBCoords($gid, $geo['location'], $lat, $lng);
+ }
+
+ return;
}
-function MAPS_displayEventsMap ($output=true, $event_id='')
+function MAPS_displayEventsMap($output = true, $event_id = '')
{
- global $_TABLES, $_CONF, $_MAPS_CONF, $LANG_MAPS_1, $LANG_CAL_1;
+ global $_TABLES, $_CONF, $_MAPS_CONF, $LANG_MAPS_1, $LANG_CAL_1;
$retval = '';
-
- //map settings
- $res = DB_query("SELECT * FROM {$_TABLES['maps_maps']} WHERE 1=1 LIMIT 1");
-
- //event map is set on mid=1.
- //TODO change this
- $A = DB_fetchArray($res);
-
- $T = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
- if ($output) {
- $T->set_file('page', 'map_autotag.thtml');
- } else {
- $T->set_file('page', 'map_only_script.thtml');
- }
- $T->set_var('mid', 'events');
- $T->set_var('name', $LANG_MAPS_1['events_map']);
- $T->set_var('description', '' . $LANG_MAPS_1['info_events_map'] . '
');
-
- $T->set_var('header', '');
- $T->set_var('footer', '');
-
- //address from global map
- $T->set_var('address', addslashes($A['geo']));
- $lat = str_replace(",",".",$A['lat']);
- $lng = str_replace(",",".",$A['lng']);
-
- $T->set_var('map_type', $_MAPS_CONF['global_type']);
- $T->set_var('map_width', $_MAPS_CONF['global_width']);
-
-
- $jsmarkers = 'var markers = [];';
- if ($event_id == '') {
- if ($lat == '') $lat = 0;
- if ($lng == '') $lng = 0;
- $T->set_var('lat', $lat);
- $T->set_var('lng', $lng);
+ //map settings
+ $res = DB_query("SELECT * FROM {$_TABLES['maps_maps']} WHERE 1=1 LIMIT 1");
+
+ //event map is set on mid=1.
+ //TODO change this
+ $A = DB_fetchArray($res);
+
+ $T = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
+ if ($output) {
+ $T->set_file('page', 'map_autotag.thtml');
+ } else {
+ $T->set_file('page', 'map_only_script.thtml');
+ }
+ $T->set_var('mid', 'events');
+ $T->set_var('name', $LANG_MAPS_1['events_map']);
+ $T->set_var('description', '' . $LANG_MAPS_1['info_events_map'] . '
');
+
+ $T->set_var('header', '');
+ $T->set_var('footer', '');
+
+ //address from global map
+ $T->set_var('address', addslashes($A['geo']));
+ $lat = str_replace(",", ".", $A['lat']);
+ $lng = str_replace(",", ".", $A['lng']);
+
+ $T->set_var('map_type', $_MAPS_CONF['global_type']);
+ $T->set_var('map_width', $_MAPS_CONF['global_width']);
+
+
+ $jsmarkers = 'var markers = [];';
+
+ if ($event_id == '') {
+ if ($lat == '') $lat = 0;
+ if ($lng == '') $lng = 0;
+ $T->set_var('lat', $lat);
+ $T->set_var('lng', $lng);
$T->set_var('zoom', $_MAPS_CONF['global_zoom']);
- $T->set_var('map_height', $_MAPS_CONF['global_height']);
-
- //select all coming events
- $result = DB_query("SELECT * FROM {$_TABLES['events']} WHERE TO_DAYS(dateend) >= TO_DAYS(NOW()) ");
- } else {
- //TODO make this configurable
+ $T->set_var('map_height', $_MAPS_CONF['global_height']);
+
+ //select all coming events
+ $result = DB_query("SELECT * FROM {$_TABLES['events']} WHERE TO_DAYS(dateend) >= TO_DAYS(NOW()) ");
+ } else {
+ //TODO make this configurable
$T->set_var('zoom', 8);
- $T->set_var('map_height', '300px');
-
- $result = DB_query("SELECT * FROM {$_TABLES['events']} WHERE eid='$event_id'");
- }
+ $T->set_var('map_height', '300px');
- $nrows = DB_numRows($result);
-
- if ($nrows > 0) {
-
- for ($i = 0;$i < $nrows; $i++) {
-
- $B = DB_fetchArray($result);
-
- $access = SEC_hasAccess($B['owner_id'],$B['group_id'],$B['perm_owner'],$B['perm_group'],$B['perm_members'],$B['perm_anon']);
-
- if ($access > 0 && $B['location']!='') {
-
- //markers
- $marker['mkid'] = $B['eid'];
- $marker['hidden'] = 0;
- $marker['active'] = 1;
- $marker['name'] = $B['title'];
-
- //start and end time
- $thestart = COM_getUserDateTimeFormat($B['datestart'] . ' ' . $B['timestart']);
+ $result = DB_query("SELECT * FROM {$_TABLES['events']} WHERE eid='$event_id'");
+ }
+
+ $nrows = DB_numRows($result);
+
+ if ($nrows > 0) {
+
+ for ($i = 0; $i < $nrows; $i++) {
+
+ $B = DB_fetchArray($result);
+
+ $access = SEC_hasAccess($B['owner_id'], $B['group_id'], $B['perm_owner'], $B['perm_group'], $B['perm_members'], $B['perm_anon']);
+
+ if ($access > 0 && $B['location'] != '') {
+
+ //markers
+ $marker['mkid'] = $B['eid'];
+ $marker['hidden'] = 0;
+ $marker['active'] = 1;
+ $marker['name'] = $B['title'];
+
+ //start and end time
+ $thestart = COM_getUserDateTimeFormat($B['datestart'] . ' ' . $B['timestart']);
$theend = COM_getUserDateTimeFormat($B['dateend'] . ' ' . $B['timeend']);
- if ($B['allday'] == 0) {
- $event_start = $LANG_MAPS_1['from_cal'] . ' ' . $thestart[0];
- $event_end = ' ' . $LANG_MAPS_1['to_cal'] . ' ' . $theend[0];
- if ($thestart[0] == $theend[0]) $event_end = '';
- } else {
- $event_start = $LANG_MAPS_1['from_cal'] . ' ' . strftime($_CONF['shortdate'], $thestart[1]);
- $event_end = ' ' . $LANG_MAPS_1['to_cal'] . ' ' . strftime($_CONF['shortdate'], $theend[1]);
- if ($thestart[1] == $theend[1]) {
- $event_start = $LANG_MAPS_1['from_cal'] . ' ' . strftime($_CONF['shortdate'], $thestart[1]);
- $event_end = '';
- }
- }
-
- if ($event_id == '') $marker['description'] = '