Skip to content

Commit 7804564

Browse files
committed
More unify code photo_edit
1 parent 0112c23 commit 7804564

2 files changed

Lines changed: 83 additions & 94 deletions

File tree

admin/admin_photo.php

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
)
8989
);
9090

91+
include_once( dirname(__FILE__) .'/../include/functions_map.php');
92+
9193
// Retrieving direct information about picture
9294
$query = 'SELECT * FROM '.IMAGES_TABLE.' WHERE id = '.$_GET['image_id'].';';
9395
$picture = pwg_db_fetch_assoc(pwg_query($query));
@@ -104,42 +106,21 @@
104106
$attrimagery = isset($conf['osm_conf']['map']['attrimagery']) ? $conf['osm_conf']['map']['attrimagery'] : 'false';
105107
$attrmodule = isset($conf['osm_conf']['map']['attrplugin']) ? $conf['osm_conf']['map']['attrplugin'] : 'false';
106108

107-
// Load baselayerURL
108-
// Key1 BC9A493B41014CAABB98F0471D759707
109-
if ($baselayer == 'mapnik') $baselayerurl = 'http://tile.openstreetmap.org/{z}/{x}/{y}.png';
110-
else if($baselayer == 'mapquest') $baselayerurl = 'http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png';
111-
else if($baselayer == 'cloudmade') $baselayerurl = 'http://{s}.tile.cloudmade.com/7807cc60c1354628aab5156cfc1d4b3b/997/256/{z}/{x}/{y}.png';
112-
else if($baselayer == 'mapnikde') $baselayerurl = 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png';
113-
else if($baselayer == 'mapnikfr') $baselayerurl = 'http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png';
114-
else if($baselayer == 'blackandwhite') $baselayerurl = 'http://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png';
115-
else if($baselayer == 'mapnikhot') $baselayerurl = 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png';
116-
else if($baselayer == 'mapquestaerial') $baselayerurl = 'http://oatile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg';
117-
else if($baselayer == 'custom') $baselayerurl = $custombaselayerurl;
118-
119-
include(dirname(__FILE__)."/../include/functions_map.php");
120-
$attribution = osmcopyright($attrleaflet, $attrimagery, $attrmodule, $baselayer, $custombaselayer);
121-
122109
if ($lat == 0 and $lon == 0) { $zoom = 2; }
123110

124-
// Generate Javascript
125-
// Override configuration due to the use of leaflet-providers.js
126-
// ----------------------------------------
127-
$js = "\nvar map = L.map('map', { 'zoomControl': false, editInOSMControlOptions: { editors: ['id'] }, }).setView([".$lat.", ".$lon."], ".$zoom.");
128-
129-
L.tileLayer('".$baselayerurl."', { maxZoom: 18 }).addTo(map);
130-
L.control.scale().addTo(map);
131-
map.addControl(L.control.zoom({position: 'topleft'}));
111+
$local_conf = array();
112+
$local_conf['contextmenu'] = 'false';
113+
$local_conf['control'] = true;
114+
$local_conf['img_popup'] = false;
115+
$local_conf['popup'] = 2;
116+
$local_conf['center_lat'] = $lat;
117+
$local_conf['center_lng'] = $lon;
118+
$local_conf['zoom'] = $zoom;
119+
$local_conf['editor'] = true;
132120

133-
L.marker([".$lat.", ".$lon."]).addTo(map)
134-
.bindPopup('".addslashes(render_element_name($picture))."').openPopup();
121+
$js_data = array(array($lat, $lon, null, null, null, null, null, null));
135122

136-
/* BEGIN leaflet-providers
137-
var baseLayers = ['OpenStreetMap.Mapnik', 'OpenStreetMap.BlackAndWhite', 'OpenStreetMap.DE', 'OpenStreetMap.HOT', 'MapQuestOpen.OSM', 'MapQuestOpen.Aerial', 'Stamen.Watercolor'],
138-
overlays = [''];
139-
140-
L.control.layers.provided(baseLayers, overlays).addTo(map);
141-
END leaflet-providers */
142-
\n";
123+
$js = osm_get_js($conf, $local_conf, $js_data);
143124

144125
$template->assign(array(
145126
'PWG_TOKEN' => get_pwg_token(),
@@ -153,3 +134,5 @@
153134
));
154135

155136
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
137+
138+
?>

include/functions_map.php

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -300,90 +300,96 @@ function osm_get_js($conf, $local_conf, $js_data)
300300
'10' => 'ImgIcon'
301301
);
302302

