ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 protected $address;
37
44 function __construct($a_title = "", $a_postvar = "")
45 {
46 parent::__construct($a_title, $a_postvar);
47 $this->setType("location");
48 }
49
55 function setLatitude($a_latitude)
56 {
57 $this->latitude = $a_latitude;
58 }
59
65 function getLatitude()
66 {
67 return $this->latitude;
68 }
69
75 function setLongitude($a_longitude)
76 {
77 $this->longitude = $a_longitude;
78 }
79
85 function getLongitude()
86 {
87 return $this->longitude;
88 }
89
95 function setZoom($a_zoom)
96 {
97 $this->zoom = $a_zoom;
98 }
99
105 function getZoom()
106 {
107 return $this->zoom;
108 }
109
115 function setAddress($a_address)
116 {
117 $this->address = $a_address;
118 }
119
125 function getAddress()
126 {
127 return $this->address;
128 }
129
135 function setValueByArray($a_values)
136 {
137 $this->setLatitude($a_values[$this->getPostVar()]["latitude"]);
138 $this->setLongitude($a_values[$this->getPostVar()]["longitude"]);
139 $this->setZoom($a_values[$this->getPostVar()]["zoom"]);
140 }
141
147 function checkInput()
148 {
149 global $lng;
150
151 $_POST[$this->getPostVar()]["latitude"] =
152 ilUtil::stripSlashes($_POST[$this->getPostVar()]["latitude"]);
153 $_POST[$this->getPostVar()]["longitude"] =
154 ilUtil::stripSlashes($_POST[$this->getPostVar()]["longitude"]);
155 if ($this->getRequired() &&
156 (trim($_POST[$this->getPostVar()]["latitude"]) == "" || trim($_POST[$this->getPostVar()]["longitude"]) == ""))
157 {
158 $this->setAlert($lng->txt("msg_input_is_required"));
159
160 return false;
161 }
162 return true;
163 }
164
169 function insert(&$a_tpl)
170 {
171 global $lng;
172
173 $lng->loadLanguageModule("maps");
174 $tpl = new ilTemplate("tpl.prop_location.html", true, true, "Services/Form");
175 $tpl->setVariable("POST_VAR", $this->getPostVar());
176 $tpl->setVariable("TXT_ZOOM", $lng->txt("maps_zoom_level"));
177 $tpl->setVariable("TXT_LATITUDE", $lng->txt("maps_latitude"));
178 $tpl->setVariable("TXT_LONGITUDE", $lng->txt("maps_longitude"));
179 $tpl->setVariable("TXT_ADDR", $lng->txt("address"));
180 $tpl->setVariable("LOC_DESCRIPTION", $lng->txt("maps_std_location_desc"));
181
182 $lat = is_numeric($this->getLatitude())
183 ? $this->getLatitude()
184 : 0;
185 $long = is_numeric($this->getLongitude())
186 ? $this->getLongitude()
187 : 0;
188 $tpl->setVariable("PROPERTY_VALUE_LAT", $lat);
189 $tpl->setVariable("PROPERTY_VALUE_LONG", $long);
190 for($i = 0; $i <= 18; $i++)
191 {
192 $levels[$i] = $i;
193 }
194 $tpl->setVariable("ZOOM_SELECT",
195 ilUtil::formSelect($this->getZoom(), $this->getPostVar()."[zoom]",
196 $levels, false, true, 0, "", array("id" => "map_".$this->getPostVar()."_zoom",
197 "onchange" => "ilUpdateMap('"."map_".$this->getPostVar()."');")));
198 $tpl->setVariable("MAP_ID", "map_".$this->getPostVar());
199 $tpl->setVariable("ID", $this->getPostVar());
200 $tpl->setVariable("TXT_LOOKUP", $lng->txt("maps_lookup_address"));
201 $tpl->setVariable("TXT_ADDRESS", $this->getAddress());
202
203 include_once("./Services/Maps/classes/class.ilMapUtil.php");
204 $map_gui = ilMapUtil::getMapGUI();
205 $map_gui->setMapId("map_".$this->getPostVar())
206 ->setLatitude($lat)
207 ->setLongitude($long)
208 ->setZoom($this->getZoom())
209 ->setEnableTypeControl(true)
210 ->setEnableLargeMapControl(true)
211 ->setEnableUpdateListener(true)
212 ->setEnableCentralMarker(true);
213
214 $tpl->setVariable("MAP", $map_gui->getHtml());
215
216 $a_tpl->setCurrentBlock("prop_generic");
217 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
218 $a_tpl->parseCurrentBlock();
219 }
220
221}
global $tpl
Definition: ilias.php:8
This class represents a property in a property form.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
This class represents a location property in a property form.
checkInput()
Check input, strip slashes etc.
setAddress($a_address)
Set Address.
setValueByArray($a_values)
Set value by array.
insert(&$a_tpl)
Insert property html.
__construct($a_title="", $a_postvar="")
Constructor.
setLatitude($a_latitude)
Set Latitude.
setLongitude($a_longitude)
Set Longitude.
static getMapGUI()
Get an instance of the GUI class.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40