ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilADTEnumSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3require_once "Services/ADT/classes/Bridges/class.ilADTSearchBridgeSingle.php";
4
6{
7 const ENUM_SEARCH_COLUMN = 'value_index';
8
9 protected function isValidADTDefinition(ilADTDefinition $a_adt_def)
10 {
11 return ($a_adt_def instanceof ilADTEnumDefinition);
12 }
13
14
15 // table2gui / filter
16
17 public function loadFilter()
18 {
19 $value = $this->readFilter();
20 if ($value !== null) {
21 $this->getADT()->setSelection($value);
22 }
23 }
24
25 public function getSearchColumn() : string
26 {
28 }
29
30 // form
31
32 public function addToForm()
33 {
34 global $DIC;
35
36 $lng = $DIC['lng'];
37
38 $def = $this->getADT()->getCopyOfDefinition();
39
40 $options = $def->getOptions();
41 asort($options); // ?
42
43 $lng->loadLanguageModule("search");
44 $options = array("" => $lng->txt("search_any")) + $options;
45
46 $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
47 $select->setOptions($options);
48
49 $select->setValue($this->getADT()->getSelection());
50
51 $this->addToParentElement($select);
52 }
53
54 public function importFromPost(array $a_post = null)
55 {
56 $post = $this->extractPostValues($a_post);
57 if (
58 is_numeric($post) &&
59 $this->shouldBeImportedFromPost($post)
60 ) {
61 if ($this->getForm() instanceof ilPropertyFormGUI) {
62 $item = $this->getForm()->getItemByPostVar($this->getElementId());
63 $item->setValue($post);
64 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
65 $this->table_filter_fields[$this->getElementId()]->setValue($post);
66 $this->writeFilter($post);
67 }
68
69 $this->getADT()->setSelection($post);
70 } else {
71 $this->writeFilter();
72 $this->getADT()->setSelection();
73 }
74 }
75
76
77 // db
78
79 public function getSQLCondition($a_element_id)
80 {
81 global $DIC;
82
83 $ilDB = $DIC['ilDB'];
84
85 $search_column = $this->getSearchColumn();
86 if (!$this->isNull() && $this->isValid()) {
87 return $search_column . ' = ' . $ilDB->quote($this->getADT()->getSelection(), ilDBConstants::T_TEXT);
88 }
89 return '';
90 }
91
92 public function isInCondition(ilADT $a_adt)
93 {
94 assert($a_adt instanceof ilADTEnum);
95
96 return $this->getADT()->equals($a_adt);
97 }
98
99
100 // import/export
101
102 public function getSerializedValue()
103 {
104 if (!$this->isNull() && $this->isValid()) {
105 return serialize(array($this->getADT()->getSelection()));
106 }
107 }
108
109 public function setSerializedValue($a_value)
110 {
111 $a_value = unserialize($a_value);
112 if (is_array($a_value)) {
113 $this->getADT()->setSelection($a_value[0]);
114 }
115 }
116}
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
isInCondition(ilADT $a_adt)
Compare directly against ADT.
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
addToForm()
Add ADT-specific fields to form.
isValidADTDefinition(ilADTDefinition $a_adt_def)
Check if given ADT definition is valid.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
importFromPost(array $a_post=null)
Import values from (search) form request POST data.
loadFilter()
Load filter value(s) into ADT.
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.
getElementId()
Get element id.
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.
global $DIC
Definition: goto.php:24
$lng
global $ilDB