ILIAS  release_7 Revision v7.30-3-g800a261c036
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 public function __construct()
41 {
43 }
44
48 public function getTileServers()
49 {
50 return $this->tile_server;
51 }
52
53 public function setTileServers($a_tile)
54 {
55 $this->tile_server = $a_tile;
56 return $this;
57 }
58
59 public function getGeolocationServer()
60 {
62 }
63
64 public function setGeolocationServer($a_geolocation)
65 {
66 $this->geolocation_server = $a_geolocation;
67 return $this;
68 }
69
70
71
72 public function getHtml()
73 {
74 global $DIC;
75 $tpl = $DIC['tpl'];
76 $lng = $DIC['lng'];
77 $https = $DIC['https'];
78
79 $this->tpl = new ilTemplate(
80 "tpl.openlayers_map.html",
81 true,
82 true,
83 "Services/Maps"
84 );
85
86
87 $lng->loadLanguageModule("maps");
88 $tpl->addCss("node_modules/ol/ol.css");
89 $tpl->addCss("Services/Maps/css/service_openlayers.css");
90 $tpl->addJavaScript("Services/Maps/js/dist/ServiceOpenLayers.js");
91
92 // add user markers
93 $cnt = 0;
94 foreach ($this->user_marker as $user_id) {
95 if (ilObject::_exists($user_id)) {
96 $user = new ilObjUser($user_id);
97 if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
98 $user->getPref("public_location") == "y") {
99 $this->tpl->setCurrentBlock("user_marker");
100 $this->tpl->setVariable(
101 "UMAP_ID",
102 $this->getMapId()
103 );
104 $this->tpl->setVariable("CNT", $cnt);
105
106 $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
107 $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
108 $info = htmlspecialchars($user->getFirstName() . " " . $user->getLastName());
109 $delim = "<br \/>";
110 if ($user->getPref("public_institution") == "y") {
111 $info .= $delim . htmlspecialchars($user->getInstitution());
112 $delim = ", ";
113 }
114 if ($user->getPref("public_department") == "y") {
115 $info .= $delim . htmlspecialchars($user->getDepartment());
116 }
117 $delim = "<br \/>";
118 if ($user->getPref("public_street") == "y") {
119 $info .= $delim . htmlspecialchars($user->getStreet());
120 }
121 if ($user->getPref("public_zip") == "y") {
122 $info .= $delim . htmlspecialchars($user->getZipcode());
123 $delim = " ";
124 }
125 if ($user->getPref("public_city") == "y") {
126 $info .= $delim . htmlspecialchars($user->getCity());
127 }
128 $delim = "<br \/>";
129 if ($user->getPref("public_country") == "y") {
130 $info .= $delim . htmlspecialchars($user->getCountry());
131 }
132 $this->tpl->setVariable(
133 "USER_INFO",
134 $info
135 );
136 $this->tpl->setVariable(
137 "IMG_USER",
138 $user->getPersonalPicturePath("xsmall")
139 );
140 $this->tpl->parseCurrentBlock();
141 $cnt++;
142 }
143 }
144 }
145
146 $this->tpl->setVariable("MAP_ID", $this->getMapId());
147 $this->tpl->setVariable("WIDTH", $this->getWidth());
148 $this->tpl->setVariable("HEIGHT", $this->getHeight());
149 $this->tpl->setVariable("LAT", $this->getLatitude());
150 $this->tpl->setVariable("LONG", $this->getLongitude());
151 $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
152
153
154 $nav_control = $this->getEnableNavigationControl()
155 ? "true"
156 : "false";
157 $this->tpl->setVariable("NAV_CONTROL", $nav_control);
158 $central_marker = $this->getEnableCentralMarker()
159 ? "true"
160 : "false";
161 $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
162 $replace_marker = $this->getEnableUpdateListener()
163 ? "true"
164 : "false";
165 $this->tpl->setVariable("REPLACE_MARKER", $replace_marker);
166
167 $tile_servers = $this->getTileServers();
168 $tile_servers = explode(" ", $tile_servers);
169 array_walk($tile_servers, function (&$string) {
170 $string = '"' . $string . '"';
171 });
172 $tile_servers = '[' . implode(', ', $tile_servers) . ']';
173
174 $this->tpl->setVariable("TILES", $tile_servers);
175 $this->tpl->setVariable("GEOLOCATION", $this->getGeolocationServer());
176 $this->tpl->setVariable("INVALID_ADDRESS_STRING", $lng->txt("invalid_address"));
177
178 return $this->tpl->get();
179 }
180
184 public function getUserListHtml()
185 {
186 $list_tpl = new ilTemplate(
187 "tpl.openlayers_map_user_list.html",
188 true,
189 true,
190 "Services/Maps"
191 );
192
193 $cnt = 0;
194 foreach ($this->user_marker as $user_id) {
195 if (ilObject::_exists($user_id)) {
196 $user = new ilObjUser($user_id);
197 $this->css_row = ($this->css_row != "tblrow1_mo")
198 ? "tblrow1_mo"
199 : "tblrow2_mo";
200 if ($user->getLatitude() != 0 && $user->getLongitude() != 0
201 && $user->getPref("public_location") == "y") {
202 $list_tpl->setCurrentBlock("item");
203 $list_tpl->setVariable("MARKER_CNT", $cnt);
204 $list_tpl->setVariable("MAP_ID", $this->getMapId());
205 $cnt++;
206 } else {
207 $list_tpl->setCurrentBlock("item_no_link");
208 }
209 $list_tpl->setVariable("CSS_ROW", $this->css_row);
210 $list_tpl->setVariable("TXT_USER", $user->getLogin());
211 $list_tpl->setVariable(
212 "IMG_USER",
213 $user->getPersonalPicturePath("xxsmall")
214 );
215 $list_tpl->parseCurrentBlock();
216 $list_tpl->touchBlock("row");
217 }
218 }
219
220 return $list_tpl->get();
221 }
222}
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
global $DIC
Definition: goto.php:24
$https
Definition: imgupload.php:19
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$lng