ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  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 
58  function getGeolocationServer() {
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 $tpl, $lng, $https;
72 
73  $this->tpl = new ilTemplate("tpl.openlayers_map.html",
74  true, true, "Services/Maps");
75 
76 
77  $lng->loadLanguageModule("maps");
78  $tpl->addJavaScript("Services/Maps/js/OpenLayers.js");
79  $tpl->addJavaScript("Services/Maps/js/ServiceOpenLayers.js");
80 
81  // add user markers
82  $cnt = 0;
83  foreach($this->user_marker as $user_id)
84  {
85  if (ilObject::_exists($user_id))
86  {
87  $user = new ilObjUser($user_id);
88  if ($user->getLatitude() != 0 && $user->getLongitude() != 0 &&
89  $user->getPref("public_location") == "y")
90  {
91  $this->tpl->setCurrentBlock("user_marker");
92  $this->tpl->setVariable("UMAP_ID",
93  $this->getMapId());
94  $this->tpl->setVariable("CNT", $cnt);
95 
96  $this->tpl->setVariable("ULAT", htmlspecialchars($user->getLatitude()));
97  $this->tpl->setVariable("ULONG", htmlspecialchars($user->getLongitude()));
98  $info = htmlspecialchars($user->getFirstName()." ".$user->getLastName());
99  $delim = "<br \/>";
100  if ($user->getPref("public_institution") == "y")
101  {
102  $info.= $delim.htmlspecialchars($user->getInstitution());
103  $delim = ", ";
104  }
105  if ($user->getPref("public_department") == "y")
106  {
107  $info.= $delim.htmlspecialchars($user->getDepartment());
108  }
109  $delim = "<br \/>";
110  if ($user->getPref("public_street") == "y")
111  {
112  $info.= $delim.htmlspecialchars($user->getStreet());
113  }
114  if ($user->getPref("public_zip") == "y")
115  {
116  $info.= $delim.htmlspecialchars($user->getZipcode());
117  $delim = " ";
118  }
119  if ($user->getPref("public_city") == "y")
120  {
121  $info.= $delim.htmlspecialchars($user->getCity());
122  }
123  $delim = "<br \/>";
124  if ($user->getPref("public_country") == "y")
125  {
126  $info.= $delim.htmlspecialchars($user->getCountry());
127  }
128  $this->tpl->setVariable("USER_INFO",
129  $info);
130  $this->tpl->setVariable("IMG_USER",
131  $user->getPersonalPicturePath("xsmall"));
132  $this->tpl->parseCurrentBlock();
133  $cnt++;
134  }
135  }
136  }
137 
138  $this->tpl->setVariable("MAP_ID", $this->getMapId());
139  $this->tpl->setVariable("WIDTH", $this->getWidth());
140  $this->tpl->setVariable("HEIGHT", $this->getHeight());
141  $this->tpl->setVariable("LAT", $this->getLatitude());
142  $this->tpl->setVariable("LONG", $this->getLongitude());
143  $this->tpl->setVariable("ZOOM", (int) $this->getZoom());
144 
145 
146  $nav_control = $this->getEnableNavigationControl()
147  ? "true"
148  : "false";
149  $this->tpl->setVariable("NAV_CONTROL", $nav_control);
150  $central_marker = $this->getEnableCentralMarker()
151  ? "true"
152  : "false";
153  $this->tpl->setVariable("CENTRAL_MARKER", $central_marker);
154  $replace_marker = $this->getEnableUpdateListener()
155  ? "true"
156  : "false";
157  $this->tpl->setVariable("REPLACE_MARKER", $replace_marker);
158 
159  $tile_servers = $this->getTileServers();
160  $tile_servers = explode(" ", $tile_servers);
161  array_walk($tile_servers, function(&$string) { $string = '"'.$string.'"';});
162  $tile_servers = '['.implode(', ', $tile_servers).']';
163 
164  $this->tpl->setVariable("TILES", $tile_servers);
165  $this->tpl->setVariable("GEOLOCATION", $this->getGeolocationServer());
166  $this->tpl->setVariable("INVALID_ADDRESS_STRING", $lng->txt("invalid_address"));
167 
168  return $this->tpl->get();
169  }
170 
174  function getUserListHtml()
175  {
176  $list_tpl = new ilTemplate("tpl.openlayers_map_user_list.html",
177  true, true, "Services/Maps");
178 
179  $cnt = 0;
180  foreach($this->user_marker as $user_id)
181  {
182  if (ilObject::_exists($user_id))
183  {
184  $user = new ilObjUser($user_id);
185  $this->css_row = ($this->css_row != "tblrow1_mo")
186  ? "tblrow1_mo"
187  : "tblrow2_mo";
188  if ($user->getLatitude() != 0 && $user->getLongitude() != 0
189  && $user->getPref("public_location") == "y")
190  {
191  $list_tpl->setCurrentBlock("item");
192  $list_tpl->setVariable("MARKER_CNT", $cnt);
193  $list_tpl->setVariable("MAP_ID", $this->getMapId());
194  $cnt++;
195  }
196  else
197  {
198  $list_tpl->setCurrentBlock("item_no_link");
199  }
200  $list_tpl->setVariable("CSS_ROW", $this->css_row);
201  $list_tpl->setVariable("TXT_USER", $user->getLogin());
202  $list_tpl->setVariable("IMG_USER",
203  $user->getPersonalPicturePath("xxsmall"));
204  $list_tpl->parseCurrentBlock();
205  $list_tpl->touchBlock("row");
206  }
207  }
208 
209  return $list_tpl->get();
210  }
211 
212 }
213 ?>
getLatitude()
Get Latitude.
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.
global $tpl
Definition: ilias.php:8
getEnableNavigationControl()
Get Use Navigation Control.
$info
Definition: example_052.php:80
global $https
Definition: imgupload.php:15
special template class to simplify handling of ITX/PEAR
getHeight()
Get Height.
setGeolocationServer($a_geolocation)
getLongitude()
Get Longitude.
global $lng
Definition: privfeed.php:40
User interface class for maps.
User interface class for OpenLayers maps.