Skip to content

Commit ec39528

Browse files
committed
Added "Select Place" functionality to batchmanagement.
1 parent 391c6bc commit ec39528

1 file changed

Lines changed: 48 additions & 5 deletions

File tree

admin/admin_batchmanager.php

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,71 @@ function osm_perform_batch_manager_prefilters($filter_sets, $prefilter)
6161
add_event_handler('loc_end_element_set_global', 'osm_loc_end_element_set_global');
6262
function osm_loc_end_element_set_global()
6363
{
64-
global $template, $conf;
64+
global $template, $conf, $prefixeTable;
65+
define('osm_place_table', $prefixeTable.'osm_places');
66+
// Save location, eg Place
67+
$list_of_places = array();
68+
$available_places = array();
69+
$place_options = array();
70+
$query = '
71+
SELECT id, name, latitude, longitude
72+
FROM '.osm_place_table.'
73+
;';
74+
$result = pwg_query($query);
75+
// JS for the template
76+
while ($row = pwg_db_fetch_assoc($result))
77+
{
78+
$list_of_places[$row['id']] = array($row['name'], $row['latitude'], $row['longitude']);
79+
$available_places[$row['id']] = $row['name'];
80+
$place_options[] = '<option value="' . $row['id'] . '">' . $row['name'] . '</options>';
81+
}
82+
$jsplaces = "\nvar arr_places = ". json_encode($list_of_places) .";\n";
6583

6684
$batch_global_height = isset($conf['osm_conf']['batch']['global_height']) ? $conf['osm_conf']['batch']['global_height'] : '200';
6785
$template->append('element_set_global_plugins_actions',
6886
array('ID' => 'openstreetmap', 'NAME'=>l10n('OSM GeoTag'), 'CONTENT' => '
6987
<label>'.l10n('Latitude').' (-90=S to 90=N)
70-
<input type="text" size="8" name="osmlat">
88+
<input type="text" size="8" id="osmlat" name="osmlat">
7189
</label>
7290
<label>'.l10n('Longitude').' (-180=W to 180=E)
73-
<input type="text" size="9" name="osmlon">
91+
<input type="text" size="9" id="osmlon" name="osmlon">
92+
</label>
7493
</label> (Empty values will erase coordinates)
94+
<label>Saved Places:
95+
<select id="osmplaces" name="osmplaces" >
96+
<option value="NULL">--</option>
97+
'. implode("\n", $place_options) . '
98+
</select>
7599
<style type="text/css"> .map1 { height: '. $batch_global_height .'px !important; width:100% !important; margin: 5px; } </style>
76100
<script src="plugins/piwigo-openstreetmap/leaflet/qleaflet.jquery.js"></script>
77101
<div class="osm-map1 map1"></div>
78102
<script>
79-
$(document).ready(function() {
103+
$(document).ready(function() {' . $jsplaces . '
104+
var map;
80105
$("#permitAction").on("change", function (e) {
81106
var optionSelected = $("option:selected", this);
82107
if ("openstreetmap" == optionSelected.val()) {
83-
$(".osm-map1").qleaflet();
108+
map = $(".osm-map1").qleaflet();
109+
map.click(function(a,b,c) {
110+
$("#osmplaces").val("NULL");
111+
});
84112
}
85113
});
114+
$("#osmplaces").change(function(){
115+
var select = $("#osmplaces").val();
116+
var lat_elem = $("#osmlat");
117+
var lon_elem = $("#osmlon");
118+
if (select == "NULL")
119+
{
120+
lat_elem.val(0);
121+
lon_elem.val(0);
122+
}
123+
else
124+
{
125+
lat_elem.val(arr_places[select][1]);
126+
lon_elem.val(arr_places[select][2]);
127+
}
128+
});
86129
});
87130
</script>
88131
'));

0 commit comments

Comments
 (0)