19declare(strict_types=1);
39 $def->setNumeric(
false);
46 public function setOptions(?array $a_values =
null): void
48 if ($a_values !==
null) {
49 foreach ($a_values as $idx => $value) {
50 $a_values[$idx] = trim($value);
51 if (!$a_values[$idx]) {
52 unset($a_values[$idx]);
55 $a_values = array_unique($a_values);
58 $this->options = $a_values;
69 $this->complex = $a_def[
"complex"] ?? [];
75 "options" => $this->options,
76 "complex" => $this->complex
92 bool $a_disabled =
false,
98 $field->setRequired(
true);
99 $field->setMulti(
true);
100 $field->setMaxLength(255);
106 $field->setValue(array_shift(
$options));
110 $field->setDisabled(
true);
122 if (is_array($old)) {
123 $missing = array_diff($old, $new);
124 if (
sizeof($missing)) {
125 foreach ($missing as $item) {
126 unset($this->complex[$item]);
131 $this->setOptions($new);
137 $a_writer->
xmlElement(
'FieldValue',
null, $value);
143 $this->options[] = $a_value;
153 return $element->getSelection();
168 !in_array($a_cdata, array_keys($this->options)) &&
169 in_array($a_cdata, $this->options)
171 $a_cdata = (string) array_search($a_cdata, $this->options);
173 $this->getADT()->setSelection($a_cdata);
193 if (array_key_exists($a_option, $this->complex)) {
194 $adt->importStdClass($this->complex[$a_option]);
202 $data_retrieval =
new ComplexOptionsDataRetrieval($this);
203 $table_builder =
new ComplexOptionsTableBuilder(
212 return $table_builder->get();
217 $adt = $this->getADTForOption($a_option);
218 foreach ($adt->getElements() as $title => $element) {
220 $a_item[$title] = $pres->getList();
228 $option = $this->findOptionById($a_option_id);
231 $title->setValue($option);
232 $title->setDisabled(
true);
235 $adt = $this->getADTForOption($option);
237 $adt_form->setForm($a_form);
239 $titles = $this->getTitles();
240 foreach ($adt_form->getElements() as
$id => $element) {
241 $element->setTitle($titles[
$id]);
244 $adt_form->addToForm();
250 $option = $this->findOptionById($a_option_id);
254 $adt_form->setForm($a_form);
255 if ($adt_form->validate()) {
256 $adt_form->importFromPost();
257 $this->importComplexOptionFromForm($option, $adt);
273 if (md5($item) == $a_id) {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ADT definition base class.
exportStdClass()
Export value as stdClass.
findOptionById(string $a_id)
addCustomFieldToDefinitionForm(ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
Add custom input elements to definition form.
getComplexOptionsOverview()
exportOptionToTableGUI($a_option, array &$a_item)
importFieldDefinition(array $a_def)
Import (type-specific) field definition from DB.
getADTForOption(string $a_option)
setOptions(?array $a_values=null)
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
importComplexOptionFromForm(string $a_option, ilADT $a_adt)
importValueFromXML(string $a_cdata)
Import value from xml.
updateComplexOption(ilPropertyFormGUI $a_form, $a_option_id)
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language='')
Import custom post values from definition form.
getFieldDefinitionForTableGUI(string $content_language)
Parse properties for table gui.
addPropertiesToXML(ilXmlWriter $a_writer)
Add (type-specific) properties to xml export.
initADTDefinition()
Init adt instance.
importXMLProperty(string $a_key, string $a_value)
Import property from XML.
getFieldDefinition()
Get (type-specific) field definition.
initOptionForm(ilPropertyFormGUI $a_form, $a_option_id)
AMD field abstract base class.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
A component is the most general form of an entity in the UI.
This describes a Data Table.
static http()
Fetches the global http state from ILIAS.