ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng;
29 
30  $def = $this->getADT()->getCopyOfDefinition();
31 
32  $options = $def->getOptions();
33  asort($options); // ?
34 
35  $lng->loadLanguageModule("search");
36  $options = array("" => $lng->txt("search_any")) + $options;
37 
38  $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
39  $select->setOptions($options);
40 
41  $select->setValue($this->getADT()->getSelection());
42 
43  $this->addToParentElement($select);
44  }
45 
46  public function importFromPost(array $a_post = null)
47  {
48  $post = $this->extractPostValues($a_post);
49 
50  if ($post && $this->shouldBeImportedFromPost($post)) {
51  if ($this->getForm() instanceof ilPropertyFormGUI) {
52  $item = $this->getForm()->getItemByPostVar($this->getElementId());
53  $item->setValue($post);
54  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
55  $this->table_filter_fields[$this->getElementId()]->setValue($post);
56  $this->writeFilter($post);
57  }
58 
59  $this->getADT()->setSelection($post);
60  } else {
61  $this->writeFilter();
62  $this->getADT()->setSelection();
63  }
64  }
65 
66 
67  // db
68 
69  public function getSQLCondition($a_element_id)
70  {
71  global $ilDB;
72 
73  if (!$this->isNull() && $this->isValid()) {
74  $type = ($this->getADT() instanceof ilADTEnumText)
75  ? "text"
76  : "integer";
77 
78  return $a_element_id . " = " . $ilDB->quote($this->getADT()->getSelection(), $type);
79  }
80  }
81 
82  public function isInCondition(ilADT $a_adt)
83  {
84  assert($a_adt instanceof ilADTEnum);
85 
86  return $this->getADT()->equals($a_adt);
87  }
88 
89 
90  // import/export
91 
92  public function getSerializedValue()
93  {
94  if (!$this->isNull() && $this->isValid()) {
95  return serialize(array($this->getADT()->getSelection()));
96  }
97  }
98 
99  public function setSerializedValue($a_value)
100  {
101  $a_value = unserialize($a_value);
102  if (is_array($a_value)) {
103  $this->getADT()->setSelection($a_value[0]);
104  }
105  }
106 }
This class represents a selection list property in a property form.
This class represents a property form user interface.
$type
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)
$post
Definition: post.php:34
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
$def
Definition: croninfo.php:21
ADT definition base class.
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20