ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAdvancedMDFieldDefinitionSelect Class Reference

AMD field type select. More...

+ Inheritance diagram for ilAdvancedMDFieldDefinitionSelect:
+ Collaboration diagram for ilAdvancedMDFieldDefinitionSelect:

Public Member Functions

 __construct (GenericData $generic_data, string $language='')
 
 getType ()
 
 getSearchQueryParserValue (ilADTSearchBridge $a_adt_search)
 
 getOptionsInDefaultLanguageAsArray ()
 
 getFieldDefinitionForTableGUI (string $content_language)
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form, string $language='')
 
 importDefinitionFormPostValuesNeedsConfirmation ()
 
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 delete ()
 
 save (bool $keep_pos_and_import_id=false, bool $keep_import_id=false)
 
 update ()
 
 importXMLProperty (string $a_key, string $a_value)
 Since the XML import only allows for a key-value pair, we also rely on the order of properties to sort translations into options. More...
 
 getValueForXML (ilADT $element)
 
 importValueFromXML (string $a_cdata)
 
 prepareElementForEditor (ilADTFormBridge $a_bridge)
 
- 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 ()
 
 options ()
 
 getOptionsInLanguageAsArray (string $language, bool $default_as_fallback=true)
 
 importFieldDefinition (array $a_def)
 
 getFieldDefinition ()
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
 
 addCreateOptionsFieldsToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled)
 
 addEditOptionsFieldsToDefinitionForm (SelectSpecificData $options, ilPropertyFormGUI $a_form, bool $a_disabled)
 
 addRadioToEntriesGroup (ilRadioGroupInputGUI $entries, array $position_select_options, ?int $position_value, string $label, string $value, string $id, bool $with_delete_checkbox, bool $disabled)
 Returns hidden inputs if a disabled checkbox is in the radio, such that we can use the workaround for having disabled checkboxes still write to post. More...
 
 addCustomFieldToDefinitionFormInTranslationMode (ilPropertyFormGUI $form, bool $disabled, string $language='')
 
 buildConfirmedObjects (ilPropertyFormGUI $a_form)
 Process custom post values from definition form. More...
 
 importNewSelectOptions (bool $multi, ilPropertyFormGUI $a_form, string $language='')
 
 findBySingleValue (ilADTSearchBridge $a_search, $a_value)
 
 importTranslatedFormPostValues (ilPropertyFormGUI $form, string $language)
 
 deleteOptions ()
 
 updateOptions ()
 
 saveOptions ()
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 
 translateLegacyImportValueFromXML (string $value)
 On import from <7 options are not given by index but by their label. More...
 
 readOptions ()
 
- 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

array $confirm_objects = []
 
array $confirm_objects_values = []
 
array $confirmed_objects = null
 
array $old_options_array = null
 
SelectSpecificData $options
 
string $default_language
 
- 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
 

Private Attributes

const REMOVE_ACTION_ID = "-iladvmdrm-"
 
const ADD_NEW_ENTRY_ID = "-advmd_add_new_entry-"
 
ilGlobalTemplateInterface $main_tpl
 
Gateway $db_gateway
 

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 select.

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 32 of file class.ilAdvancedMDFieldDefinitionSelect.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDFieldDefinitionSelect::__construct ( GenericData  $generic_data,
string  $language = '' 
)

Definition at line 49 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $DIC, ilAdvancedMDFieldDefinition\$language, ILIAS\GlobalScreen\Provider\__construct(), and readOptions().

