ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilOpenLayersMapGUI.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 protected $tile_server;
39
40 function __construct()
41 {
42 parent::__construct();
43
44 }
45
49 function getTileServers() {
50 return $this->tile_server;
51 }
52
53 function setTileServers($a_tile) {
54 $this->tile_server = $a_tile;
55 return $this;
56 }
57
60 }
61
62 function setGeolocationServer($a_geolocation) {
63 $this->geolocation_server = $a_geolocation;
64 return $this;
65 }
66
67
68
69 function getHtml()
70 {
71 global $DIC;
72 $tpl = $DIC['tpl'];
73 $lng = $DIC['lng'];
74 $https = $DIC['https'];
75
76 $this->tpl = new ilTemplate("tpl.openlayers_map.html",
77 true, true, "Services/Maps");
78
79
80 $lng->loadLanguageModule("maps");
81 $tpl->addJavaScript("Services/Maps/js/OpenLayers.js");
82 $tpl->addJavaScript("Services/Maps/js/ServiceOpenLayers.js");
83
84 // add user markers
85 $cnt = 0;
86 foreach($this->user_marker as $user_id)
87 {
88 if (ilObject::_exists($user_id))
89 {
90 $user = new ilObjUser($user_id);
91 if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
92 $user->getPref("public_location") == "y")
93 {
94 $this->tpl->setCurrentBlock("user_marker");
95 $this->tpl->setVariable("UMAP_ID",
96 $this->getMapId());
97 $this->tpl->setVariable("CNT", $cnt);
98
99 $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
100 $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
101 $info = htmlspecialchars($user->getFirstName()." ".$user->getLastName());
102 $delim = "<br \/>";
103 if ($user->getPref("public_institution") == "y")
104 {
105 $info.= $delim.htmlspecialchars($user->getInstitution());
106 $delim = ", ";
107 }
108 if ($user->getPref("public_department") == "y")
109 {
110 $info.= $delim.htmlspecialchars($user->getDepartment());
111 }
112 $delim = "<br \/>";
113 if ($user->getPref("public_street") == "y")
114 {
115 $info.= $delim.htmlspecialchars($user->getStreet());
116 }
117 if ($user->getPref("public_zip") == "y")
118 {
119 $info.= $delim.htmlspecialchars($user->getZipcode());
120 $delim = " ";
121 }
122 if ($user->getPref("public_city") == "y")
123 {
124 $info.= $delim.htmlspecialchars($user->getCity());
125 }
126 $delim = "<br \/>";
127 if ($user->getPref("public_country") == "y")
128 {
129 $info.= $delim.htmlspecialchars($user->getCountry());
130 }
131 $this->tpl->setVariable("USER_INFO",
132 $info);
133 $this->tpl->setVariable("IMG_USER",
134 $user->getPersonalPicturePath("xsmall"));
135 $this->tpl->parseCurrentBlock();
136 $cnt++;
137 }
138 }
139 }
140
141 $this->tpl->setVariable("MAP_ID", $this->getMapId());
142 $this->tpl->setVariable("WIDTH", $this->getWidth());
143 $this->tpl->setVariable("HEIGHT", $this->getHeight());
144 $this->tpl->setVariable("LAT", $this->getLatitude());
145 $this->tpl->setVariable("LONG", $this->getLongitude());
146 $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
147
148
149 $nav_control = $this->getEnableNavigationControl()
150 ? "true"
151 : "false";
152 $this->tpl->setVariable("NAV_CONTROL", $nav_control);
153 $central_marker = $this->getEnableCentralMarker()
154 ? "true"
155 : "false";
156 $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
157 $replace_marker = $this->getEnableUpdateListener()
158 ? "true"
159 : "false";
160 $this->tpl->setVariable("REPLACE_MARKER", $replace_marker);
161
162 $tile_servers = $this->getTileServers();
163 $tile_servers = explode(" ", $tile_servers);
164 array_walk($tile_servers, function(&$string) { $string = '"'.$string.'"';});
165 $tile_servers = '['.implode(', ', $tile_servers).']';
166
167 $this->tpl->setVariable("TILES", $tile_servers);
168 $this->tpl->setVariable("GEOLOCATION", $this->getGeolocationServer());
169 $this->tpl->setVariable("INVALID_ADDRESS_STRING", $lng->txt("invalid_address"));
170
171 return $this->tpl->get();
172 }
173
178 {
179 $list_tpl = new ilTemplate("tpl.openlayers_map_user_list.html",
180 true, true, "Services/Maps");
181
182 $cnt = 0;
183 foreach($this->user_marker as $user_id)
184 {
185 if (ilObject::_exists($user_id))
186 {
187 $user = new ilObjUser($user_id);
188 $this->css_row = ($this->css_row != "tblrow1_mo")
189 ? "tblrow1_mo"
190 : "tblrow2_mo";
191 if ($user->getLatitude() != 0 && $user->getLongitude() != 0
192 && $user->getPref("public_location") == "y")
193 {
194 $list_tpl->setCurrentBlock("item");
195 $list_tpl->setVariable("MARKER_CNT", $cnt);
196 $list_tpl->setVariable("MAP_ID", $this->getMapId());
197 $cnt++;
198 }
199 else
200 {
201 $list_tpl->setCurrentBlock("item_no_link");
202 }
203 $list_tpl->setVariable("CSS_ROW", $this->css_row);
204 $list_tpl->setVariable("TXT_USER", $user->getLogin());
205 $list_tpl->setVariable("IMG_USER",
206 $user->getPersonalPicturePath("xxsmall"));
207 $list_tpl->parseCurrentBlock();
208 $list_tpl->touchBlock("row");
209 }
210 }
211
212 return $list_tpl->get();
213 }
214
215}
216?>
global $tpl
Definition: ilias.php:8
An exception for terminatinating execution or to throw for unit testing.
User interface class for maps.
getMapId()
Get Map ID.
getWidth()
Get Width.
getEnableCentralMarker()
Get Enable Central Marker.
getHeight()
Get Height.
getLongitude()
Get Longitude.
getEnableNavigationControl()
Get Use Navigation Control.
getLatitude()
Get Latitude.
getZoom()
Get Zoom.
getEnableUpdateListener()
Get Activate Update Listener.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
User interface class for OpenLayers maps.
getUserListHtml()
Get User List HTML (to be displayed besides the map)
setGeolocationServer($a_geolocation)
special template class to simplify handling of ITX/PEAR
$info
Definition: example_052.php:80
global $lng
Definition: privfeed.php:17
global $DIC
$https
Definition: imgupload.php:19