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