ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLocationInputGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2007 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 
32 {
33  protected $latitude;
34  protected $longitude;
35  protected $zoom;
36 
43  function __construct($a_title = "", $a_postvar = "")
44  {
45  parent::__construct($a_title, $a_postvar);
46  $this->setType("location");
47  }
48 
54  function setLatitude($a_latitude)
55  {
56  $this->latitude = $a_latitude;
57  }
58 
64  function getLatitude()
65  {
66  return $this->latitude;
67  }
68 
74  function setLongitude($a_longitude)
75  {
76  $this->longitude = $a_longitude;
77  }
78 
84  function getLongitude()
85  {
86  return $this->longitude;
87  }
88 
94  function setZoom($a_zoom)
95  {
96  $this->zoom = $a_zoom;
97  }
98 
104  function getZoom()
105  {
106  return $this->zoom;
107  }
108 
114  function setValueByArray($a_values)
115  {
116  $this->setLatitude($a_values[$this->getPostVar()]["latitude"]);
117  $this->setLongitude($a_values[$this->getPostVar()]["longitude"]);
118  $this->setZoom($a_values[$this->getPostVar()]["zoom"]);
119  }
120 
126  function checkInput()
127  {
128  global $lng;
129 
130  $_POST[$this->getPostVar()]["latitude"] =
131  ilUtil::stripSlashes($_POST[$this->getPostVar()]["latitude"]);
132  $_POST[$this->getPostVar()]["longitude"] =
133  ilUtil::stripSlashes($_POST[$this->getPostVar()]["longitude"]);
134  if ($this->getRequired() &&
135  (trim($_POST[$this->getPostVar()]) == "" || trim($_POST[$this->getPostVar()]) == ""))
136  {
137  $this->setAlert($lng->txt("msg_input_is_required"));
138 
139  return false;
140  }
141  return true;
142  }
143 
148  function insert(&$a_tpl)
149  {
150  global $tpl, $lng;
151 
152  $lng->loadLanguageModule("gmaps");
153  $a_tpl->setCurrentBlock("prop_location");
154  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
155  $a_tpl->setVariable("TXT_ZOOM", $lng->txt("gmaps_zoom_level"));
156  $a_tpl->setVariable("LOC_DESCRIPTION", $lng->txt("gmaps_std_location_desc"));
157 
158  $lat = is_numeric($this->getLatitude())
159  ? $this->getLatitude()
160  : 0;
161  $long = is_numeric($this->getLongitude())
162  ? $this->getLongitude()
163  : 0;
164  $a_tpl->setVariable("PROPERTY_VALUE_LAT", $lat);
165  $a_tpl->setVariable("PROPERTY_VALUE_LONG", $long);
166  for($i = 0; $i <= 18; $i++)
167  {
168  $levels[$i] = $i;
169  }
170  $a_tpl->setVariable("ZOOM_SELECT",
171  ilUtil::formSelect($this->getZoom(), $this->getPostVar()."[zoom]",
172  $levels, false, true, 0, "", array("id" => "map_".$this->getPostVar()."_zoom",
173  "onchange" => "ilUpdateMap('"."map_".$this->getPostVar()."');")));
174  $a_tpl->setVariable("MAP_ID", "map_".$this->getPostVar());
175 
176  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
177  $map_gui = new ilGoogleMapGUI();
178  $map_gui->setMapId("map_".$this->getPostVar());
179  $map_gui->setLatitude($lat);
180  $map_gui->setLongitude($long);
181  $map_gui->setZoom($this->getZoom());
182  $map_gui->setEnableTypeControl(true);
183  $map_gui->setEnableLargeMapControl(true);
184  $map_gui->setEnableUpdateListener(true);
185  $map_gui->setEnableCentralMarker(true);
186 
187  $a_tpl->setVariable("MAP", $map_gui->getHtml());
188 
189  $a_tpl->parseCurrentBlock();
190  }
191 
192 }