ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilADTIntegerSearchBridgeSingle.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 ilADTIntegerDefinition);
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 
34  $min = $def->getMin();
35  if($min !== null)
36  {
37  $number->setMinValue($min);
38  }
39 
40  $max = $def->getMax();
41  if($max !== null)
42  {
43  $number->setMaxValue($max);
44 
45  $length = strlen($max);
46  $number->setSize($length);
47  $number->setMaxLength($length);
48  }
49 
50  $number->setValue($this->getADT()->getNumber());
51 
52  $this->addToParentElement($number);
53  }
54 
55  public function importFromPost(array $a_post = null)
56  {
57  $post = $this->extractPostValues($a_post);
58 
59  if($post && $this->shouldBeImportedFromPost($post))
60  {
61  $item = $this->getForm()->getItemByPostVar($this->getElementId());
62  $item->setValue($post);
63 
64  $this->getADT()->setNumber($post);
65  }
66  else
67  {
68  $this->getADT()->setNumber();
69  }
70  }
71 
72 
73  // db
74 
75  public function getSQLCondition($a_element_id)
76  {
77  global $ilDB;
78 
79  if(!$this->isNull() && $this->isValid())
80  {
81  return $a_element_id." = ".$ilDB->quote($this->getADT()->getNumber(), "integer");
82  }
83  }
84 
85  public function isInCondition(ilADT $a_adt)
86  {
87  assert($a_adt instanceof ilADTInteger);
88 
89  return $this->getADT()->equals($a_adt);
90  }
91 
92 
93  // import/export
94 
95  public function getSerializedValue()
96  {
97  if(!$this->isNull() && $this->isValid())
98  {
99  return serialize(array($this->getADT()->getNumber()));
100  }
101  }
102 
103  public function setSerializedValue($a_value)
104  {
105  $a_value = unserialize($a_value);
106  if(is_array($a_value))
107  {
108  $this->getADT()->setNumber($a_value[0]);
109  }
110  }
111 }
112 
113 ?>
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.
Create styles array
The data for the language used.
global $ilDB
ADT definition base class.
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.