ILIAS  release_8 Revision v8.24
class.ilADTEnumSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6{
7 public const ENUM_SEARCH_COLUMN = 'value_index';
8
9 protected function isValidADTDefinition(ilADTDefinition $a_adt_def): bool
10 {
11 return ($a_adt_def instanceof ilADTEnumDefinition);
12 }
13
14 // table2gui / filter
15
16 public function loadFilter(): void
17 {
18 $value = $this->readFilter();
19 if ($value !== null) {
20 $this->getADT()->setSelection($value);
21 }
22 }
23
24 public function getSearchColumn(): string
25 {
27 }
28
29 // form
30
31 public function addToForm(): void
32 {
33 $def = $this->getADT()->getCopyOfDefinition();
34
35 $options = $def->getOptions();
36 asort($options); // ?
37
38 $this->lng->loadLanguageModule("search");
39 $options = array("" => $this->lng->txt("search_any")) + $options;
40
41 $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
42 $select->setOptions($options);
43
44 $select->setValue($this->getADT()->getSelection());
45
46 $this->addToParentElement($select);
47 }
48
49 public function importFromPost(array $a_post = null): bool
50 {
51 $post = $this->extractPostValues($a_post);
52 if (
53 is_numeric($post) &&
55 ) {
56 if ($this->getForm() instanceof ilPropertyFormGUI) {
57 $item = $this->getForm()->getItemByPostVar($this->getElementId());
58 $item->setValue($post);
59 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
60 $this->table_filter_fields[$this->getElementId()]->setValue($post);
61 $this->writeFilter($post);
62 }
63
64 $this->getADT()->setSelection($post);
65 } else {
66 $this->writeFilter();
67 $this->getADT()->setSelection();
68 }
69 return true;
70 }
71
72 // db
73
74 public function getSQLCondition(string $a_element_id, int $mode = self::SQL_LIKE, array $quotedWords = []): string
75 {
76 $search_column = $this->getSearchColumn();
77 if (!$this->isNull() && $this->isValid()) {
78 return $search_column . ' = ' . $this->db->quote($this->getADT()->getSelection(), ilDBConstants::T_TEXT);
79 }
80 return '';
81 }
82
83 public function isInCondition(ilADT $a_adt): bool
84 {
85 assert($a_adt instanceof ilADTEnum);
86
87 return $this->getADT()->equals($a_adt);
88 }
89
90 // import/export
91
92 public function getSerializedValue(): string
93 {
94 if (!$this->isNull() && $this->isValid()) {
95 return serialize(array($this->getADT()->getSelection()));
96 }
97 return '';
98 }
99
100 public function setSerializedValue(string $a_value): void
101 {
102 $a_value = unserialize($a_value);
103 if (is_array($a_value) && !empty($a_value)) {
104 $this->getADT()->setSelection($a_value[0]);
105 }
106 }
107}
ADT definition base class.
isInCondition(ilADT $a_adt)
Compare directly against ADT.
setSerializedValue(string $a_value)
Set current value(s) in serialized form (for easy persisting)
addToForm()
Add ADT-specific fields to form.
isValidADTDefinition(ilADTDefinition $a_adt_def)
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
loadFilter()
Load filter value(s) into ADT.
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.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
ADT base class.
Definition: class.ilADT.php:12
This class represents a property form user interface.
This class represents a selection list property in a property form.
$post
Definition: ltitoken.php:49