50  {
51  global $DIC;
52 
53  parent::__construct($generic_data, $language);
54 
55  $this->main_tpl = $DIC->ui()->mainTemplate();
56  $this->db_gateway = new DatabaseGatewayImplementation($DIC->database());
57 
58  $this->readOptions();
59  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addCreateOptionsFieldsToDefinitionForm()

ilAdvancedMDFieldDefinitionSelect::addCreateOptionsFieldsToDefinitionForm ( ilPropertyFormGUI  $a_form,
bool  $a_disabled 
)
protected

Definition at line 153 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilPropertyFormGUI\addItem(), and ILIAS\Repository\lng().

Referenced by addCustomFieldToDefinitionForm().

156  : void {
157  $field = new ilTextInputGUI($this->lng->txt('meta_advmd_select_options'), 'opts_new');
158  $field->setRequired(true);
159  $field->setMulti(true);
160  $field->setMaxLength(255);
161  $field->setDisabled($a_disabled);
162 
163  $a_form->addItem($field);
164  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCustomFieldToDefinitionForm()

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

Definition at line 135 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\$language, addCreateOptionsFieldsToDefinitionForm(), addCustomFieldToDefinitionFormInTranslationMode(), addEditOptionsFieldsToDefinitionForm(), options(), and ilAdvancedMDFieldDefinition\useDefaultLanguageMode().

139  : void {
140  if (!$this->useDefaultLanguageMode($language)) {
141  $this->addCustomFieldToDefinitionFormInTranslationMode($a_form, $a_disabled, $language);
142  return;
143  }
144 
145  if (!$this->options()->hasOptions()) {
146  $this->addCreateOptionsFieldsToDefinitionForm($a_form, $a_disabled);
147  return;
148  }
149 
150  $this->addEditOptionsFieldsToDefinitionForm($this->options(), $a_form, $a_disabled);
151  }
addEditOptionsFieldsToDefinitionForm(SelectSpecificData $options, ilPropertyFormGUI $a_form, bool $a_disabled)
addCustomFieldToDefinitionFormInTranslationMode(ilPropertyFormGUI $form, bool $disabled, string $language='')
addCreateOptionsFieldsToDefinitionForm(ilPropertyFormGUI $a_form, bool $a_disabled)
useDefaultLanguageMode(string $language)
Check if default language mode has to be used: no language given or language equals default language...
+ Here is the call graph for this function:

◆ addCustomFieldToDefinitionFormInTranslationMode()

ilAdvancedMDFieldDefinitionSelect::addCustomFieldToDefinitionFormInTranslationMode ( ilPropertyFormGUI  $form,
bool  $disabled,
string  $language = '' 
)
protected

Definition at line 292 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\$language, ilAdvancedMDRecord\_getInstanceByRecordId(), ilPropertyFormGUI\addItem(), ilAdvancedMDFieldDefinition\getRecordId(), ILIAS\Repository\lng(), and options().

Referenced by addCustomFieldToDefinitionForm().

296  : void {
298 
299  $first = true;
300  foreach ($this->options()->getOptions() as $option) {
301  $title = '';
302  if ($first) {
303  $title = $this->lng->txt("meta_advmd_select_options");
304  }
305  $text = new ilTextInputGUI(
306  $title,
307  'opts__' . $language . '__' . $option->optionID()
308  );
309 
310  if ($option->hasTranslationInLanguage($language)) {
311  $text->setValue($option->getTranslationInLanguage($language)->getValue());
312  }
313 
314  $default_value = '';
315  if ($option->hasTranslationInLanguage($default_language)) {
316  $default_value = $option->getTranslationInLanguage($default_language)->getValue();
317  }
318 
319  $text->setInfo($default_language . ': ' . $default_value);
320  $text->setMaxLength(255);
321  $text->setRequired(true);
322 
323  $first = false;
324  $form->addItem($text);
325  }
326  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addEditOptionsFieldsToDefinitionForm()

ilAdvancedMDFieldDefinitionSelect::addEditOptionsFieldsToDefinitionForm ( SelectSpecificData  $options,
ilPropertyFormGUI  $a_form,
bool  $a_disabled 
)
protected

Definition at line 166 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilPropertyFormGUI\addItem(), addRadioToEntriesGroup(), ILIAS\MetaData\Elements\Data\Data\FieldDefinition\TypeSpecificData\Select\SelectSpecificData\getOptions(), ilRadioGroupInputGUI\getValue(), ILIAS\Repository\lng(), and null.

Referenced by addCustomFieldToDefinitionForm().

170  : void {
171  $entries = new ilRadioGroupInputGUI(
172  $this->lng->txt('meta_advmd_select_options_edit'),
173  'opts_edit'
174  );
175 
176  $position_identifiers = [
177  '0' => $this->lng->txt('meta_advmd_select_first_position_identifier')
178  ];
179  foreach ($options->getOptions() as $option) {
180  $position_identifiers[(string) ($option->getPosition() + 1)] = sprintf(
181  $this->lng->txt('meta_advmd_select_position_identifier'),
182  $option->getTranslationInLanguage($this->default_language)?->getValue() ?? ''
183  );
184  }
185 
186  $disabled_checkbox_overwrites = [];
187 
188  foreach ($options->getOptions() as $option) {
189  $option_value = $option->getTranslationInLanguage($this->default_language)?->getValue() ?? '';
190  $hidden = $this->addRadioToEntriesGroup(
191  $entries,
192  $position_identifiers,
193  $option->getPosition(),
194  $option_value,
195  $option_value,
196  (string) $option->optionID(),
197  count(iterator_to_array($options->getOptions())) > 1,
198  $a_disabled
199  );
200  if (!is_null($hidden)) {
201  $disabled_checkbox_overwrites[] = $hidden;
202  }
203  }
204 
205  /*
206  * Add radio to add new entry
207  */
208  $this->addRadioToEntriesGroup(
209  $entries,
210  $position_identifiers,
211  null,
212  $this->lng->txt('meta_advmd_select_new_option'),
213  '',
214  self::ADD_NEW_ENTRY_ID,
215  false,
216  $a_disabled
217  );
218 
219  $entries->setDisabled($a_disabled);
220  $a_form->addItem($entries);
221 
222  foreach ($disabled_checkbox_overwrites as $input) {
223  $a_form->addItem($input);
224  }
225  }
addRadioToEntriesGroup(ilRadioGroupInputGUI $entries, array $position_select_options, ?int $position_value, string $label, string $value, string $id, bool $with_delete_checkbox, bool $disabled)
Returns hidden inputs if a disabled checkbox is in the radio, such that we can use the workaround for...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addPropertiesToXML()

ilAdvancedMDFieldDefinitionSelect::addPropertiesToXML ( ilXmlWriter  $a_writer)
protected

Definition at line 797 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References options(), and ilXmlWriter\xmlElement().

797  : void
798  {
799  foreach ($this->options()->getOptions() as $option) {
800  foreach ($option->getTranslations() as $translation) {
801  $a_writer->xmlElement(
802  'FieldValue',
803  ['id' => $translation->language()],
804  $translation->getValue()
805  );
806  }
807  }
808  }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ addRadioToEntriesGroup()

ilAdvancedMDFieldDefinitionSelect::addRadioToEntriesGroup ( ilRadioGroupInputGUI  $entries,
array  $position_select_options,
?int  $position_value,
string  $label,
string  $value,
string  $id,
bool  $with_delete_checkbox,
bool  $disabled 
)
protected

Returns hidden inputs if a disabled checkbox is in the radio, such that we can use the workaround for having disabled checkboxes still write to post.

Definition at line 232 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $id, ilRadioGroupInputGUI\addOption(), ILIAS\Repository\lng(), and null.

Referenced by addEditOptionsFieldsToDefinitionForm().

241  : ?ilHiddenInputGUI {
242  $disabled_checkbox_overwrite = null;
243  $radio = new ilRadioOption($label, $id);
244 
245  $value_input = new ilTextInputGUI(
246  $this->lng->txt('meta_advmd_select_option_value'),
247  'value_' . $id
248  );
249  $value_input->setRequired(true);
250  $value_input->setMaxLength(255);
251  $value_input->setValue($value);
252  $value_input->setDisabled($disabled);
253  $radio->addSubItem($value_input);
254 
255  $position = new ilSelectInputGUI(
256  $this->lng->txt('meta_advmd_select_option_position'),
257  'position_' . $id
258  );
259  $relevant_position_select_options = $position_select_options;
260  if (!is_null($position_value) && isset($relevant_position_select_options[$position_value + 1])) {
261  unset($relevant_position_select_options[$position_value + 1]);
262  }
263  $position->setOptions($relevant_position_select_options);
264  $position->setValue($position_value);
265  $position->setDisabled($disabled);
266  $radio->addSubItem($position);
267 
268  if ($with_delete_checkbox) {
269  $delete = new ilCheckboxInputGUI(
270  $this->lng->txt('meta_advmd_select_delete_option'),
271  'delete_me_' . $id
272  );
273  $delete->setDisabled($disabled);
274  $radio->addSubItem($delete);
275 
276  /*
277  * If disabled, checkboxes don't come with a hidden input to write to post,
278  * this is a workaround.
279  */
280  if ($disabled) {
281  $hidden = new ilHiddenInputGUI('delete_me_' . $id);
282  $hidden->setValue("1");
283  $disabled_checkbox_overwrite = $hidden;
284  }
285  }
286 
287  $radio->setDisabled($disabled);
288  $entries->addOption($radio);
289  return $disabled_checkbox_overwrite;
290  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
addOption(ilRadioOption $a_option)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a hidden form property in a property form.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildConfirmedObjects()

ilAdvancedMDFieldDefinitionSelect::buildConfirmedObjects ( ilPropertyFormGUI  $a_form)
protected

Process custom post values from definition form.

Definition at line 331 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $parts, $res, ilAdvancedMDFieldDefinition\getFieldId(), ilPropertyFormGUI\getInput(), and null.

Referenced by importNewSelectOptions().

331  : ?array
332  {
333  // #15719
334  $recipes = $a_form->getInput("conf_det");
335  if (is_array($recipes[$this->getFieldId()] ?? null)) {
336  $recipes = $recipes[$this->getFieldId()];
337  $sum = $a_form->getInput("conf_det_act");
338  $sum = $sum[$this->getFieldId()];
339  $sgl = $a_form->getInput("conf");
340  $sgl = $sgl[$this->getFieldId()];
341 
342  $res = array();
343  foreach ($recipes as $old_option => $recipe) {
344  $sum_act = $sum[$old_option];
345  $sgl_act = $sgl[$old_option];
346 
347  if ($recipe == "sum") {
348  // #18885
349  if (!$sum_act) {
350  return null;
351  }
352 
353  foreach (array_keys($sgl_act) as $obj_idx) {
354  if ($sum_act == self::REMOVE_ACTION_ID) {
355  $sum_act = "";
356  }
357  if (substr($sum_act, 0, 4) == 'idx_') {
358  $parts = explode('_', $sum_act);
359  $sum_act = $parts[1];
360  }
361  $res[$old_option][$obj_idx] = $sum_act;
362  }
363  } else {
364  // #18885
365  foreach ($sgl_act as $sgl_index => $sgl_item) {
366  if (!$sgl_item) {
367  return null;
368  } elseif ($sgl_item == self::REMOVE_ACTION_ID) {
369  $sgl_act[$sgl_index] = "";
370  }
371  if (substr($sgl_item, 0, 4) == 'idx_') {
372  $parts = explode('_', $sgl_item);
373  $sgl_act[$sgl_index] = $parts[1];
374  }
375  }
376 
377  $res[$old_option] = $sgl_act;
378  }
379  }
380  return $res;
381  }
382  return null;
383  }
$res
Definition: ltiservices.php:66
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
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-...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilAdvancedMDFieldDefinitionSelect::delete ( )

Definition at line 691 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References deleteOptions().

691  : void
692  {
693  $this->deleteOptions();
694  parent::delete();
695  }
+ Here is the call graph for this function:

◆ deleteOptions()

ilAdvancedMDFieldDefinitionSelect::deleteOptions ( )
protected

Definition at line 703 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\getFieldId().

Referenced by delete().

703  : void
704  {
705  $this->db_gateway->delete($this->getFieldId());
706  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findBySingleValue()

ilAdvancedMDFieldDefinitionSelect::findBySingleValue ( ilADTSearchBridge  $a_search,
  $a_value 
)
protected
Parameters
ilADTEnumSearchBridgeMulti$a_search
$a_value
Returns
array
Todo:
fix $a_value type

Definition at line 511 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $res, ilADTActiveRecordByType\find(), ilAdvancedMDFieldDefinition\getFieldId(), and ilADTSearchBridge\getSQLCondition().

Referenced by importNewSelectOptions(), and update().

511  : array
512  {
513  $res = array();
514  $a_search->getADT()->setSelections((array) $a_value);
515  $condition = $a_search->getSQLCondition('value_index');
516 
518  "adv_md_values",
519  "Enum",
520  $this->getFieldId(),
521  $condition
522  );
523  if ($in_use) {
524  foreach ($in_use as $item) {
525  $res[] = array($item["obj_id"], $item["sub_type"], $item["sub_id"], $item["value_index"]);
526  }
527  }
528  return $res;
529  }
$res
Definition: ltiservices.php:66
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
static find(string $a_table, string $a_type, int $a_field_id, string $a_condition, ?string $a_additional_fields=null)
Find entries.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFieldDefinition()

ilAdvancedMDFieldDefinitionSelect::getFieldDefinition ( )
protected

Definition at line 118 of file class.ilAdvancedMDFieldDefinitionSelect.php.

118  : array
119  {
120  return [];
121  }

◆ getFieldDefinitionForTableGUI()

ilAdvancedMDFieldDefinitionSelect::getFieldDefinitionForTableGUI ( string  $content_language)

Definition at line 123 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References getOptionsInDefaultLanguageAsArray(), getOptionsInLanguageAsArray(), and ILIAS\Repository\lng().

123  : array
124  {
125  if (strlen($content_language)) {
126  $options = $this->getOptionsInLanguageAsArray($content_language);
127  } else {
129  }
130  return [
131  $this->lng->txt("meta_advmd_select_options") => implode(",", $options)
132  ];
133  }
getOptionsInLanguageAsArray(string $language, bool $default_as_fallback=true)
+ Here is the call graph for this function:

◆ getOptionsInDefaultLanguageAsArray()

ilAdvancedMDFieldDefinitionSelect::getOptionsInDefaultLanguageAsArray ( )

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

References options().

Referenced by getFieldDefinitionForTableGUI().

85  : ?array
86  {
87  $default_language_values = [];
88  foreach ($this->options()->getOptions() as $option) {
89  if ($translation = $option->getTranslationInLanguage($this->default_language)) {
90  $default_language_values[$option->optionID()] = $translation->getValue();
91  }
92  }
93  return $default_language_values;
94  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptionsInLanguageAsArray()

ilAdvancedMDFieldDefinitionSelect::getOptionsInLanguageAsArray ( string  $language,
bool  $default_as_fallback = true 
)
protected

Definition at line 96 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References options().

Referenced by getFieldDefinitionForTableGUI(), importNewSelectOptions(), ilAdvancedMDFieldDefinitionSelectMulti\initADTDefinition(), and initADTDefinition().

99  : ?array {
100  $current_language_values = [];
101  foreach ($this->options()->getOptions() as $option) {
102  if ($translation = $option->getTranslationInLanguage($language)) {
103  $current_language_values[$option->optionID()] = $translation->getValue();
104  } elseif (
105  $default_as_fallback &&
106  $translation = $option->getTranslationInLanguage($this->default_language)
107  ) {
108  $current_language_values[$option->optionID()] = $translation->getValue();
109  }
110  }
111  return $current_language_values;
112  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSearchQueryParserValue()

ilAdvancedMDFieldDefinitionSelect::getSearchQueryParserValue ( ilADTSearchBridge  $a_adt_search)

Definition at line 66 of file class.ilAdvancedMDFieldDefinitionSelect.php.

66  : string
67  {
68  return (string) $a_adt_search->getADT()->getSelection();
69  }

◆ getType()

ilAdvancedMDFieldDefinitionSelect::getType ( )

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

61  : int
62  {
63  return self::TYPE_SELECT;
64  }

◆ getValueForXML()

ilAdvancedMDFieldDefinitionSelect::getValueForXML ( ilADT  $element)

Options of imported local fields don't keep their ID, but get assigned a new ID based on order. To conserve assigments, the same logic has to be applied here.

Definition at line 841 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDRecord\_getInstanceByRecordId(), ILIAS\Repository\int(), and options().

841  : string
842  {
843  $record = ilAdvancedMDRecord::_getInstanceByRecordId($this->getRecordID());
844  if (!$record->getParentObject()) {
845  return (string) $element->getSelection();
846  }
852  $index = 1;
853  foreach ($this->options()->getOptions() as $option) {
854  if ($option->optionID() === (int) $element->getSelection()) {
855  return (string) $index;
856  }
857  $index++;
858  }
859  return '';
860  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:

◆ importCustomDefinitionFormPostValues()

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

Definition at line 385 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\$language, and importNewSelectOptions().

385  : void
386  {
387  $this->importNewSelectOptions(true, $a_form, $language);
388  }
importNewSelectOptions(bool $multi, ilPropertyFormGUI $a_form, string $language='')
+ Here is the call graph for this function:

◆ importDefinitionFormPostValuesNeedsConfirmation()

ilAdvancedMDFieldDefinitionSelect::importDefinitionFormPostValuesNeedsConfirmation ( )

Definition at line 546 of file class.ilAdvancedMDFieldDefinitionSelect.php.

546  : bool
547  {
548  return is_array($this->confirm_objects) && count($this->confirm_objects) > 0;
549  }

◆ importFieldDefinition()

ilAdvancedMDFieldDefinitionSelect::importFieldDefinition ( array  $a_def)
protected

Definition at line 114 of file class.ilAdvancedMDFieldDefinitionSelect.php.

114  : void
115  {
116  }

◆ importNewSelectOptions()

ilAdvancedMDFieldDefinitionSelect::importNewSelectOptions ( bool  $multi,
ilPropertyFormGUI  $a_form,
string  $language = '' 
)
protected

Definition at line 390 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $default_language, ilAdvancedMDFieldDefinition\$language, buildConfirmedObjects(), findBySingleValue(), ilAdvancedMDFieldDefinition\getADTDefinition(), ilPropertyFormGUI\getInput(), ilADTFactory\getInstance(), getOptionsInLanguageAsArray(), importTranslatedFormPostValues(), ILIAS\Repository\int(), options(), and ilAdvancedMDFieldDefinition\useDefaultLanguageMode().

Referenced by ilAdvancedMDFieldDefinitionSelectMulti\importCustomDefinitionFormPostValues(), and importCustomDefinitionFormPostValues().

394  : void {
395  if (!$this->useDefaultLanguageMode($language)) {
396  $this->importTranslatedFormPostValues($a_form, $language);
397  return;
398  }
399 
400  $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance(
401  $this->getADTDefinition(),
402  false,
403  $multi
404  );
405 
406  if (!strlen($language)) {
408  }
409 
410  if ($new = $a_form->getInput('opts_new')) {
411  foreach ($new as $position => $value) {
412  $new_option = $this->options()->addOption();
413  $new_option->setPosition((int) $position);
414  $new_translation = $new_option->addTranslation($language);
415  $new_translation->setValue(trim($value));
416  }
417  return;
418  }
419 
420  $edited_id = $a_form->getInput('opts_edit');
421  if ($edited_id === '' || is_null($edited_id)) {
422  return;
423  }
424  if ($edited_id !== self::ADD_NEW_ENTRY_ID) {
425  $edited_id = (int) $edited_id;
426  }
427 
428  $this->old_options_array = $this->getOptionsInLanguageAsArray($language);
429 
430  /*
431  * Delete option if needed
432  */
433  if ($a_form->getInput('delete_me_' . $edited_id) && $edited_id !== self::ADD_NEW_ENTRY_ID) {
434  $old_option_value = $this->options()
435  ->getOption($edited_id)
436  ?->getTranslationInLanguage($language)?->getValue() ?? '';
437  $this->options()->removeOption($edited_id);
438 
439  /*
440  * If option is to be deleted, collect objects whith that value and
441  * and prepare confirmation of their migration.
442  */
443  $this->confirmed_objects = $this->buildConfirmedObjects($a_form);
444  $already_confirmed = is_array($this->confirmed_objects);
445 
446  $in_use = $this->findBySingleValue($search, $edited_id);
447  if (is_array($in_use)) {
448  foreach ($in_use as $item) {
449  if (!$already_confirmed) {
450  $this->confirm_objects[$edited_id][] = $item;
451  $this->confirm_objects_values[$edited_id] = $old_option_value;
452  }
453  }
454  }
455 
456  return;
457  }
458 
459  $new_value = (string) $a_form->getInput('value_' . $edited_id);
460  $new_position = (int) $a_form->getInput('position_' . $edited_id);
461 
462  /*
463  * Create new option if needed, else assign the new value
464  */
465  if ($edited_id === self::ADD_NEW_ENTRY_ID) {
466  $edited_option = $this->options()->addOption();
467  } else {
468  $edited_option = $this->options()->getOption($edited_id);
469  }
470 
471  if ($edited_option->hasTranslationInLanguage($this->default_language)) {
472  $edited_option->getTranslationInLanguage($this->default_language)->setValue($new_value);
473  } else {
474  $edited_option->addTranslation($this->default_language)->setValue($new_value);
475  }
476 
477  /*
478  * Update positions and value
479  * If an entry is is moved down, shift new position to reflect entry not
480  * being in its old position anymore.
481  */
482  if ($new_position > $edited_option->getPosition()) {
483  $new_position -= 1;
484  }
485 
486  $position = 0;
487  if ($position === $new_position) {
488  $edited_option->setPosition($position);
489  $position++;
490  }
491  foreach ($this->options()->getOptions() as $option) {
492  if ($option === $edited_option) {
493  continue;
494  }
495  $option->setPosition($position);
496  $position++;
497 
498  if ($position === $new_position) {
499  $edited_option->setPosition($position);
500  $position++;
501  }
502  }
503  }
getADTDefinition()
Get ADT definition instance.
getOptionsInLanguageAsArray(string $language, bool $default_as_fallback=true)
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-...
importTranslatedFormPostValues(ilPropertyFormGUI $form, string $language)
useDefaultLanguageMode(string $language)
Check if default language mode has to be used: no language given or language equals default language...
findBySingleValue(ilADTSearchBridge $a_search, $a_value)
buildConfirmedObjects(ilPropertyFormGUI $a_form)
Process custom post values from definition form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importTranslatedFormPostValues()

ilAdvancedMDFieldDefinitionSelect::importTranslatedFormPostValues ( ilPropertyFormGUI  $form,
string  $language 
)
protected

Definition at line 531 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilPropertyFormGUI\getInput(), and options().

Referenced by importNewSelectOptions().

531  : void
532  {
533  foreach ($this->options()->getOptions() as $option) {
534  $value = $form->getInput('opts__' . $language . '__' . $option->optionID());
535  $value = trim($value);
536 
537  if ($option->hasTranslationInLanguage($language)) {
538  $option->getTranslationInLanguage($language)->setValue($value);
539  continue;
540  }
541  $new_translation = $option->addTranslation($language);
542  $new_translation->setValue($value);
543  }
544  }
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-...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importValueFromXML()

ilAdvancedMDFieldDefinitionSelect::importValueFromXML ( string  $a_cdata)

Definition at line 862 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\getADT(), and translateLegacyImportValueFromXML().

862  : void
863  {
864  $a_cdata = $this->translateLegacyImportValueFromXML($a_cdata);
865  $this->getADT()->setSelection($a_cdata);
866  }
translateLegacyImportValueFromXML(string $value)
On import from <7 options are not given by index but by their label.
+ Here is the call graph for this function:

◆ importXMLProperty()

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

Since the XML import only allows for a key-value pair, we also rely on the order of properties to sort translations into options.

Definition at line 814 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\$language, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getRecordId(), null, and options().

814  : void
815  {
816  $language = $a_key;
817  if ($language === '') {
818  $language = ilAdvancedMDRecord::_getInstanceByRecordId($this->getRecordId())->getDefaultLanguage();
819  }
820 
821  $associated_option = null;
822  $max_position = -1;
823  foreach ($this->options()->getOptions() as $option) {
824  if (
825  !$option->hasTranslationInLanguage($language) &&
826  !isset($associated_option)
827  ) {
828  $associated_option = $option;
829  }
830  $max_position = max($max_position, $option->getPosition());
831  }
832  if (!isset($associated_option)) {
833  $associated_option = $this->options()->addOption();
834  $associated_option->setPosition($max_position + 1);
835  }
836 
837  $new_translation = $associated_option->addTranslation($language);
838  $new_translation->setValue($a_value);
839  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:

◆ initADTDefinition()

ilAdvancedMDFieldDefinitionSelect::initADTDefinition ( )
protected

Definition at line 71 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilADTFactory\getInstance(), getOptionsInLanguageAsArray(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

72  {
73  $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Enum");
74  $def->setNumeric(false);
75 
76  $def->setOptions($this->getOptionsInLanguageAsArray($this->language));
77  return $def;
78  }
getOptionsInLanguageAsArray(string $language, bool $default_as_fallback=true)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
ADT definition base class.
+ Here is the call graph for this function:

◆ options()

◆ prepareCustomDefinitionFormConfirmation()

ilAdvancedMDFieldDefinitionSelect::prepareCustomDefinitionFormConfirmation ( ilPropertyFormGUI  $a_form)

PhpUndefinedMethodInspection

Definition at line 550 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $DIC, ilAdvancedMDFieldDefinition\$lng, ilObject\_lookupTitle(), ilObject\_lookupType(), ilPropertyFormGUI\addItem(), ilAdvancedMDFieldDefinition\getFieldId(), ilPropertyFormGUI\getItemByPostVar(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), options(), ilFormPropertyGUI\setRequired(), ilHiddenInputGUI\setValue(), and ilLanguage\txt().

550  : void
551  {
552  global $DIC;
553 
554  $lng = $DIC['lng'];
555  $objDefinition = $DIC['objDefinition'];
556 
557  $post_conf_det = (array) ($this->http->request()->getParsedBody()['conf_det'] ?? []);
558  $post_conf = (array) ($this->http->request()->getParsedBody()['conf'] ?? []);
559 
560  $custom_field = $a_form->getItemByPostVar('opts_edit');
561  $custom_field->setDisabled(true);
562  foreach ($custom_field->getSubInputItemsRecursive() as $sub_input) {
563  $sub_input->setDisabled(true);
564  /*
565  * If disabled, checkboxes don't come with a hidden input to write to post,
566  * this is a workaround.
567  */
568  if ($sub_input instanceof ilCheckboxInputGUI) {
569  $hidden = new ilHiddenInputGUI($sub_input->getPostVar());
570  $hidden->setValue($sub_input->getValue());
571  $a_form->addItem($hidden);
572  }
573  }
574 
575  if (is_array($this->confirm_objects) && count($this->confirm_objects) > 0) {
576  $sec = new ilFormSectionHeaderGUI();
577  $sec->setTitle($lng->txt("md_adv_confirm_definition_select_section"));
578  $a_form->addItem($sec);
579 
580  foreach ($this->confirm_objects as $old_option_index => $items) {
581  $old_option_value = $this->confirm_objects_values[$old_option_index];
582  $details = new ilRadioGroupInputGUI(
583  $lng->txt("md_adv_confirm_definition_select_option") . ': "' . $old_option_value . '"',
584  "conf_det[" . $this->getFieldId() . "][" . $old_option_index . "]"
585  );
586  $details->setRequired(true);
587  $details->setValue("sum");
588  $a_form->addItem($details);
589 
590  // automatic reload does not work
591  if (isset($post_conf_det[$this->getFieldId()][$old_option_index])) {
592  $details->setValue($post_conf_det[$this->getFieldId()][$old_option_index]);
593  }
594 
595  $sum = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_all"), "sum");
596  $details->addOption($sum);
597 
598  $sel = new ilSelectInputGUI(
599  $lng->txt("md_adv_confirm_definition_select_option_all_action"),
600  "conf_det_act[" . $this->getFieldId() . "][" . $old_option_index . "]"
601  );
602  $sel->setRequired(true);
603  $options = array(
604  "" => $lng->txt("please_select"),
605  self::REMOVE_ACTION_ID => $lng->txt("md_adv_confirm_definition_select_option_remove")
606  );
607  foreach ($this->options()->getOptions() as $new_option) {
608  $new_id = $new_option->optionID();
609  $new_value = $new_option->getTranslationInLanguage($this->default_language)->getValue();
610  $options['idx_' . $new_id] = $lng->txt("md_adv_confirm_definition_select_option_overwrite") . ': "' . $new_value . '"';
611  }
612  $sel->setOptions($options);
613  $sum->addSubItem($sel);
614 
615  // automatic reload does not work
616  if (isset($post_conf_det[$this->getFieldId()][$old_option_index])) {
617  if ($post_conf_det[$this->getFieldId()][$old_option_index]) {
618  $sel->setValue($post_conf_det[$this->getFieldId()][$old_option_index]);
619  } elseif ($post_conf_det[$this->getFieldId()][$old_option_index] == "sum") {
620  $sel->setAlert($lng->txt("msg_input_is_required"));
621  $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
622  }
623  }
624  $single = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_single"), "sgl");
625  $details->addOption($single);
626  foreach ($items as $item) {
627  $obj_id = (int) $item[0];
628  $sub_type = (string) $item[1];
629  $sub_id = (int) $item[2];
630 
631  /*
632  * media objects are saved in adv_md_values with obj_id=0, and their actual obj_id
633  * as sub_id.
634  */
635  if ($sub_type === 'mob') {
636  $obj_id = $sub_id;
637  $sub_id = 0;
638  }
639 
640  $item_id = $obj_id . "_" . $sub_type . "_" . $sub_id;
641 
642  $type = ilObject::_lookupType($obj_id);
643  $type_title = $lng->txt("obj_" . $type);
644  $title = ' "' . ilObject::_lookupTitle($obj_id) . '"';
645 
646  if ($sub_id) {
647  $class = "ilObj" . $objDefinition->getClassName($type);
648  $class_path = $objDefinition->getLocation($type);
649  $ints = class_implements($class);
650  if (isset($ints["ilAdvancedMetaDataSubItems"])) {
652  $sub_title = $class::getAdvMDSubItemTitle($obj_id, $sub_type, $sub_id);
653  if ($sub_title) {
654  $title .= ' (' . $sub_title . ')';
655  }
656  }
657  }
658 
659  $sel = new ilSelectInputGUI(
660  $type_title . ' ' . $title,
661  "conf[" . $this->getFieldId() . "][" . $old_option_index . "][" . $item_id . "]"
662  );
663  $sel->setRequired(true);
664  $options = array(
665  "" => $lng->txt("please_select"),
666  self::REMOVE_ACTION_ID => $lng->txt("md_adv_confirm_definition_select_option_remove")
667  );
668  foreach ($this->options()->getOptions() as $new_option) {
669  $new_id = $new_option->optionID();
670  $new_value = $new_option->getTranslationInLanguage($this->default_language)->getValue();
671  $options['idx_' . $new_id] = $lng->txt("md_adv_confirm_definition_select_option_overwrite") . ': "' . $new_value . '"';
672  }
673  $sel->setOptions($options);
674 
675  // automatic reload does not work
676  if (isset($post_conf[$this->getFieldId()][$old_option_index][$item_id])) {
677  if ($post_conf[$this->getFieldId()][$old_option_index][$item_id]) {
678  $sel->setValue($post_conf[$this->getFieldId()][$old_option_index][$item_id]);
679  } elseif ($post_conf_det[$this->getFieldId()][$old_option_index] == "sgl") {
680  $sel->setAlert($lng->txt("msg_input_is_required"));
681  $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
682  }
683  }
684 
685  $single->addSubItem($sel);
686  }
687  }
688  }
689  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
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...
getItemByPostVar(string $a_post_var)
setValue(string $a_value)
This class represents a hidden form property in a property form.
static http()
Fetches the global http state from ILIAS.
This class represents a property in a property form.
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
setRequired(bool $a_required)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ prepareElementForEditor()

ilAdvancedMDFieldDefinitionSelect::prepareElementForEditor ( ilADTFormBridge  $a_bridge)

Definition at line 893 of file class.ilAdvancedMDFieldDefinitionSelect.php.

893  : void
894  {
895  assert($a_bridge instanceof ilADTEnumFormBridge);
896 
897  $a_bridge->setAutoSort(false);
898  }

◆ readOptions()

ilAdvancedMDFieldDefinitionSelect::readOptions ( )
protected

Definition at line 900 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\_clone(), ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getFieldId(), ilAdvancedMDFieldDefinition\getRecordId(), and options().

Referenced by __construct().

900  : void
901  {
902  if ($this->getFieldId()) {
903  $this->options = $this->db_gateway->readByID($this->getFieldId());
904  }
905  if (!isset($this->options)) {
907  }
908 
910  $this->default_language = $record->getDefaultLanguage();
911  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDFieldDefinitionSelect::save ( bool  $keep_pos_and_import_id = false,
bool  $keep_import_id = false 
)

Definition at line 697 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References saveOptions().

697  : void
698  {
699  parent::save($keep_pos_and_import_id, $keep_import_id);
700  $this->saveOptions();
701  }
+ Here is the call graph for this function:

◆ saveOptions()

ilAdvancedMDFieldDefinitionSelect::saveOptions ( )
protected

Definition at line 714 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\getFieldId(), and options().

Referenced by save().

714  : void
715  {
716  $this->db_gateway->create($this->getFieldId(), $this->options());
717  $this->options = $this->db_gateway->readByID($this->getFieldId());
718  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translateLegacyImportValueFromXML()

ilAdvancedMDFieldDefinitionSelect::translateLegacyImportValueFromXML ( string  $value)
protected

On import from <7 options are not given by index but by their label.

There is nothing in the XML by which one could tell apart legacy and standard imports, so we have to make a best guess here (32410).

Might fail for enums where the labels are integers. See also ilAdvancedMDFieldDefinitionGroupBased::importValueFromXML.

Definition at line 877 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getRecordId(), and options().

Referenced by ilAdvancedMDFieldDefinitionSelectMulti\importValueFromXML(), and importValueFromXML().

877  : string
878  {
879  if (is_numeric($value) && !is_null($this->options()->getOption((int) $value))) {
880  return $value;
881  }
882 
884  foreach ($this->options()->getOptions() as $option) {
885  if ($value === $option->getTranslationInLanguage($default_language)) {
886  return (string) $option->optionID();
887  }
888  }
889 
890  return $value;
891  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilAdvancedMDFieldDefinitionSelect::update ( )

Definition at line 720 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $parts, ilADTActiveRecordByType\create(), ilADTActiveRecordByType\deleteByPrimary(), findBySingleValue(), ilAdvancedMDFieldDefinition\getADTDefinition(), ilAdvancedMDFieldDefinition\getFieldId(), ilADTFactory\getInstance(), ilADTFactory\initActiveRecordByType(), ILIAS\Repository\int(), ilPCAMDPageList\migrateField(), ilDBConstants\T_INTEGER, and updateOptions().

720  : void
721  {
722  if (is_array($this->confirmed_objects) && count($this->confirmed_objects) > 0) {
723  // we need the "old" options for the search
724  $def = $this->getADTDefinition();
725  $def = clone($def);
726  $def->setOptions($this->old_options_array);
727  $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($def, false, true);
729 
730  $page_list_mappings = [];
731 
732  foreach ($this->confirmed_objects as $old_option => $item_ids) {
733  // get complete old values
734  $old_values = [];
735  foreach ($this->findBySingleValue($search, $old_option) as $item) {
736  $old_values[$item[0] . "_" . $item[1] . "_" . $item[2]] = $item[3];
737  }
738 
739  foreach ($item_ids as $item => $new_option) {
740  $parts = explode("_", $item);
741  $obj_id = (int) $parts[0];
742  $sub_type = $parts[1];
743  $sub_id = (int) $parts[2];
744 
745  // update existing value (with changed option)
746  if (isset($old_values[$item])) {
747  $old_id = $old_values[$item];
748 
749  $primary = array(
750  "obj_id" => array("integer", $obj_id),
751  "sub_type" => array("text", $sub_type),
752  "sub_id" => array("integer", $sub_id),
753  "field_id" => array("integer", $this->getFieldId())
754  );
755 
756  $id_old = array_merge(
757  $primary,
758  [
759  'value_index' => [ilDBConstants::T_INTEGER, $old_id]
760  ]
761  );
762  $id_new = array_merge(
763  $primary,
764  [
765  'value_index' => [ilDBConstants::T_INTEGER, $new_option]
766  ]
767  );
768  ilADTActiveRecordByType::deleteByPrimary('adv_md_values', $id_old, 'MultiEnum');
769 
770  if (is_numeric($new_option)) {
771  ilADTActiveRecordByType::deleteByPrimary('adv_md_values', $id_new, 'MultiEnum');
772  ilADTActiveRecordByType::create('adv_md_values', $id_new, 'MultiEnum');
773  }
774  }
775 
776  if ($sub_type == "wpg") {
777  // #15763 - adapt advmd page lists
778  $page_list_mappings[(string) $old_option] = (string) $new_option;
779  }
780  }
781  }
782 
783  if (!empty($page_list_mappings)) {
785  $this->getFieldId(),
786  $page_list_mappings
787  );
788  }
789 
790  $this->confirmed_objects = array();
791  }
792 
793  parent::update();
794  $this->updateOptions();
795  }
getADTDefinition()
Get ADT definition instance.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
static initActiveRecordByType()
Init active record by type.
static migrateField(int $a_field_id, array $mapping)
Migrate search/filter values on advmd change.
static deleteByPrimary(string $a_table, array $a_primary, ?string $a_type=null)
static create(string $table, array $fields, string $type)
findBySingleValue(ilADTSearchBridge $a_search, $a_value)
+ Here is the call graph for this function:

◆ updateOptions()

ilAdvancedMDFieldDefinitionSelect::updateOptions ( )
protected

Definition at line 708 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\getFieldId(), and options().

Referenced by update().

708  : void
709  {
710  $this->db_gateway->update($this->options());
711  $this->options = $this->db_gateway->readByID($this->getFieldId());
712  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $confirm_objects

array ilAdvancedMDFieldDefinitionSelect::$confirm_objects = []
protected

Definition at line 37 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ $confirm_objects_values

array ilAdvancedMDFieldDefinitionSelect::$confirm_objects_values = []
protected

Definition at line 38 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ $confirmed_objects

array ilAdvancedMDFieldDefinitionSelect::$confirmed_objects = null
protected

Definition at line 39 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ $db_gateway

Gateway ilAdvancedMDFieldDefinitionSelect::$db_gateway
private

Definition at line 47 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ $default_language

string ilAdvancedMDFieldDefinitionSelect::$default_language
protected

Definition at line 43 of file class.ilAdvancedMDFieldDefinitionSelect.php.

Referenced by importNewSelectOptions().

◆ $main_tpl

ilGlobalTemplateInterface ilAdvancedMDFieldDefinitionSelect::$main_tpl
private

Definition at line 45 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ $old_options_array

array ilAdvancedMDFieldDefinitionSelect::$old_options_array = null
protected

Definition at line 40 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ $options

SelectSpecificData ilAdvancedMDFieldDefinitionSelect::$options
protected

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

Referenced by options().

◆ ADD_NEW_ENTRY_ID

const ilAdvancedMDFieldDefinitionSelect::ADD_NEW_ENTRY_ID = "-advmd_add_new_entry-"
private

Definition at line 35 of file class.ilAdvancedMDFieldDefinitionSelect.php.

◆ REMOVE_ACTION_ID

const ilAdvancedMDFieldDefinitionSelect::REMOVE_ACTION_ID = "-iladvmdrm-"
private

Definition at line 34 of file class.ilAdvancedMDFieldDefinitionSelect.php.


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