ILIAS  release_8 Revision v8.24
class.ilAdvancedMDFieldDefinitionSelectMulti.php
Go to the documentation of this file.
1<?php
2
19declare(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 {
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()) .
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 definition base class.
ADT form bridge base class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ADT base class.
Definition: class.ilADT.php:12
prepareElementForEditor(ilADTFormBridge $a_bridge)
Prepare editor form elements.
getSearchQueryParserValue(ilADTSearchBridge $a_adt_search)
Get value for search query parser.
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language='')
Import custom post values from definition form.
importNewSelectOptions(bool $multi, ilPropertyFormGUI $a_form, string $language='')
translateLegacyImportValueFromXML(string $value)
On import from <7 options are not given by index but by their label.
This class represents a property form user interface.