ILIAS  release_7 Revision v7.30-3-g800a261c036
ilADTDateSearchBridgeRange Class Reference
+ Inheritance diagram for ilADTDateSearchBridgeRange:
+ Collaboration diagram for ilADTDateSearchBridgeRange:

Public Member Functions

 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...
 
 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...
 
- Public Member Functions inherited from ilADTSearchBridgeRange
 getLowerADT ()
 Get lower ADT. More...
 
 getUpperADT ()
 Get lower ADT. More...
 
 isNull ()
 Is null ? More...
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- 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...
 
 getSearchColumn ()
 
 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)
 Check if given ADT definition is valid. More...
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
- Protected Member Functions inherited from ilADTSearchBridgeRange
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
- 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...
 

Additional Inherited Members

- Data Fields inherited from ilADTSearchBridge
const DEFAULT_SEARCH_COLUMN = 'value'
 
- 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.ilADTDateSearchBridgeRange.php.

Member Function Documentation

◆ addToForm()

ilADTDateSearchBridgeRange::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

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

32 {
33 global $DIC;
34
35 $lng = $DIC['lng'];
36
37 if ($this->getForm() instanceof ilPropertyFormGUI) {
38 $check = new ilCustomInputGUI($this->getTitle());
39
40 $date_from = new ilDateTimeInputGUI($lng->txt('from'), $this->addToElementId("lower"));
41 $date_from->setShowTime(false);
42 $check->addSubItem($date_from);
43
44 if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
45 $date_from->setDate($this->getLowerADT()->getDate());
46 $checked = true;
47 }
48
49 $date_until = new ilDateTimeInputGUI($lng->txt('until'), $this->addToElementId("upper"));
50 $date_until->setShowTime(false);
51 $check->addSubItem($date_until);
52
53 if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
54 $date_until->setDate($this->getUpperADT()->getDate());
55 $checked = true;
56 }
57
58 $this->addToParentElement($check);
59 } else {
60 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
61 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
62
63 $item = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
64
65 $lower = new ilDateTimeInputGUI("", $this->addToElementId("lower"));
66 $item->addCombinationItem("lower", $lower, $lng->txt("from"));
67
68 if ($this->getLowerADT()->getDate() && !$this->getLowerADT()->isNull()) {
69 $lower->setDate($this->getLowerADT()->getDate());
70 }
71
72 $upper = new ilDateTimeInputGUI("", $this->addToElementId("upper"));
73 $item->addCombinationItem("upper", $upper, $lng->txt("to"));
74
75 if ($this->getUpperADT()->getDate() && !$this->getUpperADT()->isNull()) {
76 $upper->setDate($this->getUpperADT()->getDate());
77 }
78
79 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
80
81 $this->addToParentElement($item);
82 }
83 }
addToElementId($a_add)
Add sub-element.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
This class represents a number property in a property form.
This class represents a custom property in a property form.
This class represents a date/time property in a property form.
This class represents a property form user interface.
global $DIC
Definition: goto.php:24
$lng

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

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTDateSearchBridgeRange::getSerializedValue ( )

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

Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 169 of file class.ilADTDateSearchBridgeRange.php.

170 {
171 if (!$this->isNull() && $this->isValid()) {
172 $res = array();
173 if (!$this->getLowerADT()->isNull()) {
174 $res["lower"] = $this->getLowerADT()->getDate()->get(IL_CAL_DATE);
175 }
176 if (!$this->getUpperADT()->isNull()) {
177 $res["upper"] = $this->getUpperADT()->getDate()->get(IL_CAL_DATE);
178 }
179 return serialize($res);
180 }
181 }
const IL_CAL_DATE
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTDateSearchBridgeRange::getSQLCondition (   $a_element_id)

Get SQL condition for current value(s)

Parameters
string$a_element_id
Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 135 of file class.ilADTDateSearchBridgeRange.php.

136 {
137 global $DIC;
138
139 $ilDB = $DIC['ilDB'];
140
141 if (!$this->isNull() && $this->isValid()) {
142 $sql = array();
143 if (!$this->getLowerADT()->isNull()) {
144 $sql[] = $a_element_id . " >= " . $ilDB->quote($this->getLowerADT()->getDate()->get(IL_CAL_DATE), "date");
145 }
146 if (!$this->getUpperADT()->isNull()) {
147 $sql[] = $a_element_id . " <= " . $ilDB->quote($this->getUpperADT()->getDate()->get(IL_CAL_DATE), "date");
148 }
149 return "(" . implode(" AND ", $sql) . ")";
150 }
151 }
global $ilDB

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

+ Here is the call graph for this function:

◆ importFromPost()

ilADTDateSearchBridgeRange::importFromPost ( array  $a_post = null)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 94 of file class.ilADTDateSearchBridgeRange.php.

