ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
ilADTLocationSearchBridgeSingle Class Reference
+ Inheritance diagram for ilADTLocationSearchBridgeSingle:
+ Collaboration diagram for ilADTLocationSearchBridgeSingle:

Public Member Functions

 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 isValid ()
 
 getSQLCondition ($a_element_id)
 
 getSerializedValue ()
 
 setSerializedValue ($a_value)
 
- Public Member Functions inherited from ilADTSearchBridgeSingle
 getADT ()
 Get ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 
- 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...
 
 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)
 
 shouldBeImportedFromPost ($a_post)
 
 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)
 
- 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
 

Detailed Description

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

Member Function Documentation

◆ addToForm()

ilADTLocationSearchBridgeSingle::addToForm ( )

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

References ilADTSearchBridgeSingle\$adt, $lng, ilADTSearchBridge\addToElementId(), ilADTSearchBridge\addToParentElement(), ilADTSearchBridgeSingle\getADT(), ilMapUtil\getDefaultSettings(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getTitle(), ilLocationInputGUI\setLongitude(), and ilNumberInputGUI\setSize().

30  {
31  global $lng;
32 
33  $adt = $this->getADT();
34 
35  $default = false;
36  if($adt->isNull())
37  {
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  {
54  $optional->setChecked(true);
55  }
56 
57  $loc = new ilLocationInputGUI($lng->txt("location"), $this->getElementId());
58  $loc->setLongitude($adt->getLongitude());
59  $loc->setLatitude($adt->getLatitude());
60  $loc->setZoom($adt->getZoom());
61  $optional->addSubItem($loc);
62 
63  $rad = new ilNumberInputGUI($lng->txt("form_location_radius"), $this->addToElementId("rad"));
64  $rad->setSize(4);
65  $rad->setSuffix($lng->txt("form_location_radius_km"));
66  $rad->setValue($this->radius);
67  $rad->setRequired(true);
68  $optional->addSubItem($rad);
69 
70  $this->addToParentElement($optional);
71  }
setLongitude($a_longitude)
Set Longitude.
This class represents a checkbox property in a property form.
This class represents a number property in a property form.
static getDefaultSettings()
Get default longitude, latitude and zoom.
This class represents a location property in a property form.
setSize($a_size)
Set Size.
global $lng
Definition: privfeed.php:17
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
addToElementId($a_add)
Add sub-element.
+ 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 126 of file class.ilADTLocationSearchBridgeSingle.php.

References array.

Referenced by getSQLCondition().

127  {
128  $earth_radius = 6371;
129 
130  // http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/
131  $max_lat = $a_latitude + rad2deg($a_radius/$earth_radius);
132  $min_lat = $a_latitude - rad2deg($a_radius/$earth_radius);
133  $max_long = $a_longitude + rad2deg($a_radius/$earth_radius/cos(deg2rad($a_latitude)));
134  $min_long = $a_longitude - rad2deg($a_radius/$earth_radius/cos(deg2rad($a_latitude)));
135 
136  return array(
137  "lat" => array("min"=>$min_lat, "max"=>$max_lat)
138  ,"long" => array("min"=>$min_long, "max"=>$max_long)
139  );
140  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTLocationSearchBridgeSingle::getSerializedValue ( )

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

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

167  {
168  if(!$this->isNull() && $this->isValid())
169  {
170  return serialize(array(
171  "lat" => $this->getADT()->getLatitude()
172  ,"long" => $this->getADT()->getLongitude()
173  ,"zoom" => $this->getADT()->getZoom()
174  ,"radius" => (int)$this->radius
175  ));
176  }
177  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTLocationSearchBridgeSingle::getSQLCondition (   $a_element_id)

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

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

146  {
147  global $ilDB;
148 
149  if(!$this->isNull() && $this->isValid())
150  {
151  $box = $this->getBoundingBox($this->getADT()->getLatitude(), $this->getADT()->getLongitude(), $this->radius);
152 
153  $res = array();
154  $res[] = $a_element_id."_lat >= ".$ilDB->quote($box["lat"]["min"], "float");
155  $res[] = $a_element_id."_lat <= ".$ilDB->quote($box["lat"]["max"], "float");
156  $res[] = $a_element_id."_long >= ".$ilDB->quote($box["long"]["min"], "float");
157  $res[] = $a_element_id."_long <= ".$ilDB->quote($box["long"]["max"], "float");
158 
159  return "(".implode(" AND ", $res).")";
160  }
161  }
Create styles array
The data for the language used.
getBoundingBox($a_latitude, $a_longitude, $a_radius)
Get bounding box for location circum search.
global $ilDB
+ Here is the call graph for this function:

◆ importFromPost()

ilADTLocationSearchBridgeSingle::importFromPost ( array  $a_post = null)

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

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

79  {
80  $post = $this->extractPostValues($a_post);
81 
82  if($post && $this->shouldBeImportedFromPost($post))
83  {
84  $tgl = $this->getForm()->getItemByPostVar($this->addToElementId("tgl"));
85  $tgl->setChecked(true);
86 
87  $item = $this->getForm()->getItemByPostVar($this->getElementId());
88  $item->setLongitude($post["longitude"]);
89  $item->setLatitude($post["latitude"]);
90  $item->setZoom($post["zoom"]);
91 
92  $this->radius = (int)$post["rad"];
93 
94  $this->getADT()->setLongitude($post["longitude"]);
95  $this->getADT()->setLatitude($post["latitude"]);
96  $this->getADT()->setZoom($post["zoom"]);
97  }
98  else
99  {
100  // optional empty is valid
101  $this->force_valid = true;
102 
103  $this->getADT()->setLongitude(null);
104  $this->getADT()->setLatitude(null);
105  $this->getADT()->setZoom(null);
106  $this->radius = null;
107  }
108  }
extractPostValues(array $a_post=null)
Extract data from (post) values.
getElementId()
Get element id.
addToElementId($a_add)
Add sub-element.
+ Here is the call graph for this function:

◆ isValid()

ilADTLocationSearchBridgeSingle::isValid ( )

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

Referenced by getSerializedValue(), and getSQLCondition().

111  {
112  return (parent::isValid() && ((int)$this->radius || (bool)$this->force_valid));
113  }
+ Here is the caller graph for this function:

◆ isValidADTDefinition()

ilADTLocationSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

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

◆ loadFilter()

ilADTLocationSearchBridgeSingle::loadFilter ( )

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

References ilADTSearchBridge\readFilter().

18  {
19  $value = $this->readFilter();
20  if($value !== null)
21  {
22  // :TODO:
23  }
24  }
readFilter()
Load value(s) from filter store (in session)
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTLocationSearchBridgeSingle::setSerializedValue (   $a_value)

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

References ilADTSearchBridgeSingle\getADT().

180  {
181  $a_value = unserialize($a_value);
182  if(is_array($a_value))
183  {
184  $this->getADT()->setLatitude($a_value["lat"]);
185  $this->getADT()->setLongitude($a_value["long"]);
186  $this->getADT()->setZoom($a_value["zoom"]);
187  $this->radius = (int)$a_value["radius"];
188  }
189  }
+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTLocationSearchBridgeSingle::shouldBeImportedFromPost (   $a_post)
protected

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

Referenced by importFromPost().

74  {
75  return (bool)$a_post["tgl"];
76  }
+ 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: