ILIAS  Release_4_4_x_branch Revision 61816
 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/GoogleMaps/js/ServiceGoogleMaps.js");
51 
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/GoogleMaps/js/ServiceGoogleMaps.js");
296 
297  // add user markers
298  $cnt = 0;
299  foreach($this->user_marker as $user_id)
300  {
301  if (ilObject::_exists($user_id))
302  {
303  $user = new ilObjUser($user_id);
304  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
305  $user->getPref("public_location") == "y")
306  {
307  $this->tpl->setCurrentBlock("user_marker");
308  $this->tpl->setVariable("UMAP_ID",
309  $this->getMapId());
310  $this->tpl->setVariable("CNT", $cnt);
311 
312  $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
313  $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
314  $info = htmlspecialchars($user->getFirstName()." ".$user->getLastName());
315  $delim = "<br \/>";
316  if ($user->getPref("public_institution") == "y")
317  {
318  $info.= $delim.htmlspecialchars($user->getInstitution());
319  $delim = ", ";
320  }
321  if ($user->getPref("public_department") == "y")
322  {
323  $info.= $delim.htmlspecialchars($user->getDepartment());
324  }
325  $delim = "<br \/>";
326  if ($user->getPref("public_street") == "y")
327  {
328  $info.= $delim.htmlspecialchars($user->getStreet());
329  }
330  if ($user->getPref("public_zip") == "y")
331  {
332  $info.= $delim.htmlspecialchars($user->getZipcode());
333  $delim = " ";
334  }
335  if ($user->getPref("public_city") == "y")
336  {
337  $info.= $delim.htmlspecialchars($user->getCity());
338  }
339  $delim = "<br \/>";
340  if ($user->getPref("public_country") == "y")
341  {
342  $info.= $delim.htmlspecialchars($user->getCountry());
343  }
344  $this->tpl->setVariable("USER_INFO",
345  $info);
346  $this->tpl->setVariable("IMG_USER",
347  $user->getPersonalPicturePath("xsmall"));
348  $this->tpl->parseCurrentBlock();
349  $cnt++;
350  }
351  }
352  }
353 
354  $this->tpl->setVariable("MAP_ID", $this->getMapId());
355  $this->tpl->setVariable("WIDTH", $this->getWidth());
356  $this->tpl->setVariable("HEIGHT", $this->getHeight());
357  $this->tpl->setVariable("LAT", $this->getLatitude());
358  $this->tpl->setVariable("LONG", $this->getLongitude());
359  $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
360  $type_control = $this->getEnableTypeControl()
361  ? "true"
362  : "false";
363  $this->tpl->setVariable("TYPE_CONTROL", $type_control);
364  $nav_control = $this->getEnableNavigationControl()
365  ? "true"
366  : "false";
367  $this->tpl->setVariable("NAV_CONTROL", $nav_control);
368  $update_listener = $this->getEnableUpdateListener()
369  ? "true"
370  : "false";
371  $this->tpl->setVariable("UPDATE_LISTENER", $update_listener);
372  $large_map_control = $this->getEnableLargeMapControl()
373  ? "true"
374  : "false";
375  $this->tpl->setVariable("LARGE_CONTROL", $large_map_control);
376  $central_marker = $this->getEnableCentralMarker()
377  ? "true"
378  : "false";
379  $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
380 
381  return $this->tpl->get();
382  }
383 
387  function getUserListHtml()
388  {
389  global $tpl;
390 
391  $list_tpl = new ilTemplate("tpl.google_map_user_list.html",
392  true, true, "Services/GoogleMaps");
393 
394  $cnt = 0;
395  foreach($this->user_marker as $user_id)
396  {
397  if (ilObject::_exists($user_id))
398  {
399  $user = new ilObjUser($user_id);
400  $this->css_row = ($this->css_row != "tblrow1_mo")
401  ? "tblrow1_mo"
402  : "tblrow2_mo";
403  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
404  && $user->getPref("public_location") == "y")
405  {
406  $list_tpl->setCurrentBlock("item");
407  $list_tpl->setVariable("MARKER_CNT", $cnt);
408  $list_tpl->setVariable("MAP_ID", $this->getMapId());
409  $cnt++;
410  }
411  else
412  {
413  $list_tpl->setCurrentBlock("item_no_link");
414  }
415  $list_tpl->setVariable("CSS_ROW", $this->css_row);
416  $list_tpl->setVariable("TXT_USER", $user->getLogin());
417  $list_tpl->setVariable("IMG_USER",
418  $user->getPersonalPicturePath("xxsmall"));
419  $list_tpl->parseCurrentBlock();
420  $list_tpl->touchBlock("row");
421  }
422  }
423 
424  return $list_tpl->get();
425  }
426 
427 }
428 ?>