ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADTLocationSearchBridgeSingle Class Reference
+ Inheritance diagram for ilADTLocationSearchBridgeSingle:
+ Collaboration diagram for ilADTLocationSearchBridgeSingle:

Public Member Functions

 __construct (ilADTDefinition $a_adt_def)
 
 loadFilter ()
 Load filter value(s) into ADT. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 importFromPost (?array $a_post=null)
 
 isValid ()
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 Get SQL condition for current value(s) 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...
 
- Public Member Functions inherited from ilADTSearchBridgeSingle
 getADT ()
 Get ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- 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...
 
 addToFilterForm ()
 Add ADT-specific fields to filter. 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)
 Check if incoming values should be imported at all. More...
 
 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

Constructor & Destructor Documentation

◆ __construct()

ilADTLocationSearchBridgeSingle::__construct ( ilADTDefinition  $a_adt_def)

Reimplemented from ilADTSearchBridge.

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

32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 parent::__construct($a_adt_def);
37 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addToForm()

ilADTLocationSearchBridgeSingle::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

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

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 }
addToElementId(string $a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
isNull()
Is currently null.
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.

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

+ 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.

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 }

Referenced by getSQLCondition().

+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTLocationSearchBridgeSingle::getSerializedValue ( )

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

Reimplemented from ilADTSearchBridge.

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

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 }

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

+ Here is the call graph for this function:

◆ getSQLCondition()

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

Get SQL condition for current value(s)

Reimplemented from ilADTSearchBridge.

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

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 }
getBoundingBox(float $a_latitude, float $a_longitude, int $a_radius)
Get bounding box for location circum search.
$res
Definition: ltiservices.php:69

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

+ Here is the call graph for this function:

◆ importFromPost()

ilADTLocationSearchBridgeSingle::importFromPost ( ?array  $a_post = null)
Todo:
make post required

Reimplemented from ilADTSearchBridge.

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

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 }
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
extractPostValues(?array $a_post=null)
Extract data from (post) values.
$post
Definition: ltitoken.php:46

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

+ Here is the call graph for this function:

◆ isValid()

ilADTLocationSearchBridgeSingle::isValid ( )

Reimplemented from ilADTSearchBridgeSingle.

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

130 : bool
131 {
132 return (parent::isValid() && ((int) $this->radius || $this->force_valid));
133 }

Referenced by getSerializedValue(), and getSQLCondition().

+ Here is the caller graph for this function:

◆ isValidADTDefinition()

ilADTLocationSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Reimplemented from ilADTSearchBridge.

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

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

◆ loadFilter()

ilADTLocationSearchBridgeSingle::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

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

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

References ilADTSearchBridge\readFilter().

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTLocationSearchBridgeSingle::setSerializedValue ( string  $a_value)

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

Reimplemented from ilADTSearchBridge.

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

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 }

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

+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTLocationSearchBridgeSingle::shouldBeImportedFromPost (   $a_post)
protected

Check if incoming values should be imported at all.

Parameters
string | int$a_post
Returns
bool

Reimplemented from ilADTSearchBridge.

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

95 : bool
96 {
97 return (bool) ($a_post["tgl"] ?? false);
98 }

Referenced by importFromPost().

+ 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: