ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 
33 require_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("libs/bower/bower_components/openlayers/build/ol.css");
89  $tpl->addJavaScript("libs/bower/bower_components/openlayers/build/ol.js");
90  $tpl->addCss("Services/Maps/css/service_openlayers.css");
91  $tpl->addJavaScript("Services/Maps/js/ServiceOpenLayers.js");
92 
93  // add user markers
94  $cnt = 0;
95  foreach ($this->user_marker as $user_id) {
96  if (ilObject::_exists($user_id)) {
97  $user = new ilObjUser($user_id);
98  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
99  $user->getPref("public_location") == "y") {
100  $this->tpl->setCurrentBlock("user_marker");
101  $this->tpl->setVariable(
102  "UMAP_ID",
103  $this->getMapId()
104  );
105  $this->tpl->setVariable("CNT", $cnt);
106 
107  $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
108  $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
109  $info = htmlspecialchars($user->getFirstName() . " " . $user->getLastName());
110  $delim = "<br \/>";
111  if ($user->getPref("public_institution") == "y") {
112  $info .= $delim . htmlspecialchars($user->getInstitution());
113  $delim = ", ";
114  }
115  if ($user->getPref("public_department") == "y") {
116  $info .= $delim . htmlspecialchars($user->getDepartment());
117  }
118  $delim = "<br \/>";
119  if ($user->getPref("public_street") == "y") {
120  $info .= $delim . htmlspecialchars($user->getStreet());
121  }
122  if ($user->getPref("public_zip") == "y") {
123  $info .= $delim . htmlspecialchars($user->getZipcode());
124  $delim = " ";
125  }
126  if ($user->getPref("public_city") == "y") {
127  $info .= $delim . htmlspecialchars($user->getCity());
128  }
129  $delim = "<br \/>";
130  if ($user->getPref("public_country") == "y") {
131  $info .= $delim . htmlspecialchars($user->getCountry());
132  }
133  $this->tpl->setVariable(
134  "USER_INFO",
135  $info
136  );
137  $this->tpl->setVariable(
138  "IMG_USER",
139  $user->getPersonalPicturePath("xsmall")
140  );
141  $this->tpl->parseCurrentBlock();
142  $cnt++;
143  }
144  }
145  }
146 
147  $this->tpl->setVariable("MAP_ID", $this->getMapId());
148  $this->tpl->setVariable("WIDTH", $this->getWidth());
149  $this->tpl->setVariable("HEIGHT", $this->getHeight());
150  $this->tpl->setVariable("LAT", $this->getLatitude());
151  $this->tpl->setVariable("LONG", $this->getLongitude());
152  $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
153 
154 
155  $nav_control = $this->getEnableNavigationControl()
156  ? "true"
157  : "false";
158  $this->tpl->setVariable("NAV_CONTROL", $nav_control);
159  $central_marker = $this->getEnableCentralMarker()
160  ? "true"
161  : "false";
162  $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
163  $replace_marker = $this->getEnableUpdateListener()
164  ? "true"
165  : "false";
166  $this->tpl->setVariable("REPLACE_MARKER", $replace_marker);
167 
168  $tile_servers = $this->getTileServers();
169  $tile_servers = explode(" ", $tile_servers);
170  array_walk($tile_servers, function (&$string) {
171  $string = '"' . $string . '"';
172  });
173  $tile_servers = '[' . implode(', ', $tile_servers) . ']';
174 
175  $this->tpl->setVariable("TILES", $tile_servers);
176  $this->tpl->setVariable("GEOLOCATION", $this->getGeolocationServer());
177  $this->tpl->setVariable("INVALID_ADDRESS_STRING", $lng->txt("invalid_address"));
178 
179  return $this->tpl->get();
180  }
181 
185  public function getUserListHtml()
186  {
187  $list_tpl = new ilTemplate(
188  "tpl.openlayers_map_user_list.html",
189  true,
190  true,
191  "Services/Maps"
192  );
193 
194  $cnt = 0;
195  foreach ($this->user_marker as $user_id) {
196  if (ilObject::_exists($user_id)) {
197  $user = new ilObjUser($user_id);
198  $this->css_row = ($this->css_row != "tblrow1_mo")
199  ? "tblrow1_mo"
200  : "tblrow2_mo";
201  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
202  && $user->getPref("public_location") == "y") {
203  $list_tpl->setCurrentBlock("item");
204  $list_tpl->setVariable("MARKER_CNT", $cnt);
205  $list_tpl->setVariable("MAP_ID", $this->getMapId());
206  $cnt++;
207  } else {
208  $list_tpl->setCurrentBlock("item_no_link");
209  }
210  $list_tpl->setVariable("CSS_ROW", $this->css_row);
211  $list_tpl->setVariable("TXT_USER", $user->getLogin());
212  $list_tpl->setVariable(
213  "IMG_USER",
214  $user->getPersonalPicturePath("xxsmall")
215  );
216  $list_tpl->parseCurrentBlock();
217  $list_tpl->touchBlock("row");
218  }
219  }
220 
221  return $list_tpl->get();
222  }
223 }
getLatitude()
Get Latitude.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
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.
getUserListHtml()
Get User List HTML (to be displayed besides the map)
getEnableCentralMarker()
Get Enable Central Marker.
getEnableUpdateListener()
Get Activate Update Listener.
getWidth()
Get Width.
getEnableNavigationControl()
Get Use Navigation Control.
$lng
$https
Definition: imgupload.php:19
getHeight()
Get Height.
setGeolocationServer($a_geolocation)
__construct(Container $dic, ilPlugin $plugin)
getLongitude()
Get Longitude.
$DIC
Definition: xapitoken.php:46
User interface class for maps.
User interface class for OpenLayers maps.