ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAdvancedMDFieldDefinitionGroupBased Class Reference

AMD field type address. More...

+ Inheritance diagram for ilAdvancedMDFieldDefinitionGroupBased:
+ Collaboration diagram for ilAdvancedMDFieldDefinitionGroupBased:

Public Member Functions

 setOptions (?array $a_values=null)
 
 getOptions ()
 
 getFieldDefinitionForTableGUI (string $content_language)
 Parse properties for table gui. More...
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form, string $language='')
 Import custom post values from definition form. More...
 
 importXMLProperty (string $a_key, string $a_value)
 Import property from XML. More...
 
 getValueForXML (ilADT $element)
 Parse ADT value for xml (export) More...
 
 importValueFromXML (string $a_cdata)
 Import value from xml. More...
 
 getADTGroup ()
 
 getTitles ()
 
 hasComplexOptions ()
 
 getComplexOptionsOverview (object $a_parent_gui, string $a_parent_cmd)
 
Parameters
object$a_parent_gui
string$parent_cmd
Returns
null
More...
 
 exportOptionToTableGUI ($a_option, array &$a_item)
 
 initOptionForm (ilPropertyFormGUI $a_form, $a_option_id)
 
 updateComplexOption (ilPropertyFormGUI $a_form, $a_option_id)
 
