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

Public Member Functions

 setTextInputMode ($a_value)
 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.
 getSQLCondition ($a_element_id)
 Get SQL condition for current value(s)
 isInCondition (ilADTDateTime $a_adt)
 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 ilADTSearchBridgeRange
 getLowerADT ()
 Get lower ADT.
 getUpperADT ()
 Get lower ADT.
 isNull ()
 Is null ?
 isValid ()
 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 (array $a_post)
- Protected Member Functions inherited from ilADTSearchBridgeRange
 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.
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all.
 extractPostValues (array $a_post=null)
 Extract data from (post) values.

Protected Attributes

 $text_input
- Protected Attributes inherited from ilADTSearchBridgeRange
 $adt_lower
 $adt_upper
- Protected Attributes inherited from ilADTSearchBridge
 $form
 $table_gui
 $table_filter_fields
 $id
 $title
 $info

Detailed Description

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

Member Function Documentation

ilADTDateTimeSearchBridgeRange::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Definition at line 41 of file class.ilADTDateTimeSearchBridgeRange.php.

References $lng, ilADTSearchBridge\addToElementId(), ilADTSearchBridge\addToParentElement(), ilCombinationInputGUI\COMPARISON_ASCENDING, ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridge\getTitle(), ilADTSearchBridgeRange\getUpperADT(), ilADTSearchBridgeRange\isNull(), ilDateTimeInputGUI\MODE_INPUT, and ilDateTimeInputGUI\setShowTime().

