ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
20 $this->getADT()->setSelection($value);
21 }
22 }
23
24
25 // form
26
27 public function addToForm()
28 {
29 global $lng;
30
31 $def = $this->getADT()->getCopyOfDefinition();
32
33 $options = $def->getOptions();
34 asort($options); // ?
35
36 $lng->loadLanguageModule("search");
37 $options = array("" => $lng->txt("search_any")) + $options;
38
39 $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
40 $select->setOptions($options);
41
42 $select->setValue($this->getADT()->getSelection());
43
44 $this->addToParentElement($select);
45 }
46
47 public function importFromPost(array $a_post = null)
48 {
49 $post = $this->extractPostValues($a_post);
50
51 if($post && $this->shouldBeImportedFromPost($post))
52 {
53 if($this->getForm() instanceof ilPropertyFormGUI)
54 {
55 $item = $this->getForm()->getItemByPostVar($this->getElementId());
56 $item->setValue($post);
57 }
58 else if(array_key_exists($this->getElementId(), $this->table_filter_fields))
59 {
60 $this->table_filter_fields[$this->getElementId()]->setValue($post);
61 $this->writeFilter($post);
62 }
63
64 $this->getADT()->setSelection($post);
65 }
66 else
67 {
68 $this->writeFilter();
69 $this->getADT()->setSelection();
70 }
71 }
72
73
74 // db
75
76 public function getSQLCondition($a_element_id)
77 {
78 global $ilDB;
79
80 if(!$this->isNull() && $this->isValid())
81 {
82 $type = ($this->getADT() instanceof ilADTEnumText)
83 ? "text"
84 : "integer";
85
86 return $a_element_id." = ".$ilDB->quote($this->getADT()->getSelection(), $type);
87 }
88 }
89
90 public function isInCondition(ilADTEnum $a_adt)
91 {
92 return $this->getADT()->equals($a_adt);
93 }
94
95
96 // import/export
97
98 public function getSerializedValue()
99 {
100 if(!$this->isNull() && $this->isValid())
101 {
102 return serialize(array($this->getADT()->getSelection()));
103 }
104 }
105
106 public function setSerializedValue($a_value)
107 {
108 $a_value = unserialize($a_value);
109 if(is_array($a_value))
110 {
111 $this->getADT()->setSelection($a_value[0]);
112 }
113 }
114}
115
116?>
ADT definition base class.
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)
This class represents a property form user interface.
This class represents a selection list property in a property form.
global $lng
Definition: privfeed.php:40
global $ilDB
if(!is_array($argv)) $options