ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilGoogleMapGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
33 {
34 
35  protected $enabletypecontrol = false;
36  protected $enableupdatelistener = false;
37  protected $enablenavigationcontrol = false;
38  protected $enablelargemapcontrol = false;
39  protected $width = "500px";
40  protected $height = "300px";
41  protected $user_marker = array();
42 
43  function ilGoogleMapGUI()
44  {
45  global $lng, $tpl;
46 
47  $lng->loadLanguageModule("gmaps");
48 
49  $tpl->addJavaScript("//maps.google.com/maps/api/js?sensor=false", false);
50  $tpl->addJavaScript("Services/JavaScript/js/Basic.js");
51  $tpl->addJavaScript("Services/GoogleMaps/js/ServiceGoogleMaps.js");
52  }
53 
59  function setMapId($a_mapid)
60  {
61  $this->mapid = $a_mapid;
62  }
63 
69  function getMapId()
70  {
71  return $this->mapid;
72  }
73 
79  function setWidth($a_width)
80  {
81  $this->width = $a_width;
82  }
83 
89  function getWidth()
90  {
91  return $this->width;
92  }
93 
99  function setHeight($a_height)
100  {
101  $this->height = $a_height;
102  }
103 
109  function getHeight()
110  {
111  return $this->height;
112  }
113 
119  function setLatitude($a_latitude)
120  {
121  $this->latitude = $a_latitude;
122  }
123 
129  function getLatitude()
130  {
131  return $this->latitude;
132  }
133 
139  function setLongitude($a_longitude)
140  {
141  $this->longitude = $a_longitude;
142  }
143 
149  function getLongitude()
150  {
151  return $this->longitude;
152  }
153 
159  function setZoom($a_zoom)
160  {
161  $this->zoom = $a_zoom;
162  }
163 
169  function getZoom()
170  {
171  return $this->zoom;
172  }
173 
179  function setEnableTypeControl($a_enabletypecontrol)
180  {
181  $this->enabletypecontrol = $a_enabletypecontrol;
182  }
183 
190  {
192  }
193 
199  function setEnableNavigationControl($a_enablenavigationcontrol)
200  {
201  $this->enablenavigationcontrol = $a_enablenavigationcontrol;
202  }
203 
210  {
212  }
213 
219  function setEnableUpdateListener($a_enableupdatelistener)
220  {
221  $this->enableupdatelistener = $a_enableupdatelistener;
222  }
223 
230  {
232  }
233 
239  function setEnableLargeMapControl($a_largemapcontrol)
240  {
241  $this->largemapcontrol = $a_largemapcontrol;
242  }
243 
250  {
251  return $this->largemapcontrol;
252  }
253 
259  function setEnableCentralMarker($a_centralmarker)
260  {
261  $this->centralmarker = $a_centralmarker;
262  }
263 
270  {
271  return $this->centralmarker;
272  }
273 
279  function addUserMarker($a_user_id)
280  {
281  return $this->user_marker[] = $a_user_id;
282  }
283 
287  function getHtml()
288  {
289  global $tpl;
290 
291  $this->tpl = new ilTemplate("tpl.google_map.html",
292  true, true, "Services/GoogleMaps");
293 
294  $tpl->addJavaScript("//maps.google.com/maps/api/js?sensor=false", false);
295  $tpl->addJavaScript("Services/JavaScript/js/Basic.js");
296  $tpl->addJavaScript("Services/GoogleMaps/js/ServiceGoogleMaps.js");
297 
298  // add user markers
299  $cnt = 0;
300  foreach($this->user_marker as $user_id)
301  {
302  if (ilObject::_exists($user_id))
303  {
304  $user = new ilObjUser($user_id);
305  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
306  $user->getPref("public_location") == "y")
307  {
308  $this->tpl->setCurrentBlock("user_marker");
309  $this->tpl->setVariable("UMAP_ID",
310  $this->getMapId());
311  $this->tpl->setVariable("CNT", $cnt);
312 
313  $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
314  $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
315  $info = htmlspecialchars($user->getFirstName()." ".$user->getLastName());
316  $delim = "<br \/>";
317  if ($user->getPref("public_institution") == "y")
318  {
319  $info.= $delim.htmlspecialchars($user->getInstitution());
320  $delim = ", ";
321  }
322  if ($user->getPref("public_department") == "y")
323  {
324  $info.= $delim.htmlspecialchars($user->getDepartment());
325  }
326  $delim = "<br \/>";
327  if ($user->getPref("public_street") == "y")
328  {
329  $info.= $delim.htmlspecialchars($user->getStreet());
330  }
331  if ($user->getPref("public_zip") == "y")
332  {
333  $info.= $delim.htmlspecialchars($user->getZipcode());
334  $delim = " ";
335  }
336  if ($user->getPref("public_city") == "y")
337  {
338  $info.= $delim.htmlspecialchars($user->getCity());
339  }
340  $delim = "<br \/>";
341  if ($user->getPref("public_country") == "y")
342  {
343  $info.= $delim.htmlspecialchars($user->getCountry());
344  }
345  $this->tpl->setVariable("USER_INFO",
346  $info);
347  $this->tpl->setVariable("IMG_USER",
348  $user->getPersonalPicturePath("xsmall"));
349  $this->tpl->parseCurrentBlock();
350  $cnt++;
351  }
352  }
353  }
354 
355  $this->tpl->setVariable("MAP_ID", $this->getMapId());
356  $this->tpl->setVariable("WIDTH", $this->getWidth());
357  $this->tpl->setVariable("HEIGHT", $this->getHeight());
358  $this->tpl->setVariable("LAT", $this->getLatitude());
359  $this->tpl->setVariable("LONG", $this->getLongitude());
360  $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
361  $type_control = $this->getEnableTypeControl()
362  ? "true"
363  : "false";
364  $this->tpl->setVariable("TYPE_CONTROL", $type_control);
365  $nav_control = $this->getEnableNavigationControl()
366  ? "true"
367  : "false";
368  $this->tpl->setVariable("NAV_CONTROL", $nav_control);
369  $update_listener = $this->getEnableUpdateListener()
370  ? "true"
371  : "false";
372  $this->tpl->setVariable("UPDATE_LISTENER", $update_listener);
373  $large_map_control = $this->getEnableLargeMapControl()
374  ? "true"
375  : "false";
376  $this->tpl->setVariable("LARGE_CONTROL", $large_map_control);
377  $central_marker = $this->getEnableCentralMarker()
378  ? "true"
379  : "false";
380  $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
381 
382  return $this->tpl->get();
383  }
384 
388  function getUserListHtml()
389  {
390  $list_tpl = new ilTemplate("tpl.google_map_user_list.html",
391  true, true, "Services/GoogleMaps");
392 
393  $cnt = 0;
394  foreach($this->user_marker as $user_id)
395  {
396  if (ilObject::_exists($user_id))
397  {
398  $user = new ilObjUser($user_id);
399  $this->css_row = ($this->css_row != "tblrow1_mo")
400  ? "tblrow1_mo"
401  : "tblrow2_mo";
402  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
403  && $user->getPref("public_location") == "y")
404  {
405  $list_tpl->setCurrentBlock("item");
406  $list_tpl->setVariable("MARKER_CNT", $cnt);
407  $list_tpl->setVariable("MAP_ID", $this->getMapId());
408  $cnt++;
409  }
410  else
411  {
412  $list_tpl->setCurrentBlock("item_no_link");
413  }
414  $list_tpl->setVariable("CSS_ROW", $this->css_row);
415  $list_tpl->setVariable("TXT_USER", $user->getLogin());
416  $list_tpl->setVariable("IMG_USER",
417  $user->getPersonalPicturePath("xxsmall"));
418  $list_tpl->parseCurrentBlock();
419  $list_tpl->touchBlock("row");
420  }
421  }
422 
423  return $list_tpl->get();
424  }
425 
426 }
427 ?>