-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavventura_dettaglio_map_elenco.php
337 lines (301 loc) · 10.9 KB
/
avventura_dettaglio_map_elenco.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
$cellSize=100;
$query="SELECT * FROM mephit_map_group WHERE fk_avventura=".$_GET[id]." ORDER BY nome";
$result=mysql_query($query);
$groups_rows=array();
$groups_parents=array();
$groups_tree=array();
while($row=mysql_fetch_assoc($result)){
$groups_rows[$row[id]]=$row;
if(is_null($row[parent_id])){
$groups_tree[$row[id]]=array();
}else{
$groups_parents[$row[parent_id]][]=$row[id];
}
}
function walkTree(&$siblings,&$parents){
foreach(array_keys($siblings) AS $s){
if(isset($parents[$s])){
foreach($parents[$s] as $c)$siblings[$s][$c]=array();
unset($parents[$s]);
walkTree($siblings[$s],$parents);
}
}
}
walkTree($groups_tree,$groups_parents);
unset($groups_parents);
$images_rows=array();
$images_grids=array();
if(count($groups_rows)>0){
$groups_id=array_keys($groups_tree);
$luogo=in_array($_GET[luogo],$groups_id)?$_GET[luogo]:$groups_id[0];
$zone=array_keys($groups_tree[$luogo]);
if(count($zone)){
$query="SELECT *
FROM mephit_map_image
WHERE fk_map_group IN (".implode(",",$zone).")
ORDER BY nome";
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result)){
$images_rows[$row[id]]=$row;
$images_grids[$row[fk_map_group]][$row[x]][$row[y]]=$row;
}
}
}
$BODY.='
<script>
var adventure_id="'.$_GET[id].'";
var user_id="'.$_SESSION[user_id].'";
var lang_delete="'.addslashes($_LANG[delete]).'";
var lang_edit="'.addslashes($_LANG[edit]).'";
</script>
<script src="js/map_elenco_hcontrol.js"></script>
<script src="js/map_elenco_vcontrol.js"></script>
<script src="js/map_elenco.js"></script>
<style>
#luoghi {padding-bottom:10px;}
#luoghi UL{list-style:none;margin:0;padding:0;}
#luoghi A{text-decoration:none;color:#fff;display:block;*width:100%;}
#luoghi A.sel{color:#C00000;background:#fff;}
#luoghi .del:hover,#luoghi .edit:hover,#luoghi .name:hover{text-decoration:underline;}
#luoghi SPAN{padding:4px;line-height:26px;}
</style>';
$BODY.='
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr valign="top">
<td width="10%" bgcolor="#C00000">
<form action="avventura_save.php" method="post" id="delluogo-form" style="display:none;">
<input type="hidden" name="what" value="'.$_GET[what].'">
<input type="hidden" name="id" value="'.$_GET[id].'">
<input type="hidden" name="luogo" value="'.$luogo.'">
<input type="hidden" name="act" value="delluogo">
<input type="hidden" name="idDel" id="delluogo-id">
</form>
<form action="avventura_save.php" method="post" id="editluogo-form" style="display:none;">
<input type="hidden" name="what" value="'.$_GET[what].'">
<input type="hidden" name="id" value="'.$_GET[id].'">
<input type="hidden" name="luogo" value="'.$luogo.'">
<input type="hidden" name="act" value="editluogo">
<input type="hidden" name="idEdit" id="editluogo-id">
<input type="hidden" name="nameEdit" id="editluogo-name">
</form>
<div id="luoghi">
<ul>';
$i=0;
foreach($groups_tree as $id=>$childs){
$g=$_GET;
$g[luogo]=$id;
$BODY.='<li>';
$BODY.='<a href="?'.http_build_query($g).'" id="luogo-'.$id.'"'.($luogo==$id?' class="sel"':'').'>';
$BODY.='<span class="del" id="luogo-del-'.$id.'" title="'.$_LANG[delete].'">×</span>';
$BODY.='<span class="name" id="luogo-name-'.$id.'" title="'.$_LANG[select].'">'.htmlspecialchars($groups_rows[$id][nome]).'</span>';
$BODY.='</a>';
$BODY.='</li>';
$i++;
}
$BODY.='
<li>
<a href="javascript:;" onclick="aggiungiLuogo();" style="color:#c00000;background:#fff;text-align:center;margin:0 20px;line-height:2em;">Aggiungi luogo</a>
<div id="aggiungiLuogo" style="display:none;padding:4px;">
<form action="avventura_save.php" method="post">
<input type="hidden" name="what" value="'.$_GET[what].'">
<input type="hidden" name="id" value="'.$_GET[id].'">
<input type="hidden" name="luogo" value="'.$luogo.'">
<input type="hidden" name="act" value="addluogo">
<input id="addluogo-name" name="name">
<input type="submit" value="'.$_LANG[add].'" />
<a href="javascript:annullaAggiungiLuogo();" style="display:inline;">'.$_LANG[cancel].'</a>
</form>
</div>
</li>
</ul>
</div>
</td>
<td width="90%"><div style="padding:10px 10px 10px 20px;">
<style>
.place_menu{
background:#c00000;line-height:26px;
}
.place_menu H3{
font-size:16px;
margin:0 0 1px 0;float:left;
padding:0 1em;
color:#000;background:#fff;
}
.place_menu UL{
float:left;padding:0;list-style:none;
margin:0 0 0 2px;
font-size:13px;
}
.place_menu LI{
float:left;padding-top:2px;
}
.place_menu A {
display:block;
padding:0 1em;
text-decoration:none;color:#fff;font-weight:normal !important;
}
.place_menu .sel A{
background:#fff;color:#c00000;
}
.group-save{
float:right;
}
.group-save a{
display:block;float:left;
text-decoration:underline;color:#fff;
}
.mapTab{font:bold 15px arial;}
.mapTab A{text-decoration:none;color:#fff;text-align:center;}
.hcontrol{height:19px;line-height:15px;margin-left:19px;}
.hcontrol A{display:block;float:left;height:15px;margin:2px 0;}
.hcontrol A:hover{opacity:0.5;-moz-opacity:0.5;filter: alpha(opacity=50);zoom:1;}
.hcontrol .add{width:40px;background:#080;}
.hcontrol .del{width:68px;background:#f00;}
.hcontrol .first{width:20px !important;}
.hcontrol .last{width:20px !important;}
.vcontrol{width:19px;}
.vcontrol A{display:block;width:15px;margin:0 2px;}
.vcontrol A:hover{opacity:0.5;-moz-opacity:0.5;filter: alpha(opacity=50);zoom:1;}
.vcontrol .add{height:40px;line-height:40px;background:#080;}
.vcontrol .del{height:68px;line-height:68px;background:#f00;}
.vcontrol .first{height:20px !important;line-height:20px !important;}
.vcontrol .last{height:20px !important;line-height:20px !important;}
.mapcell{width:108px;height:108px;}
.mapcell IMG{border:2px solid #fff;padding:2px;}
.addTop{border-top-color:#080 !important;}
.addBottom{border-bottom-color:#080 !important;}
.addLeft{border-left-color:#080 !important;}
.addRight{border-right-color:#080 !important;}
.delCell{background:#f00;}
.delCell IMG{opacity:0.5;-moz-opacity:0.5;filter: alpha(opacity=50);zoom:1;padding:0;border-width:4px;}
</style>
';
$i=0;
foreach($groups_tree as $id=>$childs){if($luogo==$id){
$BODY.='<div class="mapcontent'.($luogo==$id?'sel':'').'" id="content'.$id.'">';
$BODY.='<div style="float:right;">';
$BODY.='<a href="javascript:;" class="edit" id="luogo-edit-'.$id.'" title="'.$_LANG[edit].'">Modifica</a>';
$BODY.=' ';
$BODY.='<a href="javascript:;">Aggiungi area</a>';
$BODY.='</div>';
$BODY.='<script>
$("luogo-edit-'.$id.'").observe("click",observeLuoghi);
</script>';
$BODY.='<h2 id="group-'.$id.'-title" style="margin-top:0;">'.$groups_rows[$id][nome].'</h2>';
$BODY.='<p>'.$groups_rows[$id][note].'</p>';
foreach(array_keys($childs) as $M){
$BODY.='<div class="mapblock">';
$BODY.='<div style="margin:20px 0;text-align:left;">';
$BODY.='<div class="place_menu row">';
$BODY.='<div class="group-save">';
$BODY.='<a href="javascript:salvaGruppo('.$_GET[id].','.$M.','.$luogo.');">Salva</a>';
$BODY.=' ';
$BODY.='<a href="javascript:eliminaGruppo('.$M.');">Elimina</a>';
$BODY.='</div>';
$BODY.='<h3 id="group-'.$M.'-title">'.$groups_rows[$M][nome].'</h3>';
$BODY.='<ul id="optTabs-'.$M.'">';
$BODY.='<li class="tab sel"><a href="javascript:;">Mappa</a></li>';
$BODY.='<li class="tab"><a href="javascript:;">Descrizione</a></li>';
$BODY.='</ul>';
$BODY.='</div>';
$BODY.='</div>';
$BODY.='<div id="optCnt-'.$M.'">';
$BODY.='<div class="tabContent">';
$BODY.='<div class="mapTab">';
// inizio header
$BODY.='<div class="row hcontrol">';
for($i=0;$i<$groups_rows[$M][width];$i++){
if($i==0){
$BODY.='<a class="add first" href="javascript:;">+</a>';
}else{
$BODY.='<a class="add" href="javascript:;">+</a>';
}
$BODY.='<a class="del" href="javascript:;">-</a>';
if($i==$groups_rows[$M][width]-1){
$BODY.='<a class="add last" href="javascript:;">+</a>';
}
}
$BODY.='</div>';
// fine header
// inizio body
$BODY.='<div class="row">';
// inizio sx
$BODY.='<div class="col vcontrol">';
for($i=0;$i<$groups_rows[$M][height];$i++){
if($i==0){
$BODY.='<a class="add first" href="javascript:;">+</a>';
}else{
$BODY.='<a class="add" href="javascript:;">+</a>';
}
$BODY.='<a class="del" href="javascript:;">-</a>';
if($i==$groups_rows[$M][height]-1){
$BODY.='<a class="add last" href="javascript:;">+</a>';
}
}
$BODY.='</div>';
// fine sx
// inizio cx
$grid_rows=$groups_rows[$M][height];
$grid_cols=$groups_rows[$M][width];
$BODY.='<div class="col mapgrid" id="mapgrid-'.$M.'" style="width:'.(108*$grid_cols).'px;">';
for($r=0;$r<$grid_rows;$r++){
$BODY.='<div class="row">';
for($c=0;$c<$grid_cols;$c++){
$img=$images_grids[$M][$c][$r];
if($img["filename"]=="")$src=$GLOBALS[_MEPHIT][WWW_ROOT]."/images/mapcell_empty.jpg";
else $src=$_MEPHIT[WWW_ROOT].'/include/phpThumb/phpThumb.php?src='.rawurlencode($mapFolder.'/'.$img[filename]).'&w='.$cellSize.'&h='.$cellSize.'&far=1&bg=ffffff';
$BODY.='<div class="col mapcell">';
$BODY.='<a href="?id='.$avv[id_avventura].'&what=map&luogo='.$luogo.'&item='.$img[id].'">';
$BODY.='<img id="map-'.$img[id].'" src="'.$src.'" class="col'.$c.' row'.$r.'">';
$BODY.='</a>';
$BODY.='</div>';
}
$BODY.='</div>';
}
$BODY.='</div>';
// fine cx
// inizio dx
$BODY.='<div class="col vcontrol">';
for($i=0;$i<$groups_rows[$M][height];$i++){
if($i==0){
$BODY.='<a class="add first" href="javascript:;">+</a>';
}else{
$BODY.='<a class="add" href="javascript:;">+</a>';
}
$BODY.='<a class="del" href="javascript:;">-</a>';
if($i==$groups_rows[$M][height]-1){
$BODY.='<a class="add last" href="javascript:;">+</a>';
}
}
$BODY.='</div>';
// fine dx
$BODY.='</div>';
// fine body
// inizio footer
$BODY.='<div class="row hcontrol">';
for($i=0;$i<$groups_rows[$M][width];$i++){
if($i==0){
$BODY.='<a class="add first" href="javascript:;">+</a>';
}else{
$BODY.='<a class="add" href="javascript:;">+</a>';
}
$BODY.='<a class="del" href="javascript:;">-</a>';
if($i==$groups_rows[$M][width]-1){
$BODY.='<a class="add last" href="javascript:;">+</a>';
}
}
$BODY.='</div>';
// fine footer
$BODY.='</div>';
$BODY.='</div>';
$BODY.='<div class="tabContent" style="display:none;">';
$BODY.=$groups_rows[$M][note];
$BODY.='</div>';
$BODY.='</div>';
$BODY.='</div>';
$BODY.='<script>new jTab("optTabs-'.$M.'","optCnt-'.$M.'");</script>';
$i++;
}
}}
$BODY.='</div></td></tr></table>';
?>