ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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 $number->setDecimals($def->getDecimals());
33
34 $min = $def->getMin();
35 if ($min !== null) {
36 $number->setMinValue($min);
37 }
38
39 $max = $def->getMax();
40 if ($max !== null) {
41 $number->setMaxValue($max);
42
43 $length = strlen($max);
44 $number->setSize($length);
45 $number->setMaxLength($length);
46 }
47
48 $number->setValue($this->getADT()->getNumber());
49
50 $this->addToParentElement($number);
51 }
52
53 public function importFromPost(array $a_post = null)
54 {
55 $post = $this->extractPostValues($a_post);
56
57 if ($post && $this->shouldBeImportedFromPost($post)) {
58 $item = $this->getForm()->getItemByPostVar($this->getElementId());
59 $item->setValue($post);
60
61 $this->getADT()->setNumber($post);
62 } else {
63 $this->getADT()->setNumber();
64 }
65 }
66
67
68 // db
69
70 public function getSQLCondition($a_element_id)
71 {
72 global $ilDB;
73
74 if (!$this->isNull() && $this->isValid()) {
75 return $a_element_id . " = " . $ilDB->quote($this->getADT()->getNumber(), "float");
76 }
77 }
78
79 public function isInCondition(ilADT $a_adt)
80 {
81 assert($a_adt instanceof ilADTFloat);
82
83 return $this->getADT()->equals($a_adt);
84 }
85
86
87 // import/export
88
89 public function getSerializedValue()
90 {
91 if (!$this->isNull() && $this->isValid()) {
92 return serialize(array($this->getADT()->getNumber()));
93 }
94 }
95
96 public function setSerializedValue($a_value)
97 {
98 $a_value = unserialize($a_value);
99 if (is_array($a_value)) {
100 $this->getADT()->setNumber($a_value[0]);
101 }
102 }
103}
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.
$def
Definition: croninfo.php:21
$post
Definition: post.php:34
global $ilDB