ILIAS  Release_5_0_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 require_once("Services/Maps/classes/class.ilMapGUI.php");
34 
35 class ilGoogleMapGUI extends ilMapGUI
36 {
37  function __construct()
38  {
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  $tpl->addJavaScript("//maps.google.com/maps/api/js?sensor=false", false);
57  $tpl->addJavaScript("Services/Maps/js/ServiceGoogleMaps.js");
58 
59  // add user markers
60  $cnt = 0;
61  foreach($this->user_marker as $user_id)
62  {
63  if (ilObject::_exists($user_id))
64  {
65  $user = new ilObjUser($user_id);
66  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
67  $user->getPref("public_location") == "y")
68  {
69  $this->tpl->setCurrentBlock("user_marker");
70  $this->tpl->setVariable("UMAP_ID",
71  $this->getMapId());
72  $this->tpl->setVariable("CNT", $cnt);
73 
74  $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
75  $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
76  $info = htmlspecialchars($user->getFirstName()." ".$user->getLastName());
77  $delim = "<br \/>";
78  if ($user->getPref("public_institution") == "y")
79  {
80  $info.= $delim.htmlspecialchars($user->getInstitution());
81  $delim = ", ";
82  }
83  if ($user->getPref("public_department") == "y")
84  {
85  $info.= $delim.htmlspecialchars($user->getDepartment());
86  }
87  $delim = "<br \/>";
88  if ($user->getPref("public_street") == "y")
89  {
90  $info.= $delim.htmlspecialchars($user->getStreet());
91  }
92  if ($user->getPref("public_zip") == "y")
93  {
94  $info.= $delim.htmlspecialchars($user->getZipcode());
95  $delim = " ";
96  }
97  if ($user->getPref("public_city") == "y")
98  {
99  $info.= $delim.htmlspecialchars($user->getCity());
100  }
101  $delim = "<br \/>";
102  if ($user->getPref("public_country") == "y")
103  {
104  $info.= $delim.htmlspecialchars($user->getCountry());
105  }
106  $this->tpl->setVariable("USER_INFO",
107  $info);
108  $this->tpl->setVariable("IMG_USER",
109  $user->getPersonalPicturePath("xsmall"));
110  $this->tpl->parseCurrentBlock();
111  $cnt++;
112  }
113  }
114  }
115 
116  $this->tpl->setVariable("MAP_ID", $this->getMapId());
117  $this->tpl->setVariable("WIDTH", $this->getWidth());
118  $this->tpl->setVariable("HEIGHT", $this->getHeight());
119  $this->tpl->setVariable("LAT", $this->getLatitude());
120  $this->tpl->setVariable("LONG", $this->getLongitude());
121  $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
122  $type_control = $this->getEnableTypeControl()
123  ? "true"
124  : "false";
125  $this->tpl->setVariable("TYPE_CONTROL", $type_control);
126  $nav_control = $this->getEnableNavigationControl()
127  ? "true"
128  : "false";
129  $this->tpl->setVariable("NAV_CONTROL", $nav_control);
130  $update_listener = $this->getEnableUpdateListener()
131  ? "true"
132  : "false";
133  $this->tpl->setVariable("UPDATE_LISTENER", $update_listener);
134  $large_map_control = $this->getEnableLargeMapControl()
135  ? "true"
136  : "false";
137  $this->tpl->setVariable("LARGE_CONTROL", $large_map_control);
138  $central_marker = $this->getEnableCentralMarker()
139  ? "true"
140  : "false";
141  $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
142 
143  return $this->tpl->get();
144  }
145 
149  function getUserListHtml()
150  {
151  global $tpl;
152 
153  $list_tpl = new ilTemplate("tpl.google_map_user_list.html",
154  true, true, "Services/Maps");
155 
156  $cnt = 0;
157  foreach($this->user_marker as $user_id)
158  {
159  if (ilObject::_exists($user_id))
160  {
161  $user = new ilObjUser($user_id);
162  $this->css_row = ($this->css_row != "tblrow1_mo")
163  ? "tblrow1_mo"
164  : "tblrow2_mo";
165  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
166  && $user->getPref("public_location") == "y")
167  {
168  $list_tpl->setCurrentBlock("item");
169  $list_tpl->setVariable("MARKER_CNT", $cnt);
170  $list_tpl->setVariable("MAP_ID", $this->getMapId());
171  $cnt++;
172  }
173  else
174  {
175  $list_tpl->setCurrentBlock("item_no_link");
176  }
177  $list_tpl->setVariable("CSS_ROW", $this->css_row);
178  $list_tpl->setVariable("TXT_USER", $user->getLogin());
179  $list_tpl->setVariable("IMG_USER",
180  $user->getPersonalPicturePath("xxsmall"));
181  $list_tpl->parseCurrentBlock();
182  $list_tpl->touchBlock("row");
183  }
184  }
185 
186  return $list_tpl->get();
187  }
188 
189 }
190 ?>