{
global $lng;
if($this->getForm() instanceof ilPropertyFormGUI)
{
// :TODO: use DateDurationInputGUI ?!
if(!(bool)$this->text_input)
{
$check = new ilCheckboxInputGUI($this->getTitle(), $this->addToElementId("tgl"));
$check->setValue(1);
$checked = false;
}
else
{
$check = new ilCustomInputGUI($this->getTitle());
}
$date_from = new ilDateTimeInputGUI($lng->txt('from'), $this->addToElementId("lower"));
$date_from->setShowTime(true);
$check->addSubItem($date_from);
if($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull())
{
$date_from->setDate($this->getLowerADT()->getDate());
$checked = true;
}
$date_until = new ilDateTimeInputGUI($lng->txt('until'), $this->addToElementId("upper"));
$date_until->setShowTime(true);
$check->addSubItem($date_until);
if($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull())
{
$date_until->setDate($this->getUpperADT()->getDate());
$checked = true;
}
if(!(bool)$this->text_input)
{
$check->setChecked($checked);
}
else
{
$date_from->setMode(ilDateTimeInputGUI::MODE_INPUT);
$date_until->setMode(ilDateTimeInputGUI::MODE_INPUT);
}
$this->addToParentElement($check);
}
else
{
// see ilTable2GUI::addFilterItemByMetaType()
include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
$item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
$lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
$lower->setShowTime(true);
$item->addCombinationItem("lower", $lower, $lng->txt("from"));
if($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull())
{
$lower->setDate($this->getLowerADT()->getDate());
}
$upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
$upper->setShowTime(true);
$item->addCombinationItem("upper", $upper, $lng->txt("to"));
if($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull())
{
$upper->setDate($this->getUpperADT()->getDate());
}
$this->addToParentElement($item);
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::getSerializedValue ( )

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

Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 256 of file class.ilADTDateTimeSearchBridgeRange.php.

References $res, ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, ilADTSearchBridgeRange\isNull(), and ilADTSearchBridgeRange\isValid().

{
if(!$this->isNull() && $this->isValid())
{
$res = array();
if(!$this->getLowerADT()->isNull())
{
$res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATETIME);
}
if(!$this->getUpperADT()->isNull())
{
$res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATETIME);
}
return serialize($res);
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::getSQLCondition (   $a_element_id)

Get SQL condition for current value(s)

Parameters
string$a_element_id
Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 218 of file class.ilADTDateTimeSearchBridgeRange.php.

References $ilDB, ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, ilADTSearchBridgeRange\isNull(), and ilADTSearchBridgeRange\isValid().

{
global $ilDB;
if(!$this->isNull() && $this->isValid())
{
$sql = array();
if(!$this->getLowerADT()->isNull())
{
$sql[] = $a_element_id." >= ".$ilDB->quote($this->getLowerADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
}
if(!$this->getUpperADT()->isNull())
{
$sql[] = $a_element_id." <= ".$ilDB->quote($this->getUpperADT()->getDate()->get(IL_CAL_DATETIME), "timestamp");
}
return "(".implode(" AND ", $sql).")";
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::importFromPost ( array  $a_post = null)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 134 of file class.ilADTDateTimeSearchBridgeRange.php.

References ilADTSearchBridge\extractPostValues(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), ilADTDateSearchUtil\handleSelectInputPost(), ilADTDateSearchUtil\handleTextInputPost(), IL_CAL_DATETIME, IL_CAL_UNIX, ilADTDateSearchUtil\MODE_DATETIME, shouldBeImportedFromPost(), and ilADTSearchBridge\writeFilter().

{
$post = $this->extractPostValues($a_post);
if($post && $this->shouldBeImportedFromPost($post))
{
include_once "Services/ADT/classes/class.ilADTDateSearchUtil.php";
if(!$this->getForm() instanceof ilPropertyFormGUI ||
(bool)$this->text_input)
{
}
else
{
// if checkInput() is called before, this will not work
}
if($start && $end && $start > $end)
{
$tmp = $start;
$start = $end;
$end = $tmp;
}
// :TODO: all dates are imported as valid
if($start)
{
$start = new ilDateTime($start, IL_CAL_UNIX);
}
if($end)
{
$end = new ilDateTime($end, IL_CAL_UNIX);
}
if($this->getForm() instanceof ilPropertyFormGUI)
{
$item = $this->getForm()->getItemByPostVar($this->getElementId()."[lower]");
$item->setDate($start);
$item = $this->getForm()->getItemByPostVar($this->getElementId()."[upper]");
$item->setDate($end);
if(!(bool)$this->text_input)
{
$item = $this->getForm()->getItemByPostVar($this->getElementId()."[tgl]");
$item->setChecked(true);
}
}
else if(array_key_exists($this->getElementId(), $this->table_filter_fields))
{
$this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
$this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
$this->writeFilter(array(
"lower" => (!$start || $start->isNull()) ? null: $start->get(IL_CAL_DATETIME),
"upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATETIME)
));
}
$this->getLowerADT()->setDate($start);
$this->getUpperADT()->setDate($end);
}
else
{
if($this->getForm() instanceof ilPropertyFormGUI &&
!(bool)$this->text_input)
{
$item = $this->getForm()->getItemByPostVar($this->getElementId()."[tgl]");
$item->setChecked(false);
}
$this->getLowerADT()->setDate();
$this->getUpperADT()->setDate();
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::isInCondition ( ilADTDateTime  $a_adt)

Definition at line 237 of file class.ilADTDateTimeSearchBridgeRange.php.

References ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), ilADT\isInbetweenOrEqual(), ilADT\isLargerOrEqual(), ilADTSearchBridgeRange\isNull(), and ilADT\isSmallerOrEqual().

{
if(!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull())
{
return $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
}
else if(!$this->getLowerADT()->isNull())
{
return $a_adt->isLargerOrEqual($this->getLowerADT());
}
else
{
return $a_adt->isSmallerOrEqual($this->getUpperADT());
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::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.ilADTDateTimeSearchBridgeRange.php.

{
return ($a_adt_def instanceof ilADTDateTimeDefinition);
}
ilADTDateTimeSearchBridgeRange::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

Definition at line 22 of file class.ilADTDateTimeSearchBridgeRange.php.

References ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATETIME, and ilADTSearchBridge\readFilter().

{
$value = $this->readFilter();
if($value !== null)
{
if($value["lower"])
{
$this->getLowerADT()->setDate(new ilDateTime($value["lower"], IL_CAL_DATETIME));
}
if($value["upper"])
{
$this->getUpperADT()->setDate(new ilDateTime($value["upper"], IL_CAL_DATETIME));
}
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::setSerializedValue (   $a_value)

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

Parameters
string

Reimplemented from ilADTSearchBridge.

Definition at line 273 of file class.ilADTDateTimeSearchBridgeRange.php.

References ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), and IL_CAL_DATETIME.

{
$a_value = unserialize($a_value);
if(is_array($a_value))
{
if(isset($a_value["lower"]))
{
$this->getLowerADT()->setDate(new ilDateTime($a_value["lower"], IL_CAL_DATETIME));
}
if(isset($a_value["upper"]))
{
$this->getUpperADT()->setDate(new ilDateTime($a_value["upper"], IL_CAL_DATETIME));
}
}
}

+ Here is the call graph for this function:

ilADTDateTimeSearchBridgeRange::setTextInputMode (   $a_value)

Definition at line 14 of file class.ilADTDateTimeSearchBridgeRange.php.

{
$this->text_input = (bool)$a_value;
}
ilADTDateTimeSearchBridgeRange::shouldBeImportedFromPost ( array  $a_post)
protected

Definition at line 124 of file class.ilADTDateTimeSearchBridgeRange.php.

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

{
if($this->getForm() instanceof ilPropertyFormGUI &&
!(bool)$this->text_input)
{
return (bool)$a_post["tgl"];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilADTDateTimeSearchBridgeRange::$text_input
protected

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


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