19 declare(strict_types=1);
35 $this->
lng = $DIC->language();
49 if ($value !==
null) {
66 $adt->setLatitude((
float) ($def[
"latitude"] ??
null));
67 $adt->setLongitude((
float) ($def[
"longitude"] ?? null));
68 $adt->setZoom((
int) ($def[
"zoom"] ?? 0));
76 $optional->setChecked(
true);
81 $loc->setLatitude(
$adt->getLatitude());
82 $loc->setZoom(
$adt->getZoom());
83 $optional->addSubItem($loc);
87 $rad->setSuffix($this->
lng->txt(
"form_location_radius_km"));
88 $rad->setValue($this->radius);
89 $rad->setRequired(
true);
90 $optional->addSubItem($rad);
97 return (
bool) ($a_post[
"tgl"] ??
false);
106 $tgl->setChecked(
true);
109 $item->setLongitude(
$post[
"longitude"]);
110 $item->setLatitude(
$post[
"latitude"]);
111 $item->setZoom(
$post[
"zoom"]);
120 $this->force_valid =
true;
125 $this->radius =
null;
132 return (parent::isValid() && ((
int) $this->radius || $this->force_valid));
145 protected function getBoundingBox(
float $a_latitude,
float $a_longitude,
int $a_radius): array
147 $earth_radius = 6371;
150 $max_lat = $a_latitude + rad2deg($a_radius / $earth_radius);
151 $min_lat = $a_latitude - rad2deg($a_radius / $earth_radius);
152 $max_long = $a_longitude + rad2deg($a_radius / $earth_radius / cos(deg2rad($a_latitude)));
153 $min_long = $a_longitude - rad2deg($a_radius / $earth_radius / cos(deg2rad($a_latitude)));
156 "lat" => array(
"min" => $min_lat,
"max" => $max_lat)
158 "long" => array(
"min" => $min_long,
"max" => $max_long)
164 public function getSQLCondition(
string $a_element_id,
int $mode = self::SQL_LIKE, array $quotedWords = []): string
168 $this->
getADT()->getLatitude(),
169 $this->
getADT()->getLongitude(),
174 $res[] = $a_element_id .
"_lat >= " . $this->db->quote($box[
"lat"][
"min"],
"float");
175 $res[] = $a_element_id .
"_lat <= " . $this->db->quote($box[
"lat"][
"max"],
"float");
176 $res[] = $a_element_id .
"_long >= " . $this->db->quote($box[
"long"][
"min"],
"float");
177 $res[] = $a_element_id .
"_long <= " . $this->db->quote($box[
"long"][
"max"],
"float");
179 return "(" . implode(
" AND ",
$res) .
")";
189 return serialize(array(
190 "lat" => $this->
getADT()->getLatitude()
192 "long" => $this->
getADT()->getLongitude()
194 "zoom" => $this->
getADT()->getZoom()
196 "radius" => (
int) $this->radius
204 $a_value = unserialize($a_value);
205 if (is_array($a_value)) {
206 $this->
getADT()->setLatitude($a_value[
"lat"]);
207 $this->
getADT()->setLongitude($a_value[
"long"]);
208 $this->
getADT()->setZoom($a_value[
"zoom"]);
209 $this->radius = (
int) $a_value[
"radius"];
setSerializedValue(string $a_value)
importFromPost(?array $a_post=null)
getBoundingBox(float $a_latitude, float $a_longitude, int $a_radius)
Get bounding box for location circum search.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readFilter()
Load value(s) from filter store (in session)
Class ilADTSearchBridgeSingle.
shouldBeImportedFromPost($a_post)
static getDefaultSettings()
Get default longitude, latitude and zoom.
isNull()
Is currently null.
isValidADTDefinition(ilADTDefinition $a_adt_def)
__construct(ilADTDefinition $a_adt_def)
extractPostValues(?array $a_post=null)
Extract data from (post) values.
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
__construct(Container $dic, ilPlugin $plugin)
addToElementId(string $a_add)
Add sub-element.
ADT definition base class.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.