ILIAS  release_7 Revision v7.30-3-g800a261c036
ilADTLocationSearchBridgeSingle Class Reference
+ Inheritance diagram for ilADTLocationSearchBridgeSingle:
+ Collaboration diagram for ilADTLocationSearchBridgeSingle:

Public Member Functions

 loadFilter ()
 Load filter value(s) into ADT. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 importFromPost (array $a_post=null)
 Import values from (search) form request POST data. More...
 
 isValid ()
 
 getSQLCondition ($a_element_id)
 Get SQL condition for current value(s) More...
 
 getSerializedValue ()
 Get current value(s) in serialized form (for easy persisting) More...
 
 setSerializedValue ($a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 
- Public Member Functions inherited from ilADTSearchBridgeSingle
 getADT ()
 Get ADT. More...
 
 isNull ()
 Is null ? More...
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- Public Member Functions inherited from ilADTSearchBridge
 __construct (ilADTDefinition $a_adt_def)
 Constructor. More...
 
 isNull ()
 Is null ? More...
 
 setForm (ilPropertyFormGUI $a_form)
 Set form. More...
 
 getForm ()
 Get form. More...
 
 setElementId ($a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 Get element id. More...
 
 setTitle ($a_value)
 Set title (aka form field caption) More...
 
 getTitle ()
 Get title. More...
 
 getSearchColumn ()
 
 setTableGUI (ilTable2GUI $a_table)
 Set table gui (for filter mode) More...
 
 getTableGUI ()
 Get table gui. More...
 
 loadFilter ()
 Load filter value(s) into ADT. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 importFromPost (array $a_post=null)
 Import values from (search) form request POST data. More...
 
 validate ()
 Validate current data. More...
 
 getSQLCondition ($a_element_id)
 Get SQL condition for current value(s) More...
 
 isInCondition (ilADT $a_adt)
 Compare directly against ADT. More...
 
 getSerializedValue ()
 Get current value(s) in serialized form (for easy persisting) More...
 
 setSerializedValue ($a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 

Protected Member Functions

 isValidADTDefinition (ilADTDefinition $a_adt_def)
 Check if given ADT definition is valid. More...
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
 getBoundingBox ($a_latitude, $a_longitude, $a_radius)
 Get bounding box for location circum search. More...
 
- Protected Member Functions inherited from ilADTSearchBridgeSingle
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
- Protected Member Functions inherited from ilADTSearchBridge
 isValidADTDefinition (ilADTDefinition $a_adt_def)
 Check if given ADT definition is valid. More...
 
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
 writeFilter ($a_value=null)
 Write value(s) to filter store (in session) More...
 
 readFilter ()
 Load value(s) from filter store (in session) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 addToElementId ($a_add)
 Add sub-element. More...
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
 extractPostValues (array $a_post=null)
 Extract data from (post) values. More...
 

Protected Attributes

 $radius
 
- Protected Attributes inherited from ilADTSearchBridgeSingle
 $adt
 
- Protected Attributes inherited from ilADTSearchBridge
 $form
 
 $table_gui
 
 $table_filter_fields = []
 
 $id
 
 $title
 
 $info
 

Additional Inherited Members

- Data Fields inherited from ilADTSearchBridge
const DEFAULT_SEARCH_COLUMN = 'value'
 

Detailed Description

Definition at line 5 of file class.ilADTLocationSearchBridgeSingle.php.

Member Function Documentation

◆ addToForm()

ilADTLocationSearchBridgeSingle::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Definition at line 28 of file class.ilADTLocationSearchBridgeSingle.php.

29 {
30 global $DIC;
31
32 $lng = $DIC['lng'];
33
34 $adt = $this->getADT();
35
36 $default = false;
37 if ($adt->isNull()) {
38 // see ilPersonalProfileGUI::addLocationToForm()
39
40 // use installation default
41 include_once("./Services/Maps/classes/class.ilMapUtil.php");
43 $adt->setLatitude($def["latitude"]);
44 $adt->setLongitude($def["longitude"]);
45 $adt->setZoom($def["zoom"]);
46
47 $default = true;
48 }
49
50 $optional = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl"));
51
52 if (!$default && !$adt->isNull()) {
53 $optional->setChecked(true);
54 }
55
56 $loc = new ilLocationInputGUI($lng->txt("location"), $this->getElementId());
57 $loc->setLongitude($adt->getLongitude());
58 $loc->setLatitude($adt->getLatitude());
59 $loc->setZoom($adt->getZoom());
60 $optional->addSubItem($loc);
61
62 $rad = new ilNumberInputGUI($lng->txt("form_location_radius"), $this->addToElementId("rad"));
63 $rad->setSize(4);
64 $rad->setSuffix($lng->txt("form_location_radius_km"));
65 $rad->setValue($this->radius);
66 $rad->setRequired(true);
67 $optional->addSubItem($rad);
68
69 $this->addToParentElement($optional);
70 }
addToElementId($a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents a checkbox property in a property form.
This class represents a location property in a property form.
static getDefaultSettings()
Get default longitude, latitude and zoom.
This class represents a number property in a property form.
global $DIC
Definition: goto.php:24
$lng

References ilADTSearchBridgeSingle\$adt, $DIC, $lng, ilADTSearchBridge\addToElementId(), ilADTSearchBridge\addToParentElement(), ilADTSearchBridgeSingle\getADT(), ilMapUtil\getDefaultSettings(), and ilADTSearchBridge\getTitle().

+ Here is the call graph for this function:

◆ getBoundingBox()

ilADTLocationSearchBridgeSingle::getBoundingBox (   $a_latitude,
  $a_longitude,
  $a_radius 
)
protected

Get bounding box for location circum search.

Parameters
float$a_latitude
float$a_longitude
int$a_radius
Returns
array

Definition at line 122 of file class.ilADTLocationSearchBridgeSingle.php.

123 {
124 $earth_radius = 6371;
125
126 // http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/
127 $max_lat = $a_latitude + rad2deg($a_radius / $earth_radius);
128 $min_lat = $a_latitude - rad2deg($a_radius / $earth_radius);
129 $max_long = $a_longitude + rad2deg($a_radius / $earth_radius / cos(deg2rad($a_latitude)));
130 $min_long = $a_longitude - rad2deg($a_radius / $earth_radius / cos(deg2rad($a_latitude)));
131
132 return array(
133 "lat" => array("min" => $min_lat, "max" => $max_lat)
134 ,"long" => array("min" => $min_long, "max" => $max_long)
135 );
136 }

Referenced by getSQLCondition().

+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTLocationSearchBridgeSingle::getSerializedValue ( )

Get current value(s) in serialized form (for easy persisting)

Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 163 of file class.ilADTLocationSearchBridgeSingle.php.

164 {
165 if (!$this->isNull() && $this->isValid()) {
166 return serialize(array(
167 "lat" => $this->getADT()->getLatitude()
168 ,"long" => $this->getADT()->getLongitude()
169 ,"zoom" => $this->getADT()->getZoom()
170 ,"radius" => (int) $this->radius
171 ));
172 }
173 }

References ilADTSearchBridgeSingle\getADT(), ilADTSearchBridgeSingle\isNull(), and isValid().

+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTLocationSearchBridgeSingle::getSQLCondition (   $a_element_id)

Get SQL condition for current value(s)

Parameters
string$a_element_id
Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 141 of file class.ilADTLocationSearchBridgeSingle.php.

142 {
143 global $DIC;
144
145 $ilDB = $DIC['ilDB'];
146
147 if (!$this->isNull() && $this->isValid()) {
148 $box = $this->getBoundingBox($this->getADT()->getLatitude(), $this->getADT()->getLongitude(), $this->radius);
149
150 $res = array();
151 $res[] = $a_element_id . "_lat >= " . $ilDB->quote($box["lat"]["min"], "float");
152 $res[] = $a_element_id . "_lat <= " . $ilDB->quote($box["lat"]["max"], "float");
153 $res[] = $a_element_id . "_long >= " . $ilDB->quote($box["long"]["min"], "float");
154 $res[] = $a_element_id . "_long <= " . $ilDB->quote($box["long"]["max"], "float");
155
156 return "(" . implode(" AND ", $res) . ")";
157 }
158 }
getBoundingBox($a_latitude, $a_longitude, $a_radius)
Get bounding box for location circum search.
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, $res, ilADTSearchBridgeSingle\getADT(), getBoundingBox(), ilADTSearchBridgeSingle\isNull(), and isValid().

+ Here is the call graph for this function:

◆ importFromPost()

ilADTLocationSearchBridgeSingle::importFromPost ( array  $a_post = null)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 77 of file class.ilADTLocationSearchBridgeSingle.php.

78 {
79 $post = $this->extractPostValues($a_post);
80
81 if ($post && $this->shouldBeImportedFromPost($post)) {
82 $tgl = $this->getForm()->getItemByPostVar($this->addToElementId("tgl"));
83 $tgl->setChecked(true);
84
85 $item = $this->getForm()->getItemByPostVar($this->getElementId());
86 $item->setLongitude($post["longitude"]);
87 $item->setLatitude($post["latitude"]);
88 $item->setZoom($post["zoom"]);
89
90 $this->radius = (int) $post["rad"];
91
92 $this->getADT()->setLongitude($post["longitude"]);
93 $this->getADT()->setLatitude($post["latitude"]);
94 $this->getADT()->setZoom($post["zoom"]);
95 } else {
96 // optional empty is valid
97 $this->force_valid = true;
98
99 $this->getADT()->setLongitude(null);
100 $this->getADT()->setLatitude(null);
101 $this->getADT()->setZoom(null);
102 $this->radius = null;
103 }
104 }
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
extractPostValues(array $a_post=null)
Extract data from (post) values.
getElementId()
Get element id.

References ilADTSearchBridge\addToElementId(), ilADTSearchBridge\extractPostValues(), ilADTSearchBridgeSingle\getADT(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), and shouldBeImportedFromPost().

+ Here is the call graph for this function:

◆ isValid()

ilADTLocationSearchBridgeSingle::isValid ( )

Reimplemented from ilADTSearchBridgeSingle.

Definition at line 106 of file class.ilADTLocationSearchBridgeSingle.php.

107 {
108 return (parent::isValid() && ((int) $this->radius || (bool) $this->force_valid));
109 }

Referenced by getSerializedValue(), and getSQLCondition().

+ Here is the caller graph for this function:

◆ isValidADTDefinition()

ilADTLocationSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Check if given ADT definition is valid.

:TODO: This could be avoided with type-specifc constructors :TODO: bridge base class?

Parameters
ilADTDefinition$a_adt_def

Reimplemented from ilADTSearchBridge.

Definition at line 9 of file class.ilADTLocationSearchBridgeSingle.php.

10 {
11 return ($a_adt_def instanceof ilADTLocationDefinition);
12 }

◆ loadFilter()

ilADTLocationSearchBridgeSingle::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

Definition at line 17 of file class.ilADTLocationSearchBridgeSingle.php.

18 {
19 $value = $this->readFilter();
20 if ($value !== null) {
21 // :TODO:
22 }
23 }
readFilter()
Load value(s) from filter store (in session)

References ilADTSearchBridge\readFilter().

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTLocationSearchBridgeSingle::setSerializedValue (   $a_value)

Set current value(s) in serialized form (for easy persisting)

Parameters
string

Reimplemented from ilADTSearchBridge.

Definition at line 175 of file class.ilADTLocationSearchBridgeSingle.php.

176 {
177 $a_value = unserialize($a_value);
178 if (is_array($a_value)) {
179 $this->getADT()->setLatitude($a_value["lat"]);
180 $this->getADT()->setLongitude($a_value["long"]);
181 $this->getADT()->setZoom($a_value["zoom"]);
182 $this->radius = (int) $a_value["radius"];
183 }
184 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTLocationSearchBridgeSingle::shouldBeImportedFromPost (   $a_post)
protected

Check if incoming values should be imported at all.

Parameters
mixed$a_post
Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 72 of file class.ilADTLocationSearchBridgeSingle.php.

73 {
74 return (bool) $a_post["tgl"];
75 }

Referenced by importFromPost().

+ Here is the caller graph for this function:

Field Documentation

◆ $radius

ilADTLocationSearchBridgeSingle::$radius
protected

Definition at line 7 of file class.ilADTLocationSearchBridgeSingle.php.


The documentation for this class was generated from the following file: