ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTIntegerSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected function isValidADTDefinition(ilADTDefinition $a_adt_def): bool
24 {
25 return ($a_adt_def instanceof ilADTIntegerDefinition);
26 }
27
28 // table2gui / filter
29
30 public function loadFilter(): void
31 {
32 $value = $this->readFilter();
33 if ($value !== null) {
34 $this->getADT()->setNumber($value);
35 }
36 }
37
38 // form
39
40 public function addToForm(): void
41 {
42 $def = $this->getADT()->getCopyOfDefinition();
43
44 $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
45 $number->setSize(10);
46
47 $min = $def->getMin();
48 // do not set min value for search
49 if ($min !== null) {
50 //$number->setMinValue($min);
51 }
52 $max = $def->getMax();
53 // do not set min value for search
54 if ($max !== null) {
55 #$number->setMaxValue($max);
56 #$length = strlen((string) $max);
57 #$number->setSize($length);
58 #$number->setMaxLength($length);
59 }
60 $number->setValue((string) $this->getADT()->getNumber());
61 $this->addToParentElement($number);
62 }
63
64 public function importFromPost(?array $a_post = null): bool
65 {
66 $post = $this->extractPostValues($a_post);
67
68 if ($post && $this->shouldBeImportedFromPost($post)) {
69 $item = $this->getForm()->getItemByPostVar($this->getElementId());
70 $item->setValue($post);
71 $this->getADT()->setNumber($post);
72 } else {
73 $this->getADT()->setNumber();
74 }
75 return true;
76 }
77
78 // db
79
80 public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE, array $quotedWords = []): string
81 {
82 if (!$this->isNull() && $this->isValid()) {
83 return $a_element_id . " = " . $this->db->quote($this->getADT()->getNumber(), "integer");
84 }
85 return '';
86 }
87
88 public function isInCondition(ilADT $a_adt): bool
89 {
90 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
91 return $this->getADT()->equals($a_adt);
92 }
93 return false;
94 }
95
96 // import/export
97
98 public function getSerializedValue(): string
99 {
100 if (!$this->isNull() && $this->isValid()) {
101 return serialize(array($this->getADT()->getNumber()));
102 }
103 return '';
104 }
105
106 public function setSerializedValue(string $a_value): void
107 {
108 $a_value = unserialize($a_value);
109 if (is_array($a_value)) {
110 $this->getADT()->setNumber($a_value[0]);
111 }
112 }
113}
ADT definition base class.
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
isInCondition(ilADT $a_adt)
Compare directly against ADT.
setSerializedValue(string $a_value)
Set current value(s) in serialized form (for easy persisting)
Class ilADTSearchBridgeSingle.
readFilter()
Load value(s) from filter store (in session)
extractPostValues(?array $a_post=null)
Extract data from (post) values.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
ADT base class.
Definition: class.ilADT.php:26
This class represents a number property in a property form.
$post
Definition: ltitoken.php:46