ILIAS  release_8 Revision v8.24
class.ilADTIntegerSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
23{
24 protected function isValidADTDefinition(ilADTDefinition $a_adt_def): bool
25 {
26 return ($a_adt_def instanceof ilADTIntegerDefinition);
27 }
28
29 // table2gui / filter
30
31 public function loadFilter(): void
32 {
33 $value = $this->readFilter();
34 if ($value !== null) {
35 $this->getADT()->setNumber($value);
36 }
37 }
38
39 // form
40
41 public function addToForm(): void
42 {
43 $def = $this->getADT()->getCopyOfDefinition();
44
45 $number = new ilNumberInputGUI($this->getTitle(), $this->getElementId());
46 $number->setSize(10);
47
48 $min = $def->getMin();
49 // do not set min value for search
50 if ($min !== null) {
51 //$number->setMinValue($min);
52 }
53 $max = $def->getMax();
54 // do not set min value for search
55 if ($max !== null) {
56 #$number->setMaxValue($max);
57 #$length = strlen((string) $max);
58 #$number->setSize($length);
59 #$number->setMaxLength($length);
60 }
61 $number->setValue((string) $this->getADT()->getNumber());
62 $this->addToParentElement($number);
63 }
64
65 public function importFromPost(array $a_post = null): bool
66 {
67 $post = $this->extractPostValues($a_post);
68
69 if ($post && $this->shouldBeImportedFromPost($post)) {
70 $item = $this->getForm()->getItemByPostVar($this->getElementId());
71 $item->setValue($post);
72 $this->getADT()->setNumber($post);
73 } else {
74 $this->getADT()->setNumber();
75 }
76 return true;
77 }
78
79 // db
80
81 public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE, array $quotedWords = []): string
82 {
83 if (!$this->isNull() && $this->isValid()) {
84 return $a_element_id . " = " . $this->db->quote($this->getADT()->getNumber(), "integer");
85 }
86 return '';
87 }
88
89 public function isInCondition(ilADT $a_adt): bool
90 {
91 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
92 return $this->getADT()->equals($a_adt);
93 }
94 return false;
95 }
96
97 // import/export
98
99 public function getSerializedValue(): string
100 {
101 if (!$this->isNull() && $this->isValid()) {
102 return serialize(array($this->getADT()->getNumber()));
103 }
104 return '';
105 }
106
107 public function setSerializedValue(string $a_value): void
108 {
109 $a_value = unserialize($a_value);
110 if (is_array($a_value)) {
111 $this->getADT()->setNumber($a_value[0]);
112 }
113 }
114}
ADT definition base class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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:12
This class represents a number property in a property form.
$post
Definition: ltitoken.php:49