ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdvancedMDFieldDefinitionSelectMulti.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "Services/AdvancedMetaData/classes/Types/class.ilAdvancedMDFieldDefinitionSelect.php";
5 
15 {
16  const XML_SEPARATOR = "~|~";
17 
18  //
19  // generic types
20  //
21 
22  // search
23  public function getSearchQueryParserValue(ilADTSearchBridge $search_bridge)
24  {
25  return $search_bridge->getADT()->getSelections()[0] ?? 0;
26  }
27 
28 
29  public function getType()
30  {
31  return self::TYPE_SELECT_MULTI;
32  }
33 
34 
35 
36  protected function initADTDefinition()
37  {
38  $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("MultiEnum");
39  $def->setNumeric(false);
40 
41  $options = $this->getOptions();
42  $translated_options = [];
43  if (isset($this->getOptionTranslations()[$this->language])) {
44  $translated_options = $this->getOptionTranslations()[$this->language];
45  }
46  $def->setOptions(array_replace($options, $translated_options));
47  return $def;
48  }
49 
50 
51 
52  //
53  // definition (NOT ADT-based)
54  //
55 
61  {
62  $this->importNewSelectOptions(false, $a_form, $language);
63  }
64 
65 
66  //
67  // definition CRUD
68  //
69 
70 
71 
72  //
73  // import/export
74  //
75 
76  public function getValueForXML(ilADT $element)
77  {
78  return self::XML_SEPARATOR .
79  implode(self::XML_SEPARATOR, $element->getSelections()) .
80  self::XML_SEPARATOR;
81  }
82 
83  public function importValueFromXML($a_cdata)
84  {
85  $this->getADT()->setSelections(explode(self::XML_SEPARATOR, $a_cdata));
86  }
87 
88 
89  //
90  // presentation
91  //
92 
93  public function prepareElementForEditor(ilADTFormBridge $a_enum)
94  {
95  assert($a_enum instanceof ilADTMultiEnumFormBridge);
96 
97  $a_enum->setAutoSort(false);
98  }
99 }
This class represents a property form user interface.
ADT form bridge base class.
static getInstance()
Get singleton.
ADT base class.
Definition: class.ilADT.php:11
importNewSelectOptions(bool $multi, ilPropertyFormGUI $a_form, string $language='')
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language='')
ADT search bridge base class.
language()
Definition: language.php:2