Gino Gmaps  1.0.1
Modulo di gestione di mappe interattive per Gino CMS
 Tutto Strutture dati File Funzioni Variabili Gruppi Pagine
class_gmaps.php
Vai alla documentazione di questo file.
1 <?php
21 require_once('class.gmapsMap.php');
22 require_once('class.gmapsPointCtg.php');
23 require_once('class.gmapsPoint.php');
24 require_once('class.gmapsService.php');
25 require_once('class.gmapsPolylineCtg.php');
26 require_once('class.gmapsPolyline.php');
27 require_once('class.gmapsPolygonCtg.php');
28 require_once('class.gmapsPolygon.php');
29 require_once('class.gmapsImage.php');
30 require_once('class.gmapsCollection.php');
31 require_once('class.gmapsCollectionImage.php');
32 require_once('class.gmapsVideo.php');
33 require_once('class.gmapsEvent.php');
34 require_once('class.gmapsAttachment.php');
35 require_once('class.gmapsMarker.php');
36 
50 class gmaps extends AbstractEvtClass {
51 
55  protected $_data_dir;
56 
60  protected $_data_www;
61 
65  private $_optionsValue;
66 
70  private $_title;
71 
75  private $_default_map;
76 
80  private $_list_fields;
81 
85  private $_options;
86 
91 
95  private $_tbl_map = 'gmaps_map';
96 
100  private $_tbl_map_point = 'gmaps_map_point';
101 
105  private $_tbl_map_polyline = 'gmaps_map_polyline';
106 
110  private $_tbl_map_polygon = 'gmaps_map_polygon';
111 
115  private $_tbl_point_ctg = 'gmaps_point_ctg';
116 
120  private $_tbl_point = 'gmaps_point';
121 
125  private $_tbl_point_image = 'gmaps_point_image';
126 
130  private $_tbl_point_video = 'gmaps_point_video';
131 
135  private $_tbl_point_event = 'gmaps_point_event';
136 
140  private $_tbl_point_attachment = 'gmaps_point_attachment';
141 
145  private $_tbl_point_service = 'gmaps_point_service';
146 
150  private $_tbl_point_point_ctg = 'gmaps_point_point_ctg';
151 
155  private $_tbl_polyline_ctg = 'gmaps_polyline_ctg';
156 
160  private $_tbl_polyline = 'gmaps_polyline';
161 
165  private $_tbl_polyline_polyline_ctg = 'gmaps_polyline_polyline_ctg';
166 
170  private $_tbl_polyline_point = 'gmaps_polyline_point';
171 
172  /*
173  * @brief Nome della tabella che contiene le categorie delle aree
174  */
175  private $_tbl_polygon_ctg = 'gmaps_polygon_ctg';
176 
180  private $_tbl_polygon = 'gmaps_polygon';
181 
185  private $_tbl_polygon_polygon_ctg = 'gmaps_polygon_polygon_ctg';
186 
190  private $_tbl_polygon_point = 'gmaps_polygon_point';
191 
195  private $_tbl_opt = 'gmaps_opt';
196 
200  private $_tbl_usr = 'gmaps_usr';
201 
205  private $_action;
206 
210  private $_block;
211 
216 
221 
225  private $_icon_event;
226 
230  private $_icon_image;
231 
235  private $_icon_video;
236 
241 
246 
251 
256 
257 
265  function __construct($mdlId){
266 
267  parent::__construct();
268 
269  $this->_instance = $mdlId;
270  $this->_instanceName = $this->_db->getFieldFromId($this->_tbl_module, 'name', 'id', $this->_instance);
271  $this->_instanceLabel = $this->_db->getFieldFromId($this->_tbl_module, 'label', 'id', $this->_instance);
272 
273  $this->_data_dir = $this->_data_dir.$this->_os.$this->_instanceName;
274  $this->_data_www = $this->_data_www."/".$this->_instanceName;
275 
276  $this->setAccess();
277 
278  // Opzioni di default
279  $this->_optionsValue = array(
280  'title'=>_("Mappe interattive"),
281  'list_fields'=>'label,categories'
282  );
283 
284  $this->_title = htmlChars($this->setOption('title', array('value'=>$this->_optionsValue['title'], 'translation'=>true)));
285  $this->_default_map = htmlChars($this->setOption('default_map', array('value'=>'', 'translation'=>false)));
286  $this->_list_fields = $this->setOption('list_fields', array('value'=>$this->_optionsValue['list_fields'], 'translation'=>false));
287 
288  $list_fields_exp = _("Inserire i campi separati da virgole<br/>Campi disponibili:<ul>
289  <li><b>label</b>: etichetta (punti e percorsi)</li>
290  <li><b>categories</b>: categorie (punti e percorsi)</li>
291  <li><b>address</b>: indirizzo (punti)</li>
292  <li><b>cap</b>: cap (punti)</li>
293  <li><b>city</b>: città (punti)</li>
294  <li><b>services</b>: servizi (punti)</li>
295  </ul>");
296  $this->_options = new options($this->_className, $this->_instance);
297  $this->_optionsLabels = array(
298  "title"=>array('label'=>_("Titolo del modulo"), 'value'=>$this->_optionsValue['title'], 'required'=>false),
299  "default_map"=>array('label'=>array(_("Mappa di default"), _("ID della mappa da mostrare nella vista quando non viene passato un id tramite GET")), 'value'=>'', 'required'=>false),
300  "list_fields"=>array('label'=>array(_("Campi mostrati nelle liste (mappa full, itinerari, aree)"), $list_fields_exp), 'value'=>$this->_optionsValue['list_fields'], 'required'=>false)
301  );
302 
303  $this->_action = cleanVar($_REQUEST, 'action', 'string', '');
304  $this->_block = cleanVar($_REQUEST, 'block', 'string', '');
305 
306  $this->_list_point_items = 15;
307 
308  $this->_icon_attachment = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_attachment.gif\" alt=\""._("allegati")."\" title=\""._("allegati")."\" />";
309  $this->_icon_event = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_event.gif\" alt=\""._("eventi")."\" title=\""._("eventi")."\" />";
310  $this->_icon_image = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_image.gif\" alt=\""._("immagini")."\" title=\""._("immagini")."\" />";
311  $this->_icon_video = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_video.gif\" alt=\""._("video")."\" title=\""._("video")."\" />";
312  $this->_icon_collection = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_collection.gif\" alt=\""._("collezioni")."\" title=\""._("collezioni")."\" />";
313  $this->_icon_map_element = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_map_element.gif\" alt=\""._("elementi mappa")."\" title=\""._("elementi mappa")."\" />";
314  $this->_icon_polyline_points = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_map_element.gif\" alt=\""._("punti percorso")."\" title=\""._("punti percorso")."\" />";
315  $this->_icon_polygon_points = "<img class=\"icon_tooltip\" src=\"".$this->_class_img."/ico_map_element.gif\" alt=\""._("punti area")."\" title=\""._("punti percorso")."\" />";
316 
317  }
318 
326  public static function getClassElements() {
327 
328  return array("tables"=>array('gmaps_map', 'gmaps_map_point', 'gmaps_map_polyline', 'gmaps_point', 'gmaps_point_image', 'gmaps_point_video', 'gmaps_point_event', 'gmaps_point_attachment', 'gmaps_point_collection', 'gmaps_point_collection_image', 'gmaps_point_service', 'gmaps_point_point_ctg', 'gmaps_point_ctg', 'gmaps_polyline', 'gmaps_polyline_point', 'gmaps_polyline_ctg', 'gmaps_polyline_polyline_ctg', 'gmaps_polygon', 'gmaps_polygon_point', 'gmaps_polygon_ctg', 'gmaps_polygon_polygon_ctg', 'gmaps_service', 'gmaps_marker', 'gmaps_opt', 'gmaps_grp', 'gmaps_usr'),
329  "css"=>array('gmaps.css'),
330  "folderStructure"=>array(
331  CONTENT_DIR.OS.'gmaps'=>array(
332  "service"=>null,
333  "point_ctg"=>null,
334  "polyline_ctg"=>null,
335  "polygon_ctg"=>null,
336  "point"=>array(
337  'images'=>null,
338  'events'=>null,
339  'attachments'=>null,
340  'collections'=>array(
341  "images"=>null
342  )
343  )
344  )
345  )
346  );
347  }
348 
357  public function deleteInstance() {
358 
359  $this->accessGroup('');
360 
361  $res = true;
362 
363  $res = $res && gmapsMap::deleteInstance($this->_instance);
364  $res = $res && gmapsPoint::deleteInstance($this->_instance);
365  $res = $res && gmapsPointCtg::deleteInstance($this->_instance);
366  $res = $res && gmapsPolyline::deleteInstance($this->_instance);
367  $res = $res && gmapsPolylineCtg::deleteInstance($this->_instance);
368  $res = $res && gmapsService::deleteInstance($this->_instance);
369  $res = $res && gmapsMarker::deleteInstance($this->_instance);
370 
371  /*
372  * delete record and translation from the options' table
373  */
374  $opt_id = $this->_db->getFieldFromId($this->_tbl_opt, "id", "instance", $this->_instance);
375  language::deleteTranslations($this->_tbl_opt, $opt_id);
376 
377  $query = "DELETE FROM ".$this->_tbl_opt." WHERE instance='$this->_instance'";
378  $res = $res && $this->_db->actionquery($query);
379 
380  /*
381  * delete group users association
382  */
383  $query = "DELETE FROM ".$this->_tbl_usr." WHERE instance='$this->_instance'";
384  $res = $res && $this->_db->actionquery($query);
385 
386  /*
387  * delete css files
388  */
389  $classElements = $this->getClassElements();
390  foreach($classElements['css'] as $css) {
391  unlink(APP_DIR.OS.$this->_className.OS.baseFileName($css)."_".$this->_instanceName.".css");
392  }
393 
394  /*
395  * delete folder structure
396  */
397  foreach($classElements['folderStructure'] as $fld=>$fldStructure) {
398  $this->deleteFileDir($fld.OS.$this->_instanceName, true);
399  }
400 
401  return $res;
402  }
403 
414  public static function outputFunctions() {
415 
416  $list = array(
417  "view" => array("label"=>_("Visualizzazione mappa (aggiungere l'id della mappa: es. &id=1, di default viene caricata la mappa impostata da opzioni)"), "role"=>'1'),
418  "viewFull" => array("label"=>_("Visualizzazione mappa con lista elementi (aggiungere l'id della mappa: es. &id=1, di default viene caricata la mappa impostata da opzioni)"), "role"=>'1')
419  );
420 
421  return $list;
422  }
423 
430  public function instanceName() {
431 
432  return $this->_instanceName;
433 
434  }
435 
444  public function view() {
445 
446  $this->setAccess($this->_access_base);
447 
448  $get_id = cleanVar($_GET, 'id', 'int', '');
449  $map_id = $get_id ? $get_id : $this->_default_map;
450  $map = new gmapsMap($map_id, $this);
451 
452  $registry = registry::instance();
453  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
454  $registry->addJs(SITE_WWW."/app/gmaps/markerclusterer_packed.js");
455  $registry->addJs(SITE_WWW."/app/gmaps/infobox.js");
456  $registry->addJs(SITE_WWW."/app/gmaps/MooComplete.js");
457  $registry->addJs(SITE_WWW."/app/gmaps/ProgressBar.js");
458  $registry->addJs(SITE_WWW."/app/gmaps/gmaps.js");
459  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
460  $registry->addCss(SITE_WWW."/app/gmaps/MooComplete.css");
461 
462  $buffer = '';
463 
464  $buffer .= "<section id=\"view_gmaps_".$this->_instanceName."\">";
465  $buffer .= $this->map($map);
466  $buffer .= "</section>";
467 
468  return $buffer;
469 
470  }
471 
480  public function viewFull() {
481 
482  $this->setAccess($this->_access_base);
483 
484  $get_id = cleanVar($_GET, 'id', 'int', '');
485  $map_id = $get_id ? $get_id : $this->_default_map;
486  $map = new gmapsMap($map_id, $this);
487 
488  $registry = registry::instance();
489  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
490  $registry->addJs(SITE_WWW."/app/gmaps/markerclusterer_packed.js");
491  $registry->addJs(SITE_WWW."/app/gmaps/infobox.js");
492  $registry->addJs(SITE_WWW."/app/gmaps/MooComplete.js");
493  $registry->addJs(SITE_WWW."/app/gmaps/ProgressBar.js");
494  $registry->addJs(SITE_WWW."/app/gmaps/gmaps.js");
495  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
496  $registry->addCss(SITE_WWW."/app/gmaps/MooComplete.css");
497 
498  $buffer = '';
499 
500  $buffer .= "<section id=\"viewfull_gmaps_".$this->_instanceName."\">";
501  $buffer .= $this->map($map, true);
502  $buffer .= "</section>";
503 
504  return $buffer;
505 
506  }
507 
514  public function iframeMap() {
515 
516  $this->setAccess($this->_access_base);
517 
518  $id = cleanVar($_GET, 'id', 'int', '');
519  $map = new gmapsMap($id, $this);
520 
521  $registry = registry::instance();
522  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
523  $registry->addJs(SITE_WWW."/app/gmaps/markerclusterer_packed.js");
524  $registry->addJs(SITE_WWW."/app/gmaps/infobox.js");
525  $registry->addJs(SITE_WWW."/app/gmaps/MooComplete.js");
526  $registry->addJs(SITE_WWW."/app/gmaps/ProgressBar.js");
527  $registry->addJs(SITE_WWW."/app/gmaps/gmaps.js");
528  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
529  $registry->addCss(SITE_WWW."/app/gmaps/MooComplete.css");
530 
531  $pub = new pub();
532 
533  $buffer = "<!DOCTYPE html>";
534  $buffer .= "<html lang=\"".LANG."\">\n";
535  $buffer .= "<head>\n";
536  $buffer .= "<meta charset=\"utf-8\" />\n";
537  $buffer .= "<title>".htmlChars($map->name)."</title>\n";
538  $buffer .= "<base href=\"".$pub->getUrl('root').SITE_WWW."/\" />\n";
539  $buffer .= $registry->variables('css');
540  $buffer .= $registry->variables('js');
541  $buffer .= "</head>\n";
542 
543  $buffer .= "<body style=\"background: transparent;\">\n";
544  $buffer .= "<section style=\"text-align:left; padding: 0; margin: 0; width:".$map->width."; height:".$map->height.";\">";
545  $buffer .= $this->map($map);
546  $buffer .= "</section>";
547  $buffer .= "</body>\n";
548  $buffer .= "</html>\n";
549 
550  echo $buffer;
551  exit;
552 
553  }
554 
563  private function map($map, $list = false) {
564 
565  $buffer = '';
566 
567  $gform = new Form('form_map', 'post', false, array('tblLayout'=>false));
568 
569  $buffer .= "<nav id=\"gmaps_nav\">";
570  $buffer .= "<ul>";
571  $buffer .= "<li>";
572  $buffer .= _("Help");
573  $buffer .= "<ul>";
574  $buffer .= "<li data-menu=\"maphelp\">"._("<p>Utilizzare la voce 'Mappa' per modificare il tipo di mappa.<br/>Utilizzare il campo di testo per ricercare punti di interesse, percorsi o aree nella mappa, iniziando a digitare le chiavi di ricerca verranno visualizzati dei suggerimenti, selezionare quello desiderato e premere il bottone 'cerca'. Per tornare alla visualizzazione completa premere il bottone 'tutti'. <br />Se si desidera filtrare per categoria utlizzare l'apposito menu a tendina.</p>")."</li>";
575  $buffer .= "</ul>";
576  $buffer .= "</li>";
577  $buffer .= "<li>";
578  $buffer .= _("Mappa");
579  $buffer .= "<ul>";
580  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"hybrid\">"._("Ibrida")."</li>";
581  $buffer .= "<li class=\"link selected\" data-menu=\"maptype\" data-type=\"roadmap\">"._("roadmap")."</li>";
582  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"satellite\">"._("satellite")."</li>";
583  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"terrain\">"._("terrain")."</li>";
584  $buffer .= "</ul>";
585  $buffer .= "</li>";
586  $buffer .= "<li>";
587  $buffer .= "<input type=\"text\" name=\"text_search\" id=\"text_search\" value=\"\" placeholder=\""._("cerca...")."\" />";
588  $buffer .= " <input type=\"button\" name=\"button_search\" id=\"button_search\" value=\""._("cerca")."\" />";
589  $buffer .= " <input type=\"button\" name=\"button_search_reset\" id=\"button_search_reset\" value=\""._("tutti")."\" />";
590  $buffer .= "</li>";
591 
592  $point_ctgs = gmapsPointCtg::getForSelect($this->_instance);
593  $polyline_ctgs = gmapsPolylineCtg::getForSelect($this->_instance);
594  $polygon_ctgs = gmapsPolygonCtg::getForSelect($this->_instance);
595 
596  $buffer .= "<li>";
597  $buffer .= "<select id=\"ctg_search\">";
598  $buffer .= "<option selected>"._("tutte le categorie")."</option>";
599  if(count($point_ctgs)) {
600  $buffer .= "<optgroup label=\""._("Punti di interesse")."\">";
601  foreach($point_ctgs as $id=>$label) {
602  $buffer .= "<option value=\"point_".$id."\">".$label."</option>";
603  }
604  $buffer .= "</optgroup>";
605  }
606  if(count($polyline_ctgs)) {
607  $buffer .= "<optgroup label=\""._("Percorsi")."\">";
608  foreach($polyline_ctgs as $id=>$label) {
609  $buffer .= "<option value=\"polyline_".$id."\">".$label."</option>";
610  }
611  }
612  if(count($polygon_ctgs)) {
613  $buffer .= "<optgroup label=\""._("Aree")."\">";
614  foreach($polygon_ctgs as $id=>$label) {
615  $buffer .= "<option value=\"polygon_".$id."\">".$label."</option>";
616  }
617  }
618  $buffer .= "</optgroup>";
619  $buffer .= "</select>";
620  $buffer .= "</li>";
621  $buffer .= "</ul>";
622  $buffer .= "</nav>";
623  $buffer .= "<div id=\"map_canvas\" style=\"width:".$map->width.";height:".$map->height."\"></div>";
624 
625  $voices = array();
626  foreach(explode(',', $this->_list_fields) as $f) {
627  $f = trim($f);
628  if(in_array($f, array('label', 'categories', 'address', 'cap', 'city', 'services'))) {
629  $voices[] = $f;
630  }
631  }
632  $voices = "'".implode("', '", $voices)."'";
633 
634  $buffer .= "<script>";
635  $buffer .= "window.addEvent('load', function() {";
636  $buffer .= "var gmap = new Gmap($('map_canvas'), {elements_list: ".($list ? 'true' : 'false').", elements_voices: [".$voices."], points_label: '".jsVar(_('Punti di interesse'))."', polylines_label: '".jsVar("Percorsi")."', polygons_label: '"._("Aree")."', empty_search_result: '".jsVar(_("La ricerca non ha prodotto risultati"))."'});";
637  $points_ids = $map->points_id();
638  $points_polylines = array();
639  $points_polygons = array();
640  foreach($map->polylines() as $polyline) {
641  foreach($polyline->points_id() as $point_id) {
642  $points_ids[] = $point_id;
643  if(!isset($points_polylines[$point_id]))
644  $points_polylines[$point_id] = array($polyline->id);
645  else $points_polylines[$point_id][] = $polyline->id;
646  }
647  }
648  foreach($map->polygons() as $polygon) {
649  foreach($polygon->points_id() as $point_id) {
650  $points_ids[] = $point_id;
651  if(!isset($points_polygons[$point_id]))
652  $points_polygons[$point_id] = array($polygon->id);
653  else $points_polygons[$point_id][] = $polygon->id;
654  }
655  }
656 
657  $points_ids = array_unique($points_ids);
658 
659  if(count($points_ids)) {
660  $points = 'var points = {};';
661  foreach($points_ids as $point_id) {
662  $point_obj = new gmapsPoint($point_id, $this);
663  $point_polylines = isset($points_polylines[$point_id]) ? $points_polylines[$point_id] : array();
664  $point_polygons = isset($points_polygons[$point_id]) ? $points_polygons[$point_id] : array();
665  $points .= "points.id".$point_obj->id." = ".$point_obj->jsObject('gmap', $point_polylines, $point_polygons, $map->id);
666  }
667  $buffer .= $points;
668  $buffer .= "gmap.addPoints(points);";
669  }
670 
671  if(count($map->polylines())) {
672  $polylines = 'var polylines = {};';
673  foreach($map->polylines() as $polyline_obj) {
674  $polylines .= "polylines.id".$polyline_obj->id." = ".$polyline_obj->jsObject('gmap', $map->id);
675  }
676  $buffer .= $polylines;
677  $buffer .= "gmap.addPolylines(polylines);";
678  }
679 
680  if(count($map->polygons())) {
681  $polygons = 'var polygons = {};';
682  foreach($map->polygons() as $polygon_obj) {
683  $polygons .= "polygons.id".$polygon_obj->id." = ".$polygon_obj->jsObject('gmap', $map->id);
684  }
685  $buffer .= $polygons;
686  $buffer .= "gmap.addPolygons(polygons);";
687  }
688 
689  $buffer .= "gmap.renderMap();";
690  $buffer .= "})";
691  $buffer .= "</script>";
692 
693  return $buffer;
694  }
695 
702  public function infowindow() {
703 
704  $this->setAccess($this->_access_base);
705 
706  $point_id = cleanVar($_GET, 'point_id', 'int', '');
707  $polyline_id = cleanVar($_GET, 'polyline_id', 'int', '');
708  $polygon_id = cleanVar($_GET, 'polygon_id', 'int', '');
709  $map_id = cleanVar($_GET, 'map_id', 'int', '');
710 
711  if($point_id) {
712 
713  $point = new gmapsPoint($point_id, $this);
714 
715  $buffer = "<section>";
716  $buffer .= "<h1>".htmlCHars($point->ml('label'))."</h1>";
717 
718  $nation = $this->_db->getFieldFromId('nation', $_SESSION['lng'], 'id', $point->nation);
719  $caddress = htmlChars($point->ml('address').', '.$point->cap.' '.$point->ml('city').', '.$nation);
720  $buffer .= "<p><i>".$caddress."</i></p>";
721 
722  $remove_images = false;
723  if($images = $point->images()) {
724  $image = $images[0];
725  $buffer .= $image->thumb('left');
726  $remove_images = true;
727  }
728  $buffer .= cutHtmlText(HtmlChars($point->ml('description')), 220, '...', false, false, $remove_images, array('endingPosition'=>'in'));
729  $buffer .= "<p><a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id))."\">"._("leggi tutto")."</a></p>";
730  $buffer .= "<div class=\"null\"></div>";
731  $buffer .= "</section>";
732  }
733  elseif($polyline_id) {
734 
735  $polyline = new gmapsPolyline($polyline_id, $this);
736 
737  $buffer = "<section>";
738  $buffer .= "<h1>".htmlCHars($polyline->ml('label'))."</h1>";
739 
740  $buffer .= cutHtmlText(HtmlChars($polyline->ml('description')), 220, '...', false, false, false, array('endingPosition'=>'in'));
741  $buffer .= "<p><a href=\"".$this->_plink->aLink($this->_instanceName, 'itinerary', array("id"=>$polyline->id, 'map'=>$map_id))."\">"._("leggi tutto")."</a></p>";
742  $buffer .= "<div class=\"null\"></div>";
743  $buffer .= "</section>";
744  }
745  elseif($polygon_id) {
746 
747  $polygon = new gmapsPolygon($polygon_id, $this);
748 
749  $buffer = "<section>";
750  $buffer .= "<h1>".htmlCHars($polygon->ml('label'))."</h1>";
751 
752  $buffer .= cutHtmlText(HtmlChars($polygon->ml('description')), 220, '...', false, false, false, array('endingPosition'=>'in'));
753  $buffer .= "<p><a href=\"".$this->_plink->aLink($this->_instanceName, 'area', array("id"=>$polygon->id, 'map'=>$map_id))."\">"._("leggi tutto")."</a></p>";
754  $buffer .= "<div class=\"null\"></div>";
755  $buffer .= "</section>";
756  }
757 
758  return $buffer;
759 
760  }
761 
768  public function itinerary() {
769 
770  $registry = registry::instance();
771  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
772  $registry->addJs(SITE_WWW."/app/gmaps/markerclusterer_packed.js");
773  $registry->addJs(SITE_WWW."/app/gmaps/infobox.js");
774  $registry->addJs(SITE_WWW."/app/gmaps/MooComplete.js");
775  $registry->addJs(SITE_WWW."/app/gmaps/ProgressBar.js");
776  $registry->addJs(SITE_WWW."/app/gmaps/gmaps.js");
777  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
778  $registry->addCss(SITE_WWW."/app/gmaps/MooComplete.css");
779 
780  $id = cleanVar($_GET, 'id', 'int', '');
781  $map_id = cleanVar($_GET, 'map', 'int', '');
782 
783  $polyline = new gmapsPolyline($id, $this);
784 
785  $link_map = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'viewFull', array('id'=>$map_id))."\">"._("mappa")."</a>";
786 
787  $title = $polyline->ml('label');
788  $htmlsection = new htmlSection(array('class'=>'public', 'id'=>'itinerary_gmaps_'.$this->_instanceName, 'headerTag'=>'header', 'headerLabel'=>$title, 'headerLinks'=>$link_map));
789 
790  $buffer = "<div id=\"itinerary_map\">";
791 
792  $buffer .= "<nav id=\"gmaps_nav\">";
793  $buffer .= "<ul>";
794  $buffer .= "<li>";
795  $buffer .= _("Help");
796  $buffer .= "<ul>";
797  $buffer .= "<li data-menu=\"maphelp\">"._("<p>Utilizzare la voce 'Mappa' per modificare il tipo di mappa.<br/>Utilizzare il campo di testo per ricercare punti di interesse o percorsi nella mappa, iniziando a digitare le chiavi di ricerca verranno visualizzati dei suggerimenti, selezionare quello desiderato e premere il bottone 'cerca'. Per tornare alla visualizzazione completa premere il bottone 'tutti'. <br />Se si desidera filtrare per categoria utlizzare l'apposito menu a tendina.</p>")."</li>";
798  $buffer .= "</ul>";
799  $buffer .= "</li>";
800  $buffer .= "<li>";
801  $buffer .= _("Mappa");
802  $buffer .= "<ul>";
803  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"hybrid\">"._("Ibrida")."</li>";
804  $buffer .= "<li class=\"link selected\" data-menu=\"maptype\" data-type=\"roadmap\">"._("roadmap")."</li>";
805  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"satellite\">"._("satellite")."</li>";
806  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"terrain\">"._("terrain")."</li>";
807  $buffer .= "</ul>";
808  $buffer .= "</li>";
809  $buffer .= "<li>";
810  $buffer .= "<input type=\"text\" name=\"text_search\" id=\"text_search\" value=\"\" placeholder=\""._("cerca...")."\" />";
811  $buffer .= " <input type=\"button\" name=\"button_search\" id=\"button_search\" value=\""._("cerca")."\" />";
812  $buffer .= " <input type=\"button\" name=\"button_search_reset\" id=\"button_search_reset\" value=\""._("tutti")."\" />";
813  $buffer .= "</li>";
814 
815  $buffer .= "<li>";
816  $buffer .= "<select id=\"ctg_search\">";
817  $buffer .= "<option selected>"._("tutte le categorie")."</option>";
818  $buffer .= "<optgroup label=\""._("Punti di interesse")."\">";
819  foreach(gmapsPointCtg::getForSelect($this->_instance) as $id=>$label) {
820  $buffer .= "<option value=\"point_".$id."\">".$label."</option>";
821  }
822  $buffer .= "</optgroup>";
823  $buffer .= "</select>";
824  $buffer .= "</li>";
825  $buffer .= "</ul>";
826  $buffer .= "</nav>";
827  $buffer .= "<div id=\"map_canvas\" class=\"map\"></div>";
828  $buffer .= "</div>";
829 
830  $voices = array();
831  foreach(explode(',', $this->_list_fields) as $f) {
832  $f = trim($f);
833  if(in_array($f, array('label', 'categories', 'address', 'cap', 'city', 'services'))) {
834  $voices[] = $f;
835  }
836  }
837  $voices = "'".implode("', '", $voices)."'";
838 
839  $buffer .= "<script>";
840  $buffer .= "window.addEvent('load', function() {";
841  $buffer .= "var gmap = new Gmap($('map_canvas'), {elements_list: true, elements_voices: [".$voices."] ,empty_search_result: '".jsVar(_("La ricerca non ha prodotto risultati"))."'});";
842  $points_ids = $polyline->points_id();
843 
844  if(count($points_ids)) {
845  $points = 'var points = {};';
846  foreach($points_ids as $point_id) {
847  $point_obj = new gmapsPoint($point_id, $this);
848  $point_polylines = array($polyline->id);
849  $points .= "points.id".$point_obj->id." = ".$point_obj->jsObject('gmap', $point_polylines, array(), $map_id);
850  }
851  $buffer .= $points;
852  $buffer .= "gmap.addPoints(points);";
853  }
854 
855  $polylines = 'var polylines = {};';
856  $polylines .= "polylines.id".$polyline->id." = ".$polyline->jsObject('gmap', $map_id);
857  $buffer .= $polylines;
858  $buffer .= "gmap.addPolylines(polylines);";
859  $buffer .= "gmap.renderMap();";
860  $buffer .= "})";
861  $buffer .= "</script>";
862  $buffer .= htmlChars($polyline->description);
863 
864  $htmlsection->content = $buffer;
865 
866  return $htmlsection->render();
867  }
868 
875  public function area() {
876 
877  $registry = registry::instance();
878  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
879  $registry->addJs(SITE_WWW."/app/gmaps/markerclusterer_packed.js");
880  $registry->addJs(SITE_WWW."/app/gmaps/infobox.js");
881  $registry->addJs(SITE_WWW."/app/gmaps/MooComplete.js");
882  $registry->addJs(SITE_WWW."/app/gmaps/ProgressBar.js");
883  $registry->addJs(SITE_WWW."/app/gmaps/gmaps.js");
884  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
885  $registry->addCss(SITE_WWW."/app/gmaps/MooComplete.css");
886 
887  $id = cleanVar($_GET, 'id', 'int', '');
888  $map_id = cleanVar($_GET, 'map', 'int', '');
889 
890  $polygon = new gmapsPolygon($id, $this);
891 
892  $title = $polygon->ml('label');
893  $link_map = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'viewFull', array('id'=>$map_id))."\">"._("mappa")."</a>";
894 
895  $htmlsection = new htmlSection(array('class'=>'public', 'id'=>'area_gmaps_'.$this->_instanceName, 'headerTag'=>'header', 'headerLabel'=>$title, 'headerLinks'=>$link_map));
896 
897  $buffer = "<div id=\"area_map\">";
898 
899  $buffer .= "<nav id=\"gmaps_nav\">";
900  $buffer .= "<ul>";
901  $buffer .= "<li>";
902  $buffer .= _("Help");
903  $buffer .= "<ul>";
904  $buffer .= "<li data-menu=\"maphelp\">"._("<p>Utilizzare la voce 'Mappa' per modificare il tipo di mappa.<br/>Utilizzare il campo di testo per ricercare punti di interesse o aree nella mappa, iniziando a digitare le chiavi di ricerca verranno visualizzati dei suggerimenti, selezionare quello desiderato e premere il bottone 'cerca'. Per tornare alla visualizzazione completa premere il bottone 'tutti'. <br />Se si desidera filtrare per categoria utlizzare l'apposito menu a tendina.</p>")."</li>";
905  $buffer .= "</ul>";
906  $buffer .= "</li>";
907  $buffer .= "<li>";
908  $buffer .= _("Mappa");
909  $buffer .= "<ul>";
910  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"hybrid\">"._("Ibrida")."</li>";
911  $buffer .= "<li class=\"link selected\" data-menu=\"maptype\" data-type=\"roadmap\">"._("roadmap")."</li>";
912  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"satellite\">"._("satellite")."</li>";
913  $buffer .= "<li class=\"link\" data-menu=\"maptype\" data-type=\"terrain\">"._("terrain")."</li>";
914  $buffer .= "</ul>";
915  $buffer .= "</li>";
916  $buffer .= "<li>";
917  $buffer .= "<input type=\"text\" name=\"text_search\" id=\"text_search\" value=\"\" placeholder=\""._("cerca...")."\" />";
918  $buffer .= " <input type=\"button\" name=\"button_search\" id=\"button_search\" value=\""._("cerca")."\" />";
919  $buffer .= " <input type=\"button\" name=\"button_search_reset\" id=\"button_search_reset\" value=\""._("tutti")."\" />";
920  $buffer .= "</li>";
921 
922  $buffer .= "<li>";
923  $buffer .= "<select id=\"ctg_search\">";
924  $buffer .= "<option selected>"._("tutte le categorie")."</option>";
925  $buffer .= "<optgroup label=\""._("Punti di interesse")."\">";
926  foreach(gmapsPointCtg::getForSelect($this->_instance) as $id=>$label) {
927  $buffer .= "<option value=\"point_".$id."\">".$label."</option>";
928  }
929  $buffer .= "</optgroup>";
930  $buffer .= "</select>";
931  $buffer .= "</li>";
932  $buffer .= "</ul>";
933  $buffer .= "</nav>";
934  $buffer .= "<div id=\"map_canvas\" class=\"map\"></div>";
935  $buffer .= "</div>";
936 
937  $voices = array();
938  foreach(explode(',', $this->_list_fields) as $f) {
939  $f = trim($f);
940  if(in_array($f, array('label', 'categories', 'address', 'cap', 'city', 'services'))) {
941  $voices[] = $f;
942  }
943  }
944  $voices = "'".implode("', '", $voices)."'";
945 
946  $buffer .= "<script>";
947  $buffer .= "window.addEvent('load', function() {";
948  $buffer .= "var gmap = new Gmap($('map_canvas'), {elements_list: true, elements_voices: [".$voices."] ,empty_search_result: '".jsVar(_("La ricerca non ha prodotto risultati"))."'});";
949  $points_ids = $polygon->points_id();
950 
951  if(count($points_ids)) {
952  $points = 'var points = {};';
953  foreach($points_ids as $point_id) {
954  $point_obj = new gmapsPoint($point_id, $this);
955  $point_polygons = array($polygon->id);
956  $points .= "points.id".$point_obj->id." = ".$point_obj->jsObject('gmap', array(), $point_polygons, $map_id);
957  }
958  $buffer .= $points;
959  $buffer .= "gmap.addPoints(points);";
960  }
961 
962  $polygons = 'var polygons = {};';
963  $polygons .= "polygons.id".$polygon->id." = ".$polygon->jsObject('gmap', $map_id);
964  $buffer .= $polygons;
965  $buffer .= "gmap.addPolygons(polygons);";
966  $buffer .= "gmap.renderMap();";
967  $buffer .= "})";
968  $buffer .= "</script>";
969  $buffer .= htmlChars($polygon->description);
970 
971  $htmlsection->content = $buffer;
972 
973  return $htmlsection->render();
974  }
975 
982  public function point() {
983 
984  $registry = registry::instance();
985 
986  $id = cleanVar($_GET, 'id', 'int', '');
987  $map_id = cleanVar($_GET, 'map', 'int', '');
988 
989  $point = new gmapsPoint($id, $this);
990 
991  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
992 
993  $title = $point->ml('label');
994  $link_map = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'viewFull', array('id'=>$map_id))."\">"._("Mappa")."</a>";
995 
996  $htmlsection = new htmlSection(array('class'=>'public', 'headerTag'=>'header', 'headerLabel'=>$link_map.' > '.$title));
997 
998  $htmltab = new htmlTab(array("linkPosition"=>'right', "title"=>''));
999 
1000  $links = array();
1001 
1002  if(count($point->collections())) {
1003  $link_collections = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id, 'block'=>'collections'))."\">"._("Collezioni")."</a>";
1004  $links[] = $link_collections;
1005  }
1006  if(count($point->attachments())) {
1007  $link_attachments = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id, 'block'=>'attachments'))."\">"._("Allegati")."</a>";
1008  $links[] = $link_attachments;
1009  }
1010  if(count($point->events())) {
1011  $link_events = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id, 'block'=>'events'))."\">"._("Eventi")."</a>";
1012  $links[] = $link_events;
1013  }
1014  if(count($point->videos())) {
1015  $link_videos = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id, 'block'=>'videos'))."\">"._("Video")."</a>";
1016  $links[] = $link_videos;
1017  }
1018  if(count($point->images())) {
1019  $link_images = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id, 'block'=>'images'))."\">"._("Immagini")."</a>";
1020  $links[] = $link_images;
1021  }
1022  $link_info = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id, 'block'=>'info'))."\">"._("Informazioni")."</a>";
1023  $links[] = $link_info;
1024  $link_main = "<a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array("id"=>$point->id, 'map'=>$map_id))."\">"._("Descrizione")."</a>";
1025  $links[] = $link_main;
1026  $sel_link = $link_main;
1027 
1028  if($this->_block == 'images') {
1029  $buffer = $this->pointImages($point);
1030  $sel_link = $link_images;
1031  }
1032  elseif($this->_block == 'videos') {
1033  $buffer = $this->pointVideos($point);
1034  $sel_link = $link_videos;
1035  }
1036  elseif($this->_block == 'events') {
1037  $buffer = $this->pointEvents($point);
1038  $sel_link = $link_events;
1039  }
1040  elseif($this->_block == 'attachments') {
1041  $buffer = $this->pointAttachments($point);
1042  $sel_link = $link_attachments;
1043  }
1044  elseif($this->_block == 'info') {
1045  $buffer = $this->pointInfo($point);
1046  $sel_link = $link_info;
1047  }
1048  elseif($this->_block == 'collections') {
1049  $buffer = $this->pointCollections($point);
1050  $sel_link = $link_collections;
1051  }
1052  else {
1053  $buffer = $this->pointMain($point);
1054  $sel_link = $link_main;
1055  }
1056 
1057  $htmltab->navigationLinks = $links;
1058  $htmltab->selectedLink = $sel_link;
1059  $htmltab->htmlContent = $buffer;
1060  $buffer = $htmltab->render();
1061 
1062  $htmlsection->content = $buffer;
1063 
1064  return $htmlsection->render();
1065  }
1066 
1074  private function pointCollections($point) {
1075 
1076  $registry = registry::instance();
1077  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
1078 
1079  $collection_id = cleanVar($_GET, 'collection', 'int', '');
1080 
1081  $htmlsection = new htmlSection(array('class'=>'public', 'headerTag'=>'header'));
1082 
1083  if($collection_id) {
1084  $registry->addJs("http://ajs.otto.to.it/sources/dev/ajs/ajs.js");
1085  $collection = new gmapsCollection($collection_id, $this);
1086 
1087  $buffer = "<h2>".htmlChars($collection->ml('name'))." - <a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array('id'=>$point->id, 'block'=>'collections'), '')."\">"._("tutte le collezioni")."</a></h2>";
1088  $buffer .= "<div id=\"img_container\">";
1089  $buffer .= "</div>";
1090 
1091  $js_images = "var images = [";
1092  $images = array();
1093  foreach($collection->images() as $img) {
1094  $images[] = "{
1095  thumb: '".$img->thumbPath()."',
1096  img: '".$img->path()."',
1097  title: '".jsVar($img->ml('title'))."',
1098  description: '".jsVar($img->ml('description'))."',
1099  credits: '".jsVar($img->ml('credits'))."'
1100  }";
1101  }
1102  $js_image = "var images = [".implode(',', $images)."];";
1103 
1104  $buffer .= "<script>";
1105  $buffer .= $js_image."\n";
1106  $buffer .= "ajs.use(['ajs.ui.moogallery'], function() {
1107  var mygallery = new ajs.ui.moogallery('img_container', images);
1108  })";
1109  $buffer .= "</script>";
1110  }
1111  else {
1112 
1113  if(count($point->collections())) {
1114  $buffer = "<table class=\"gmaps_collections\">";
1115  foreach($point->collections() as $collection) {
1116  $buffer .= "<tr>";
1117  $buffer .= "<td><a href=\"".$collection->path()."\" rel=\"lightbox\"><img src=\"".$collection->thumbPath()."\" /></a></td>";
1118  $buffer .= "<td>";
1119  $buffer .= "<h2>".htmlChars($collection->ml('name'))."</h2>";
1120  $buffer .= "<p>".htmlChars($collection->ml('description'))."</p>";
1121  $buffer .= "<p><a href=\"".$this->_plink->aLink($this->_instanceName, 'point', array('id'=>$point->id, 'block'=>'collections', 'collection'=>$collection->id), '')."\">"._("Vedi gli oggetti")."</a></p>";
1122  $buffer .= "</td>";
1123  $buffer .= "</tr>";
1124  }
1125  $buffer .= "</table>";
1126  }
1127  else {
1128  $buffer = "<p>"._("Non risultano collezioni pubblicate")."</p>";
1129  }
1130  }
1131 
1132  $htmlsection->content = $buffer;
1133 
1134  return $htmlsection->render();
1135  }
1136 
1144  private function pointImages($point) {
1145 
1146  $registry = registry::instance();
1147  $registry->addJs("http://ajs.otto.to.it/sources/dev/ajs/ajs.js");
1148  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
1149 
1150  $htmlsection = new htmlSection(array('class'=>'public', 'headerTag'=>'header'));
1151 
1152  $buffer = "<div id=\"img_container\">";
1153  $buffer .= "</div>";
1154 
1155  $js_images = "var images = [";
1156  $images = array();
1157  foreach($point->images() as $img) {
1158  $images[] = "{
1159  thumb: '".$img->thumbPath()."',
1160  img: '".$img->path()."',
1161  title: '".jsVar($img->ml('title'))."',
1162  description: '".jsVar($img->ml('description'))."',
1163  credits: '".jsVar($img->ml('credits'))."'
1164  }";
1165  }
1166  $js_image = "var images = [".implode(',', $images)."];";
1167 
1168  $buffer .= "<script>";
1169  $buffer .= $js_image."\n";
1170  $buffer .= "ajs.use(['ajs.ui.moogallery'], function() {
1171  var mygallery = new ajs.ui.moogallery('img_container', images);
1172  })";
1173  $buffer .= "</script>";
1174 
1175  $htmlsection->content = $buffer;
1176 
1177  return $htmlsection->render();
1178 
1179 
1180  }
1181 
1189  private function pointVideos($point) {
1190 
1191  $registry = registry::instance();
1192  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
1193 
1194  $htmlsection = new htmlSection(array('class'=>'public', 'headerTag'=>'header'));
1195 
1196  if(count($point->videos())) {
1197  $buffer = "<table class=\"gmaps_video\">";
1198  foreach($point->videos() as $video) {
1199  $buffer .= "<tr>";
1200  $buffer .= "<td>".$video->code."</td>";
1201  $buffer .= "<td>";
1202  $buffer .= "<p class=\"title\">".htmlChars($video->ml('title'))."</p>";
1203  $buffer .= "<p>".htmlChars($video->ml('description'))."</p>";
1204  if($video->credits) {
1205  $buffer .= "<p>"._("credits").': '.htmlChars($video->ml('credits'))."</p>";
1206  }
1207  $buffer .= "</td>";
1208  $buffer .= "</tr>";
1209  }
1210  $buffer .= "</table>";
1211  }
1212  else {
1213  $buffer = "<p>"._("Non risultano video pubblicati")."</p>";
1214  }
1215 
1216  $htmlsection->content = $buffer;
1217 
1218  return $htmlsection->render();
1219 
1220 
1221  }
1222 
1230  private function pointEvents($point) {
1231 
1232  $registry = registry::instance();
1233  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
1234 
1235  $htmlsection = new htmlSection(array('class'=>'public', 'headerTag'=>'header'));
1236 
1237  if(count($point->events())) {
1238  $buffer = "<table class=\"gmaps_event\">";
1239  $buffer .= "<tr>";
1240  $buffer .= "<th class=\"thIcon\"></th>";
1241  $buffer .= "<th>"._("Data")."</th>";
1242  $buffer .= "<th>"._("Durata")."</th>";
1243  $buffer .= "<th>"._("Evento")."</th>";
1244  $buffer .= "<th>"._("Descizione")."</th>";
1245  $buffer .= "</tr>";
1246  foreach($point->events() as $event) {
1247  $buffer .= "<tr>";
1248  $buffer .= "<td><a href=\"".$event->imagePath()."\" rel=\"lightbox\"><img src=\"".$event->thumbPath()."\" /></a></td>";
1249  $buffer .= "<td>".dbDateToDate($event->date, '/')."</td>";
1250  $buffer .= "<td>".$event->duration."</td>";
1251  $buffer .= "<td>".htmlChars($event->ml('name'))."</td>";
1252  $buffer .= "<td>".htmlChars($event->ml('description'))."</td>";
1253  $buffer .= "</tr>";
1254  }
1255  $buffer .= "</table>";
1256  }
1257  else {
1258  $buffer = "<p>"._("Non risultano eventi pubblicati")."</p>";
1259  }
1260 
1261  $htmlsection->content = $buffer;
1262 
1263  return $htmlsection->render();
1264 
1265 
1266  }
1267 
1275  private function pointAttachments($point) {
1276 
1277  $registry = registry::instance();
1278  $registry->addCss(SITE_WWW."/app/gmaps/gmaps_".$this->_instanceName.".css");
1279 
1280  $htmlsection = new htmlSection(array('class'=>'public', 'headerTag'=>'header'));
1281 
1282  if(count($point->attachments())) {
1283  $buffer = "<table class=\"gmaps_attachment\">";
1284  foreach($point->attachments() as $a) {
1285  $buffer .= "<tr>";
1286  $buffer .= "<td><a href=\"".$a->filePath()."\">".pub::icon('download')."</a></td>";
1287  $buffer .= "<td>".$a->filename."</td>";
1288  $buffer .= "<td>".round($a->size/1000, 1)." Kb</td>";
1289  $buffer .= "<td>".htmlChars($a->ml('description'))."</td>";
1290  $buffer .= "</tr>";
1291  }
1292  $buffer .= "</table>";
1293  }
1294  else {
1295  $buffer = "<p>"._("Non risultano allegati pubblicati")."</p>";
1296  }
1297 
1298  $htmlsection->content = $buffer;
1299 
1300  return $htmlsection->render();
1301 
1302 
1303  }
1304 
1312  private function pointInfo($point) {
1313 
1314  $title = _("Informazioni");
1315  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header'));
1316 
1317  $buffer = '';
1318 
1319  $categories = array();
1320  foreach($point->ctgs() as $ctg) {
1321  $categories[] = htmlChars($ctg->ml('name'));
1322  }
1323 
1324  $buffer .= "<p><b>"._("Categorie")."</b>: ".implode(', ', $categories)."</p>";
1325 
1326  $services = array();
1327  foreach($point->services() as $service) {
1328  $services[] = htmlChars($service->ml('name'));
1329  }
1330 
1331  if(count($services)) {
1332  $buffer .= "<p><b>"._("Servizi")."</b>: ".implode(', ', $services)."</p>";
1333  }
1334 
1335  if($point->phone) {
1336  $buffer .= "<p><b>"._("Telefono")."</b>: ".$point->phone."</p>";
1337  }
1338 
1339  if($point->email) {
1340  $buffer .= "<p><b>"._("Email")."</b>: <a href=\"mailto:".$point->email."\">".$point->email."</a></p>";
1341  }
1342 
1343  if($point->web) {
1344  $buffer .= "<p><b>"._("Sito web")."</b>: <a href=\"".$point->web."\">".$point->web."</a></p>";
1345  }
1346 
1347  $nation = $this->_db->getFieldFromId('nation', $_SESSION['lng'], 'id', $point->nation);
1348  $buffer .= "<p><b>"._("Indirizzo")."</b>: ".htmlChars($point->ml('address').', '.$point->cap.' '.$point->ml('city').', '.$nation)."</p>";
1349 
1350  $buffer .= htmlChars($point->ml('information'));
1351 
1352  if($point->opening_hours) {
1353  $buffer .= "<p><b>"._("Orari di apertura")."</b>: ".$point->ml('opening_hours')."</p>";
1354  }
1355 
1356  $htmlsection->content = $buffer;
1357 
1358  return $htmlsection->render();
1359  }
1360 
1368  private function pointMain($point) {
1369 
1370  $title = _("Descrizione");
1371  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header'));
1372 
1373  $buffer = '';
1374 
1375  $buffer = htmlChars($point->ml('description'));
1376 
1377  $buffer .= "<div class=\"null\"></div>";
1378 
1379  $htmlsection->content = $buffer;
1380 
1381  return $htmlsection->render();
1382  }
1383 
1390  public function manageDoc() {
1391 
1392  $this->accessGroup('ALL');
1393 
1394  $htmltab = new htmlTab(array("linkPosition"=>'right', "title"=>$this->_instanceLabel));
1395  $link_admin = "<a href=\"".$this->_home."?evt[$this->_instanceName-manageDoc]&block=permissions\">"._("Permessi")."</a>";
1396  $link_options = "<a href=\"".$this->_home."?evt[$this->_instanceName-manageDoc]&block=options\">"._("Opzioni")."</a>";
1397  $link_polygon = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon\">"._("Aree")."</a>";
1398  $link_polygon_ctg = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg\">"._("Ctg A")."</a>";
1399  $link_polyline = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline\">"._("Percorsi")."</a>";
1400  $link_polyline_ctg = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg\">"._("Ctg P")."</a>";
1401  $link_point = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point\">"._("Punti di interesse")."</a>";
1402  $link_point_ctg = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg\">"._("Ctg PI")."</a>";
1403  $link_service = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service\">"._("Servizi")."</a>";
1404  $link_marker = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker\">"._("Markers")."</a>";
1405  $link_dft = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]\">"._("Mappe")."</a>";
1406  $sel_link = $link_dft;
1407 
1408  if($this->_block == 'options') {
1409  $buffer = sysfunc::manageOptions($this->_instance, $this->_className);
1410  $sel_link = $link_options;
1411  }
1412  elseif($this->_block == 'permissions') {
1413  $buffer = sysfunc::managePermissions($this->_instance, $this->_className);
1414  $sel_link = $link_admin;
1415  }
1416  elseif($this->_block == 'service') {
1417  $buffer = $this->manageService();
1418  $sel_link = $link_service;
1419  }
1420  elseif($this->_block == 'marker') {
1421  $buffer = $this->manageMarker();
1422  $sel_link = $link_marker;
1423  }
1424  elseif($this->_block == 'point_ctg') {
1425  $buffer = $this->managePointCtg();
1426  $sel_link = $link_point_ctg;
1427  }
1428  elseif($this->_block == 'point_image') {
1429  $buffer = $this->managePointImage();
1430  $sel_link = $link_point;
1431  }
1432  elseif($this->_block == 'point_video') {
1433  $buffer = $this->managePointVideo();
1434  $sel_link = $link_point;
1435  }
1436  elseif($this->_block == 'point_event') {
1437  $buffer = $this->managePointEvent();
1438  $sel_link = $link_point;
1439  }
1440  elseif($this->_block == 'point_attachment') {
1441  $buffer = $this->managePointAttachment();
1442  $sel_link = $link_point;
1443  }
1444  elseif($this->_block == 'point_collection') {
1445  $buffer = $this->managePointCollection();
1446  $sel_link = $link_point;
1447  }
1448  elseif($this->_block == 'point') {
1449  $buffer = $this->managePoint();
1450  $sel_link = $link_point;
1451  }
1452  elseif($this->_block == 'polygon') {
1453  $buffer = $this->managePolygon();
1454  $sel_link = $link_polygon;
1455  }
1456  elseif($this->_block == 'polygon_point') {
1457  $buffer = $this->managePolygonPoint();
1458  $sel_link = $link_polygon;
1459  }
1460  elseif($this->_block == 'polygon_ctg') {
1461  $buffer = $this->managePolygonCtg();
1462  $sel_link = $link_polygon_ctg;
1463  }
1464  elseif($this->_block == 'polyline') {
1465  $buffer = $this->managePolyline();
1466  $sel_link = $link_polyline;
1467  }
1468  elseif($this->_block == 'polyline_point') {
1469  $buffer = $this->managePolylinePoint();
1470  $sel_link = $link_polyline;
1471  }
1472  elseif($this->_block == 'polyline_ctg') {
1473  $buffer = $this->managePolylineCtg();
1474  $sel_link = $link_polyline_ctg;
1475  }
1476  elseif($this->_block == 'map_item') {
1477  $buffer = $this->manageMapItem();
1478  }
1479  else {
1480  $buffer = $this->manageMap();
1481  }
1482 
1483  $htmltab->navigationLinks = array($link_admin, $link_options, $link_service, $link_polygon_ctg, $link_polygon, $link_polyline_ctg, $link_polyline, $link_point_ctg, $link_point, $link_marker, $link_dft);
1484  $htmltab->selectedLink = $sel_link;
1485  $htmltab->htmlContent = $buffer;
1486  return $htmltab->render();
1487 
1488  }
1489 
1496  private function manageMarker() {
1497 
1498  $id = cleanVar($_REQUEST, 'id', 'int', '');
1499  $marker = new gmapsMarker($id, $this);
1500  $marker->instance = $this->_instance;
1501 
1502  $col1 = $this->listMarker($id);
1503 
1504  if(in_array($this->_action, array('insert', 'modify'))) {
1505  $col2 = $marker->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker");
1506  }
1507  elseif($this->_action == 'delete') {
1508  $res = $marker->delete();
1509  if($res === 'points') {
1510  exit(error::errorMessage(array('error'=>_("Il marker è utilizzato da uno o più punti di interesse. Eliminarli o cambiarne il marker e riprovare")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker"));
1511  }
1512  elseif($res === false) {
1513  exit(error::errorMessage(array('error'=>_("Impossibile eliminare il marker, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker"));
1514  }
1515  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=marker");
1516  }
1517  else {
1518  $col2 = $this->infoMarker();
1519  }
1520 
1521  $buffer = "<div class=\"vertical_1\">";
1522  $buffer .= $col1;
1523  $buffer .= "</div>";
1524 
1525  $buffer .= "<div class=\"vertical_2\">";
1526  $buffer .= $col2;
1527  $buffer .= "</div>";
1528 
1529  $buffer .= "<div class=\"null\"></div>";
1530 
1531  return $buffer;
1532  }
1533 
1541  private function listMarker($sel_id) {
1542 
1543  $title = _("Markers");
1544  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker&action=insert\">".pub::icon('insert', _("nuovo marker"))."</a>";
1545  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
1546 
1547  $marker_ids = gmapsMarker::get($this->_instance);
1548 
1549  if($tot = count($marker_ids)) {
1550  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
1551  $buffer = $htmlList->start();
1552  foreach($marker_ids as $marker_id) {
1553  $marker = new gmapsMarker($marker_id, $this);
1554  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker&action=modify&id=".$marker->id."\">".pub::icon('modify')."</a>";
1555  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare il servizio?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=marker&action=delete&id=".$marker->id."';\">".pub::icon('delete')."</span>";
1556  $selected = $marker->id == $sel_id ? true : false;
1557  $buffer .= $htmlList->item(htmlChars($marker->label), array($link_modify, $link_delete), $selected, true);
1558  }
1559  $buffer .= $htmlList->end();
1560  }
1561  else {
1562  $buffer = "<p class=\"message\">"._("Non risultano markers registrati")."</p>";
1563  }
1564 
1565  $htmlsection->content = $buffer;
1566 
1567  return $htmlsection->render();
1568  }
1569 
1576  private function infoMarker() {
1577 
1578  $title = _("Informazioni");
1579  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
1580 
1581  $buffer = _("Gestione dei marker associabili ai punti di interesse");
1582 
1583  $htmlsection->content = $buffer;
1584 
1585  return $htmlsection->render();
1586 
1587  }
1588 
1589 
1596  private function managePointAttachment() {
1597 
1598  $point_id = cleanVar($_REQUEST, 'point_id', 'int', '');
1599  $point = new gmapsPoint($point_id, $this);
1600  $id = cleanVar($_REQUEST, 'id', 'int', '');
1601  $attachment = new gmapsAttachment($id, $this);
1602  $attachment->point_id = $point->id;
1603 
1604  $col1 = $this->listAttachment($point, $attachment);
1605 
1606  if(in_array($this->_action, array('insert', 'modify'))) {
1607  $col2 = $attachment->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_attachment&point_id=$point_id");
1608  }
1609  elseif($this->_action == 'delete') {
1610  $res = $attachment->delete();
1611  if($res === false) {
1612  exit(error::errorMessage(array('error'=>_("Impossibile eliminare l'allegato, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_attachment&point_id=".$point_id));
1613  }
1614  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_attachment&point_id=".$point_id);
1615  }
1616  else {
1617  $col2 = $this->infoAttachment();
1618  }
1619 
1620  $buffer = "<div class=\"vertical_1\">";
1621  $buffer .= $col1;
1622  $buffer .= "</div>";
1623 
1624  $buffer .= "<div class=\"vertical_2\">";
1625  $buffer .= $col2;
1626  $buffer .= "</div>";
1627 
1628  $buffer .= "<div class=\"null\"></div>";
1629 
1630  return $buffer;
1631  }
1632 
1639  private function managePointCollection() {
1640 
1641  $point_id = cleanVar($_REQUEST, 'point_id', 'int', '');
1642  $point = new gmapsPoint($point_id, $this);
1643  $id = cleanVar($_REQUEST, 'id', 'int', '');
1644  $mng = cleanVar($_REQUEST, 'mng', 'string', '');
1645  $collection = new gmapsCollection($id, $this);
1646  $collection->point_id = $point->id;
1647 
1648  $col1 = $this->listCollection($point, $collection);
1649 
1650  if($mng == 'image') {
1651  $image_id = cleanVar($_REQUEST, 'image_id', 'int', '');
1652  $image = new gmapsCollectionImage($image_id, $this);
1653  $image->collection_id = $collection->id;
1654 
1655  if(in_array($this->_action, array('insert_image', 'modify_image'))) {
1656  $col2 = $image->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=$collection->point_id&id=$collection->id&mng=image");
1657  }
1658  elseif($this->_action == 'delete_image') {
1659  $res = $image->delete();
1660  if($res === false) {
1661  exit(error::errorMessage(array('error'=>_("Impossibile eliminare l'immagine, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=".$collection->point_id."&id=".$collection->id));
1662  }
1663  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_collection&point_id=".$collection->point_id."&id=".$collection->id);
1664  }
1665  else {
1666  $col2 = $this->listCollectionImage($collection);
1667  }
1668  }
1669  else {
1670  if(in_array($this->_action, array('insert', 'modify'))) {
1671  $col2 = $collection->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=$point_id");
1672  }
1673  elseif($this->_action == 'delete') {
1674  $res = $collection->delete();
1675  if($res === false) {
1676  exit(error::errorMessage(array('error'=>_("Impossibile eliminare la collezione, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=".$point_id));
1677  }
1678  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_collection&point_id=".$point_id);
1679  }
1680  else {
1681  $col2 = $this->infoCollection();
1682  }
1683  }
1684 
1685  $buffer = "<div class=\"vertical_1\">";
1686  $buffer .= $col1;
1687  $buffer .= "</div>";
1688 
1689  $buffer .= "<div class=\"vertical_2\">";
1690  $buffer .= $col2;
1691  $buffer .= "</div>";
1692 
1693  $buffer .= "<div class=\"null\"></div>";
1694 
1695  return $buffer;
1696  }
1697 
1706  private function listAttachment($point, $sel_attachment) {
1707 
1708  $title = sprintf(_("Allegati del punto di interesse '%s'"), htmlChars($point->label));
1709  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_attachment&point_id=".$point->id."&action=insert\">".pub::icon('insert', _("nuovo allegato"))."</a>";
1710  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
1711 
1712  if($tot = count($point->attachments())) {
1713  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
1714  $buffer = $htmlList->start();
1715  foreach($point->attachments() as $attachment) {
1716  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_attachment&action=modify&point_id=".$point->id."&id=".$attachment->id."\">".pub::icon('modify')."</a>";
1717  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare l'allegato?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_attachment&action=delete&point_id=".$point->id."&id=".$attachment->id."';\">".pub::icon('delete')."</span>";
1718  $selected = $attachment->id == $sel_attachment->id ? true : false;
1719  $buffer .= $htmlList->item(htmlChars($attachment->name), array($link_modify, $link_delete), $selected, true);
1720  }
1721  $buffer .= $htmlList->end();
1722  }
1723  else {
1724  $buffer = "<p class=\"message\">"._("Non risultano allegati registrati")."</p>";
1725  }
1726 
1727  $htmlsection->content = $buffer;
1728 
1729  return $htmlsection->render();
1730  }
1731 
1740  private function listCollection($point, $sel_collection) {
1741 
1742  $title = sprintf(_("Collezioni del punto di interesse '%s'"), htmlChars($point->label));
1743  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=".$point->id."&action=insert\">".pub::icon('insert', _("nuova collezione"))."</a>";
1744  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
1745 
1746  if($tot = count($point->collections())) {
1747  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
1748  $buffer = $htmlList->start();
1749  foreach($point->collections() as $collection) {
1750  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&action=modify&point_id=".$point->id."&id=".$collection->id."\">".pub::icon('modify')."</a>";
1751  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare la collezione?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&action=delete&point_id=".$point->id."&id=".$collection->id."';\">".pub::icon('delete')."</span>";
1752  $link_images = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&action=modify&point_id=".$point->id."&id=".$collection->id."&mng=image\">".$this->_icon_image."</a>";
1753  $selected = $collection->id == $sel_collection->id ? true : false;
1754  $buffer .= $htmlList->item(htmlChars($collection->name), array($link_modify, $link_delete, $link_images), $selected, true);
1755  }
1756  $buffer .= $htmlList->end();
1757  }
1758  else {
1759  $buffer = "<p class=\"message\">"._("Non risultano collezioni registrate")."</p>";
1760  }
1761 
1762  $htmlsection->content = $buffer;
1763 
1764  return $htmlsection->render();
1765  }
1766 
1774  private function listCollectionImage($collection) {
1775 
1776  $title = sprintf(_("Immagini della collezione '%s'"), htmlChars($collection->name));
1777  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=".$collection->point_id."&id=".$collection->id."&mng=image&action=insert_image\">".pub::icon('insert', _("nuova collezione"))."</a>";
1778  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
1779 
1780  if($tot = count($collection->images())) {
1781  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
1782  $buffer = $htmlList->start();
1783  foreach($collection->images() as $image) {
1784  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&action=modify_image&point_id=".$collection->point_id."&id=".$collection->id."&mng=image&image_id=".$image->id."\">".pub::icon('modify')."</a>";
1785  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare l'immagine?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&action=delete_image&point_id=".$collection->point_id."&id=".$collection->id."&mng=image&image_id=".$image->id."';\">".pub::icon('delete')."</span>";
1786  $buffer .= $htmlList->item(htmlChars($image->title), array($link_modify, $link_delete), false, true);
1787  }
1788  $buffer .= $htmlList->end();
1789  }
1790  else {
1791  $buffer = "<p class=\"message\">"._("Non risultano immagini registrate")."</p>";
1792  }
1793 
1794  $htmlsection->content = $buffer;
1795 
1796  return $htmlsection->render();
1797  }
1798 
1805  private function infoAttachment() {
1806 
1807  $title = _("Informazioni");
1808  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
1809 
1810  $buffer = _("Gestione degli allegati associati al punto di interesse");
1811 
1812  $htmlsection->content = $buffer;
1813 
1814  return $htmlsection->render();
1815 
1816  }
1817 
1824  private function infoCollection() {
1825 
1826  $title = _("Informazioni");
1827  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
1828 
1829  $buffer = _("Gestione delle collezioni associate al punto di interesse, Ciasuna collezione può contenere un numero variabile di immagini.");
1830 
1831  $htmlsection->content = $buffer;
1832 
1833  return $htmlsection->render();
1834 
1835  }
1836 
1843  private function managePointEvent() {
1844 
1845  $point_id = cleanVar($_REQUEST, 'point_id', 'int', '');
1846  $point = new gmapsPoint($point_id, $this);
1847  $id = cleanVar($_REQUEST, 'id', 'int', '');
1848  $event = new gmapsEvent($id, $this);
1849  $event->point_id = $point->id;
1850 
1851  $col1 = $this->listEvent($point, $event);
1852 
1853  if(in_array($this->_action, array('insert', 'modify'))) {
1854  $col2 = $event->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_event&point_id=$point_id");
1855  }
1856  elseif($this->_action == 'delete') {
1857  $res = $event->delete();
1858  if($res === false) {
1859  exit(error::errorMessage(array('error'=>_("Impossibile eliminare l'evento, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_event&point_id=".$point_id));
1860  }
1861  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_event&point_id=".$point_id);
1862  }
1863  else {
1864  $col2 = $this->infoEvent();
1865  }
1866 
1867  $buffer = "<div class=\"vertical_1\">";
1868  $buffer .= $col1;
1869  $buffer .= "</div>";
1870 
1871  $buffer .= "<div class=\"vertical_2\">";
1872  $buffer .= $col2;
1873  $buffer .= "</div>";
1874 
1875  $buffer .= "<div class=\"null\"></div>";
1876 
1877  return $buffer;
1878  }
1879 
1888  private function listEvent($point, $sel_event) {
1889 
1890  $title = sprintf(_("Eventi del punto di interesse '%s'"), htmlChars($point->label));
1891  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_event&point_id=".$point->id."&action=insert\">".pub::icon('insert', _("nuovo evento"))."</a>";
1892  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
1893 
1894  if($tot = count($point->events())) {
1895  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
1896  $buffer = $htmlList->start();
1897  foreach($point->events() as $event) {
1898  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_event&action=modify&point_id=".$point->id."&id=".$event->id."\">".pub::icon('modify')."</a>";
1899  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare l'evento?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_event&action=delete&point_id=".$point->id."&id=".$event->id."';\">".pub::icon('delete')."</span>";
1900  $selected = $event->id == $sel_event->id ? true : false;
1901  $buffer .= $htmlList->item(htmlChars($event->name), array($link_modify, $link_delete), $selected, true);
1902  }
1903  $buffer .= $htmlList->end();
1904  }
1905  else {
1906  $buffer = "<p class=\"message\">"._("Non risultano eventi registrati")."</p>";
1907  }
1908 
1909  $htmlsection->content = $buffer;
1910 
1911  return $htmlsection->render();
1912  }
1913 
1920  private function infoEvent() {
1921 
1922  $title = _("Informazioni");
1923  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
1924 
1925  $buffer = _("Gestione degli eventi associati al punto di interesse");
1926 
1927  $htmlsection->content = $buffer;
1928 
1929  return $htmlsection->render();
1930 
1931  }
1932 
1939  private function managePointVideo() {
1940 
1941  $point_id = cleanVar($_REQUEST, 'point_id', 'int', '');
1942  $point = new gmapsPoint($point_id, $this);
1943  $id = cleanVar($_REQUEST, 'id', 'int', '');
1944  $video = new gmapsVideo($id, $this);
1945  $video->point_id = $point->id;
1946 
1947  $col1 = $this->listVideo($point, $video);
1948 
1949  if(in_array($this->_action, array('insert', 'modify'))) {
1950  $col2 = $video->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_video&point_id=$point_id");
1951  }
1952  elseif($this->_action == 'delete') {
1953  $res = $video->delete();
1954  if($res === false) {
1955  exit(error::errorMessage(array('error'=>_("Impossibile eliminare il video, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_video&point_id=".$point_id));
1956  }
1957  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_video&point_id=".$point_id);
1958  }
1959  else {
1960  $col2 = $this->infoVideo();
1961  }
1962 
1963  $buffer = "<div class=\"vertical_1\">";
1964  $buffer .= $col1;
1965  $buffer .= "</div>";
1966 
1967  $buffer .= "<div class=\"vertical_2\">";
1968  $buffer .= $col2;
1969  $buffer .= "</div>";
1970 
1971  $buffer .= "<div class=\"null\"></div>";
1972 
1973  return $buffer;
1974  }
1975 
1984  private function listVideo($point, $sel_video) {
1985 
1986  $title = sprintf(_("Video del punto di interesse '%s'"), htmlChars($point->label));
1987  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_video&point_id=".$point->id."&action=insert\">".pub::icon('insert', _("nuovo video"))."</a>";
1988  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
1989 
1990  if($tot = count($point->videos())) {
1991  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
1992  $buffer = $htmlList->start();
1993  foreach($point->videos() as $video) {
1994  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_video&action=modify&point_id=".$point->id."&id=".$video->id."\">".pub::icon('modify')."</a>";
1995  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare il video?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_video&action=delete&point_id=".$point->id."&id=".$video->id."';\">".pub::icon('delete')."</span>";
1996  $selected = $video->id == $sel_video->id ? true : false;
1997  $buffer .= $htmlList->item(htmlChars($video->title), array($link_modify, $link_delete), $selected, true);
1998  }
1999  $buffer .= $htmlList->end();
2000  }
2001  else {
2002  $buffer = "<p class=\"message\">"._("Non risultano video registrati")."</p>";
2003  }
2004 
2005  $htmlsection->content = $buffer;
2006 
2007  return $htmlsection->render();
2008  }
2009 
2016  private function infoVideo() {
2017 
2018  $title = _("Informazioni");
2019  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
2020 
2021  $buffer = _("Gestione dei video associati al punto di interesse");
2022 
2023  $htmlsection->content = $buffer;
2024 
2025  return $htmlsection->render();
2026 
2027  }
2028 
2035  private function managePointImage() {
2036 
2037  $point_id = cleanVar($_REQUEST, 'point_id', 'int', '');
2038  $point = new gmapsPoint($point_id, $this);
2039  $id = cleanVar($_REQUEST, 'id', 'int', '');
2040  $image = new gmapsImage($id, $this);
2041  $image->point_id = $point->id;
2042 
2043  $col1 = $this->listImage($point, $image);
2044 
2045  if(in_array($this->_action, array('insert', 'modify'))) {
2046  $col2 = $image->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_image&point_id=$point_id");
2047  }
2048  elseif($this->_action == 'delete') {
2049  $res = $image->delete();
2050  if($res === false) {
2051  exit(error::errorMessage(array('error'=>_("Impossibile eliminare l'immagine, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_image&point_id=".$point_id));
2052  }
2053  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_image&point_id=".$point_id);
2054  }
2055  else {
2056  $col2 = $this->infoImage();
2057  }
2058 
2059  $buffer = "<div class=\"vertical_1\">";
2060  $buffer .= $col1;
2061  $buffer .= "</div>";
2062 
2063  $buffer .= "<div class=\"vertical_2\">";
2064  $buffer .= $col2;
2065  $buffer .= "</div>";
2066 
2067  $buffer .= "<div class=\"null\"></div>";
2068 
2069  return $buffer;
2070  }
2071 
2080  private function listImage($point, $sel_image) {
2081 
2082  $title = sprintf(_("Immagini del punto di interesse '%s'"), htmlChars($point->label));
2083  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_image&point_id=".$point->id."&action=insert\">".pub::icon('insert', _("nuova immagine"))."</a>";
2084  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
2085 
2086  if($tot = count($point->images())) {
2087  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
2088  $buffer = $htmlList->start();
2089  foreach($point->images() as $image) {
2090  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_image&action=modify&point_id=".$point->id."&id=".$image->id."\">".pub::icon('modify')."</a>";
2091  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare l'immagine?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_image&action=delete&point_id=".$point->id."&id=".$image->id."';\">".pub::icon('delete')."</span>";
2092  $selected = $image->id == $sel_image->id ? true : false;
2093  $buffer .= $htmlList->item(htmlChars($image->title), array($link_modify, $link_delete), $selected, true);
2094  }
2095  $buffer .= $htmlList->end();
2096  }
2097  else {
2098  $buffer = "<p class=\"message\">"._("Non risultano immagini registrate")."</p>";
2099  }
2100 
2101  $htmlsection->content = $buffer;
2102 
2103  return $htmlsection->render();
2104  }
2105 
2112  private function infoImage() {
2113 
2114  $title = _("Informazioni");
2115  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
2116 
2117  $buffer = _("Gestione delle immagini associate al punto di interesse");
2118 
2119  $htmlsection->content = $buffer;
2120 
2121  return $htmlsection->render();
2122 
2123  }
2124 
2131  private function manageService() {
2132 
2133  $id = cleanVar($_REQUEST, 'id', 'int', '');
2134  $service = new gmapsService($id, $this);
2135  $service->instance = $this->_instance;
2136 
2137  $col1 = $this->listService($id);
2138 
2139  if(in_array($this->_action, array('insert', 'modify'))) {
2140  $col2 = $service->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service");
2141  }
2142  elseif($this->_action == 'delete') {
2143  $res = $service->delete();
2144  if($res === 'points') {
2145  exit(error::errorMessage(array('error'=>_("Il servizio è presente in uno o più punti di interesse. Eliminarli o cambiarne il servizio e riprovare")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service"));
2146  }
2147  elseif($res === false) {
2148  exit(error::errorMessage(array('error'=>_("Impossibile eliminare il servizio, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service"));
2149  }
2150  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=service");
2151  }
2152  else {
2153  $col2 = $this->infoService();
2154  }
2155 
2156  $buffer = "<div class=\"vertical_1\">";
2157  $buffer .= $col1;
2158  $buffer .= "</div>";
2159 
2160  $buffer .= "<div class=\"vertical_2\">";
2161  $buffer .= $col2;
2162  $buffer .= "</div>";
2163 
2164  $buffer .= "<div class=\"null\"></div>";
2165 
2166  return $buffer;
2167 
2168  }
2169 
2177  private function listService($sel_id) {
2178 
2179  $title = _("Servizi");
2180  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service&action=insert\">".pub::icon('insert', _("nuovo servizio"))."</a>";
2181  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
2182 
2183  $service_ids = gmapsService::get($this->_instance);
2184 
2185  if($tot = count($service_ids)) {
2186  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
2187  $buffer = $htmlList->start();
2188  foreach($service_ids as $service_id) {
2189  $service = new gmapsService($service_id, $this);
2190  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service&action=modify&id=".$service->id."\">".pub::icon('modify')."</a>";
2191  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare il servizio?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=service&action=delete&id=".$service->id."';\">".pub::icon('delete')."</span>";
2192  $selected = $service->id == $sel_id ? true : false;
2193  $buffer .= $htmlList->item(htmlChars($service->name), array($link_modify, $link_delete), $selected, true);
2194  }
2195  $buffer .= $htmlList->end();
2196  }
2197  else {
2198  $buffer = "<p class=\"message\">"._("Non risultano servizi registrati")."</p>";
2199  }
2200 
2201  $htmlsection->content = $buffer;
2202 
2203  return $htmlsection->render();
2204  }
2205 
2212  private function infoService() {
2213 
2214  $title = _("Informazioni");
2215  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
2216 
2217  $buffer = _("Gestione dei servizi associabili ai punti di interesse");
2218 
2219  $htmlsection->content = $buffer;
2220 
2221  return $htmlsection->render();
2222 
2223  }
2224 
2231  private function manageMapItem() {
2232 
2233  $registry = registry::instance();
2234  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
2235 
2236  $id = cleanVar($_REQUEST, 'id', 'int', '');
2237  $map = new gmapsMap($id, $this);
2238 
2239  $title = sprintf(_("Punti di interesse, percorsi ed aree associati alla mappa '%s'"), htmlChars($map->name));
2240  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
2241 
2242  $buffer = '';
2243 
2244  if(isset($_POST['submit_add'])) {
2245  $add_point_ids = cleanVar($_POST, 'point_add', 'array', '');
2246  $res = $map->addPoints($add_point_ids);
2247  if(count($add_point_ids) && !$res) {
2248  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=$id"));
2249  }
2250 
2251  $add_polylines_ids = cleanVar($_POST, 'polyline_add', 'array', '');
2252  $res = $map->addPolylines($add_polylines_ids);
2253 
2254  if(count($add_polylines_ids) && !$res) {
2255  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=$id"));
2256  }
2257 
2258  $add_polygons_ids = cleanVar($_POST, 'polygon_add', 'array', '');
2259  $res = $map->addPolygons($add_polygons_ids);
2260 
2261  if(count($add_polygons_ids) && !$res) {
2262  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=$id"));
2263  }
2264  else {
2265  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=map_item&id=".$id);
2266  }
2267  }
2268  elseif(isset($_POST['submit_remove'])) {
2269  $remove_point_ids = cleanVar($_POST, 'point_remove', 'array', '');
2270  $res = $map->removePoints($remove_point_ids);
2271  if(count($remove_point_ids) && !$res) {
2272  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=$id"));
2273  }
2274 
2275  $remove_polyline_ids = cleanVar($_POST, 'polyline_remove', 'array', '');
2276  $res = $map->removePolylines($remove_polyline_ids);
2277  if(count($remove_polyline_ids) && !$res) {
2278  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=$id"));
2279  }
2280 
2281  $remove_polygon_ids = cleanVar($_POST, 'polygon_remove', 'array', '');
2282  $res = $map->removePolygons($remove_polygon_ids);
2283  if(count($remove_polygon_ids) && !$res) {
2284  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=$id"));
2285  }
2286 
2287  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=map_item&id=".$id);
2288  }
2289 
2290  $points_code = '';
2291  $polylines_code = '';
2292  $polygons_code = '';
2293  $buffer .= "<h2>"._("Punti di interesse, percorsi ed aree presenti")."</h2>";
2294  if(count($map->points()) || count($map->polylines()) || count($map->polygons())) {
2295  $gform = new Form('form_remove_map_point', 'post', false, array('tblLayout'=>false));
2296  $buffer .= $gform->form('', false, '');
2297  $buffer .= $gform->hidden('id', $id);
2298  $buffer .= "<table class=\"generic\" style=\"margin-bottom: 10px;\">";
2299 
2300  if(count($map->points())) {
2301 
2302  $buffer .= "<tr>";
2303  $buffer .= "<th>Etichetta punto di interesse</th>";
2304  $buffer .= "<th>Rimuovi</th>";
2305  $buffer .= "</tr>";
2306  foreach($map->points() as $point) {
2307  $points_code .= $point->gmapCode('map', 'bounds');
2308  $buffer .= "<tr>";
2309  $buffer .= "<td>".htmlChars($point->label)."</td>";
2310  $buffer .= "<td><input type=\"checkbox\" name=\"point_remove[]\" value=\"".$point->id."\" /></td>";
2311  $buffer .= "</tr>";
2312  }
2313  }
2314  if(count($map->polylines())) {
2315 
2316  $buffer .= "<tr>";
2317  $buffer .= "<th>Etichetta percorso</th>";
2318  $buffer .= "<th>Rimuovi</th>";
2319  $buffer .= "</tr>";
2320  foreach($map->polylines() as $polyline) {
2321  $polylines_code .= $polyline->gmapCode('map', 'bounds');
2322  $buffer .= "<tr>";
2323  $buffer .= "<td>".htmlChars($polyline->label)."</td>";
2324  $buffer .= "<td><input type=\"checkbox\" name=\"polyline_remove[]\" value=\"".$polyline->id."\" /></td>";
2325  $buffer .= "</tr>";
2326  }
2327  }
2328  if(count($map->polygons())) {
2329 
2330  $buffer .= "<tr>";
2331  $buffer .= "<th>Etichetta percorso</th>";
2332  $buffer .= "<th>Rimuovi</th>";
2333  $buffer .= "</tr>";
2334  foreach($map->polygons() as $polygon) {
2335  $polygons_code .= $polygon->gmapCode('map', 'bounds');
2336  $buffer .= "<tr>";
2337  $buffer .= "<td>".htmlChars($polygon->label)."</td>";
2338  $buffer .= "<td><input type=\"checkbox\" name=\"polygon_remove[]\" value=\"".$polygon->id."\" /></td>";
2339  $buffer .= "</tr>";
2340  }
2341  }
2342  $buffer .= "</table>";
2343  $buffer .= "<p>".$gform->input('submit_remove', 'submit', _("rimuovi selezionati"), array('classField'=>'submit'))."</p>";
2344  $buffer .= $gform->cform();
2345  }
2346  else {
2347  $buffer .= "<p class=\"message\">"._("Non risultano punti di interesse, percorsi o aree associati")."</p>";
2348  }
2349 
2350  $buffer .= "<h2>Situazione attuale</h2>";
2351  $buffer .= "<div id=\"map_canvas\" style=\"width:100%; height: 300px;\"></div>";
2352  $buffer .= "<script>";
2353  $buffer .= "window.addEvent('load', function() {
2354  var myopt = {
2355  center: new google.maps.LatLng(45, 7),
2356  zoom: 10,
2357  mapTypeId: google.maps.MapTypeId.ROADMAP
2358  }
2359 
2360  var map = new google.maps.Map($('map_canvas'), myopt);
2361  var bounds = new google.maps.LatLngBounds();
2362  ".$points_code."
2363  ".$polylines_code."
2364  ".$polygons_code."
2365  map.fitBounds(bounds);
2366 
2367  })";
2368  $buffer .= "</script>";
2369 
2370  $buffer .= "<h2>"._("Ricerca ed aggiunta punti, percorsi ed aree")."</h2>";
2371 
2372  $buffer .= $this->formAddMapPolygonPolylinePoint($map);
2373 
2374  $htmlsection->content = $buffer;
2375 
2376  return $htmlsection->render();
2377  }
2378 
2386  private function formAddMapPolygonPolylinePoint($map) {
2387 
2388  $gform = new Form('form_search_add_map_polygon_polyline_point', 'post', false);
2389  $buffer = $gform->form('', false, '');
2390 
2391  $buffer .= $gform->cselect('point_ctg', '', gmapsPointCtg::getForSelect($this->_instance), _("Categoria punti di interesse"), array('id'=>'point_ctg'));
2392  $buffer .= $gform->cinput('point_label', 'text', '', _("Etichetta punti di interesse"), array('maxlength'=>200, 'id'=>'point_label'));
2393  $buffer .= $gform->cselect('polyline_ctg', '', gmapsPolylineCtg::getForSelect($this->_instance), _("Categoria percorsi"), array('id'=>'polyline_ctg'));
2394  $buffer .= $gform->cinput('polyline_label', 'text', '', _("Etichetta percorsi"), array('maxlength'=>200, 'id'=>'polyline_label'));
2395  $buffer .= $gform->cselect('polygon_ctg', '', gmapsPolygonCtg::getForSelect($this->_instance), _("Categoria aree"), array('id'=>'polygon_ctg'));
2396  $buffer .= $gform->cinput('polygon_label', 'text', '', _("Etichetta aree"), array('maxlength'=>200, 'id'=>'polygon_label'));
2397 
2398  $onclick = "ajaxRequest('post', '".$this->_home."?pt[".$this->_instanceName."-mapPolygonPolylinePointSearch]', 'id=".$map->id."&point_ctg='+$('point_ctg').value+'&point_label='+$('point_label').value+'&polyline_ctg='+$('polyline_ctg').value+'&polyline_label='+$('polyline_label').value+'&polygon_ctg='+$('polygon_ctg').value+'&polygon_label='+$('polygon_label').value, 'map_polygon_polyline_point_search', {load: 'map_polygon_polyline_point_search'})";
2399 
2400  $buffer .= $gform->cinput('submit_search', 'button', _("cerca"), '', array('classField'=>'submit', 'js'=>"onclick=\"$onclick\""));
2401 
2402  $buffer .= $gform->cform();
2403 
2404  $buffer .= "<div id=\"map_polygon_polyline_point_search\" style=\"margin-top: 10px;\"></div>";
2405 
2406  return $buffer;
2407  }
2408 
2415  public function mapPolygonPolylinePointSearch() {
2416 
2417  $this->accessGroup('ALL');
2418 
2419  $id = cleanVar($_POST, 'id', 'int', '');
2420  $point_ctg = cleanVar($_POST, 'point_ctg', 'int', '');
2421  $point_label = cleanVar($_POST, 'point_label', 'string', '');
2422  $polyline_ctg = cleanVar($_POST, 'polyline_ctg', 'int', '');
2423  $polyline_label = cleanVar($_POST, 'polyline_label', 'string', '');
2424  $polygon_ctg = cleanVar($_POST, 'polygon_ctg', 'int', '');
2425  $polygon_label = cleanVar($_POST, 'polygon_label', 'string', '');
2426 
2427  $map = new gmapsMap($id, $this);
2428 
2429  $where = array();
2430  if(count($map->points_id())) {
2431  $where[] = "id NOT IN (".implode(',', $map->points_id()).")";
2432  }
2433  if(count($map->polylines_id())) {
2434  $nopoints = array();
2435  foreach($map->polylines() as $polyline) {
2436  $nopoints = array_merge($nopoints, $polyline->points_id());
2437  }
2438  $where[] = "id NOT IN (".implode(',', $nopoints).")";
2439  }
2440  if(count($map->polygons_id())) {
2441  $nopoints = array();
2442  foreach($map->polygons() as $polygon) {
2443  $nopoints = array_merge($nopoints, $polygon->points_id());
2444  }
2445  $where[] = "id NOT IN (".implode(',', $nopoints).")";
2446  }
2447  if($point_ctg) {
2448  $where[] = "id IN (SELECT point_id FROM ".$this->_tbl_point_point_ctg." WHERE ctg_id='$point_ctg')";
2449  }
2450  if($point_label) {
2451  $where[] = "label LIKE '%$point_label%'";
2452  }
2453 
2454  $point_ids = gmapsPoint::get($this->_instance, array('where'=>implode(" AND ", $where)));
2455 
2456  $where = array();
2457  if(count($map->polylines_id())) {
2458  $where[] = "id NOT IN (".implode(',', $map->polylines_id()).")";
2459  }
2460  if($polyline_ctg) {
2461  $where[] = "id IN (SELECT polyline_id FROM ".$this->_tbl_polyline_polyline_ctg." WHERE ctg_id='$polyline_ctg')";
2462  }
2463  if($polyline_label) {
2464  $where[] = "label LIKE '%$polyline_label%'";
2465  }
2466 
2467  $polyline_ids = gmapsPolyline::get($this->_instance, array('where'=>implode(" AND ", $where)));
2468 
2469  $where = array();
2470  if(count($map->polygons_id())) {
2471  $where[] = "id NOT IN (".implode(',', $map->polygons_id()).")";
2472  }
2473  if($polygon_ctg) {
2474  $where[] = "id IN (SELECT polygon_id FROM ".$this->_tbl_polygon_polygon_ctg." WHERE ctg_id='$polygon_ctg')";
2475  }
2476  if($polygon_label) {
2477  $where[] = "label LIKE '%$polygon_label%'";
2478  }
2479 
2480  $polygon_ids = gmapsPolygon::get($this->_instance, array('where'=>implode(" AND ", $where)));
2481 
2482  $buffer = "<p><b>"._("Punti di interesse, percorsi e aree")."</b></p>";
2483 
2484  $gform = new Form('form_add_map_polygon_polyline_point', 'post', false, array('tblLayout'=>false));
2485  $buffer .= $gform->form('', false, '');
2486  $buffer .= $gform->hidden('id', $id);
2487  $buffer .= "<table class=\"generic\">";
2488  if(count($point_ids)) {
2489 
2490  $buffer .= "<tr>";
2491  $buffer .= "<th>"._("Etichetta punto di interesse")."</th>";
2492  $buffer .= "<th>"._("Aggiungi")."</th>";
2493  $buffer .= "</tr>";
2494  foreach($point_ids as $point_id) {
2495  $point = new gmapsPoint($point_id, $this);
2496  $buffer .= "<tr>";
2497  $buffer .= "<td>".htmlChars($point->label)."</td>";
2498  $buffer .= "<td><input type=\"checkbox\" name=\"point_add[]\" value=\"".$point->id."\" /></td>";
2499  $buffer .= "</tr>";
2500  }
2501  }
2502  if(count($polyline_ids)) {
2503 
2504  $buffer .= "<tr>";
2505  $buffer .= "<th>"._("Etichetta percorso")."</th>";
2506  $buffer .= "<th>"._("Aggiungi")."</th>";
2507  $buffer .= "</tr>";
2508  foreach($polyline_ids as $polyline_id) {
2509  $polyline = new gmapsPolyline($polyline_id, $this);
2510  $buffer .= "<tr>";
2511  $buffer .= "<td>".htmlChars($polyline->label)."</td>";
2512  $buffer .= "<td><input type=\"checkbox\" name=\"polyline_add[]\" value=\"".$polyline->id."\" /></td>";
2513  $buffer .= "</tr>";
2514  }
2515  }
2516  if(count($polygon_ids)) {
2517 
2518  $buffer .= "<tr>";
2519  $buffer .= "<th>"._("Etichetta area")."</th>";
2520  $buffer .= "<th>"._("Aggiungi")."</th>";
2521  $buffer .= "</tr>";
2522  foreach($polygon_ids as $polygon_id) {
2523  $polygon = new gmapsPolygon($polygon_id, $this);
2524  $buffer .= "<tr>";
2525  $buffer .= "<td>".htmlChars($polygon->label)."</td>";
2526  $buffer .= "<td><input type=\"checkbox\" name=\"polygon_add[]\" value=\"".$polyline->id."\" /></td>";
2527  $buffer .= "</tr>";
2528  }
2529  }
2530  $buffer .= "</table>";
2531  $buffer .= "<p>".$gform->input('submit_add', 'submit', _("aggiungi selezionati"), array('classField'=>'submit'))."</p>";
2532  $buffer .= $gform->cform();
2533 
2534 
2535  if(!count($point_ids) && !count($polyline_ids) && !count($polygon_ids)) {
2536  $buffer = "<p class=\"message\">"._("La ricerca non ha prodotto risultati")."</p>";
2537  }
2538 
2539  return $buffer;
2540 
2541  }
2542 
2549  private function manageMap() {
2550 
2551  $id = cleanVar($_REQUEST, 'id', 'int', '');
2552  $map = new gmapsMap($id, $this);
2553  $map->instance = $this->_instance;
2554 
2555  if(in_array($this->_action, array('insert', 'modify'))) {
2556  $col = $map->form($this->_home."?evt[".$this->_instanceName."-manageDoc]");
2557  }
2558  elseif($this->_action == 'delete') {
2559  $map->delete();
2560  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "");
2561  }
2562  else {
2563  $col = $this->listMap();
2564  }
2565 
2566  $buffer = "<div>";
2567  $buffer .= $col;
2568  $buffer .= "</div>";
2569 
2570  return $buffer;
2571  }
2572 
2579  private function listMap() {
2580 
2581  $title = _("Mappe");
2582  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&action=insert\">".pub::icon('insert', _("nuova mappa"))."</a>";
2583  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>array($link_insert), 'headerLabel'=>$title));
2584 
2585  $buffer = '';
2586 
2587  $map_ids = gmapsMap::get($this->_instance, array());
2588  if($tot = count($map_ids)) {
2589 
2590  $buffer .= "<table class=\"generic\">";
2591  $buffer .= "<tr>";
2592  $buffer .= "<th>"._("ID")."</th>";
2593  $buffer .= "<th>"._("Nome")."</th>";
2594  $buffer .= "<th>"._("Larghezza")."</th>";
2595  $buffer .= "<th>"._("Altezza")."</th>";
2596  $buffer .= "<th class=\"thIcon\"></th>";
2597  $buffer .= "</tr>";
2598  foreach($map_ids as $map_id) {
2599  $map = new gmapsMap($map_id, $this);
2600  $buffer .= "<tr>";
2601  $buffer .= "<td>".$map->id."</td>";
2602  $buffer .= "<td>".htmlChars($map->name)."</td>";
2603  $buffer .= "<td>".htmlChars($map->width)."</td>";
2604  $buffer .= "<td>".htmlChars($map->height)."</td>";
2605  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&action=modify&id=".$map->id."\">".pub::icon('modify')."</a>";
2606  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare la mappa?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&action=delete&id=".$map->id."';\">".pub::icon('delete')."</span>";
2607  $link_items = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=map_item&id=".$map->id."\">".$this->_icon_map_element."</a>";
2608  $onclick = "window.myWin = new layerWindow({'title':'"._("Codice embed")."', 'url':'".$this->_home."?pt[".$this->_instanceName."-iframeCode]&id=$map_id', 'width':600});window.myWin.display();";
2609  $link_link = "<span class=\"link\" onclick=\"$onclick\">".pub::icon('link', _("Codice inserimento iframe"))."</span>";
2610  $buffer .= "<td class=\"tdIcon\">$link_modify $link_delete $link_items $link_link</td>";
2611  $buffer .= "</tr>";
2612 
2613  }
2614  $buffer .= "</table>";
2615 
2616  }
2617  else {
2618  $buffer .= "<p class=\"message\">"._("Non risultano mappe registrate")."</p>";
2619  }
2620 
2621  $htmlsection->content = $buffer;
2622 
2623  return $htmlsection->render();
2624  }
2625 
2632  public function iframeCode() {
2633 
2634  $this->accessGroup('ALL');
2635 
2636  $id = cleanVar($_GET, 'id', 'int', '');
2637  $map = new gmapsMap($id, $this);
2638 
2639  $buffer = "<p>"._("Copia il codice seguente ed incollalo nella posizione desideratea all'interno del codice html del sito nel quale vuoi includere la mappa. Potrebbe essere necessario ritoccare i valore width ed height in modo da far scomparire eventuali barre di scorrimento.")."</p>";
2640  $buffer .= "<textarea style=\"width:99%\" rows=\"3\" readonly>";
2641  $buffer .= "<iframe frameborder=\"0\" width=\"".$map->width."\" height=\"".$map->height."\" src=\"".$this->_url_root.SITE_WWW.'/'.$this->_plink->aLink($this->_instanceName, 'iframeMap', array('id'=>$map->id), '')."\">Your browser doesn't support iframes</iframe>&lt;script type=\"text/javascript\"&gt;function gmaps_chg_parent_url(url) { document.location = url; }&lt;/script&gt;";
2642  $buffer .= "</textarea>";
2643 
2644  return $buffer;
2645 
2646  }
2647 
2654  private function managePolylinePoint() {
2655 
2656  $registry = registry::instance();
2657  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
2658 
2659  $id = cleanVar($_REQUEST, 'id', 'int', '');
2660  $polyline = new gmapsPolyline($id, $this);
2661 
2662  $title = sprintf(_("Punti di interesse associati al percorso '%s'"), htmlChars($polyline->label));
2663  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
2664 
2665  $buffer = '';
2666 
2667  if(isset($_POST['submit_add'])) {
2668  $add_point_ids = cleanVar($_POST, 'point_add', 'array', '');
2669  $res = $polyline->addPoints($add_point_ids);
2670  if(!$res) {
2671  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_point&id=$id"));
2672  }
2673  else {
2674  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polyline_point&id=".$id);
2675  }
2676  }
2677  elseif(isset($_POST['submit_remove'])) {
2678  $remove_point_ids = cleanVar($_POST, 'point_remove', 'array', '');
2679  $res = $polyline->removePoints($remove_point_ids);
2680  if(!$res) {
2681  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_point&id=$id"));
2682  }
2683  else {
2684  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polyline_point&id=".$id);
2685  }
2686  }
2687 
2688  $buffer .= "<h2>"._("Punti presenti")."</h2>";
2689 
2690  if(count($polyline->points())) {
2691 
2692  $gform = new Form('form_remove_polyline_point', 'post', false, array('tblLayout'=>false));
2693  $buffer .= $gform->form('', false, '');
2694  $buffer .= $gform->hidden('id', $id);
2695  $buffer .= "<table class=\"generic\" style=\"margin-bottom: 10px;\">";
2696  $buffer .= "<tr>";
2697  $buffer .= "<th>Etichetta</th>";
2698  $buffer .= "<th>Rimuovi</th>";
2699  $buffer .= "</tr>";
2700  foreach($polyline->points() as $point) {
2701  $buffer .= "<tr>";
2702  $buffer .= "<td>".htmlChars($point->label)."</td>";
2703  $buffer .= "<td><input type=\"checkbox\" name=\"point_remove[]\" value=\"".$point->id."\" /></td>";
2704  $buffer .= "</tr>";
2705  }
2706  $buffer .= "</table>";
2707  $buffer .= "<p>".$gform->input('submit_remove', 'submit', _("rimuovi selezionati"), array('classField'=>'submit'))."</p>";
2708  $buffer .= $gform->cform();
2709  }
2710  else {
2711  $buffer .= "<p class=\"message\">"._("Non risultano punti di interesse associati")."</p>";
2712  }
2713 
2714  $buffer .= "<h2>"._("Situazione attuale")."</h2>";
2715  $buffer .= "<div id=\"map_canvas\" style=\"width:100%; height: 300px;\"></div>";
2716  $buffer .= "<script>";
2717  $buffer .= "window.addEvent('load', function() {
2718  var myopt = {
2719  center: new google.maps.LatLng(45, 7),
2720  zoom: 10,
2721  mapTypeId: google.maps.MapTypeId.ROADMAP
2722  }
2723 
2724  var map = new google.maps.Map($('map_canvas'), myopt);
2725  var bounds = new google.maps.LatLngBounds();
2726  ".$polyline->gmapCode('map', 'bounds')."
2727  map.fitBounds(bounds);
2728 
2729  })";
2730  $buffer .= "</script>";
2731 
2732 
2733  $buffer .= "<h2>"._("Ricerca ed aggiunta punti")."</h2>";
2734 
2735  $buffer .= $this->formAddPolylinePoint($polyline);
2736 
2737  $htmlsection->content = $buffer;
2738 
2739  return $htmlsection->render();
2740 
2741  }
2742 
2749  private function managePolygonPoint() {
2750 
2751  $registry = registry::instance();
2752  $registry->addJs("http://maps.googleapis.com/maps/api/js?key=AIzaSyArAE-uBvCZTRaf_eaFn4umUdESmoUvoxM&sensor=true");
2753 
2754  $id = cleanVar($_REQUEST, 'id', 'int', '');
2755  $polygon = new gmapsPolygon($id, $this);
2756 
2757  $title = sprintf(_("Punti di interesse associati all'area '%s'"), htmlChars($polygon->label));
2758  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
2759 
2760  $buffer = '';
2761 
2762  if(isset($_POST['submit_add'])) {
2763  $add_point_ids = cleanVar($_POST, 'point_add', 'array', '');
2764  $res = $polygon->addPoints($add_point_ids);
2765  if(!$res) {
2766  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_point&id=$id"));
2767  }
2768  else {
2769  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polygon_point&id=".$id);
2770  }
2771  }
2772  elseif(isset($_POST['submit_remove'])) {
2773  $remove_point_ids = cleanVar($_POST, 'point_remove', 'array', '');
2774  $res = $polygon->removePoints($remove_point_ids);
2775  if(!$res) {
2776  exit(error::errorMessage(array('error'=>_("Si è verificato un errore, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_point&id=$id"));
2777  }
2778  else {
2779  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polygon_point&id=".$id);
2780  }
2781  }
2782 
2783  $buffer .= "<h2>"._("Punti presenti")."</h2>";
2784 
2785  if(count($polygon->points())) {
2786 
2787  $gform = new Form('form_remove_polygon_point', 'post', false, array('tblLayout'=>false));
2788  $buffer .= $gform->form('', false, '');
2789  $buffer .= $gform->hidden('id', $id);
2790  $buffer .= "<table class=\"generic\" style=\"margin-bottom: 10px;\">";
2791  $buffer .= "<tr>";
2792  $buffer .= "<th>Etichetta</th>";
2793  $buffer .= "<th>Rimuovi</th>";
2794  $buffer .= "</tr>";
2795  foreach($polygon->points() as $point) {
2796  $buffer .= "<tr>";
2797  $buffer .= "<td>".htmlChars($point->label)."</td>";
2798  $buffer .= "<td><input type=\"checkbox\" name=\"point_remove[]\" value=\"".$point->id."\" /></td>";
2799  $buffer .= "</tr>";
2800  }
2801  $buffer .= "</table>";
2802  $buffer .= "<p>".$gform->input('submit_remove', 'submit', _("rimuovi selezionati"), array('classField'=>'submit'))."</p>";
2803  $buffer .= $gform->cform();
2804  }
2805  else {
2806  $buffer .= "<p class=\"message\">"._("Non risultano punti di interesse associati")."</p>";
2807  }
2808 
2809  $buffer .= "<h2>"._("Situazione attuale")."</h2>";
2810  $buffer .= "<div id=\"map_canvas\" style=\"width:100%; height: 300px;\"></div>";
2811  $buffer .= "<script>";
2812  $buffer .= "window.addEvent('load', function() {
2813  var myopt = {
2814  center: new google.maps.LatLng(45, 7),
2815  zoom: 10,
2816  mapTypeId: google.maps.MapTypeId.ROADMAP
2817  }
2818 
2819  var map = new google.maps.Map($('map_canvas'), myopt);
2820  var bounds = new google.maps.LatLngBounds();
2821  ".$polygon->gmapCode('map', 'bounds')."
2822  map.fitBounds(bounds);
2823 
2824  })";
2825  $buffer .= "</script>";
2826 
2827 
2828  $buffer .= "<h2>"._("Ricerca ed aggiunta punti")."</h2>";
2829 
2830  $buffer .= $this->formAddPolygonPoint($polygon);
2831 
2832  $htmlsection->content = $buffer;
2833 
2834  return $htmlsection->render();
2835 
2836  }
2837 
2845  private function formAddPolylinePoint($polyline) {
2846 
2847  $gform = new Form('form_search_add_polyline_point', 'post', false);
2848  $buffer = $gform->form('', false, '');
2849 
2850  $buffer .= $gform->cselect('point_ctg', '', gmapsPointCtg::getForSelect($this->_instance), _("Categoria"), array('id'=>'point_ctg'));
2851  $buffer .= $gform->cinput('point_label', 'text', '', _("Etichetta"), array('maxlength'=>200, 'id'=>'point_label'));
2852 
2853  $onclick = "ajaxRequest('post', '".$this->_home."?pt[".$this->_instanceName."-polylinePointSearch]', 'id=".$polyline->id."&ctg='+$('point_ctg').value+'&label='+$('point_label').value, 'polyline_point_search', {load: 'polyline_point_search'})";
2854 
2855  $buffer .= $gform->cinput('submit_search', 'button', _("cerca"), '', array('classField'=>'submit', 'js'=>"onclick=\"$onclick\""));
2856 
2857  $buffer .= $gform->cform();
2858 
2859  $buffer .= "<div id=\"polyline_point_search\" style=\"margin-top: 10px;\"></div>";
2860 
2861  return $buffer;
2862  }
2863 
2871  private function formAddPolygonPoint($polygon) {
2872 
2873  $gform = new Form('form_search_add_polygon_point', 'post', false);
2874  $buffer = $gform->form('', false, '');
2875 
2876  $buffer .= $gform->cselect('point_ctg', '', gmapsPointCtg::getForSelect($this->_instance), _("Categoria"), array('id'=>'point_ctg'));
2877  $buffer .= $gform->cinput('point_label', 'text', '', _("Etichetta"), array('maxlength'=>200, 'id'=>'point_label'));
2878 
2879  $onclick = "ajaxRequest('post', '".$this->_home."?pt[".$this->_instanceName."-polygonPointSearch]', 'id=".$polygon->id."&ctg='+$('point_ctg').value+'&label='+$('point_label').value, 'polygon_point_search', {load: 'polygon_point_search'})";
2880 
2881  $buffer .= $gform->cinput('submit_search', 'button', _("cerca"), '', array('classField'=>'submit', 'js'=>"onclick=\"$onclick\""));
2882 
2883  $buffer .= $gform->cform();
2884 
2885  $buffer .= "<div id=\"polygon_point_search\" style=\"margin-top: 10px;\"></div>";
2886 
2887  return $buffer;
2888  }
2889 
2890 
2897  public function polylinePointSearch() {
2898 
2899  $this->accessGroup('ALL');
2900 
2901  $id = cleanVar($_POST, 'id', 'int', '');
2902  $ctg = cleanVar($_POST, 'ctg', 'int', '');
2903  $label = cleanVar($_POST, 'label', 'string', '');
2904 
2905  $polyline = new gmapsPolyline($id, $this);
2906 
2907  $where = array();
2908  if(count($polyline->points_id())) {
2909  $where[] = "id NOT IN (".implode(',', $polyline->points_id()).")";
2910  }
2911  if($label) {
2912  $where[] = "label LIKE '%$label%'";
2913  }
2914 
2915  $point_ids = gmapsPoint::get($this->_instance, array('where'=>implode(" AND ", $where), 'ctg'=>$ctg));
2916 
2917  if(count($point_ids)) {
2918 
2919  $gform = new Form('form_add_polyline_point', 'post', false, array('tblLayout'=>false));
2920  $buffer = $gform->form('', false, '');
2921  $buffer .= $gform->hidden('id', $id);
2922 
2923  $buffer .= "<table class=\"generic\">";
2924  $buffer .= "<tr>";
2925  $buffer .= "<th>"._("Etichetta")."</th>";
2926  $buffer .= "<th>"._("Aggiungi")."</th>";
2927  $buffer .= "</tr>";
2928  foreach($point_ids as $point_id) {
2929  $point = new gmapsPoint($point_id, $this);
2930  $buffer .= "<tr>";
2931  $buffer .= "<td>".htmlChars($point->label)."</td>";
2932  $buffer .= "<td><input type=\"checkbox\" name=\"point_add[]\" value=\"".$point->id."\" /></td>";
2933  $buffer .= "</tr>";
2934  }
2935  $buffer .= "<table>";
2936 
2937  $buffer .= "<p>".$gform->input('submit_add', 'submit', _("aggiungi selezionati"), array('classField'=>'submit'))."</p>";
2938  $buffer .= $gform->cform();
2939 
2940  }
2941  else {
2942  $buffer = "<p class=\"message\">"._("La ricerca non ha prodotto risultati")."</p>";
2943  }
2944 
2945  return $buffer;
2946 
2947  }
2948 
2955  public function polygonPointSearch() {
2956 
2957  $this->accessGroup('ALL');
2958 
2959  $id = cleanVar($_POST, 'id', 'int', '');
2960  $ctg = cleanVar($_POST, 'ctg', 'int', '');
2961  $label = cleanVar($_POST, 'label', 'string', '');
2962 
2963  $polygon = new gmapsPolygon($id, $this);
2964 
2965  $where = array();
2966  if(count($polygon->points_id())) {
2967  $where[] = "id NOT IN (".implode(',', $polygon->points_id()).")";
2968  }
2969  if($label) {
2970  $where[] = "label LIKE '%$label%'";
2971  }
2972 
2973  $point_ids = gmapsPoint::get($this->_instance, array('where'=>implode(" AND ", $where), 'ctg'=>$ctg));
2974 
2975  if(count($point_ids)) {
2976 
2977  $gform = new Form('form_add_polygon_point', 'post', false, array('tblLayout'=>false));
2978  $buffer = $gform->form('', false, '');
2979  $buffer .= $gform->hidden('id', $id);
2980 
2981  $buffer .= "<table class=\"generic\">";
2982  $buffer .= "<tr>";
2983  $buffer .= "<th>"._("Etichetta")."</th>";
2984  $buffer .= "<th>"._("Aggiungi")."</th>";
2985  $buffer .= "</tr>";
2986  foreach($point_ids as $point_id) {
2987  $point = new gmapsPoint($point_id, $this);
2988  $buffer .= "<tr>";
2989  $buffer .= "<td>".htmlChars($point->label)."</td>";
2990  $buffer .= "<td><input type=\"checkbox\" name=\"point_add[]\" value=\"".$point->id."\" /></td>";
2991  $buffer .= "</tr>";
2992  }
2993  $buffer .= "<table>";
2994 
2995  $buffer .= "<p>".$gform->input('submit_add', 'submit', _("aggiungi selezionati"), array('classField'=>'submit'))."</p>";
2996  $buffer .= $gform->cform();
2997 
2998  }
2999  else {
3000  $buffer = "<p class=\"message\">"._("La ricerca non ha prodotto risultati")."</p>";
3001  }
3002 
3003  return $buffer;
3004 
3005  }
3006 
3013  private function managePolyline() {
3014 
3015  $id = cleanVar($_REQUEST, 'id', 'int', '');
3016  $start = cleanVar($_GET, 'start', 'int', '');
3017  $polyline = new gmapsPolyline($id, $this);
3018  $polyline->instance = $this->_instance;
3019 
3020  if(in_array($this->_action, array('insert', 'modify'))) {
3021  $col = $polyline->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline&start=$start");
3022  }
3023  elseif($this->_action == 'delete') {
3024  // delete polyline and all associations
3025  $polyline->delete();
3026  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polyline&start=$start");
3027  }
3028  else {
3029  $col = $this->listPolyline();
3030  }
3031 
3032  $buffer = "<div>";
3033  $buffer .= $col;
3034  $buffer .= "</div>";
3035 
3036  return $buffer;
3037  }
3038 
3045  private function managePolygon() {
3046 
3047  $id = cleanVar($_REQUEST, 'id', 'int', '');
3048  $start = cleanVar($_GET, 'start', 'int', '');
3049  $polygon = new gmapsPolygon($id, $this);
3050  $polygon->instance = $this->_instance;
3051 
3052  if(in_array($this->_action, array('insert', 'modify'))) {
3053  $col = $polygon->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon&start=$start");
3054  }
3055  elseif($this->_action == 'delete') {
3056  // delete polyline and all associations
3057  $polygon->delete();
3058  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polygon&start=$start");
3059  }
3060  else {
3061  $col = $this->listPolygon();
3062  }
3063 
3064  $buffer = "<div>";
3065  $buffer .= $col;
3066  $buffer .= "</div>";
3067 
3068  return $buffer;
3069  }
3070 
3071 
3078  private function listPolyline() {
3079 
3080  $title = _("Percorsi");
3081  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline&action=insert\">".pub::icon('insert', _("nuovo percorso"))."</a>";
3082  $onclick = "myreveal.toggle();";
3083  $link_search = "<span class=\"link\" onclick=\"".$onclick."\">".pub::icon('search')."</span>";
3084  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>array($link_insert, $link_search), 'headerLabel'=>$title));
3085 
3086  $formsearch = $this->adminSearchPolyline();
3087 
3088  $buffer = "<div id=\"admin_search_polyline\" style=\"display:".((isset($_SESSION['apl_search']) && $_SESSION['apl_search']) ? "block" : "none")."; border:1px solid #ddd; background: #eee; padding: 10px; padding-top: 0; margin-bottom: 10px;\">";
3089  $buffer .= "<p>Le ricerche effettuate rimangono in sessione</p>";
3090  $buffer .= $formsearch;
3091  $buffer .= "</div>";
3092  $buffer .= "<script>";
3093  $buffer .= "myreveal = new Fx.Reveal('admin_search_polyline');";
3094  $buffer .= "</script>";
3095 
3096  $polyline_ids = gmapsPolyline::get($this->_instance, array('where'=>$_SESSION['apl_where']));
3097  if($tot = count($polyline_ids)) {
3098 
3099  $plist = new PageList(2, $tot, 'array');
3100  $start = $plist->start();
3101  $end = min($start + 2, $tot);
3102 
3103  $buffer .= "<table class=\"generic\">";
3104  $buffer .= "<tr>";
3105  $buffer .= "<th>"._("Categorie")."</th>";
3106  $buffer .= "<th>"._("Etichetta")."</th>";
3107  $buffer .= "<th>"._("Colore")."</th>";
3108  $buffer .= "<th>"._("Spessore")."</th>";
3109  $buffer .= "<th class=\"thIcon\"></th>";
3110  $buffer .= "</tr>";
3111  for($i = $start; $i < $end; $i++) {
3112  $polyline_id = $polyline_ids[$i];
3113  $polyline = new gmapsPolyline($polyline_id, $this);
3114  $ctg = new gmapsPolylineCtg($polyline->ctg, $this);
3115  $buffer .= "<tr>";
3116  $buffer .= "<td>";
3117  $ctgs_string = '';
3118  foreach($polyline->ctgs() as $ctg) {
3119  $ctgs_string .= htmlChars($ctg->name).", ";
3120  }
3121  $buffer .= substr($ctgs_string, 0, -2);
3122  $buffer .= "</td>";
3123  $buffer .= "<td>".htmlChars($polyline->label)."</td>";
3124  $buffer .= "<td>".htmlChars($polyline->color)."</td>";
3125  $buffer .= "<td>".htmlChars($polyline->width)."px</td>";
3126  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline&action=modify&id=".$polyline->id."&start=".$start."\">".pub::icon('modify')."</a>";
3127  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare il percorso?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline&action=delete&id=".$polyline->id."&start=".$start."';\">".pub::icon('delete')."</span>";
3128  $link_points = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_point&id=".$polyline->id."&start=".$start."\">".$this->_icon_polyline_points."</a>";
3129  $buffer .= "<td class=\"tdIcon\">$link_modify $link_delete $link_points</td>";
3130  $buffer .= "</tr>";
3131 
3132  }
3133  $buffer .= "</table>";
3134 
3135  $htmlsection->footer = "<p>".$plist->listReferenceGINO($this->_plink->aLink($this->_instanceName, 'manageDoc', '', "block=polyline", array("basename"=>false)))."</p>";
3136 
3137  }
3138  else {
3139  $buffer .= "<p class=\"message\">"._("Non risultano percorsi registrati")."</p>";
3140  }
3141 
3142  $htmlsection->content = $buffer;
3143 
3144  return $htmlsection->render();
3145  }
3146 
3153  private function listPolygon() {
3154 
3155  $title = _("Aree");
3156  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon&action=insert\">".pub::icon('insert', _("nuova area"))."</a>";
3157  $onclick = "myreveal.toggle();";
3158  $link_search = "<span class=\"link\" onclick=\"".$onclick."\">".pub::icon('search')."</span>";
3159  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'h1', 'headerLinks'=>array($link_insert, $link_search), 'headerLabel'=>$title));
3160 
3161  $formsearch = $this->adminSearchPolygon();
3162 
3163  $buffer = "<div id=\"admin_search_polygon\" style=\"display:".((isset($_SESSION['apg_search']) && $_SESSION['apg_search']) ? "block" : "none")."; border:1px solid #ddd; background: #eee; padding: 10px; padding-top: 0; margin-bottom: 10px;\">";
3164  $buffer .= "<p>Le ricerche effettuate rimangono in sessione</p>";
3165  $buffer .= $formsearch;
3166  $buffer .= "</div>";
3167  $buffer .= "<script>";
3168  $buffer .= "myreveal = new Fx.Reveal('admin_search_polygon');";
3169  $buffer .= "</script>";
3170 
3171  $polygon_ids = gmapsPolygon::get($this->_instance, array('where'=>$_SESSION['apl_where']));
3172  if($tot = count($polygon_ids)) {
3173 
3174  $plist = new PageList(2, $tot, 'array');
3175  $start = $plist->start();
3176  $end = min($start + 2, $tot);
3177 
3178  $buffer .= "<table class=\"generic\">";
3179  $buffer .= "<tr>";
3180  $buffer .= "<th>"._("Categorie")."</th>";
3181  $buffer .= "<th>"._("Etichetta")."</th>";
3182  $buffer .= "<th>"._("Colore")."</th>";
3183  $buffer .= "<th>"._("Spessore")."</th>";
3184  $buffer .= "<th class=\"thIcon\"></th>";
3185  $buffer .= "</tr>";
3186  for($i = $start; $i < $end; $i++) {
3187  $polygon_id = $polygon_ids[$i];
3188  $polygon = new gmapsPolygon($polygon_id, $this);
3189  $ctg = new gmapsPolygonCtg($polygon->ctg, $this);
3190  $buffer .= "<tr>";
3191  $buffer .= "<td>";
3192  $ctgs_string = '';
3193  foreach($polygon->ctgs() as $ctg) {
3194  $ctgs_string .= htmlChars($ctg->name).", ";
3195  }
3196  $buffer .= substr($ctgs_string, 0, -2);
3197  $buffer .= "</td>";
3198  $buffer .= "<td>".htmlChars($polygon->label)."</td>";
3199  $buffer .= "<td>".htmlChars($polygon->color)."</td>";
3200  $buffer .= "<td>".htmlChars($polygon->width)."px</td>";
3201  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon&action=modify&id=".$polygon->id."&start=".$start."\">".pub::icon('modify')."</a>";
3202  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare l'area?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon&action=delete&id=".$polygon->id."&start=".$start."';\">".pub::icon('delete')."</span>";
3203  $link_points = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_point&id=".$polygon->id."&start=".$start."\">".$this->_icon_polygon_points."</a>";
3204  $buffer .= "<td class=\"tdIcon\">$link_modify $link_delete $link_points</td>";
3205  $buffer .= "</tr>";
3206 
3207  }
3208  $buffer .= "</table>";
3209 
3210  $htmlsection->footer = "<p>".$plist->listReferenceGINO($this->_plink->aLink($this->_instanceName, 'manageDoc', '', "block=polygon", array("basename"=>false)))."</p>";
3211 
3212  }
3213  else {
3214  $buffer .= "<p class=\"message\">"._("Non risultano aree registrate")."</p>";
3215  }
3216 
3217  $htmlsection->content = $buffer;
3218 
3219  return $htmlsection->render();
3220  }
3221 
3222 
3229  private function adminSearchPolyline() {
3230 
3231  if(!isset($_SESSION['apl_search'])) {
3232  $_SESSION['apl_ctg'] = 0;
3233  $_SESSION['apl_label'] = '';
3234  $_SESSION['apl_where'] = '';
3235  }
3236 
3237  if(isset($_POST['submit_search'])) {
3238  $_SESSION['apl_ctg'] = cleanVar($_POST, 'apl_ctg', 'int', '');
3239  $_SESSION['apl_label'] = cleanVar($_POST, 'apl_label', 'string', '');
3240 
3241  $where = array();
3242 
3243  if($_SESSION['apl_ctg']) $where[] = "id IN (SELECT polyline_id FROM ".$this->_tbl_polyline_polyline_ctg." WHERE ctg_id='".$_SESSION['apl_ctg']."')";
3244  if($_SESSION['apl_label']) $where[] = "label LIKE '%".$_SESSION['apl_label']."%'";
3245 
3246  $_SESSION['apl_where'] = implode(" AND ", $where);
3247 
3248  if($_SESSION['apl_ctg'] || $_SESSION['apl_label']) $_SESSION['apl_search'] = true;
3249  else $_SESSION['apl_search'] = false;
3250  }
3251  elseif(isset($_POST['submit_reset'])) {
3252  $_SESSION['apl_ctg'] = 0;
3253  $_SESSION['apl_label'] = '';
3254  $_SESSION['apl_where'] = '';
3255  $_SESSION['apl_search'] = false;
3256  }
3257 
3258  $gform = new Form('form_admin_search_polyline', 'post', false);
3259  $buffer = $gform->form('', false, '');
3260 
3261  $buffer .= $gform->cselect('apl_ctg', $_SESSION['apl_ctg'], gmapsPolylineCtg::getForSelect($this->_instance), _("Categoria"), array('required'=>true));
3262  $buffer .= $gform->cinput('apl_label', 'text', $_SESSION['apl_label'], _("Etichetta"), array('required'=>true, 'maxlength'=>200));
3263  $reset = $gform->input('submit_reset', 'submit', _("azzera"), array('classField'=>'submit'));
3264  $buffer .= $gform->cinput('submit_search', 'submit', _("cerca"), '', array('classField'=>'submit', 'text_add'=>" $reset"));
3265 
3266  $buffer .= $gform->cform();
3267 
3268  return $buffer;
3269  }
3270 
3277  private function adminSearchPolygon() {
3278 
3279  if(!isset($_SESSION['apl_search'])) {
3280  $_SESSION['apg_ctg'] = 0;
3281  $_SESSION['apg_label'] = '';
3282  $_SESSION['apg_where'] = '';
3283  }
3284 
3285  if(isset($_POST['submit_search'])) {
3286  $_SESSION['apg_ctg'] = cleanVar($_POST, 'apg_ctg', 'int', '');
3287  $_SESSION['apg_label'] = cleanVar($_POST, 'apg_label', 'string', '');
3288 
3289  $where = array();
3290 
3291  if($_SESSION['apg_ctg']) $where[] = "id IN (SELECT polygon_id FROM ".$this->_tbl_polygon_polygon_ctg." WHERE ctg_id='".$_SESSION['apg_ctg']."')";
3292  if($_SESSION['apg_label']) $where[] = "label LIKE '%".$_SESSION['apg_label']."%'";
3293 
3294  $_SESSION['apg_where'] = implode(" AND ", $where);
3295 
3296  if($_SESSION['apg_ctg'] || $_SESSION['apg_label']) $_SESSION['apg_search'] = true;
3297  else $_SESSION['apg_search'] = false;
3298  }
3299  elseif(isset($_POST['submit_reset'])) {
3300  $_SESSION['apg_ctg'] = 0;
3301  $_SESSION['apg_label'] = '';
3302  $_SESSION['apg_where'] = '';
3303  $_SESSION['apg_search'] = false;
3304  }
3305 
3306  $gform = new Form('form_admin_search_polygon', 'post', false);
3307  $buffer = $gform->form('', false, '');
3308 
3309  $buffer .= $gform->cselect('apg_ctg', $_SESSION['apg_ctg'], gmapsPolygonCtg::getForSelect($this->_instance), _("Categoria"), array('required'=>true));
3310  $buffer .= $gform->cinput('apg_label', 'text', $_SESSION['apg_label'], _("Etichetta"), array('required'=>true, 'maxlength'=>200));
3311  $reset = $gform->input('submit_reset', 'submit', _("azzera"), array('classField'=>'submit'));
3312  $buffer .= $gform->cinput('submit_search', 'submit', _("cerca"), '', array('classField'=>'submit', 'text_add'=>" $reset"));
3313 
3314  $buffer .= $gform->cform();
3315 
3316  return $buffer;
3317  }
3318 
3319 
3326  private function managePoint() {
3327 
3328  $id = cleanVar($_REQUEST, 'id', 'int', '');
3329  $start = cleanVar($_GET, 'start', 'int', '');
3330  $point = new gmapsPoint($id, $this);
3331  $point->instance = $this->_instance;
3332 
3333  if(in_array($this->_action, array('insert', 'modify'))) {
3334  $col = $point->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point&start=$start");
3335  }
3336  elseif($this->_action == 'delete') {
3337  $point->delete();
3338  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point&start=$start");
3339  }
3340  else {
3341  $col = $this->listPoint();
3342  }
3343 
3344  $buffer = "<div>";
3345  $buffer .= $col;
3346  $buffer .= "</div>";
3347 
3348  return $buffer;
3349  }
3350 
3357  private function listPoint() {
3358 
3359  $title = _("Punti di interesse");
3360  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point&action=insert\">".pub::icon('insert', _("nuovo punto di interesse"))."</a>";
3361  $onclick = "myreveal.toggle();";
3362  $link_search = "<span class=\"link\" onclick=\"".$onclick."\">".pub::icon('search')."</span>";
3363  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>array($link_insert, $link_search), 'headerLabel'=>$title));
3364 
3365  $formsearch = $this->adminSearchPoint();
3366 
3367  $buffer = "<div id=\"admin_search_point\" style=\"display:".((isset($_SESSION['ap_search']) && $_SESSION['ap_search']) ? "block" : "none")."; border:1px solid #ddd; background: #eee; padding: 10px; padding-top: 0; margin-bottom: 10px;\">";
3368  $buffer .= "<p>Le ricerche effettuate rimangono in sessione</p>";
3369  $buffer .= $formsearch;
3370  $buffer .= "</div>";
3371  $buffer .= "<script>";
3372  $buffer .= "myreveal = new Fx.Reveal('admin_search_point');";
3373  $buffer .= "</script>";
3374 
3375  $point_ids = gmapsPoint::get($this->_instance, array('where'=>$_SESSION['ap_where']));
3376  if($tot = count($point_ids)) {
3377 
3378  $plist = new PageList($this->_list_point_items, $tot, 'array');
3379  $start = $plist->start();
3380  $end = min($start + $this->_list_point_items, $tot);
3381 
3382  $buffer .= "<table class=\"generic\">";
3383  $buffer .= "<tr>";
3384  $buffer .= "<th>"._("Categorie")."</th>";
3385  $buffer .= "<th>"._("Etichetta")."</th>";
3386  $buffer .= "<th>"._("Latitudine")."</th>";
3387  $buffer .= "<th>"._("Longitudine")."</th>";
3388  $buffer .= "<th class=\"thIcon\" style=\"width: 160px;\"></th>";
3389  $buffer .= "</tr>";
3390  for($i = $start; $i < $end; $i++) {
3391  $point_id = $point_ids[$i];
3392  $point = new gmapsPoint($point_id, $this);
3393  $ctg = new gmapsPointCtg($point->ctg, $this);
3394  $buffer .= "<tr>";
3395  $buffer .= "<td>";
3396  $ctgs_string = '';
3397  foreach($point->ctgs() as $ctg) {
3398  $ctgs_string .= htmlChars($ctg->name).', ';
3399  }
3400  $buffer .= substr($ctgs_string, 0, -2);
3401  $buffer .= "</td>";
3402  $buffer .= "<td>".htmlChars($point->label)."</td>";
3403  $buffer .= "<td>".htmlChars(round($point->lat, 4))."</td>";
3404  $buffer .= "<td>".htmlChars(round($point->lng, 4))."</td>";
3405  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point&action=modify&id=".$point->id."&start=".$start."\">".pub::icon('modify')."</a>";
3406  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare il punto di interesse?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point&action=delete&id=".$point->id."&start=".$start."';\">".pub::icon('delete')."</span>";
3407  $link_images = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_image&point_id=".$point->id."\">".$this->_icon_image."</a>";
3408  $link_videos = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_video&point_id=".$point->id."\">".$this->_icon_video."</a>";
3409  $link_events = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_event&point_id=".$point->id."\">".$this->_icon_event."</a>";
3410  $link_attachments = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_attachment&point_id=".$point->id."\">".$this->_icon_attachment."</a>";
3411  $link_collections = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_collection&point_id=".$point->id."\">".$this->_icon_collection."</a>";
3412  $buffer .= "<td class=\"tdIcon\">$link_modify $link_delete $link_images $link_videos $link_events $link_attachments $link_collections</td>";
3413  $buffer .= "</tr>";
3414 
3415  }
3416  $buffer .= "</table>";
3417 
3418  $htmlsection->footer = "<p>".$plist->listReferenceGINO($this->_plink->aLink($this->_instanceName, 'manageDoc', '', "block=point", array("basename"=>false)))."</p>";
3419 
3420  }
3421  else {
3422  $buffer .= "<p class=\"message\">"._("Non risultano punti di interesse registrati")."</p>";
3423  }
3424 
3425  $htmlsection->content = $buffer;
3426 
3427  return $htmlsection->render();
3428 
3429  }
3430 
3437  private function adminSearchPoint() {
3438 
3439  if(!isset($_SESSION['ap_search'])) {
3440  $_SESSION['ap_ctg'] = 0;
3441  $_SESSION['ap_label'] = '';
3442  $_SESSION['ap_where'] = '';
3443  }
3444 
3445  if(isset($_POST['submit_search'])) {
3446  $_SESSION['ap_ctg'] = cleanVar($_POST, 'ap_ctg', 'int', '');
3447  $_SESSION['ap_label'] = cleanVar($_POST, 'ap_label', 'string', '');
3448 
3449  $where = array();
3450 
3451  if($_SESSION['ap_ctg']) $where[] = "id IN (SELECT point_id FROM ".$this->_tbl_point_point_ctg." WHERE ctg_id='".$_SESSION['ap_ctg']."')";
3452  if($_SESSION['ap_label']) $where[] = "label LIKE '%".$_SESSION['ap_label']."%'";
3453 
3454  $_SESSION['ap_where'] = implode(" AND ", $where);
3455 
3456  if($_SESSION['ap_ctg'] || $_SESSION['ap_label']) $_SESSION['ap_search'] = true;
3457  else $_SESSION['ap_search'] = false;
3458  }
3459  elseif(isset($_POST['submit_reset'])) {
3460  $_SESSION['ap_ctg'] = 0;
3461  $_SESSION['ap_label'] = '';
3462  $_SESSION['ap_where'] = '';
3463  $_SESSION['ap_search'] = false;
3464  }
3465 
3466  $gform = new Form('form_admin_search_point', 'post', false);
3467  $buffer = $gform->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point", false, '');
3468 
3469  $buffer .= $gform->cselect('ap_ctg', $_SESSION['ap_ctg'], gmapsPointCtg::getForSelect($this->_instance), _("Categoria"), array('required'=>true));
3470  $buffer .= $gform->cinput('ap_label', 'text', $_SESSION['ap_label'], _("Etichetta"), array('required'=>true, 'maxlength'=>200));
3471  $reset = $gform->input('submit_reset', 'submit', _("azzera"), array('classField'=>'submit'));
3472  $buffer .= $gform->cinput('submit_search', 'submit', _("cerca"), '', array('classField'=>'submit', 'text_add'=>" $reset"));
3473 
3474  $buffer .= $gform->cform();
3475 
3476  return $buffer;
3477  }
3478 
3485  private function managePolylineCtg() {
3486 
3487  $id = cleanVar($_REQUEST, 'id', 'int', '');
3488  $ctg = new gmapsPolylineCtg($id, $this);
3489  $ctg->instance = $this->_instance;
3490 
3491  $col1 = $this->listPolylineCtg($id);
3492 
3493  if(in_array($this->_action, array('insert', 'modify'))) {
3494  $col2 = $ctg->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg");
3495  }
3496  elseif($this->_action == 'delete') {
3497  $res = $ctg->delete();
3498  if($res === 'polylines') {
3499  exit(error::errorMessage(array('error'=>_("La categoria contiene dei percorsi, eliminarli o cambiarne la categoria e riprovare")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg"));
3500  }
3501  elseif($res === false) {
3502  exit(error::errorMessage(array('error'=>_("Impossibile eliminare la categoria, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg"));
3503  }
3504  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polyline_ctg");
3505  }
3506  else {
3507  $col2 = $this->infoPolylineCtg();
3508  }
3509 
3510  $buffer = "<div class=\"vertical_1\">";
3511  $buffer .= $col1;
3512  $buffer .= "</div>";
3513 
3514  $buffer .= "<div class=\"vertical_2\">";
3515  $buffer .= $col2;
3516  $buffer .= "</div>";
3517 
3518  $buffer .= "<div class=\"null\"></div>";
3519 
3520  return $buffer;
3521 
3522  }
3523 
3530  private function managePolygonCtg() {
3531 
3532  $id = cleanVar($_REQUEST, 'id', 'int', '');
3533  $ctg = new gmapsPolygonCtg($id, $this);
3534  $ctg->instance = $this->_instance;
3535 
3536  $col1 = $this->listPolygonCtg($id);
3537 
3538  if(in_array($this->_action, array('insert', 'modify'))) {
3539  $col2 = $ctg->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg");
3540  }
3541  elseif($this->_action == 'delete') {
3542  $res = $ctg->delete();
3543  if($res === 'polygons') {
3544  exit(error::errorMessage(array('error'=>_("La categoria contiene delle aree, eliminarle o cambiarne la categoria e riprovare")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg"));
3545  }
3546  elseif($res === false) {
3547  exit(error::errorMessage(array('error'=>_("Impossibile eliminare la categoria, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg"));
3548  }
3549  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=polygon_ctg");
3550  }
3551  else {
3552  $col2 = $this->infoPolygonCtg();
3553  }
3554 
3555  $buffer = "<div class=\"vertical_1\">";
3556  $buffer .= $col1;
3557  $buffer .= "</div>";
3558 
3559  $buffer .= "<div class=\"vertical_2\">";
3560  $buffer .= $col2;
3561  $buffer .= "</div>";
3562 
3563  $buffer .= "<div class=\"null\"></div>";
3564 
3565  return $buffer;
3566 
3567  }
3568 
3575  private function listPolylineCtg($sel_id) {
3576 
3577  $title = _("Categorie");
3578  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg&action=insert\">".pub::icon('insert', _("nuova categoria"))."</a>";
3579  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
3580 
3581  $ctg_ids = gmapsPolylineCtg::get($this->_instance);
3582 
3583  if($tot = count($ctg_ids)) {
3584  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
3585  $buffer = $htmlList->start();
3586  foreach($ctg_ids as $ctg_id) {
3587  $ctg = new gmapsPolylineCtg($ctg_id, $this);
3588  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg&action=modify&id=".$ctg->id."\">".pub::icon('modify')."</a>";
3589  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare la categoria?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polyline_ctg&action=delete&id=".$ctg->id."';\">".pub::icon('delete')."</span>";
3590  $selected = $ctg->id == $sel_id ? true : false;
3591  $buffer .= $htmlList->item(htmlChars($ctg->name), array($link_modify, $link_delete), $selected, true);
3592  }
3593  $buffer .= $htmlList->end();
3594  }
3595  else {
3596  $buffer = "<p class=\"message\">"._("Non risultano categorie registrate")."</p>";
3597  }
3598 
3599  $htmlsection->content = $buffer;
3600 
3601  return $htmlsection->render();
3602  }
3603 
3610  private function listPolygonCtg($sel_id) {
3611 
3612  $title = _("Categorie");
3613  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg&action=insert\">".pub::icon('insert', _("nuova categoria"))."</a>";
3614  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
3615 
3616  $ctg_ids = gmapsPolygonCtg::get($this->_instance);
3617 
3618  if($tot = count($ctg_ids)) {
3619  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
3620  $buffer = $htmlList->start();
3621  foreach($ctg_ids as $ctg_id) {
3622  $ctg = new gmapsPolygonCtg($ctg_id, $this);
3623  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg&action=modify&id=".$ctg->id."\">".pub::icon('modify')."</a>";
3624  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare la categoria?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=polygon_ctg&action=delete&id=".$ctg->id."';\">".pub::icon('delete')."</span>";
3625  $selected = $ctg->id == $sel_id ? true : false;
3626  $buffer .= $htmlList->item(htmlChars($ctg->name), array($link_modify, $link_delete), $selected, true);
3627  }
3628  $buffer .= $htmlList->end();
3629  }
3630  else {
3631  $buffer = "<p class=\"message\">"._("Non risultano categorie registrate")."</p>";
3632  }
3633 
3634  $htmlsection->content = $buffer;
3635 
3636  return $htmlsection->render();
3637  }
3638 
3639 
3646  private function infoPolylineCtg() {
3647 
3648  $title = _("Informazioni");
3649  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
3650 
3651  $buffer = _("Gestione delle categorie dei percorsi");
3652 
3653  $htmlsection->content = $buffer;
3654 
3655  return $htmlsection->render();
3656 
3657  }
3658 
3665  private function infoPolygonCtg() {
3666 
3667  $title = _("Informazioni");
3668  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
3669 
3670  $buffer = _("Gestione delle categorie delle aree");
3671 
3672  $htmlsection->content = $buffer;
3673 
3674  return $htmlsection->render();
3675 
3676  }
3677 
3678 
3685  private function managePointCtg() {
3686 
3687  $id = cleanVar($_REQUEST, 'id', 'int', '');
3688  $ctg = new gmapsPointCtg($id, $this);
3689  $ctg->instance = $this->_instance;
3690 
3691  $col1 = $this->listPointCtg($id);
3692 
3693  if(in_array($this->_action, array('insert', 'modify'))) {
3694  $col2 = $ctg->form($this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg");
3695  }
3696  elseif($this->_action == 'delete') {
3697  $res = $ctg->delete();
3698  if($res === 'points') {
3699  exit(error::errorMessage(array('error'=>_("La categoria contiene dei punti di interesse, eliminarli o cambiarne la categoria e riprovare")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg"));
3700  }
3701  elseif($res === false) {
3702  exit(error::errorMessage(array('error'=>_("Impossibile eliminare la categoria, contattare l'amministratore del sistema.")), $this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg"));
3703  }
3704  EvtHandler::HttpCall($this->_home, $this->_instanceName."-manageDoc", "block=point_ctg");
3705  }
3706  else {
3707  $col2 = $this->infoPointCtg();
3708  }
3709 
3710  $buffer = "<div class=\"vertical_1\">";
3711  $buffer .= $col1;
3712  $buffer .= "</div>";
3713 
3714  $buffer .= "<div class=\"vertical_2\">";
3715  $buffer .= $col2;
3716  $buffer .= "</div>";
3717 
3718  $buffer .= "<div class=\"null\"></div>";
3719 
3720  return $buffer;
3721 
3722  }
3723 
3730  private function listPointCtg($sel_id) {
3731 
3732  $title = _("Categorie");
3733  $link_insert = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg&action=insert\">".pub::icon('insert', _("nuova categoria"))."</a>";
3734  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLinks'=>$link_insert, 'headerLabel'=>$title));
3735 
3736  $ctg_ids = gmapsPointCtg::get($this->_instance);
3737 
3738  if($tot = count($ctg_ids)) {
3739  $htmlList = new htmlList(array("numItems"=>$tot, "separator"=>true));
3740  $buffer = $htmlList->start();
3741  foreach($ctg_ids as $ctg_id) {
3742  $ctg = new gmapsPointCtg($ctg_id, $this);
3743  $link_modify = "<a href=\"".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg&action=modify&id=".$ctg->id."\">".pub::icon('modify')."</a>";
3744  $link_delete = "<span class=\"link\" onclick=\"if(confirm('".jsVar(_("Sicuro di voler eliminare la categoria?"))."')) location.href='".$this->_home."?evt[".$this->_instanceName."-manageDoc]&block=point_ctg&action=delete&id=".$ctg->id."';\">".pub::icon('delete')."</span>";
3745  $selected = $ctg->id == $sel_id ? true : false;
3746  $buffer .= $htmlList->item(htmlChars($ctg->name), array($link_modify, $link_delete), $selected, true);
3747  }
3748  $buffer .= $htmlList->end();
3749  }
3750  else {
3751  $buffer = "<p class=\"message\">"._("Non risultano categorie registrate")."</p>";
3752  }
3753 
3754  $htmlsection->content = $buffer;
3755 
3756  return $htmlsection->render();
3757  }
3758 
3765  private function infoPointCtg() {
3766 
3767  $title = _("Informazioni");
3768  $htmlsection = new htmlSection(array('class'=>'admin', 'headerTag'=>'header', 'headerLabel'=>$title));
3769 
3770  $buffer = _("Gestione delle categorie dei punti di interesse");
3771 
3772  $htmlsection->content = $buffer;
3773 
3774  return $htmlsection->render();
3775 
3776  }
3777 
3778 }
3779 
3780 
3781 ?>