- Public Member Functions inherited from ilAdvancedMDFieldDefinition
 __construct (GenericData $generic_data, string $language='')
 
 getType ()
 Get type. More...
 
 useDefaultLanguageMode (string $language)
 Check if default language mode has to be used: no language given or language equals default language. More...
 
 getTypeTitle ()
 
 getADTDefinition ()
 Get ADT definition instance. More...
 
 getADT ()
 
 getFieldId ()
 Get field_id. More...
 
 setRecordId (int $a_id)
 Set record id. More...
 
 getRecordId ()
 Get record id. More...
 
 setImportId (string $a_id_string)
 Set import id. More...
 
 getImportId ()
 Get import id. More...
 
 setPosition (int $a_pos)
 Set position. More...
 
 getPosition ()
 Get position. More...
 
 setTitle (string $a_title)
 Get title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription (string $a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 isSearchSupported ()
 Is search supported at all. More...
 
 isFilterSupported ()
 Is search by filter supported. More...
 
 setSearchable (bool $a_status)
 Toggle searchable. More...
 
 isSearchable ()
 Is searchable. More...
 
 setRequired (bool $a_status)
 Toggle required. More...
 
 isRequired ()
 Is required field. More...
 
 getFieldDefinitionForTableGUI (string $content_language)
 Parse properties for table gui. More...
 
 addToFieldDefinitionForm (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
 Add input elements to definition form. More...
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form, string $language='')
 Import custom post values from definition form. More...
 
 importDefinitionFormPostValues (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $active_language)
 Import post values from definition form. More...
 
 importDefinitionFormPostValuesNeedsConfirmation ()
 
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 prepareDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 generateImportId (int $a_field_id)
 Generate unique record id. More...
 
 save (bool $keep_pos_and_import_id=false, bool $keep_import_id=false)
 Create new field entry. More...
 
 update ()
 Update field entry. More...
 
 delete ()
 Delete field entry. More...
 
 toXML (ilXmlWriter $a_writer)
 To Xml. More...
 
 importXMLProperty (string $a_key, string $a_value)
 Import property from XML. More...
 
 getValueForXML (ilADT $element)
 Parse ADT value for xml (export) More...
 
 importValueFromXML (string $a_cdata)
 Import value from xml. More...
 
 importFromECS (string $a_ecs_type, $a_value, string $a_sub_id)
 Import meta data from ECS. More...
 
 prepareElementForEditor (ilADTFormBridge $a_bridge)
 Prepare editor form elements. More...
 
 getSearchQueryParserValue (ilADTSearchBridge $a_adt_search)
 Get value for search query parser. More...
 
 getSearchValueSerialized (ilADTSearchBridge $a_adt_search)
 
 setSearchValueSerialized (ilADTSearchBridge $a_adt_search, $a_value)
 Set value from search persistence. More...
 
 searchSubObjects (ilADTSearchBridge $a_adt_search, int $a_obj_id, string $sub_obj_type)
 
 searchObjects (ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, string $a_locate, string $a_search_type)
 Search objects. More...
 
 getLuceneSearchString ($a_value)
 Get search string in lucene syntax. More...
 
 prepareElementForSearch (ilADTSearchBridge $a_bridge)
 Prepare search form elements. More...
 
 _clone (int $a_new_record_id)
 Clone field definition. More...
 
 hasComplexOptions ()
 
 getComplexOptionsOverview (object $a_parent_gui, string $parent_cmd)
 

Protected Member Functions

 initADTDefinition ()
 Init adt instance. More...
 
 importFieldDefinition (array $a_def)
 Import (type-specific) field definition from DB. More...
 
 getFieldDefinition ()
 Get (type-specific) field definition. More...
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
 Add custom input elements to definition form. More...
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 Add (type-specific) properties to xml export. More...
 
 getADTForOption (string $a_option)
 
 importComplexOptionFromForm (string $a_option, ilADT $a_adt)
 
 findOptionById (string $a_id)
 
- Protected Member Functions inherited from ilAdvancedMDFieldDefinition
 initADTDefinition ()
 Init adt instance. More...
 
 setADT (ilADT $a_adt)
 Set ADT instance. More...
 
 importFieldDefinition (array $a_def)
 Import (type-specific) field definition from DB. More...
 
 getFieldDefinition ()
 Get (type-specific) field definition. More...
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
 Add custom input elements to definition form. More...
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 Add (type-specific) properties to xml export. More...
 
 parseSearchObjects (array $a_records, array $a_object_types)
 Add object-data needed for global search to AMD search results. More...
 

Protected Attributes

 $options = []
 
 $complex = []
 
- Protected Attributes inherited from ilAdvancedMDFieldDefinition
GenericData $generic_data
 
ilADTDefinition $adt_def = null
 
ilADT $adt = null
 
string $language = ''
 
ilDBInterface $db
 
ilLanguage $lng
 
ilLogger $logger
 
GlobalHttpState $http
 
RefineryFactory $refinery
 

Additional Inherited Members

- Static Public Member Functions inherited from ilAdvancedMDFieldDefinition
static getInstance (?int $a_field_id, ?int $a_type=null, string $language='')
 
static exists (int $a_field_id)
 
static getInstanceByTypeString (string $a_type)
 Get instance by type string (used by import) More...
 
static getInstancesByRecordId ( $a_record_id, $a_only_searchable=false, string $language='')
 Get definitions by record id. More...
 
static getInstancesByObjType ($a_obj_type, $a_active_only=true)
 
static getInstanceByImportId (string $a_import_id)
 
static getSearchableDefinitionIds ()
 Get searchable definition ids (performance is key) More...
 
static getADTGroupForDefinitions (array $a_defs)
 Init ADTGroup for definitions. More...
 
static getValidTypes ()
 Get all valid types. More...
 
static isValidType (int $a_type)
 
- Data Fields inherited from ilAdvancedMDFieldDefinition
const TYPE_SELECT = 1
 TODO: put this in when minimum php version is set to 8.2. More...
 
const TYPE_TEXT = 2
 
const TYPE_DATE = 3
 
const TYPE_DATETIME = 4
 
const TYPE_INTEGER = 5
 
const TYPE_FLOAT = 6
 
const TYPE_LOCATION = 7
 
const TYPE_SELECT_MULTI = 8
 
const TYPE_ADDRESS = 99
 
const TYPE_EXTERNAL_LINK = 9
 
const TYPE_INTERNAL_LINK = 10
 
- Static Protected Member Functions inherited from ilAdvancedMDFieldDefinition
static getInstanceWithData (GenericData $generic_data, string $language='')
 
static getTypeString (int $a_type)
 Get type as string. More...
 

Detailed Description

AMD field type address.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

Member Function Documentation

◆ addCustomFieldToDefinitionForm()

ilAdvancedMDFieldDefinitionGroupBased::addCustomFieldToDefinitionForm ( ilPropertyFormGUI  $a_form,
bool  $a_disabled = false,
string  $language = '' 
)
protected

Add custom input elements to definition form.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 85 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

89 : void {
90 global $lng;
91
92 $field = new ilTextInputGUI($lng->txt("options"), "opts");
93 $field->setRequired(true);
94 $field->setMulti(true);
95 $field->setMaxLength(255); // :TODO:
96 $a_form->addItem($field);
97
98 $options = $this->getOptions();
99 if ($options) {
100 $field->setMultiValues($options);
101 $field->setValue(array_shift($options));
102 }
103
104 if ($a_disabled) {
105 $field->setDisabled(true);
106 }
107 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
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.

◆ addPropertiesToXML()

ilAdvancedMDFieldDefinitionGroupBased::addPropertiesToXML ( ilXmlWriter  $a_writer)
protected

Add (type-specific) properties to xml export.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 129 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

129 : void
130 {
131 foreach ($this->getOptions() as $value) {
132 $a_writer->xmlElement('FieldValue', null, $value);
133 }
134 }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

References ilXmlWriter\xmlElement().

+ Here is the call graph for this function:

◆ exportOptionToTableGUI()

ilAdvancedMDFieldDefinitionGroupBased::exportOptionToTableGUI (   $a_option,
array &  $a_item 
)

Definition at line 203 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

203 : void
204 {
205 $adt = $this->getADTForOption($a_option);
206 foreach ($adt->getElements() as $title => $element) {
207 $pres = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element);
208 $a_item[$title] = $pres->getList();
209 }
210 }

References ilADTFactory\getInstance().

+ Here is the call graph for this function:

◆ findOptionById()

ilAdvancedMDFieldDefinitionGroupBased::findOptionById ( string  $a_id)
protected

Definition at line 258 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

258 : ?string
259 {
260 foreach ($this->getOptions() as $item) {
261 if (md5($item) == $a_id) {
262 return $item;
263 }
264 }
265 return null;
266 }

◆ getADTForOption()

ilAdvancedMDFieldDefinitionGroupBased::getADTForOption ( string  $a_option)
protected

Definition at line 185 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

185 : ilADT
186 {
187 $adt = ilADTFactory::getInstance()->getInstanceByDefinition($this->getADTGroup());
188 if (array_key_exists($a_option, $this->complex)) {
189 $adt->importStdClass($this->complex[$a_option]);
190 }
191 return $adt;
192 }
ADT base class.
Definition: class.ilADT.php:26
importStdClass(?stdClass $a_std)
Import value from stdClass.

References ilADTFactory\getInstance().

+ Here is the call graph for this function:

◆ getADTGroup()

ilAdvancedMDFieldDefinitionGroupBased::getADTGroup ( )
abstract

◆ getComplexOptionsOverview()

ilAdvancedMDFieldDefinitionGroupBased::getComplexOptionsOverview ( object  $a_parent_gui,
string  $a_parent_cmd 
)

Parameters
object$a_parent_gui
string$parent_cmd
Returns
null

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 197 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

197 : ?string
198 {
199 $tbl = new ilAdvancedMDFieldDefinitionGroupTableGUI($a_parent_gui, $a_parent_cmd, $this);
200 return $tbl->getHTML();
201 }

◆ getFieldDefinition()

ilAdvancedMDFieldDefinitionGroupBased::getFieldDefinition ( )
protected

Get (type-specific) field definition.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 67 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

67 : array
68 {
69 return array(
70 "options" => $this->options,
71 "complex" => $this->complex
72 );
73 }

◆ getFieldDefinitionForTableGUI()

ilAdvancedMDFieldDefinitionGroupBased::getFieldDefinitionForTableGUI ( string  $content_language)

Parse properties for table gui.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 75 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

75 : array
76 {
77 global $lng;
78
79 return array($lng->txt("options") => implode(",", $this->getOptions()));
80 }

References ilAdvancedMDFieldDefinition\$lng, getOptions(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getOptions()

ilAdvancedMDFieldDefinitionGroupBased::getOptions ( )

Definition at line 56 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

56 : array
57 {
58 return $this->options;
59 }

References $options.

Referenced by getFieldDefinitionForTableGUI(), and initADTDefinition().

+ Here is the caller graph for this function:

◆ getTitles()

ilAdvancedMDFieldDefinitionGroupBased::getTitles ( )
abstract

◆ getValueForXML()

ilAdvancedMDFieldDefinitionGroupBased::getValueForXML ( ilADT  $element)

Parse ADT value for xml (export)

Reimplemented from ilAdvancedMDFieldDefinition.

Definition at line 146 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

146 : string
147 {
148 return $element->getSelection();
149 }

◆ hasComplexOptions()

ilAdvancedMDFieldDefinitionGroupBased::hasComplexOptions ( )

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 180 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

180 : bool
181 {
182 return true;
183 }

◆ importComplexOptionFromForm()

ilAdvancedMDFieldDefinitionGroupBased::importComplexOptionFromForm ( string  $a_option,
ilADT  $a_adt 
)
protected

Definition at line 253 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

254 {
255 $this->complex[$a_option] = $a_adt->exportStdClass();
256 }
exportStdClass()
Export value as stdClass.

References ilADT\exportStdClass().

+ Here is the call graph for this function:

◆ importCustomDefinitionFormPostValues()

ilAdvancedMDFieldDefinitionGroupBased::importCustomDefinitionFormPostValues ( ilPropertyFormGUI  $a_form,
string  $language = '' 
)

Import custom post values from definition form.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 112 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

112 : void
113 {
114 $old = $this->getOptions();
115 $new = $a_form->getInput("opts");
116
117 if (is_array($old)) {
118 $missing = array_diff($old, $new);
119 if (sizeof($missing)) {
120 foreach ($missing as $item) {
121 unset($this->complex[$item]);
122 }
123 }
124 }
125
126 $this->setOptions($new);
127 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ importFieldDefinition()

ilAdvancedMDFieldDefinitionGroupBased::importFieldDefinition ( array  $a_def)
protected

Import (type-specific) field definition from DB.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 61 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

61 : void
62 {
63 $this->setOptions($a_def["options"] ?? []);
64 $this->complex = $a_def["complex"] ?? [];
65 }

References setOptions().

+ Here is the call graph for this function:

◆ importValueFromXML()

ilAdvancedMDFieldDefinitionGroupBased::importValueFromXML ( string  $a_cdata)

Import value from xml.

Parameters
string$a_cdata

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 151 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

151 : void
152 {
153 /*
154 * On import from <7 options are not given by index but by
155 * their label. There is nothing in the XML by which one could
156 * tell apart legacy and standard imports, so we have to
157 * make a best guess here (32410).
158 *
159 * Might fail for enums where the labels are integers.
160 * See also ilAdvancedMDFieldDefinitionSelect::translateLegacyImportValueFromXML.
161 */
162 if (
163 !in_array($a_cdata, array_keys($this->options)) &&
164 in_array($a_cdata, $this->options)
165 ) {
166 $a_cdata = (string) array_search($a_cdata, $this->options);
167 }
168 $this->getADT()->setSelection($a_cdata);
169 }

◆ importXMLProperty()

ilAdvancedMDFieldDefinitionGroupBased::importXMLProperty ( string  $a_key,
string  $a_value 
)

Import property from XML.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 136 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

136 : void
137 {
138 $this->options[] = $a_value;
139 }

◆ initADTDefinition()

ilAdvancedMDFieldDefinitionGroupBased::initADTDefinition ( )
protected

Init adt instance.

Reimplemented from ilAdvancedMDFieldDefinition.

Reimplemented in ilAdvancedMDFieldDefinitionText.

Definition at line 31 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

32 {
33 $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Enum");
34 $def->setNumeric(false);
35
36 $options = $this->getOptions();
37 $def->setOptions($options);
38 return $def;
39 }
ADT definition base class.

References $options, ilADTFactory\getInstance(), and getOptions().

+ Here is the call graph for this function:

◆ initOptionForm()

ilAdvancedMDFieldDefinitionGroupBased::initOptionForm ( ilPropertyFormGUI  $a_form,
  $a_option_id 
)

Definition at line 212 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

213 {
214 global $lng;
215
216 $option = $this->findOptionById($a_option_id);
217 if ($option) {
218 $title = new ilTextInputGUI($lng->txt("option"), "option");
219 $title->setValue($option);
220 $title->setDisabled(true);
221 $a_form->addItem($title);
222
223 $adt = $this->getADTForOption($option);
224 $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($adt);
225 $adt_form->setForm($a_form);
226
227 $titles = $this->getTitles();
228 foreach ($adt_form->getElements() as $id => $element) {
229 $element->setTitle($titles[$id]);
230 }
231
232 $adt_form->addToForm();
233 }
234 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, $lng, ilPropertyFormGUI\addItem(), and ilADTFactory\getInstance().

+ Here is the call graph for this function:

◆ setOptions()

ilAdvancedMDFieldDefinitionGroupBased::setOptions ( ?array  $a_values = null)

Definition at line 41 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

41 : void
42 {
43 if ($a_values !== null) {
44 foreach ($a_values as $idx => $value) {
45 $a_values[$idx] = trim($value);
46 if (!$a_values[$idx]) {
47 unset($a_values[$idx]);
48 }
49 }
50 $a_values = array_unique($a_values);
51 // sort($a_values);
52 }
53 $this->options = $a_values;
54 }

Referenced by importFieldDefinition().

+ Here is the caller graph for this function:

◆ updateComplexOption()

ilAdvancedMDFieldDefinitionGroupBased::updateComplexOption ( ilPropertyFormGUI  $a_form,
  $a_option_id 
)

Definition at line 236 of file class.ilAdvancedMDFieldDefinitionGroupBased.php.

237 {
238 $option = $this->findOptionById($a_option_id);
239 if ($option) {
240 $adt = ilADTFactory::getInstance()->getInstanceByDefinition($this->getADTGroup());
241 $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($adt);
242 $adt_form->setForm($a_form);
243 if ($adt_form->validate()) {
244 $adt_form->importFromPost();
245 $this->importComplexOptionFromForm($option, $adt);
246 return true;
247 }
248 }
249
250 return false;
251 }

References ilADTFactory\getInstance().

+ Here is the call graph for this function:

Field Documentation

◆ $complex

ilAdvancedMDFieldDefinitionGroupBased::$complex = []
protected

◆ $options

ilAdvancedMDFieldDefinitionGroupBased::$options = []
protected

The documentation for this class was generated from the following file: