ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilADTIntegerSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTSearchBridgeSingle.php";
4
6{
7 protected function isValidADTDefinition(ilADTDefinition $a_adt_def)
8 {
9 return ($a_adt_def instanceof ilADTIntegerDefinition);
10 }
11
12
13 // table2gui / filter
14
15 public function loadFilter()
16 {
17 $value = $this->readFilter();
18 if ($value !== null) {
19 $this->getADT()->setNumber($value);
20 }
21 }
22
23
24 // form
25
26 public function addToForm()
27 {
28 $def = $this->getADT()->getCopyOfDefinition();
29
30 $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
31 $number->setSize(10);
32
33 $min = $def->getMin();
34 if ($min !== null) {
35 $number->setMinValue($min);
36 }
37
38 $max = $def->getMax();
39 if ($max !== null) {
40 $number->setMaxValue($max);
41
42 $length = strlen($max);
43 $number->setSize($length);
44 $number->setMaxLength($length);
45 }
46
47 $number->setValue($this->getADT()->getNumber());
48
49 $this->addToParentElement($number);
50 }
51
52 public function importFromPost(array $a_post = null)
53 {
54 $post = $this->extractPostValues($a_post);
55
56 if ($post && $this->shouldBeImportedFromPost($post)) {
57 $item = $this->getForm()->getItemByPostVar($this->getElementId());
58 $item->setValue($post);
59
60 $this->getADT()->setNumber($post);
61 } else {
62 $this->getADT()->setNumber();
63 }
64 }
65
66
67 // db
68
69 public function getSQLCondition($a_element_id)
70 {
71 global $DIC;
72
73 $ilDB = $DIC['ilDB'];
74
75 if (!$this->isNull() && $this->isValid()) {
76 return $a_element_id . " = " . $ilDB->quote($this->getADT()->getNumber(), "integer");
77 }
78 }
79
80 public function isInCondition(ilADT $a_adt)
81 {
82 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
83 return $this->getADT()->equals($a_adt);
84 }
85 return false;
86 }
87
88
89 // import/export
90
91 public function getSerializedValue()
92 {
93 if (!$this->isNull() && $this->isValid()) {
94 return serialize(array($this->getADT()->getNumber()));
95 }
96 }
97
98 public function setSerializedValue($a_value)
99 {
100 $a_value = unserialize($a_value);
101 if (is_array($a_value)) {
102 $this->getADT()->setNumber($a_value[0]);
103 }
104 }
105}
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
isInCondition(ilADT $a_adt)
Compare directly against ADT.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
isValidADTDefinition(ilADTDefinition $a_adt_def)
Check if given ADT definition is valid.
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
importFromPost(array $a_post=null)
Import values from (search) form request POST data.
readFilter()
Load value(s) from filter store (in session)
extractPostValues(array $a_post=null)
Extract data from (post) values.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
ADT base class.
Definition: class.ilADT.php:12
This class represents a number property in a property form.
global $DIC
Definition: goto.php:24
global $ilDB