ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTFloatSearchBridgeSingle.php
Go to the documentation of this file.
1 <?php
2 
3 require_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 $DIC;
73 
74  $ilDB = $DIC['ilDB'];
75 
76  if (!$this->isNull() && $this->isValid()) {
77  return $a_element_id . " = " . $ilDB->quote($this->getADT()->getNumber(), "float");
78  }
79  }
80 
81  public function isInCondition(ilADT $a_adt)
82  {
83  assert($a_adt instanceof ilADTFloat);
84 
85  return $this->getADT()->equals($a_adt);
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 }
global $DIC
Definition: saml.php:7
ADT base class.
Definition: class.ilADT.php:11
extractPostValues(array $a_post=null)
Extract data from (post) values.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
readFilter()
Load value(s) from filter store (in session)
This class represents a number property in a property form.
$post
Definition: post.php:34
global $ilDB
$def
Definition: croninfo.php:21
ADT definition base class.
getElementId()
Get element id.
isValidADTDefinition(ilADTDefinition $a_adt_def)
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.