3require_once
"Services/ADT/classes/Bridges/class.ilADTSearchBridgeSingle.php";
20 if ($value !==
null) {
39 include_once(
"./Services/Maps/classes/class.ilMapUtil.php");
42 $adt->setLongitude(
$def[
"longitude"]);
50 if (!$default && !
$adt->isNull()) {
51 $optional->setChecked(
true);
55 $loc->setLongitude(
$adt->getLongitude());
56 $loc->setLatitude(
$adt->getLatitude());
57 $loc->setZoom(
$adt->getZoom());
58 $optional->addSubItem($loc);
62 $rad->setSuffix(
$lng->txt(
"form_location_radius_km"));
63 $rad->setValue($this->radius);
64 $rad->setRequired(
true);
65 $optional->addSubItem($rad);
72 return (
bool) $a_post[
"tgl"];
81 $tgl->setChecked(
true);
84 $item->setLongitude(
$post[
"longitude"]);
85 $item->setLatitude(
$post[
"latitude"]);
86 $item->setZoom(
$post[
"zoom"]);
88 $this->radius = (int)
$post[
"rad"];
95 $this->force_valid =
true;
97 $this->
getADT()->setLongitude(
null);
98 $this->
getADT()->setLatitude(
null);
99 $this->
getADT()->setZoom(
null);
100 $this->radius =
null;
106 return (parent::isValid() && ((
int) $this->radius || (
bool) $this->force_valid));
122 $earth_radius = 6371;
125 $max_lat = $a_latitude + rad2deg($a_radius/$earth_radius);
126 $min_lat = $a_latitude - rad2deg($a_radius/$earth_radius);
127 $max_long = $a_longitude + rad2deg($a_radius/$earth_radius/cos(deg2rad($a_latitude)));
128 $min_long = $a_longitude - rad2deg($a_radius/$earth_radius/cos(deg2rad($a_latitude)));
131 "lat" => array(
"min"=>$min_lat,
"max"=>$max_lat)
132 ,
"long" => array(
"min"=>$min_long,
"max"=>$max_long)
147 $res[] = $a_element_id .
"_lat >= " .
$ilDB->quote($box[
"lat"][
"min"],
"float");
148 $res[] = $a_element_id .
"_lat <= " .
$ilDB->quote($box[
"lat"][
"max"],
"float");
149 $res[] = $a_element_id .
"_long >= " .
$ilDB->quote($box[
"long"][
"min"],
"float");
150 $res[] = $a_element_id .
"_long <= " .
$ilDB->quote($box[
"long"][
"max"],
"float");
152 return "(" . implode(
" AND ",
$res) .
")";
162 return serialize(array(
163 "lat" => $this->
getADT()->getLatitude()
164 ,
"long" => $this->
getADT()->getLongitude()
165 ,
"zoom" => $this->
getADT()->getZoom()
166 ,
"radius" => (
int) $this->radius
173 $a_value = unserialize($a_value);
174 if (is_array($a_value)) {
175 $this->
getADT()->setLatitude($a_value[
"lat"]);
176 $this->
getADT()->setLongitude($a_value[
"long"]);
177 $this->
getADT()->setZoom($a_value[
"zoom"]);
178 $this->radius = (int) $a_value[
"radius"];
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
addToForm()
Add ADT-specific fields to form.
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
getBoundingBox($a_latitude, $a_longitude, $a_radius)
Get bounding box for location circum search.
loadFilter()
Load filter value(s) into ADT.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
isValidADTDefinition(ilADTDefinition $a_adt_def)
Check if given ADT definition is valid.
importFromPost(array $a_post=null)
Import values from (search) form request POST data.
readFilter()
Load value(s) from filter store (in session)
extractPostValues(array $a_post=null)
Extract data from (post) values.
addToElementId($a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
static getDefaultSettings()
Get default longitude, latitude and zoom.
foreach($_POST as $key=> $value) $res