public function addToForm() { global $lng; $adt = $this->getADT(); $default = false; if ($adt->isNull()) { // see ilPersonalProfileGUI::addLocationToForm() // use installation default include_once "./Services/Maps/classes/class.ilMapUtil.php"; $def = ilMapUtil::getDefaultSettings(); $adt->setLatitude($def["latitude"]); $adt->setLongitude($def["longitude"]); $adt->setZoom($def["zoom"]); $default = true; } // :TODO: title? $title = $this->isRequired() ? $this->getTitle() : $lng->txt("location"); $loc = new ilLocationInputGUI($title, $this->getElementId()); $loc->setLongitude($adt->getLongitude()); $loc->setLatitude($adt->getLatitude()); $loc->setZoom($adt->getZoom()); $this->addBasicFieldProperties($loc, $adt->getCopyOfDefinition()); if (!$this->isRequired()) { $optional = new ilCheckboxInputGUI($this->getTitle(), $this->getElementId() . "_tgl"); $optional->addSubItem($loc); $this->addToParentElement($optional); if (!$default && !$adt->isNull()) { $optional->setChecked(true); } } else { $this->addToParentElement($loc); } }
public function addToForm() { global $lng; $adt = $this->getADT(); $default = false; if ($adt->isNull()) { // see ilPersonalProfileGUI::addLocationToForm() // use installation default include_once "./Services/Maps/classes/class.ilMapUtil.php"; $def = ilMapUtil::getDefaultSettings(); $adt->setLatitude($def["latitude"]); $adt->setLongitude($def["longitude"]); $adt->setZoom($def["zoom"]); $default = true; } $optional = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl")); if (!$default && !$adt->isNull()) { $optional->setChecked(true); } $loc = new ilLocationInputGUI($lng->txt("location"), $this->getElementId()); $loc->setLongitude($adt->getLongitude()); $loc->setLatitude($adt->getLatitude()); $loc->setZoom($adt->getZoom()); $optional->addSubItem($loc); $rad = new ilNumberInputGUI($lng->txt("form_location_radius"), $this->addToElementId("rad")); $rad->setSize(4); $rad->setSuffix($lng->txt("form_location_radius_km")); $rad->setValue($this->radius); $rad->setRequired(true); $optional->addSubItem($rad); $this->addToParentElement($optional); }
/** * Add location fields to form if activated * * @param ilPropertyFormGUI $a_form * @param ilObjUser $a_user */ function addLocationToForm(ilPropertyFormGUI $a_form, ilObjUser $a_user) { global $ilCtrl; // check map activation include_once "./Services/Maps/classes/class.ilMapUtil.php"; if (!ilMapUtil::isActivated()) { return; } // Don't really know if this is still necessary... $this->lng->loadLanguageModule("maps"); // Get user settings $latitude = $a_user->getLatitude(); $longitude = $a_user->getLongitude(); $zoom = $a_user->getLocationZoom(); // Get Default settings, when nothing is set if ($latitude == 0 && $longitude == 0 && $zoom == 0) { $def = ilMapUtil::getDefaultSettings(); $latitude = $def["latitude"]; $longitude = $def["longitude"]; $zoom = $def["zoom"]; } $street = $a_user->getStreet(); if (!$street) { $street = $this->lng->txt("street"); } $city = $a_user->getCity(); if (!$city) { $city = $this->lng->txt("city"); } $country = $a_user->getCountry(); if (!$country) { $country = $this->lng->txt("country"); } // location property $loc_prop = new ilLocationInputGUI($this->lng->txt("location"), "location"); $loc_prop->setLatitude($latitude); $loc_prop->setLongitude($longitude); $loc_prop->setZoom($zoom); $loc_prop->setAddress($street . "," . $city . "," . $country); $a_form->addItem($loc_prop); }
/** * Edit Map Settings */ function editMapSettingsObject() { global $ilUser, $ilCtrl, $ilUser, $ilAccess; $this->setSubTabs("properties"); $this->tabs_gui->setTabActive('settings'); if (!ilMapUtil::isActivated() || !$ilAccess->checkAccess("write", "", $this->object->getRefId())) { return; } $latitude = $this->object->getLatitude(); $longitude = $this->object->getLongitude(); $zoom = $this->object->getLocationZoom(); // Get Default settings, when nothing is set if ($latitude == 0 && $longitude == 0 && $zoom == 0) { $def = ilMapUtil::getDefaultSettings(); $latitude = $def["latitude"]; $longitude = $def["longitude"]; $zoom = $def["zoom"]; } include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this)); $form->setTitle($this->lng->txt("crs_map_settings")); // enable map $public = new ilCheckboxInputGUI($this->lng->txt("crs_enable_map"), "enable_map"); $public->setValue("1"); $public->setChecked($this->object->getEnableCourseMap()); $form->addItem($public); // map location $loc_prop = new ilLocationInputGUI($this->lng->txt("crs_map_location"), "location"); $loc_prop->setLatitude($latitude); $loc_prop->setLongitude($longitude); $loc_prop->setZoom($zoom); $form->addItem($loc_prop); $form->addCommandButton("saveMapSettings", $this->lng->txt("save")); $this->tpl->setVariable("ADM_CONTENT", $form->getHTML()); //$this->tpl->show(); }