ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTLocationSearchBridgeSingle Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilADTLocationSearchBridgeSingle:
+ Collaboration diagram for ilADTLocationSearchBridgeSingle:

Public Member Functions

 __construct (ilADTDefinition $a_adt_def)
 
 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 isValid ()
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 
 getSerializedValue ()
 
 setSerializedValue (string $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)
 
 isNull ()
 
 setForm (ilPropertyFormGUI $a_form)
 
 getForm ()
 
 setElementId (string $a_value)
 
 getElementId ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 getSearchColumn ()
 
 setTableGUI (ilTable2GUI $a_table)
 
 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)
 
 validate ()
 Validate current data. More...
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 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 (string $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 (float $a_latitude, float $a_longitude, int $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)
 
 setDefinition (ilADTDefinition $a_adt_def)
 
 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 (string $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

int $radius = null
 
bool $force_valid = false
 
ilLanguage $lng
 
- Protected Attributes inherited from ilADTSearchBridgeSingle
ilADT $adt
 
- Protected Attributes inherited from ilADTSearchBridge
ilPropertyFormGUI $form = null
 
ilTable2GUI $table_gui = null
 
array $table_filter_fields = []
 
string $id = ''
 
string $title = ''
 
string $info = ''
 
ilLanguage $lng
 
ilDBInterface $db
 
HttpServices $http
 

Additional Inherited Members

- Data Fields inherited from ilADTSearchBridge
const SQL_STRICT = 1
 
const SQL_LIKE = 2
 
const SQL_LIKE_END = 3
 
const SQL_LIKE_START = 4
 
const DEFAULT_SEARCH_COLUMN = 'value'
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilADTLocationSearchBridgeSingle::__construct ( ilADTDefinition  $a_adt_def)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\lng().

32  {
33  global $DIC;
34 
35  $this->lng = $DIC->language();
36  parent::__construct($a_adt_def);
37  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addToForm()

ilADTLocationSearchBridgeSingle::addToForm ( )

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

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

56  : void
57  {
58  $adt = $this->getADT();
59 
60  $default = false;
61  if ($adt->isNull()) {
62  // see ilPersonalProfileGUI::addLocationToForm()
63 
64  // use installation default
66  $adt->setLatitude((float) ($def["latitude"] ?? null));
67  $adt->setLongitude((float) ($def["longitude"] ?? null));
68  $adt->setZoom((int) ($def["zoom"] ?? 0));
69 
70  $default = true;
71  }
72 
73  $optional = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl"));
74 
75  if (!$default && !$adt->isNull()) {
76  $optional->setChecked(true);
77  }
78 
79  $loc = new ilLocationInputGUI($this->lng->txt("location"), $this->getElementId());
80  $loc->setLongitude($adt->getLongitude());
81  $loc->setLatitude($adt->getLatitude());
82  $loc->setZoom($adt->getZoom());
83  $optional->addSubItem($loc);
84 
85  $rad = new ilNumberInputGUI($this->lng->txt("form_location_radius"), $this->addToElementId("rad"));
86  $rad->setSize(4);
87  $rad->setSuffix($this->lng->txt("form_location_radius_km"));
88  $rad->setValue($this->radius);
89  $rad->setRequired(true);
90  $optional->addSubItem($rad);
91 
92  $this->addToParentElement($optional);
93  }
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.
isNull()
Is currently null.
addToElementId(string $a_add)
Add sub-element.
setLongitude(?float $a_longitude)
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
+ Here is the call graph for this function:

◆ getBoundingBox()

ilADTLocationSearchBridgeSingle::getBoundingBox ( float  $a_latitude,
float  $a_longitude,
int  $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 145 of file class.ilADTLocationSearchBridgeSingle.php.

Referenced by getSQLCondition().

145  : array
146  {
147  $earth_radius = 6371;
148 
149  // http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/
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)));
154 
155  return array(
156  "lat" => array("min" => $min_lat, "max" => $max_lat)
157  ,
158  "long" => array("min" => $min_long, "max" => $max_long)
159  );
160  }
+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTLocationSearchBridgeSingle::getSerializedValue ( )

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

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

186  : string
187  {
188  if (!$this->isNull() && $this->isValid()) {
189  return serialize(array(
190  "lat" => $this->getADT()->getLatitude()
191  ,
192  "long" => $this->getADT()->getLongitude()
193  ,
194  "zoom" => $this->getADT()->getZoom()
195  ,
196  "radius" => (int) $this->radius
197  ));
198  }
199  return '';
200  }
+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTLocationSearchBridgeSingle::getSQLCondition ( string  $a_element_id,
int  $mode = self::SQL_LIKE,
array  $quotedWords = [] 
)

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

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

164  : string
165  {
166  if (!$this->isNull() && $this->isValid()) {
167  $box = $this->getBoundingBox(
168  $this->getADT()->getLatitude(),
169  $this->getADT()->getLongitude(),
170  $this->radius
171  );
172 
173  $res = [];
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");
178 
179  return "(" . implode(" AND ", $res) . ")";
180  }
181  return '';
182  }
$res
Definition: ltiservices.php:69
getBoundingBox(float $a_latitude, float $a_longitude, int $a_radius)
Get bounding box for location circum search.
+ Here is the call graph for this function:

◆ importFromPost()

ilADTLocationSearchBridgeSingle::importFromPost ( array  $a_post = null)

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

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

100  : bool
101  {
102  $post = $this->extractPostValues($a_post);
103 
104  if ($post && $this->shouldBeImportedFromPost($post)) {
105  $tgl = $this->getForm()->getItemByPostVar($this->addToElementId("tgl"));
106  $tgl->setChecked(true);
107 
108  $item = $this->getForm()->getItemByPostVar($this->getElementId());
109  $item->setLongitude($post["longitude"]);
110  $item->setLatitude($post["latitude"]);
111  $item->setZoom($post["zoom"]);
112 
113  $this->radius = (int) $post["rad"];
114 
115  $this->getADT()->setLongitude($post["longitude"]);
116  $this->getADT()->setLatitude($post["latitude"]);
117  $this->getADT()->setZoom($post["zoom"]);
118  } else {
119  // optional empty is valid
120  $this->force_valid = true;
121 
122  $this->getADT()->setLongitude(null);
123  $this->getADT()->setLatitude(null);
124  $this->getADT()->setZoom(null);
125  $this->radius = null;
126  }
127  return true;
128  }
extractPostValues(array $a_post=null)
Extract data from (post) values.
addToElementId(string $a_add)
Add sub-element.
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:

◆ isValid()

ilADTLocationSearchBridgeSingle::isValid ( )

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

Referenced by getSerializedValue(), and getSQLCondition().

130  : bool
131  {
132  return (parent::isValid() && ((int) $this->radius || $this->force_valid));
133  }
+ Here is the caller graph for this function:

◆ isValidADTDefinition()

ilADTLocationSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

39  : bool
40  {
41  return ($a_adt_def instanceof ilADTLocationDefinition);
42  }

◆ loadFilter()

ilADTLocationSearchBridgeSingle::loadFilter ( )

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

References ilADTSearchBridge\readFilter().

46  : void
47  {
48  $value = $this->readFilter();
49  if ($value !== null) {
50  // :TODO:
51  }
52  }
readFilter()
Load value(s) from filter store (in session)
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTLocationSearchBridgeSingle::setSerializedValue ( string  $a_value)

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

References ilADTSearchBridgeSingle\getADT(), and ILIAS\Repository\int().

202  : void
203  {
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"];
210  }
211  }
+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTLocationSearchBridgeSingle::shouldBeImportedFromPost (   $a_post)
protected

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

Referenced by importFromPost().

95  : bool
96  {
97  return (bool) ($a_post["tgl"] ?? false);
98  }
+ Here is the caller graph for this function:

Field Documentation

◆ $force_valid

bool ilADTLocationSearchBridgeSingle::$force_valid = false
protected

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

◆ $lng

ilLanguage ilADTLocationSearchBridgeSingle::$lng
protected

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

◆ $radius

int ilADTLocationSearchBridgeSingle::$radius = null
protected

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


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