ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  {
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(ilADTFloat $a_adt)
87  {
88  return $this->getADT()->equals($a_adt);
89  }
90 
91 
92  // import/export
93 
94  public function getSerializedValue()
95  {
96  if(!$this->isNull() && $this->isValid())
97  {
98  return serialize(array($this->getADT()->getNumber()));
99  }
100  }
101 
102  public function setSerializedValue($a_value)
103  {
104  $a_value = unserialize($a_value);
105  if(is_array($a_value))
106  {
107  $this->getADT()->setNumber($a_value[0]);
108  }
109  }
110 }
111 
112 ?>
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.
global $ilDB
ADT definition base class.
getElementId()
Get element id.
isValidADTDefinition(ilADTDefinition $a_adt_def)
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.