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