95 {
96 $post = $this->extractPostValues($a_post);
97
98 if ($post && $this->shouldBeImportedFromPost($post)) {
99 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
100 $start = ilCalendarUtil::parseIncomingDate($post["lower"]);
101 $end = ilCalendarUtil::parseIncomingDate($post["upper"]);
102
103 if ($start && $end && $start->get(IL_CAL_UNIX) > $end->get(IL_CAL_UNIX)) {
104 $tmp = $start;
105 $start = $end;
106 $end = $tmp;
107 }
108
109 if ($this->getForm() instanceof ilPropertyFormGUI) {
110 $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[lower]");
111 $item->setDate($start);
112
113 $item = $this->getForm()->getItemByPostVar($this->getElementId() . "[upper]");
114 $item->setDate($end);
115 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
116 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("lower")->setDate($start);
117 $this->table_filter_fields[$this->getElementId()]->getCombinationItem("upper")->setDate($end);
118 $this->writeFilter(array(
119 "lower" => (!$start || $start->isNull()) ? null: $start->get(IL_CAL_DATE),
120 "upper" => (!$end || $end->isNull()) ? null : $end->get(IL_CAL_DATE)
121 ));
122 }
123
124 $this->getLowerADT()->setDate($start);
125 $this->getUpperADT()->setDate($end);
126 } else {
127 $this->getLowerADT()->setDate();
128 $this->getUpperADT()->setDate();
129 }
130 }
const IL_CAL_UNIX
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
extractPostValues(array $a_post=null)
Extract data from (post) values.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.

References ilADTSearchBridge\extractPostValues(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridgeRange\getLowerADT(), ilADTSearchBridgeRange\getUpperADT(), IL_CAL_DATE, IL_CAL_UNIX, ilCalendarUtil\parseIncomingDate(), shouldBeImportedFromPost(), and ilADTSearchBridge\writeFilter().

+ Here is the call graph for this function:

◆ isInCondition()

ilADTDateSearchBridgeRange::isInCondition ( ilADT  $a_adt)

Compare directly against ADT.

Parameters
ilADT$a_adt
Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 153 of file class.ilADTDateSearchBridgeRange.php.

154 {
155 assert($a_adt instanceof ilADTDate);
156
157 if (!$this->getLowerADT()->isNull() && !$this->getUpperADT()->isNull()) {
158 return $a_adt->isInbetweenOrEqual($this->getLowerADT(), $this->getUpperADT());
159 } elseif (!$this->getLowerADT()->isNull()) {
160 return $a_adt->isLargerOrEqual($this->getLowerADT());
161 } else {
162 return $a_adt->isSmallerOrEqual($this->getUpperADT());
163 }
164 }
isSmallerOrEqual(ilADT $a_adt)
Check if given ADT is smaller or equal than self.
isLargerOrEqual(ilADT $a_adt)
Check if given ADT is larger or equal than self.
isInbetweenOrEqual(ilADT $a_adt_from, ilADT $a_adt_to)
Check if self is inbetween given ADTs (inclusive)

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

+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTDateSearchBridgeRange::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 7 of file class.ilADTDateSearchBridgeRange.php.

8 {
9 return ($a_adt_def instanceof ilADTDateDefinition);
10 }

◆ loadFilter()

ilADTDateSearchBridgeRange::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

Definition at line 15 of file class.ilADTDateSearchBridgeRange.php.

16 {
17 $value = $this->readFilter();
18 if ($value !== null) {
19 if ($value["lower"]) {
20 $this->getLowerADT()->setDate(new ilDate($value["lower"], IL_CAL_DATE));
21 }
22 if ($value["upper"]) {
23 $this->getUpperADT()->setDate(new ilDate($value["upper"], IL_CAL_DATE));
24 }
25 }
26 }
readFilter()
Load value(s) from filter store (in session)
Class for single dates.

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

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTDateSearchBridgeRange::setSerializedValue (   $a_value)

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

Parameters
string

Reimplemented from ilADTSearchBridge.

Definition at line 183 of file class.ilADTDateSearchBridgeRange.php.

184 {
185 $a_value = unserialize($a_value);
186 if (is_array($a_value)) {
187 if (isset($a_value["lower"])) {
188 $this->getLowerADT()->setDate(new ilDate($a_value["lower"], IL_CAL_DATE));
189 }
190 if (isset($a_value["upper"])) {
191 $this->getUpperADT()->setDate(new ilDate($a_value["upper"], IL_CAL_DATE));
192 }
193 }
194 }

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

+ Here is the call graph for this function:

◆ shouldBeImportedFromPost()

ilADTDateSearchBridgeRange::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 85 of file class.ilADTDateSearchBridgeRange.php.

86 {
87 if ($this->getForm() instanceof ilPropertyFormGUI &&
88 !(bool) $this->text_input) {
89 return (bool) $a_post["tgl"];
90 }
91 return parent::shouldBeImportedFromPost($a_post);
92 }

References ilADTSearchBridge\getForm().

Referenced by importFromPost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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