ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilADTLocationSearchBridgeSingle Class Reference
+ Inheritance diagram for ilADTLocationSearchBridgeSingle:
+ Collaboration diagram for ilADTLocationSearchBridgeSingle:

Public Member Functions

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

Protected Member Functions

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

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

ilADTLocationSearchBridgeSingle::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Definition at line 30 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().

{
global $lng;
$adt = $this->getADT();
$default = false;
if($adt->isNull())
{
// see ilPersonalProfileGUI::addLocationToForm()
// use installation default
include_once("./Services/Maps/classes/class.ilMapUtil.php");
$adt->setLatitude($def["latitude"]);
$adt->setLongitude($def["longitude"]);
$adt->setZoom($def["zoom"]);
$default = true;
}
$optional = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl"));
if(!$default && !$adt->isNull())
{
$optional->setChecked(true);
}
$loc = new ilLocationInputGUI($lng->txt("location"), $this->getElementId());
$loc->setLongitude($adt->getLongitude());
$loc->setLatitude($adt->getLatitude());
$loc->setZoom($adt->getZoom());
$optional->addSubItem($loc);
$rad = new ilNumberInputGUI($lng->txt("form_location_radius"), $this->addToElementId("rad"));
$rad->setSize(4);
$rad->setSuffix($lng->txt("form_location_radius_km"));
$rad->setValue($this->radius);
$rad->setRequired(true);
$optional->addSubItem($rad);
$this->addToParentElement($optional);
}

+ Here is the call graph for this function:

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 124 of file class.ilADTLocationSearchBridgeSingle.php.

Referenced by getSQLCondition().

{
$earth_radius = 6371;
// http://www.d-mueller.de/blog/umkreissuche-latlong-und-der-radius/
$max_lat = $a_latitude + rad2deg($a_radius/$earth_radius);
$min_lat = $a_latitude - rad2deg($a_radius/$earth_radius);
$max_long = $a_longitude + rad2deg($a_radius/$earth_radius/cos(deg2rad($a_latitude)));
$min_long = $a_longitude - rad2deg($a_radius/$earth_radius/cos(deg2rad($a_latitude)));
return array(
"lat" => array("min"=>$min_lat, "max"=>$max_lat)
,"long" => array("min"=>$min_long, "max"=>$max_long)
);
}

+ Here is the caller graph for this function:

ilADTLocationSearchBridgeSingle::getSerializedValue ( )

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

Returns
string

Reimplemented from ilADTSearchBridge.

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

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

{
if(!$this->isNull() && $this->isValid())
{
return serialize(array(
"lat" => $this->getADT()->getLatitude()
,"long" => $this->getADT()->getLongitude()
,"radius" => (int)$this->radius
));
}
}

+ Here is the call graph for this function:

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 143 of file class.ilADTLocationSearchBridgeSingle.php.

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

{
global $ilDB;
if(!$this->isNull() && $this->isValid())
{
$box = $this->getBoundingBox($this->getADT()->getLatitude(), $this->getADT()->getLongitude(), $this->radius);
$res = array();
$res[] = $a_element_id."_lat >= ".$ilDB->quote($box["lat"]["min"], "float");
$res[] = $a_element_id."_lat <= ".$ilDB->quote($box["lat"]["max"], "float");
$res[] = $a_element_id."_long >= ".$ilDB->quote($box["long"]["min"], "float");
$res[] = $a_element_id."_long <= ".$ilDB->quote($box["long"]["max"], "float");
return "(".implode(" AND ", $res).")";
}
}

+ Here is the call graph for this function:

ilADTLocationSearchBridgeSingle::importFromPost ( array  $a_post = null)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

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

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

{
$post = $this->extractPostValues($a_post);
if($post && $this->shouldBeImportedFromPost($post))
{
$item = $this->getForm()->getItemByPostVar($this->getElementId());
$item->setLongitude($post["longitude"]);
$item->setLatitude($post["latitude"]);
$item->setZoom($post["zoom"]);
$this->radius = (int)$post["rad"];
$this->getADT()->setLongitude($post["longitude"]);
$this->getADT()->setLatitude($post["latitude"]);
$this->getADT()->setZoom($post["zoom"]);
}
else
{
// optional empty is valid
$this->force_valid = true;
$this->getADT()->setLongitude(null);
$this->getADT()->setLatitude(null);
$this->getADT()->setZoom(null);
$this->radius = null;
}
}

+ Here is the call graph for this function:

ilADTLocationSearchBridgeSingle::isValid ( )

Reimplemented from ilADTSearchBridgeSingle.

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

Referenced by getSerializedValue(), and getSQLCondition().

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

+ Here is the caller graph for this function:

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.

{
return ($a_adt_def instanceof ilADTLocationDefinition);
}
ilADTLocationSearchBridgeSingle::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

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

References ilADTSearchBridge\readFilter().

{
$value = $this->readFilter();
if($value !== null)
{
// :TODO:
// $this->getADT()->setDate(new ilDateTime($value, IL_CAL_DATETIME));
}
}

+ Here is the call graph for this function:

ilADTLocationSearchBridgeSingle::setSerializedValue (   $a_value)

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

Parameters
string

Reimplemented from ilADTSearchBridge.

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

References ilADTSearchBridgeSingle\getADT().

{
$a_value = unserialize($a_value);
if(is_array($a_value))
{
$this->getADT()->setLatitude($a_value["lat"]);
$this->getADT()->setLongitude($a_value["long"]);
$this->radius = (int)$a_value["radius"];
}
}

+ Here is the call graph for this function:

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 74 of file class.ilADTLocationSearchBridgeSingle.php.

Referenced by importFromPost().

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

+ Here is the caller graph for this function:

Field Documentation

ilADTLocationSearchBridgeSingle::$radius
protected

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


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