ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilADTFloatSearchBridgeSingle.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 ilADTFloatDefinition);
10 }
11
12
13 // table2gui / filter
14
15 public function loadFilter()
16 {
17 $value = $this->readFilter();
18 if($value !== null)
19 {
20 $this->getADT()->setNumber($value);
21 }
22 }
23
24
25 // form
26
27 public function addToForm()
28 {
29 $def = $this->getADT()->getCopyOfDefinition();
30
31 $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
32 $number->setSize(10);
33 $number->setDecimals($def->getDecimals());
34
35 $min = $def->getMin();
36 if($min !== null)
37 {
38 $number->setMinValue($min);
39 }
40
41 $max = $def->getMax();
42 if($max !== null)
43 {
44 $number->setMaxValue($max);
45
46 $length = strlen($max);
47 $number->setSize($length);
48 $number->setMaxLength($length);
49 }
50
51 $number->setValue($this->getADT()->getNumber());
52
53 $this->addToParentElement($number);
54 }
55
56 public function importFromPost(array $a_post = null)
57 {
58 $post = $this->extractPostValues($a_post);
59
60 if($post && $this->shouldBeImportedFromPost($post))
61 {
62 $item = $this->getForm()->getItemByPostVar($this->getElementId());
63 $item->setValue($post);
64
65 $this->getADT()->setNumber($post);
66 }
67 else
68 {
69 $this->getADT()->setNumber();
70 }
71 }
72
73
74 // db
75
76 public function getSQLCondition($a_element_id)
77 {
78 global $ilDB;
79
80 if(!$this->isNull() && $this->isValid())
81 {
82 return $a_element_id." = ".$ilDB->quote($this->getADT()->getNumber(), "float");
83 }
84 }
85
86 public function isInCondition(ilADT $a_adt)
87 {
88 assert($a_adt instanceof ilADTFloat);
89
90 return $this->getADT()->equals($a_adt);
91 }
92
93
94 // import/export
95
96 public function getSerializedValue()
97 {
98 if(!$this->isNull() && $this->isValid())
99 {
100 return serialize(array($this->getADT()->getNumber()));
101 }
102 }
103
104 public function setSerializedValue($a_value)
105 {
106 $a_value = unserialize($a_value);
107 if(is_array($a_value))
108 {
109 $this->getADT()->setNumber($a_value[0]);
110 }
111 }
112}
113
114?>
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
addToForm()
Add ADT-specific fields to form.
isValidADTDefinition(ilADTDefinition $a_adt_def)
Check if given ADT definition is valid.
importFromPost(array $a_post=null)
Import values from (search) form request POST data.
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
loadFilter()
Load filter value(s) into ADT.
isInCondition(ilADT $a_adt)
Compare directly against ADT.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
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 $ilDB