ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdvancedMDFieldDefinitionSelectMulti.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
28  protected const XML_SEPARATOR = "~|~";
29 
30  public function getSearchQueryParserValue(ilADTSearchBridge $a_adt_search): string
31  {
32  return (string) $a_adt_search->getADT()->getSelections()[0];
33  }
34 
35  public function getType(): int
36  {
37  return self::TYPE_SELECT_MULTI;
38  }
39 
40  protected function initADTDefinition(): ilADTDefinition
41  {
42  $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("MultiEnum");
43  $def->setNumeric(false);
44 
45  $options = $this->getOptions();
46  $translated_options = [];
47  if (isset($this->getOptionTranslations()[$this->language])) {
48  $translated_options = $this->getOptionTranslations()[$this->language];
49  }
50  $def->setOptions(array_replace($options, $translated_options));
51  return $def;
52  }
53 
54  public function importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language = ''): void
55  {
56  $this->importNewSelectOptions(false, $a_form, $language);
57  }
58 
59  public function getValueForXML(ilADT $element): string
60  {
61  return self::XML_SEPARATOR .
62  implode(self::XML_SEPARATOR, (array) $element->getSelections()) .
63  self::XML_SEPARATOR;
64  }
65 
66  public function importValueFromXML(string $a_cdata): void
67  {
68  $values = [];
69  foreach (explode(self::XML_SEPARATOR, $a_cdata) as $value) {
70  $value = $this->translateLegacyImportValueFromXML($value);
71  $values[] = $value;
72  }
73  $this->getADT()->setSelections($values);
74  }
75 
76  public function prepareElementForEditor(ilADTFormBridge $a_bridge): void
77  {
78  assert($a_bridge instanceof ilADTMultiEnumFormBridge);
79 
80  $a_bridge->setAutoSort(false);
81  }
82 }
ADT form bridge base class.
translateLegacyImportValueFromXML(string $value)
On import from <7 options are not given by index but by their label.
ADT base class.
Definition: class.ilADT.php:11
importNewSelectOptions(bool $multi, ilPropertyFormGUI $a_form, string $language='')
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language='')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ADT definition base class.