ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilADTEnumSearchBridgeSingle.php
Go to the documentation of this file.
1 <?php
2 
3 require_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(ilADT $a_adt)
91  {
92  assert($a_adt instanceof ilADTEnum);
93 
94  return $this->getADT()->equals($a_adt);
95  }
96 
97 
98  // import/export
99 
100  public function getSerializedValue()
101  {
102  if(!$this->isNull() && $this->isValid())
103  {
104  return serialize(array($this->getADT()->getSelection()));
105  }
106  }
107 
108  public function setSerializedValue($a_value)
109  {
110  $a_value = unserialize($a_value);
111  if(is_array($a_value))
112  {
113  $this->getADT()->setSelection($a_value[0]);
114  }
115  }
116 }
117 
118 ?>
This class represents a selection list property in a property form.
This class represents a property form user interface.
ADT base class.
Definition: class.ilADT.php:11
extractPostValues(array $a_post=null)
Extract data from (post) values.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
if(!is_array($argv)) $options
readFilter()
Load value(s) from filter store (in session)
Create styles array
The data for the language used.
isValidADTDefinition(ilADTDefinition $a_adt_def)
global $lng
Definition: privfeed.php:17
writeFilter($a_value=null)
Write value(s) to filter store (in session)
global $ilDB
ADT definition base class.
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.