ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilADTIntegerSearchBridgeSingle.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 ilADTIntegerDefinition);
10 }
11
12
13 // form
14
15 public function addToForm()
16 {
17 $def = $this->getADT()->getCopyOfDefinition();
18
19 $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
20 $number->setSize(10);
21
22 $min = $def->getMin();
23 if($min !== null)
24 {
25 $number->setMinValue($min);
26 }
27
28 $max = $def->getMax();
29 if($max !== null)
30 {
31 $number->setMaxValue($max);
32
33 $length = strlen($max);
34 $number->setSize($length);
35 $number->setMaxLength($length);
36 }
37
38 $this->addToParentElement($number);
39 }
40
41 public function importFromPost(array $a_post = null)
42 {
43 $post = $this->extractPostValues($a_post);
44
45 if($post && $this->shouldBeImportedFromPost($post))
46 {
47 $item = $this->getForm()->getItemByPostVar($this->getElementId());
48 $item->setValue($post);
49
50 $this->getADT()->setNumber($post);
51 }
52 else
53 {
54 $this->getADT()->setNumber();
55 }
56 }
57
58
59 // db
60
61 public function getSQLCondition($a_element_id)
62 {
63 global $ilDB;
64
65 if(!$this->isNull() && $this->isValid())
66 {
67 return $a_element_id." = ".$ilDB->quote($this->getADT()->getNumber(), "integer");
68 }
69 }
70
71 public function isInCondition(ilADTInteger $a_adt)
72 {
73 return $this->getADT()->equals($a_adt);
74 }
75
76
77 // import/export
78
79 public function getSerializedValue()
80 {
81 if(!$this->isNull() && $this->isValid())
82 {
83 return serialize(array($this->getADT()->getNumber()));
84 }
85 }
86
87 public function setSerializedValue($a_value)
88 {
89 $a_value = unserialize($a_value);
90 if(is_array($a_value))
91 {
92 $this->getLowerADT()->setNumber($a_value[0]);
93 }
94 }
95}
96
97?>
ADT definition base class.
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
isValidADTDefinition(ilADTDefinition $a_adt_def)
Check if given ADT definition is valid.
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
importFromPost(array $a_post=null)
Import values from (search) form request POST data.
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.
This class represents a number property in a property form.
global $ilDB