303+
$editor = isset($local_conf['editor']) ? "editInOSMControlOptions: { editors: ['id'] }, " : '';
304+
303305
// Create the map and get a new map instance attached and element with id="tile-map"
304306
$js .= "\nvar Url = '".$baselayerurl."',
305307
Attribution = '".$attribution."',
306308
TileLayer = new L.TileLayer(Url, {maxZoom: 18, noWrap: ".$nowarp.", attribution: Attribution}),
307309
latlng = new L.LatLng(".$local_conf['center_lat'].", ".$local_conf['center_lng'].");\n";
308-
$js .= "var " . $divname . " = new L.Map('" . $divname . "', {" . $worldcopyjump . ", center: latlng, zoom: ".$local_conf['zoom'].", layers: [TileLayer], contextmenu: " . $local_conf['contextmenu'] . "});\n";
310+
$js .= "var " . $divname . " = new L.Map('" . $divname . "', {" . $worldcopyjump . ", center: latlng, ".$editor." zoom: ".$local_conf['zoom'].", layers: [TileLayer], contextmenu: " . $local_conf['contextmenu'] . "});\n";
309311
$js .= $divname . ".attributionControl.setPrefix('');\n";
310312
$js .= "var MarkerClusterList=[];\n";
311313
$js .= "if (typeof L.MarkerClusterGroup === 'function')\n";
312314
$js .= " var markers = new L.MarkerClusterGroup();\n";
313315
if ($local_conf['control'] === true)
314316
{
315-
$js .= "L.control.scale().addTo(" . $divname . ");\n";
317+
$js .= "\nL.control.scale().addTo(" . $divname . ");\n";
316318
}
317-
// Icons
318-
$js .= "
319-
320-
var PlgIcon = L.Icon.extend({
321-
options: {
322-
shadowUrl: 'plugins/piwigo-openstreetmap/leaflet/images/marker-shadow.png',
323-
iconSize: [25, 41],
324-
shadowSize: [41, 41],
325-
iconAnchor: [21, 21],
326-
popupAnchor: [-10, -10]
327-
}
328-
});
329-
330-
var LeafIcon = L.Icon.extend({
331-
options: {
332-
shadowUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-shadow.png',
333-
iconSize: [38, 95],
334-
shadowSize: [50, 64],
335-
iconAnchor: [22, 94],
336-
shadowAnchor: [4, 62],
337-
popupAnchor: [-3, -76]
338-
}
339-
});
340-
341-
var MapIcon = L.Icon.extend({
342-
options: {
343-
shadowUrl: 'plugins/piwigo-openstreetmap/leaflet/images/mapicons-shadow.png',
344-
iconSize: [32, 37],
345-
shadowSize: [51, 37],
346-
iconAnchor: [19, 38],
347-
shadowAnchor: [4, 33],
348-
popupAnchor: [-2, -33]
349-
}
350-
});
351-
";
352319

353-
if ($pinid == 9)
320+
if ($pinid >= 2)
354321
{
355-
$js .= "\nvar CustomIcon = L.Icon.extend({
322+
// Icons
323+
$js .= "
324+
325+
var PlgIcon = L.Icon.extend({
356326
options: {
357-
iconUrl: ".$pinpath.",
358-
shadowUrl: ".$pinshadowpath.",
359-
iconSize: [".$pinsize."],
360-
shadowSize: [".$pinshadowsize."],
361-
iconAnchor: [".$pinoffset."],
362-
shadowAnchor: [".$pinoffset."],
363-
popupAnchor: [".$pinpopupoffset."]
327+
shadowUrl: 'plugins/piwigo-openstreetmap/leaflet/images/marker-shadow.png',
328+
iconSize: [25, 41],
329+
shadowSize: [41, 41],
330+
iconAnchor: [21, 21],
331+
popupAnchor: [-10, -10]
364332
}
365-
});";
366-
}
333+
});
367334
368-
$js .= "\nvar ImgIcon = L.Icon.extend({
369-
options: {
370-
iconSize: [42, 42],
371-
iconAnchor: [21, 21],
372-
popupAnchor: [0,-21]
335+
var LeafIcon = L.Icon.extend({
336+
options: {
337+
shadowUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-shadow.png',
338+
iconSize: [38, 95],
339+
shadowSize: [50, 64],
340+
iconAnchor: [22, 94],
341+
shadowAnchor: [4, 62],
342+
popupAnchor: [-3, -76]
343+
}
344+
});
345+
346+
var MapIcon = L.Icon.extend({
347+
options: {
348+
shadowUrl: 'plugins/piwigo-openstreetmap/leaflet/images/mapicons-shadow.png',
349+
iconSize: [32, 37],
350+
shadowSize: [51, 37],
351+
iconAnchor: [19, 38],
352+
shadowAnchor: [4, 33],
353+
popupAnchor: [-2, -33]
354+
}
355+
});
356+
";
357+
358+
if ($pinid == 9)
359+
{
360+
$js .= "\nvar CustomIcon = L.Icon.extend({
361+
options: {
362+
iconUrl: ".$pinpath.",
363+
shadowUrl: ".$pinshadowpath.",
364+
iconSize: [".$pinsize."],
365+
shadowSize: [".$pinshadowsize."],
366+
iconAnchor: [".$pinoffset."],
367+
shadowAnchor: [".$pinoffset."],
368+
popupAnchor: [".$pinpopupoffset."]
369+
}
370+
});";
373371
}
374-
});
375372

376-
var PlgIconGreen = new PlgIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/marker-green.png'}),
377-
PlgIconRed = new PlgIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/marker-red.png'});
373+
$js .= "\nvar ImgIcon = L.Icon.extend({
374+
options: {
375+
iconSize: [42, 42],
376+
iconAnchor: [21, 21],
377+
popupAnchor: [0,-21]
378+
}
379+
});
380+
381+
var PlgIconGreen = new PlgIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/marker-green.png'}),
382+
PlgIconRed = new PlgIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/marker-red.png'});
378383
379-
var LeafIconGreen = new LeafIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-green.png'}),
380-
LeafIconRed = new LeafIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-red.png'}),
381-
LeafIconOrange = new LeafIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-orange.png'});
384+
var LeafIconGreen = new LeafIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-green.png'}),
385+
LeafIconRed = new LeafIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-red.png'}),
386+
LeafIconOrange = new LeafIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/leaf-orange.png'});
382387
383-
var MapIconBlue = new MapIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/mapicons-blue.png'}),
384-
MapIconGreen = new MapIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/mapicons-green.png'});
388+
var MapIconBlue = new MapIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/mapicons-blue.png'}),
389+
MapIconGreen = new MapIcon({iconUrl: 'plugins/piwigo-openstreetmap/leaflet/images/mapicons-green.png'});
385390
386-
";
391+
";
392+
}
387393

388394
$js .= "for (var i = 0; i < addressPoints.length; i++) {
389395
var a = addressPoints[i];

0 commit comments

Comments
 (0)