ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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(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 ?>