ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 28 of file class.ilADTLocationSearchBridgeSingle.php.

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

29  {
30  global $lng;
31 
32  $adt = $this->getADT();
33 
34  $default = false;
35  if ($adt->isNull()) {
36  // see ilPersonalProfileGUI::addLocationToForm()
37 
38  // use installation default
39  include_once("./Services/Maps/classes/class.ilMapUtil.php");
41  $adt->setLatitude($def["latitude"]);
42  $adt->setLongitude($def["longitude"]);
43  $adt->setZoom($def["zoom"]);
44 
45  $default = true;
46  }
47 
48  $optional = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl"));
49 
50  if (!$default && !$adt->isNull()) {
51  $optional->setChecked(true);
52  }
53 
54  $loc = new ilLocationInputGUI($lng->txt("location"), $this->getElementId());
55  $loc->setLongitude($adt->getLongitude());
56  $loc->setLatitude($adt->getLatitude());
57  $loc->setZoom($adt->getZoom());
58  $optional->addSubItem($loc);
59 
60  $rad = new ilNumberInputGUI($lng->txt("form_location_radius"), $this->addToElementId("rad"));
61  $rad->setSize(4);
62  $rad->setSuffix($lng->txt("form_location_radius_km"));
63  $rad->setValue($this->radius);
64  $rad->setRequired(true);
65  $optional->addSubItem($rad);
66 
67  $this->addToParentElement($optional);
68  }
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
$def
Definition: croninfo.php:21
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 120 of file class.ilADTLocationSearchBridgeSingle.php.

References array.

Referenced by getSQLCondition().

121  {
122  $earth_radius = 6371;
123 
124  // http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/
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)));
129 
130  return array(
131  "lat" => array("min"=>$min_lat, "max"=>$max_lat)
132  ,"long" => array("min"=>$min_long, "max"=>$max_long)
133  );
134  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTLocationSearchBridgeSingle::getSerializedValue ( )

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

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

160  {
161  if (!$this->isNull() && $this->isValid()) {
162  return serialize(array(
163  "lat" => $this->getADT()->getLatitude()
164  ,"long" => $this->getADT()->getLongitude()
165  ,"zoom" => $this->getADT()->getZoom()
166  ,"radius" => (int) $this->radius
167  ));
168  }
169  }
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 139 of file class.ilADTLocationSearchBridgeSingle.php.

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

140  {
141  global $ilDB;
142 
143  if (!$this->isNull() && $this->isValid()) {
144  $box = $this->getBoundingBox($this->getADT()->getLatitude(), $this->getADT()->getLongitude(), $this->radius);
145 
146  $res = array();
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");
151 
152  return "(" . implode(" AND ", $res) . ")";
153  }
154  }
foreach($_POST as $key=> $value) $res
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 75 of file class.ilADTLocationSearchBridgeSingle.php.

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

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

◆ isValid()

ilADTLocationSearchBridgeSingle::isValid ( )

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

Referenced by getSerializedValue(), and getSQLCondition().

105  {
106  return (parent::isValid() && ((int) $this->radius || (bool) $this->force_valid));
107  }
+ 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  // :TODO:
22  }
23  }
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 171 of file class.ilADTLocationSearchBridgeSingle.php.

References ilADTSearchBridgeSingle\getADT().

172  {
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"];
179  }
180  }
+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTLocationSearchBridgeSingle::shouldBeImportedFromPost (   $a_post)
protected

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

Referenced by importFromPost().

71  {
72  return (bool) $a_post["tgl"];
73  }
+ 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: