ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  $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 }
This class represents a selection list property in a property form.
This class represents a property form user interface.
$type
global $DIC
Definition: saml.php:7
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.
readFilter()
Load value(s) from filter store (in session)
$lng
$post
Definition: post.php:34
isValidADTDefinition(ilADTDefinition $a_adt_def)
writeFilter($a_value=null)
Write value(s) to filter store (in session)
global $ilDB
$def
Definition: croninfo.php:21
ADT definition base class.
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.