Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00032 class ilGoogleMapGUI
00033 {
00034
00035 protected $enabletypecontrol = false;
00036 protected $enableupdatelistener = false;
00037 protected $enablenavigationcontrol = false;
00038 protected $enablelargemapcontrol = false;
00039 protected $width = "500px";
00040 protected $height = "300px";
00041 protected $user_marker = array();
00042
00043 function ilGoogleMapGUI()
00044 {
00045 global $lng, $tpl;
00046
00047 $gm_set = new ilSetting("google_maps");
00048 $lng->loadLanguageModule("gmaps");
00049
00050 if ($gm_set->get("api_key") != "")
00051 {
00052 $tpl->addJavaScript("http://maps.google.com/maps?file=api&v=2&key=".
00053 $gm_set->get("api_key"), false);
00054 $tpl->addJavaScript("Services/JavaScript/js/Basic.js");
00055 $tpl->addJavaScript("Services/GoogleMaps/js/ServiceGoogleMaps.js");
00056 }
00057 }
00058
00064 function setMapId($a_mapid)
00065 {
00066 $this->mapid = $a_mapid;
00067 }
00068
00074 function getMapId()
00075 {
00076 return $this->mapid;
00077 }
00078
00084 function setWidth($a_width)
00085 {
00086 $this->width = $a_width;
00087 }
00088
00094 function getWidth()
00095 {
00096 return $this->width;
00097 }
00098
00104 function setHeight($a_height)
00105 {
00106 $this->height = $a_height;
00107 }
00108
00114 function getHeight()
00115 {
00116 return $this->height;
00117 }
00118
00124 function setLatitude($a_latitude)
00125 {
00126 $this->latitude = $a_latitude;
00127 }
00128
00134 function getLatitude()
00135 {
00136 return $this->latitude;
00137 }
00138
00144 function setLongitude($a_longitude)
00145 {
00146 $this->longitude = $a_longitude;
00147 }
00148
00154 function getLongitude()
00155 {
00156 return $this->longitude;
00157 }
00158
00164 function setZoom($a_zoom)
00165 {
00166 $this->zoom = $a_zoom;
00167 }
00168
00174 function getZoom()
00175 {
00176 return $this->zoom;
00177 }
00178
00184 function setEnableTypeControl($a_enabletypecontrol)
00185 {
00186 $this->enabletypecontrol = $a_enabletypecontrol;
00187 }
00188
00194 function getEnableTypeControl()
00195 {
00196 return $this->enabletypecontrol;
00197 }
00198
00204 function setEnableNavigationControl($a_enablenavigationcontrol)
00205 {
00206 $this->enablenavigationcontrol = $a_enablenavigationcontrol;
00207 }
00208
00214 function getEnableNavigationControl()
00215 {
00216 return $this->enablenavigationcontrol;
00217 }
00218
00224 function setEnableUpdateListener($a_enableupdatelistener)
00225 {
00226 $this->enableupdatelistener = $a_enableupdatelistener;
00227 }
00228
00234 function getEnableUpdateListener()
00235 {
00236 return $this->enableupdatelistener;
00237 }
00238
00244 function setEnableLargeMapControl($a_largemapcontrol)
00245 {
00246 $this->largemapcontrol = $a_largemapcontrol;
00247 }
00248
00254 function getEnableLargeMapControl()
00255 {
00256 return $this->largemapcontrol;
00257 }
00258
00264 function setEnableCentralMarker($a_centralmarker)
00265 {
00266 $this->centralmarker = $a_centralmarker;
00267 }
00268
00274 function getEnableCentralMarker()
00275 {
00276 return $this->centralmarker;
00277 }
00278
00284 function addUserMarker($a_user_id)
00285 {
00286 return $this->user_marker[] = $a_user_id;
00287 }
00288
00292 function getHtml()
00293 {
00294 global $tpl;
00295
00296 $this->tpl = new ilTemplate("tpl.google_map.html",
00297 true, true, "Services/GoogleMaps");
00298
00299 $gm_set = new ilSetting("google_maps");
00300 if ($gm_set->get("api_key") != "")
00301 {
00302 $tpl->addJavaScript("http://maps.google.com/maps?file=api&v=2&key=".
00303 $gm_set->get("api_key"));
00304 $tpl->addJavaScript("Services/JavaScript/js/Basic.js");
00305 $tpl->addJavaScript("Services/GoogleMaps/js/ServiceGoogleMaps.js");
00306
00307
00308 $cnt = 0;
00309 foreach($this->user_marker as $user_id)
00310 {
00311 if (ilObject::_exists($user_id))
00312 {
00313 $user = new ilObjUser($user_id);
00314 if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
00315 $user->getPref("public_location") == "y")
00316 {
00317 $this->tpl->setCurrentBlock("user_marker");
00318 $this->tpl->setVariable("UMAP_ID",
00319 $this->getMapId());
00320 $this->tpl->setVariable("CNT", $cnt);
00321
00322 $this->tpl->setVariable("ULAT", $user->getLatitude());
00323 $this->tpl->setVariable("ULONG", $user->getLongitude());
00324 $info = $user->getFirstName()." ".$user->getLastName();
00325 $delim = "<br \/>";
00326 if ($user->getPref("public_institution") == "y")
00327 {
00328 $info.= $delim.$user->getInstitution();
00329 $delim = ", ";
00330 }
00331 if ($user->getPref("public_department") == "y")
00332 {
00333 $info.= $delim.$user->getDepartment();
00334 }
00335 $delim = "<br \/>";
00336 if ($user->getPref("public_street") == "y")
00337 {
00338 $info.= $delim.$user->getStreet();
00339 }
00340 if ($user->getPref("public_zip") == "y")
00341 {
00342 $info.= $delim.$user->getZipcode();
00343 $delim = " ";
00344 }
00345 if ($user->getPref("public_city") == "y")
00346 {
00347 $info.= $delim.$user->getCity();
00348 }
00349 $delim = "<br \/>";
00350 if ($user->getPref("public_country") == "y")
00351 {
00352 $info.= $delim.$user->getCountry();
00353 }
00354 $this->tpl->setVariable("USER_INFO",
00355 $info);
00356 $this->tpl->setVariable("IMG_USER",
00357 $user->getPersonalPicturePath("xsmall"));
00358 $this->tpl->parseCurrentBlock();
00359 $cnt++;
00360 }
00361 }
00362 }
00363
00364 $this->tpl->setVariable("MAP_ID", $this->getMapId());
00365 $lat = is_numeric($this->getLatitude())
00366 ? $this->getLatitude()
00367 : 0;
00368 $long = is_numeric($this->getLongitude())
00369 ? $this->getLongitude()
00370 : 0;
00371 $this->tpl->setVariable("WIDTH", $this->getWidth());
00372 $this->tpl->setVariable("HEIGHT", $this->getHeight());
00373 $this->tpl->setVariable("LAT", $this->getLatitude());
00374 $this->tpl->setVariable("LONG", $this->getLongitude());
00375 $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
00376 $type_control = $this->getEnableTypeControl()
00377 ? "true"
00378 : "false";
00379 $this->tpl->setVariable("TYPE_CONTROL", $type_control);
00380 $nav_control = $this->getEnableNavigationControl()
00381 ? "true"
00382 : "false";
00383 $this->tpl->setVariable("NAV_CONTROL", $nav_control);
00384 $update_listener = $this->getEnableUpdateListener()
00385 ? "true"
00386 : "false";
00387 $this->tpl->setVariable("UPDATE_LISTENER", $update_listener);
00388 $large_map_control = $this->getEnableLargeMapControl()
00389 ? "true"
00390 : "false";
00391 $this->tpl->setVariable("LARGE_CONTROL", $large_map_control);
00392 $central_marker = $this->getEnableCentralMarker()
00393 ? "true"
00394 : "false";
00395 $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
00396
00397 return $this->tpl->get();
00398 }
00399 else
00400 {
00401 return "";
00402 }
00403 }
00404
00408 function getUserListHtml()
00409 {
00410 global $tpl;
00411
00412 $list_tpl = new ilTemplate("tpl.google_map_user_list.html",
00413 true, true, "Services/GoogleMaps");
00414
00415 $cnt = 0;
00416 foreach($this->user_marker as $user_id)
00417 {
00418 if (ilObject::_exists($user_id))
00419 {
00420 $user = new ilObjUser($user_id);
00421 $this->css_row = ($this->css_row != "tblrow1_mo")
00422 ? "tblrow1_mo"
00423 : "tblrow2_mo";
00424 if ($user->getLatitude() != 0 && $user->getLongitude() != 0
00425 && $user->getPref("public_location") == "y")
00426 {
00427 $list_tpl->setCurrentBlock("item");
00428 $list_tpl->setVariable("MARKER_CNT", $cnt);
00429 $list_tpl->setVariable("MAP_ID", $this->getMapId());
00430 $cnt++;
00431 }
00432 else
00433 {
00434 $list_tpl->setCurrentBlock("item_no_link");
00435 }
00436 $list_tpl->setVariable("CSS_ROW", $this->css_row);
00437 $list_tpl->setVariable("TXT_USER", $user->getLogin());
00438 $list_tpl->setVariable("IMG_USER",
00439 $user->getPersonalPicturePath("xxsmall"));
00440 $list_tpl->parseCurrentBlock();
00441 $list_tpl->touchBlock("row");
00442 }
00443 }
00444
00445 return $list_tpl->get();
00446 }
00447
00448 }
00449 ?>