ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 protected function isValidADTDefinition(ilADTDefinition $a_adt_def)
8 {
9 return ($a_adt_def instanceof ilADTEnumDefinition);
10 }
11
12
13 // table2gui / filter
14
15 public function loadFilter()
16 {
17 $value = $this->readFilter();
18 if ($value !== null) {
19 $this->getADT()->setSelection($value);
20 }
21 }
22
23
24 // form
25
26 public function addToForm()
27 {
28 global $DIC;
29
30 $lng = $DIC['lng'];
31
32 $def = $this->getADT()->getCopyOfDefinition();
33
34 $options = $def->getOptions();
35 asort($options); // ?
36
37 $lng->loadLanguageModule("search");
38 $options = array("" => $lng->txt("search_any")) + $options;
39
40 $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
41 $select->setOptions($options);
42
43 $select->setValue($this->getADT()->getSelection());
44
45 $this->addToParentElement($select);
46 }
47
48 public function importFromPost(array $a_post = null)
49 {
50 $post = $this->extractPostValues($a_post);
51
52 if ($post && $this->shouldBeImportedFromPost($post)) {
53 if ($this->getForm() instanceof ilPropertyFormGUI) {
54 $item = $this->getForm()->getItemByPostVar($this->getElementId());
55 $item->setValue($post);
56 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
57 $this->table_filter_fields[$this->getElementId()]->setValue($post);
58 $this->writeFilter($post);
59 }
60
61 $this->getADT()->setSelection($post);
62 } else {
63 $this->writeFilter();
64 $this->getADT()->setSelection();
65 }
66 }
67
68
69 // db
70
71 public function getSQLCondition($a_element_id)
72 {
73 global $DIC;
74
75 $ilDB = $DIC['ilDB'];
76
77 if (!$this->isNull() && $this->isValid()) {
78 $type = ($this->getADT() instanceof ilADTEnumText)
79 ? "text"
80 : "integer";
81
82 return $a_element_id . " = " . $ilDB->quote($this->getADT()->getSelection(), $type);
83 }
84 }
85
86 public function isInCondition(ilADT $a_adt)
87 {
88 assert($a_adt instanceof ilADTEnum);
89
90 return $this->getADT()->equals($a_adt);
91 }
92
93
94 // import/export
95
96 public function getSerializedValue()
97 {
98 if (!$this->isNull() && $this->isValid()) {
99 return serialize(array($this->getADT()->getSelection()));
100 }
101 }
102
103 public function setSerializedValue($a_value)
104 {
105 $a_value = unserialize($a_value);
106 if (is_array($a_value)) {
107 $this->getADT()->setSelection($a_value[0]);
108 }
109 }
110}
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.
$type
$lng
global $ilDB
$DIC
Definition: xapitoken.php:46