ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_once("Services/Maps/classes/class.ilMapGUI.php");
34 
35 class ilGoogleMapGUI extends ilMapGUI
36 {
37  function __construct()
38  {
39  parent::__construct();
40 
41  // it's in getHTML too. why is it there twice?
42  /*$tpl->addJavaScript("//maps.google.com/maps/api/js?sensor=false", false);
43  $tpl->addJavaScript("Services/Maps/js/ServiceGoogleMaps.js");*/
44  }
45 
49  function getHtml()
50  {
51  global $tpl;
52 
53  $this->tpl = new ilTemplate("tpl.google_map.html",
54  true, true, "Services/Maps");
55 
56  require_once("Services/Maps/classes/class.ilMapUtil.php");
57  $tpl->addJavaScript("//maps.google.com/maps/api/js?key=".ilMapUtil::getApiKey(), false);
58  $tpl->addJavaScript("Services/Maps/js/ServiceGoogleMaps.js");
59 
60  // add user markers
61  $cnt = 0;
62  foreach($this->user_marker as $user_id)
63  {
64  if (ilObject::_exists($user_id))
65  {
66  $user = new ilObjUser($user_id);
67  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
68  $user->getPref("public_location") == "y")
69  {
70  $this->tpl->setCurrentBlock("user_marker");
71  $this->tpl->setVariable("UMAP_ID",
72  $this->getMapId());
73  $this->tpl->setVariable("CNT", $cnt);
74 
75  $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
76  $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
77  $info = htmlspecialchars($user->getFirstName()." ".$user->getLastName());
78  $delim = "<br \/>";
79  if ($user->getPref("public_institution") == "y")
80  {
81  $info.= $delim.htmlspecialchars($user->getInstitution());
82  $delim = ", ";
83  }
84  if ($user->getPref("public_department") == "y")
85  {
86  $info.= $delim.htmlspecialchars($user->getDepartment());
87  }
88  $delim = "<br \/>";
89  if ($user->getPref("public_street") == "y")
90  {
91  $info.= $delim.htmlspecialchars($user->getStreet());
92  }
93  if ($user->getPref("public_zip") == "y")
94  {
95  $info.= $delim.htmlspecialchars($user->getZipcode());
96  $delim = " ";
97  }
98  if ($user->getPref("public_city") == "y")
99  {
100  $info.= $delim.htmlspecialchars($user->getCity());
101  }
102  $delim = "<br \/>";
103  if ($user->getPref("public_country") == "y")
104  {
105  $info.= $delim.htmlspecialchars($user->getCountry());
106  }
107  $this->tpl->setVariable("USER_INFO",
108  $info);
109  $this->tpl->setVariable("IMG_USER",
110  $user->getPersonalPicturePath("xsmall"));
111  $this->tpl->parseCurrentBlock();
112  $cnt++;
113  }
114  }
115  }
116 
117  $this->tpl->setVariable("MAP_ID", $this->getMapId());
118  $this->tpl->setVariable("WIDTH", $this->getWidth());
119  $this->tpl->setVariable("HEIGHT", $this->getHeight());
120  $this->tpl->setVariable("LAT", $this->getLatitude());
121  $this->tpl->setVariable("LONG", $this->getLongitude());
122  $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
123  $type_control = $this->getEnableTypeControl()
124  ? "true"
125  : "false";
126  $this->tpl->setVariable("TYPE_CONTROL", $type_control);
127  $nav_control = $this->getEnableNavigationControl()
128  ? "true"
129  : "false";
130  $this->tpl->setVariable("NAV_CONTROL", $nav_control);
131  $update_listener = $this->getEnableUpdateListener()
132  ? "true"
133  : "false";
134  $this->tpl->setVariable("UPDATE_LISTENER", $update_listener);
135  $large_map_control = $this->getEnableLargeMapControl()
136  ? "true"
137  : "false";
138  $this->tpl->setVariable("LARGE_CONTROL", $large_map_control);
139  $central_marker = $this->getEnableCentralMarker()
140  ? "true"
141  : "false";
142  $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
143 
144  return $this->tpl->get();
145  }
146 
150  function getUserListHtml()
151  {
152  global $tpl;
153 
154  $list_tpl = new ilTemplate("tpl.google_map_user_list.html",
155  true, true, "Services/Maps");
156 
157  $cnt = 0;
158  foreach($this->user_marker as $user_id)
159  {
160  if (ilObject::_exists($user_id))
161  {
162  $user = new ilObjUser($user_id);
163  $this->css_row = ($this->css_row != "tblrow1_mo")
164  ? "tblrow1_mo"
165  : "tblrow2_mo";
166  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
167  && $user->getPref("public_location") == "y")
168  {
169  $list_tpl->setCurrentBlock("item");
170  $list_tpl->setVariable("MARKER_CNT", $cnt);
171  $list_tpl->setVariable("MAP_ID", $this->getMapId());
172  $cnt++;
173  }
174  else
175  {
176  $list_tpl->setCurrentBlock("item_no_link");
177  }
178  $list_tpl->setVariable("CSS_ROW", $this->css_row);
179  $list_tpl->setVariable("TXT_USER", $user->getLogin());
180  $list_tpl->setVariable("IMG_USER",
181  $user->getPersonalPicturePath("xxsmall"));
182  $list_tpl->parseCurrentBlock();
183  $list_tpl->touchBlock("row");
184  }
185  }
186 
187  return $list_tpl->get();
188  }
189 
190 }
191 ?>
getLatitude()
Get Latitude.
getZoom()
Get Zoom.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
getMapId()
Get Map ID.
getEnableCentralMarker()
Get Enable Central Marker.
getEnableUpdateListener()
Get Activate Update Listener.
getWidth()
Get Width.
getEnableLargeMapControl()
Get Large Map Control.
global $tpl
Definition: ilias.php:8
static getApiKey()
getEnableNavigationControl()
Get Use Navigation Control.
$info
Definition: example_052.php:80
special template class to simplify handling of ITX/PEAR
User interface class for google maps.
getUserListHtml()
Get User List HTML (to be displayed besides the map)
getHeight()
Get Height.
getEnableTypeControl()
Get Use Map Type Control.
getLongitude()
Get Longitude.
User interface class for maps.