Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 class ilLocationInputGUI extends ilFormPropertyGUI
00032 {
00033 protected $latitude;
00034 protected $longitude;
00035 protected $zoom;
00036
00043 function __construct($a_title = "", $a_postvar = "")
00044 {
00045 parent::__construct($a_title, $a_postvar);
00046 $this->setType("location");
00047 }
00048
00054 function setLatitude($a_latitude)
00055 {
00056 $this->latitude = $a_latitude;
00057 }
00058
00064 function getLatitude()
00065 {
00066 return $this->latitude;
00067 }
00068
00074 function setLongitude($a_longitude)
00075 {
00076 $this->longitude = $a_longitude;
00077 }
00078
00084 function getLongitude()
00085 {
00086 return $this->longitude;
00087 }
00088
00094 function setZoom($a_zoom)
00095 {
00096 $this->zoom = $a_zoom;
00097 }
00098
00104 function getZoom()
00105 {
00106 return $this->zoom;
00107 }
00108
00114 function setValueByArray($a_values)
00115 {
00116 $this->setLatitude($a_values[$this->getPostVar()]["latitude"]);
00117 $this->setLongitude($a_values[$this->getPostVar()]["longitude"]);
00118 $this->setZoom($a_values[$this->getPostVar()]["zoom"]);
00119 }
00120
00126 function checkInput()
00127 {
00128 global $lng;
00129
00130 $_POST[$this->getPostVar()]["latitude"] =
00131 ilUtil::stripSlashes($_POST[$this->getPostVar()]["latitude"]);
00132 $_POST[$this->getPostVar()]["longitude"] =
00133 ilUtil::stripSlashes($_POST[$this->getPostVar()]["longitude"]);
00134 if ($this->getRequired() &&
00135 (trim($_POST[$this->getPostVar()]) == "" || trim($_POST[$this->getPostVar()]) == ""))
00136 {
00137 $this->setAlert($lng->txt("msg_input_is_required"));
00138
00139 return false;
00140 }
00141 return true;
00142 }
00143
00148 function insert(&$a_tpl)
00149 {
00150 global $tpl, $lng;
00151
00152 $lng->loadLanguageModule("gmaps");
00153 $a_tpl->setCurrentBlock("prop_location");
00154 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
00155 $a_tpl->setVariable("TXT_ZOOM", $lng->txt("gmaps_zoom_level"));
00156 $a_tpl->setVariable("LOC_DESCRIPTION", $lng->txt("gmaps_std_location_desc"));
00157
00158 $lat = is_numeric($this->getLatitude())
00159 ? $this->getLatitude()
00160 : 0;
00161 $long = is_numeric($this->getLongitude())
00162 ? $this->getLongitude()
00163 : 0;
00164 $a_tpl->setVariable("PROPERTY_VALUE_LAT", $lat);
00165 $a_tpl->setVariable("PROPERTY_VALUE_LONG", $long);
00166 for($i = 0; $i <= 18; $i++)
00167 {
00168 $levels[$i] = $i;
00169 }
00170 $a_tpl->setVariable("ZOOM_SELECT",
00171 ilUtil::formSelect($this->getZoom(), $this->getPostVar()."[zoom]",
00172 $levels, false, true, 0, "", array("id" => "map_".$this->getPostVar()."_zoom",
00173 "onchange" => "ilUpdateMap('"."map_".$this->getPostVar()."');")));
00174 $a_tpl->setVariable("MAP_ID", "map_".$this->getPostVar());
00175
00176 include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
00177 $map_gui = new ilGoogleMapGUI();
00178 $map_gui->setMapId("map_".$this->getPostVar());
00179 $map_gui->setLatitude($lat);
00180 $map_gui->setLongitude($long);
00181 $map_gui->setZoom($this->getZoom());
00182 $map_gui->setEnableTypeControl(true);
00183 $map_gui->setEnableLargeMapControl(true);
00184 $map_gui->setEnableUpdateListener(true);
00185 $map_gui->setEnableCentralMarker(true);
00186
00187 $a_tpl->setVariable("MAP", $map_gui->getHtml());
00188
00189 $a_tpl->parseCurrentBlock();
00190 }
00191
00192 }