• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Form/classes/class.ilLocationInputGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2007 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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 }

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1