ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAdvancedMDFieldDefinitionSelect Class Reference

AMD field type select. More...

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

Public Member Functions

 __construct (?int $a_field_id=null, string $language='')
 
 getType ()
 
 getSearchQueryParserValue (ilADTSearchBridge $a_adt_search)
 
 setOptions (array $a_values=null)
 
 getOptions ()
 
 getOptionTranslations ()
 
 getOptionTranslation (string $language)
 
 setOptionTranslations (array $translations)
 
 setOptionTranslationsForLanguage (array $translations, string $language)
 
 getFieldDefinitionForTableGUI (string $content_language)
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form, string $language='')
 
 importDefinitionFormPostValuesNeedsConfirmation ()
 
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 delete ()
 
 save (bool $a_keep_pos=false)
 
 update ()
 
 importXMLProperty (string $a_key, string $a_value)
 
 getValueForXML (ilADT $element)
 
 importValueFromXML (string $a_cdata)
 
 prepareElementForEditor (ilADTFormBridge $a_bridge)
 
- Public Member Functions inherited from ilAdvancedMDFieldDefinition
 __construct (?int $a_field_id=null, 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 $a_keep_pos=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)
 

Data Fields

const REMOVE_ACTION_ID = "-iladvmdrm-"
 
- Data Fields inherited from ilAdvancedMDFieldDefinition
const TYPE_SELECT = 1
 
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
 

Protected Member Functions

 initADTDefinition ()
 
 importFieldDefinition (array $a_def)
 
 getFieldDefinition ()
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
 
 addCreateOptionsFieldsToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled)
 
 addEditOptionsFieldsToDefinitionForm (array $options, ilPropertyFormGUI $a_form, bool $a_disabled)
 
 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)
 
 deleteOptionTranslations ()
 
 updateOptionTranslations ()
 
 saveOptionTranslations ()
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 
 translateLegacyImportValueFromXML (string $value)
 On import from <7 options are not given by index but by their label. More...
 
 import (array $a_data)
 
- Protected Member Functions inherited from ilAdvancedMDFieldDefinition
 init ()
 
 initADTDefinition ()
 Init adt instance. More...
 
 setADT (ilADT $a_adt)
 Set ADT instance. More...
 
 setFieldId (int $a_id)
 Set field_id. 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...
 
 getLastPosition ()
 Get last position of record. More...
 
 getDBProperties ()
 Get all definition properties for DB. More...
 
 import (array $a_data)
 Import from DB. More...
 
 read (?int $a_field_id)
 Read field definition. 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 $options = null
 
array $confirm_objects = []
 
array $confirm_objects_values = []
 
array $confirmed_objects = null
 
array $old_options = null
 
array $option_translations = []
 
- Protected Attributes inherited from ilAdvancedMDFieldDefinition
int $field_id = null
 
int $record_id = 0
 
string $import_id = ''
 
int $position = 0
 
string $title = ''
 
string $description = ''
 
bool $searchable = false
 
bool $required = false
 
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)
 
- Static Protected Member Functions inherited from ilAdvancedMDFieldDefinition
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 26 of file class.ilAdvancedMDFieldDefinitionSelect.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDFieldDefinitionSelect::__construct ( ?int  $a_field_id = null,
string  $language = '' 
)

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

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

38  {
39  parent::__construct($a_field_id, $language);
40  }
__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 155 of file class.ilAdvancedMDFieldDefinitionSelect.php.

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

Referenced by addCustomFieldToDefinitionForm().

158  : void {
159  $field = new ilTextInputGUI($this->lng->txt('meta_advmd_select_options'), 'opts_new');
160  $field->setRequired(true);
161  $field->setMulti(true);
162  $field->setMaxLength(255);
163  $field->setDisabled($a_disabled);
164 
165  $a_form->addItem($field);
166  }
+ 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(), getOptions(), and ilAdvancedMDFieldDefinition\useDefaultLanguageMode().

139  : void {
140  if (!$this->useDefaultLanguageMode($language)) {
141  $this->addCustomFieldToDefinitionFormInTranslationMode($a_form, $a_disabled, $language);
142  return;
143  }
144 
145  $options = $this->getOptions();
146 
147  if (is_null($options)) {
148  $this->addCreateOptionsFieldsToDefinitionForm($a_form, $a_disabled);
149  return;
150  }
151 
152  $this->addEditOptionsFieldsToDefinitionForm($options, $a_form, $a_disabled);
153  }
addCustomFieldToDefinitionFormInTranslationMode(ilPropertyFormGUI $form, bool $disabled, string $language='')
addEditOptionsFieldsToDefinitionForm(array $options, ilPropertyFormGUI $a_form, bool $a_disabled)
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 247 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References $index, ilAdvancedMDFieldDefinition\$language, ilAdvancedMDFieldDefinition\$title, ilAdvancedMDRecord\_getInstanceByRecordId(), ilPropertyFormGUI\addItem(), getOptions(), getOptionTranslation(), and ILIAS\Repository\lng().

Referenced by addCustomFieldToDefinitionForm().

251  : void {
252  $default_language = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id)->getDefaultLanguage();
253 
254  $translation = $this->getOptionTranslation($language);
255 
256  $first = true;
257  foreach ($this->getOptions() as $index => $option) {
258  $title = '';
259  if ($first) {
260  $title = $this->lng->txt("meta_advmd_select_options");
261  }
262  $text = new ilTextInputGUI(
263  $title,
264  'opts__' . $language . '__' . $index
265  );
266  if (isset($translation[$index])) {
267  $text->setValue($translation[$index]);
268  }
269  $text->setInfo($default_language . ': ' . $option);
270  $text->setMaxLength(255);
271  $text->setRequired(true);
272 
273  $first = false;
274  $form->addItem($text);
275  }
276  }
$index
Definition: metadata.php:145
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 ( array  $options,
ilPropertyFormGUI  $a_form,
bool  $a_disabled 
)
protected

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

References ilAdvancedMDFieldDefinition\$position, ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setDisabled().

Referenced by addCustomFieldToDefinitionForm().

172  : void {
173  $entries = new ilRadioGroupInputGUI(
174  $this->lng->txt('meta_advmd_select_options_edit'),
175  'opts_edit'
176  );
177 
178  $position_identifiers = ['0' => $this->lng->txt('meta_advmd_select_first_position_identifier')];
179  $last_idx = 0;
180  foreach ($options as $idx => $option) {
181  $position_identifiers[$idx + 1] = sprintf(
182  $this->lng->txt('meta_advmd_select_position_identifier'),
183  $option
184  );
185  $last_idx = $idx + 1;
186  }
187 
188  $options[$last_idx] = $this->lng->txt('meta_advmd_select_new_option');
189 
190  $disabled_checkbox_overwrites = [];
191 
192  foreach ($options as $idx => $option) {
193  $radio = new ilRadioOption($option, (string) $idx);
194 
195  $value = new ilTextInputGUI(
196  $this->lng->txt('meta_advmd_select_option_value'),
197  'value_' . $idx
198  );
199  $value->setRequired(true);
200  $value->setMaxLength(255);
201  $value->setValue($idx !== $last_idx ? $option : '');
202  $value->setDisabled($a_disabled);
203  $radio->addSubItem($value);
204 
206  $this->lng->txt('meta_advmd_select_option_position'),
207  'position_' . $idx
208  );
209  $relevant_position_identifiers = $position_identifiers;
210  unset($relevant_position_identifiers[$idx + 1]);
211  $position->setOptions($relevant_position_identifiers);
212  $position->setValue($idx);
213  $position->setDisabled($a_disabled);
214  $radio->addSubItem($position);
215 
216  if ($idx !== $last_idx && $last_idx > 1) {
217  $delete = new ilCheckboxInputGUI(
218  $this->lng->txt('meta_advmd_select_delete_option'),
219  'delete_me_' . $idx
220  );
221  $delete->setDisabled($a_disabled);
222  $radio->addSubItem($delete);
223 
224  /*
225  * If disabled, checkboxes don't come with a hidden input to write to post,
226  * this is a workaround.
227  */
228  if ($a_disabled) {
229  $hidden = new ilHiddenInputGUI('delete_me_' . $idx);
230  $hidden->setValue("1");
231  $disabled_checkbox_overwrites[] = $hidden;
232  }
233  }
234 
235  $radio->setDisabled($a_disabled);
236  $entries->addOption($radio);
237  }
238 
239  $entries->setDisabled($a_disabled);
240  $a_form->addItem($entries);
241 
242  foreach ($disabled_checkbox_overwrites as $input) {
243  $a_form->addItem($input);
244  }
245  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
setDisabled(bool $a_disabled)
+ 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 800 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References getOptions(), getOptionTranslations(), and ilXmlWriter\xmlElement().

800  : void
801  {
802  foreach ($this->getOptions() as $value) {
803  $a_writer->xmlElement('FieldValue', null, $value);
804  }
805  foreach ($this->getOptionTranslations() as $lang_key => $translations) {
806  foreach ((array) $translations as $value) {
807  $a_writer->xmlElement('FieldValue', ['id' => $lang_key], $value);
808  }
809  }
810  }
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:

◆ buildConfirmedObjects()

ilAdvancedMDFieldDefinitionSelect::buildConfirmedObjects ( ilPropertyFormGUI  $a_form)
protected

Process custom post values from definition form.

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

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

Referenced by importNewSelectOptions().

281  : ?array
282  {
283  // #15719
284  $recipes = $a_form->getInput("conf_det");
285  if (is_array($recipes[$this->getFieldId()] ?? null)) {
286  $recipes = $recipes[$this->getFieldId()];
287  $sum = $a_form->getInput("conf_det_act");
288  $sum = $sum[$this->getFieldId()];
289  $sgl = $a_form->getInput("conf");
290  $sgl = $sgl[$this->getFieldId()];
291 
292  $res = array();
293  foreach ($recipes as $old_option => $recipe) {
294  $sum_act = $sum[$old_option];
295  $sgl_act = $sgl[$old_option];
296 
297  if ($recipe == "sum") {
298  // #18885
299  if (!$sum_act) {
300  return null;
301  }
302 
303  foreach (array_keys($sgl_act) as $obj_idx) {
304  if ($sum_act == self::REMOVE_ACTION_ID) {
305  $sum_act = "";
306  }
307  if (substr($sum_act, 0, 4) == 'idx_') {
308  $parts = explode('_', $sum_act);
309  $sum_act = $parts[1];
310  }
311  $res[$old_option][$obj_idx] = $sum_act;
312  }
313  } else {
314  // #18885
315  foreach ($sgl_act as $sgl_index => $sgl_item) {
316  if (!$sgl_item) {
317  return null;
318  } elseif ($sgl_item == self::REMOVE_ACTION_ID) {
319  $sgl_act[$sgl_index] = "";
320  }
321  if (substr($sgl_item, 0, 4) == 'idx_') {
322  $parts = explode('_', $sgl_item);
323  $sgl_act[$sgl_index] = $parts[1];
324  }
325  }
326 
327  $res[$old_option] = $sgl_act;
328  }
329  }
330  return $res;
331  }
332  return null;
333  }
$res
Definition: ltiservices.php:69
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
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:

◆ delete()

ilAdvancedMDFieldDefinitionSelect::delete ( )

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

References deleteOptionTranslations().

663  : void
664  {
665  $this->deleteOptionTranslations();
666  parent::delete();
667  }
+ Here is the call graph for this function:

◆ deleteOptionTranslations()

ilAdvancedMDFieldDefinitionSelect::deleteOptionTranslations ( )
protected

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

References $query, ilAdvancedMDFieldDefinition\getFieldId(), and ilDBConstants\T_INTEGER.

Referenced by delete(), and updateOptionTranslations().

675  : void
676  {
677  $query = 'delete from adv_mdf_enum ' .
678  'where field_id = ' . $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER);
679  $this->db->manipulate($query);
680  }
$query
+ 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 490 of file class.ilAdvancedMDFieldDefinitionSelect.php.

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

Referenced by importNewSelectOptions(), and update().

490  : array
491  {
492  $res = array();
493  $a_search->getADT()->setSelections((array) $a_value);
494  $condition = $a_search->getSQLCondition('value_index');
495 
497  "adv_md_values",
498  "Enum",
499  $this->getFieldId(),
500  $condition
501  );
502  if ($in_use) {
503  foreach ($in_use as $item) {
504  $res[] = array($item["obj_id"], $item["sub_type"], $item["sub_id"], $item["value_index"]);
505  }
506  }
507  return $res;
508  }
$res
Definition: ltiservices.php:69
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 114 of file class.ilAdvancedMDFieldDefinitionSelect.php.

114  : array
115  {
116  return [];
117  }

◆ getFieldDefinitionForTableGUI()

ilAdvancedMDFieldDefinitionSelect::getFieldDefinitionForTableGUI ( string  $content_language)

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

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

119  : array
120  {
121  global $DIC;
122 
123  $lng = $DIC['lng'];
124 
125  if (strlen($content_language)) {
126  $options = $this->getOptionTranslation($content_language);
127  } else {
128  $options = $this->getOptions();
129  }
130  return [
131  $lng->txt("meta_advmd_select_options") => implode(",", $options)
132  ];
133  }
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...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ getOptions()

◆ getOptionTranslation()

ilAdvancedMDFieldDefinitionSelect::getOptionTranslation ( string  $language)

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

References ilAdvancedMDFieldDefinition\$language, and getOptionTranslations().

Referenced by addCustomFieldToDefinitionFormInTranslationMode(), getFieldDefinitionForTableGUI(), and importNewSelectOptions().

90  : array
91  {
92  if (isset($this->getOptionTranslations()[$language])) {
93  return $this->getOptionTranslations()[$language];
94  }
95  return [];
96  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptionTranslations()

ilAdvancedMDFieldDefinitionSelect::getOptionTranslations ( )

◆ getSearchQueryParserValue()

ilAdvancedMDFieldDefinitionSelect::getSearchQueryParserValue ( ilADTSearchBridge  $a_adt_search)

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

47  : string
48  {
49  return (string) $a_adt_search->getADT()->getSelection();
50  }

◆ getType()

ilAdvancedMDFieldDefinitionSelect::getType ( )

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

42  : int
43  {
44  return self::TYPE_SELECT;
45  }

◆ getValueForXML()

ilAdvancedMDFieldDefinitionSelect::getValueForXML ( ilADT  $element)

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

821  : string
822  {
823  return $element->getSelection();
824  }

◆ import()

ilAdvancedMDFieldDefinitionSelect::import ( array  $a_data)
protected

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

References $query, $res, ilAdvancedMDFieldDefinition\_clone(), ilAdvancedMDRecord\_getInstanceByRecordId(), ilDBConstants\FETCHMODE_OBJECT, ilAdvancedMDFieldDefinition\getFieldId(), ilAdvancedMDFieldDefinition\getRecordId(), ILIAS\Repository\int(), setOptions(), setOptionTranslations(), and ilDBConstants\T_INTEGER.

859  : void
860  {
861  parent::import($a_data);
862 
863  $query = 'select * from adv_mdf_enum ' .
864  'where field_id = ' . $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER) . ' ' .
865  'order by idx';
866  $res = $this->db->query($query);
867  $options = [];
868  $default = [];
870  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
871  if ($row->lang_code == $record->getDefaultLanguage()) {
872  $default[(int) $row->idx] = (string) $row->value;
873  }
874  $options[(string) $row->lang_code][(int) $row->idx] = (string) $row->value;
875  }
876  $this->setOptions($default);
878  }
$res
Definition: ltiservices.php:69
static _getInstanceByRecordId(int $a_record_id)
$query
+ Here is the call graph for this function:

◆ importCustomDefinitionFormPostValues()

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

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

References ilAdvancedMDFieldDefinition\$language, and importNewSelectOptions().

335  : void
336  {
337  $this->importNewSelectOptions(true, $a_form, $language);
338  }
importNewSelectOptions(bool $multi, ilPropertyFormGUI $a_form, string $language='')
+ Here is the call graph for this function:

◆ importDefinitionFormPostValuesNeedsConfirmation()

ilAdvancedMDFieldDefinitionSelect::importDefinitionFormPostValuesNeedsConfirmation ( )

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

522  : bool
523  {
524  return is_array($this->confirm_objects) && count($this->confirm_objects) > 0;
525  }

◆ importFieldDefinition()

ilAdvancedMDFieldDefinitionSelect::importFieldDefinition ( array  $a_def)
protected

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

References setOptions().

108  : void
109  {
110  // options (field_values from adv_mdf_field_definitions are not used)
111  $this->setOptions([]);
112  }
+ Here is the call graph for this function:

◆ importNewSelectOptions()

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

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

References ilAdvancedMDFieldDefinition\$language, ilAdvancedMDRecord\_getInstanceByRecordId(), buildConfirmedObjects(), findBySingleValue(), ilAdvancedMDFieldDefinition\getADTDefinition(), ilPropertyFormGUI\getInput(), ilADTFactory\getInstance(), getOptionTranslation(), getOptionTranslations(), ilAdvancedMDFieldDefinition\getRecordId(), importTranslatedFormPostValues(), ILIAS\Repository\int(), setOptions(), setOptionTranslationsForLanguage(), and ilAdvancedMDFieldDefinition\useDefaultLanguageMode().

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

344  : void {
345  if (!$this->useDefaultLanguageMode($language)) {
346  $this->importTranslatedFormPostValues($a_form, $language);
347  return;
348  }
349 
350  if (!strlen($language)) {
351  $language = ilAdvancedMDRecord::_getInstanceByRecordId($this->getRecordId())->getDefaultLanguage();
352  }
353 
354  $old = $this->getOptionTranslation($language);
355  if ($new = $a_form->getInput('opts_new')) {
356  $this->setOptions($new);
358  return;
359  }
360 
361  $edited_idx = $a_form->getInput('opts_edit');
362  if($edited_idx === '' || is_null($edited_idx)) {
363  return;
364  }
365  $edited_idx = (int) $edited_idx;
366 
367  $new_value = (string) $a_form->getInput('value_' . $edited_idx);
368  $new_position = (int) $a_form->getInput('position_' . $edited_idx);
369  $delete = (bool) $a_form->getInput('delete_me_' . $edited_idx);
370 
371  /*
372  * Build the new options, keeping track of how indices change in a map.
373  */
374  $new = [];
375  $index_map = [];
376  $new_idx = 0;
377 
378  /*
379  * If an entry is is moved down, shift new position to reflect entry not
380  * being in its old position anymore.
381  */
382  if ($new_position > $edited_idx) {
383  $new_position -= 1;
384  }
385 
386  foreach ($old as $old_idx => $old_value) {
387  if ($old_idx === $edited_idx) {
388  continue;
389  }
390 
391  if (!$delete && $new_idx === $new_position) {
392  $new[$new_idx] = $new_value;
393  /*
394  * Newly added indices must not be used as 'old indices' in the index map,
395  * otherwise the search doesn't work.
396  */
397  if ($edited_idx !== $new_idx && array_key_exists($edited_idx, $old)) {
398  $index_map[$edited_idx] = $new_idx;
399  }
400  $new_idx++;
401  }
402 
403  $new[$new_idx] = $old_value;
404  if ($old_idx !== $new_idx) {
405  $index_map[$old_idx] = $new_idx;
406  }
407  $new_idx++;
408  }
409 
410  /*
411  * If an entry is moved to or added at the end, append it.
412  */
413  if (!$delete && $new_idx === $new_position) {
414  $new[$new_idx] = $new_value;
415  if ($edited_idx !== $new_idx) {
416  $index_map[$edited_idx] = $new_idx;
417  }
418  }
419 
420  /*
421  * Prepare migration of existing values, prepare for confirmation if more
422  * user input is required.
423  */
424  if ($delete || count($index_map)) {
425  $this->confirmed_objects = $this->buildConfirmedObjects($a_form);
426  $already_confirmed = is_array($this->confirmed_objects);
427 
428  $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance(
429  $this->getADTDefinition(),
430  false,
431  $multi
432  );
433 
434  /*
435  * If option is to be deleted, collect objects whith that value and
436  * and prepare confirmation of their migration.
437  */
438  if ($delete) {
439  $in_use = $this->findBySingleValue($search, $edited_idx);
440  foreach ($in_use as $item) {
441  if (!$already_confirmed) {
442  $this->confirm_objects[$edited_idx][] = $item;
443  $this->confirm_objects_values[$edited_idx] = $old[$edited_idx];
444  }
445  }
446  }
447 
448  /*
449  * Prepare objects that can be automatically migrated.
450  */
451  foreach ($index_map as $old_idx => $new_idx) {
452  $in_use = $this->findBySingleValue($search, $old_idx);
453  foreach ($in_use as $item) {
454  $complete_id = $item[0] . "_" . $item[1] . "_" . $item[2];
455  $this->confirmed_objects[$old_idx][$complete_id] = $new_idx;
456  }
457  }
458  }
459  $this->old_options = $old;
460 
461  /*
462  * Finally set the new options, and change the indices of translations
463  * according to the index map.
464  */
466  $this->setOptions($new);
467  foreach ($this->getOptionTranslations() as $current_lang => $options) {
468  $current_lang = (string) $current_lang;
469  if ($current_lang === $language) {
470  continue;
471  }
472  $updated_translations = [];
473  foreach ($options as $idx => $option) {
474  if (array_key_exists($idx, $index_map)) {
475  $updated_translations[$index_map[$idx]] = $option;
476  continue;
477  }
478  $updated_translations[$idx] = $option;
479  }
480  $this->setOptionTranslationsForLanguage($updated_translations, $current_lang);
481  }
482  }
getADTDefinition()
Get ADT definition instance.
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)
static _getInstanceByRecordId(int $a_record_id)
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)
setOptionTranslationsForLanguage(array $translations, string $language)
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 510 of file class.ilAdvancedMDFieldDefinitionSelect.php.

References ilAdvancedMDFieldDefinition\$language, ilPropertyFormGUI\getInput(), getOptions(), getOptionTranslations(), and setOptionTranslations().

Referenced by importNewSelectOptions().

510  : void
511  {
512  $translated_options = [];
513  foreach ($this->getOptions() as $idx => $value) {
514  $value = $form->getInput('opts__' . $language . '__' . $idx);
515  $translated_options[] = trim($value);
516  }
517  $translations = $this->getOptionTranslations();
518  $translations[$language] = $translated_options;
519  $this->setOptionTranslations($translations);
520  }
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 826 of file class.ilAdvancedMDFieldDefinitionSelect.php.

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

826  : void
827  {
828  $a_cdata = $this->translateLegacyImportValueFromXML($a_cdata);
829  $this->getADT()->setSelection($a_cdata);
830  }
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 
)

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

812  : void
813  {
814  if (!$a_key) {
815  $this->options[] = $a_value;
816  } else {
817  $this->option_translations[$a_key][] = $a_value;
818  }
819  }

◆ initADTDefinition()

ilAdvancedMDFieldDefinitionSelect::initADTDefinition ( )
protected

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

References ilAdvancedMDFieldDefinition\$language, ilADTFactory\getInstance(), getOptions(), getOptionTranslations(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

53  {
54  $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("Enum");
55  $def->setNumeric(false);
56 
57  $options = $this->getOptions();
58  $translated_options = [];
59  if (isset($this->getOptionTranslations()[$this->language])) {
60  $translated_options = $this->getOptionTranslations()[$this->language];
61  }
62  $def->setOptions(array_replace($options, $translated_options));
63  return $def;
64  }
ADT definition base class.
+ Here is the call graph for this function:

◆ prepareCustomDefinitionFormConfirmation()

ilAdvancedMDFieldDefinitionSelect::prepareCustomDefinitionFormConfirmation ( ilPropertyFormGUI  $a_form)

PhpUndefinedMethodInspection

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

References ILIAS\LTI\ToolProvider\$details, $DIC, ilAdvancedMDFieldDefinition\$lng, ilAdvancedMDFieldDefinition\$title, $type, ilObject\_lookupTitle(), ilObject\_lookupType(), ilPropertyFormGUI\addItem(), ilAdvancedMDFieldDefinition\getFieldId(), ilPropertyFormGUI\getItemByPostVar(), getOptions(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ilHiddenInputGUI\setValue(), and ilLanguage\txt().

526  : void
527  {
528  global $DIC;
529 
530  $lng = $DIC['lng'];
531  $objDefinition = $DIC['objDefinition'];
532 
533  $post_conf_det = (array) ($this->http->request()->getParsedBody()['conf_det'] ?? []);
534  $post_conf = (array) ($this->http->request()->getParsedBody()['conf'] ?? []);
535 
536  $custom_field = $a_form->getItemByPostVar('opts_edit');
537  $custom_field->setDisabled(true);
538  foreach ($custom_field->getSubInputItemsRecursive() as $sub_input) {
539  $sub_input->setDisabled(true);
540  /*
541  * If disabled, checkboxes don't come with a hidden input to write to post,
542  * this is a workaround.
543  */
544  if ($sub_input instanceof ilCheckboxInputGUI) {
545  $hidden = new ilHiddenInputGUI($sub_input->getPostVar());
546  $hidden->setValue($sub_input->getValue());
547  $a_form->addItem($hidden);
548  }
549  }
550 
551  if (is_array($this->confirm_objects) && count($this->confirm_objects) > 0) {
552  $sec = new ilFormSectionHeaderGUI();
553  $sec->setTitle($lng->txt("md_adv_confirm_definition_select_section"));
554  $a_form->addItem($sec);
555 
556  foreach ($this->confirm_objects as $old_option_index => $items) {
557  $old_option_value = $this->confirm_objects_values[$old_option_index];
559  $lng->txt("md_adv_confirm_definition_select_option") . ': "' . $old_option_value . '"',
560  "conf_det[" . $this->getFieldId() . "][" . $old_option_index . "]"
561  );
562  $details->setRequired(true);
563  $details->setValue("sum");
564  $a_form->addItem($details);
565 
566  // automatic reload does not work
567  if (isset($post_conf_det[$this->getFieldId()][$old_option_index])) {
568  $details->setValue($post_conf_det[$this->getFieldId()][$old_option_index]);
569  }
570 
571  $sum = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_all"), "sum");
572  $details->addOption($sum);
573 
574  $sel = new ilSelectInputGUI(
575  $lng->txt("md_adv_confirm_definition_select_option_all_action"),
576  "conf_det_act[" . $this->getFieldId() . "][" . $old_option_index . "]"
577  );
578  $sel->setRequired(true);
579  $options = array(
580  "" => $lng->txt("please_select"),
581  self::REMOVE_ACTION_ID => $lng->txt("md_adv_confirm_definition_select_option_remove")
582  );
583  foreach ($this->getOptions() as $new_option_index => $new_option) {
584  $options['idx_' . $new_option_index] = $lng->txt("md_adv_confirm_definition_select_option_overwrite") . ': "' . $new_option . '"';
585  }
586  $sel->setOptions($options);
587  $sum->addSubItem($sel);
588 
589  // automatic reload does not work
590  if (isset($post_conf_det[$this->getFieldId()][$old_option_index])) {
591  if ($post_conf_det[$this->getFieldId()][$old_option_index]) {
592  $sel->setValue($post_conf_det[$this->getFieldId()][$old_option_index]);
593  } elseif ($post_conf_det[$this->getFieldId()][$old_option_index] == "sum") {
594  $sel->setAlert($lng->txt("msg_input_is_required"));
595  $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
596  }
597  }
598  $single = new ilRadioOption($lng->txt("md_adv_confirm_definition_select_option_single"), "sgl");
599  $details->addOption($single);
600  foreach ($items as $item) {
601  $obj_id = (int) $item[0];
602  $sub_type = (string) $item[1];
603  $sub_id = (int) $item[2];
604 
605  /*
606  * media objects are saved in adv_md_values with obj_id=0, and their actual obj_id
607  * as sub_id.
608  */
609  if ($sub_type === 'mob') {
610  $obj_id = $sub_id;
611  $sub_id = 0;
612  }
613 
614  $item_id = $obj_id . "_" . $sub_type . "_" . $sub_id;
615 
616  $type = ilObject::_lookupType($obj_id);
617  $type_title = $lng->txt("obj_" . $type);
618  $title = ' "' . ilObject::_lookupTitle($obj_id) . '"';
619 
620  if ($sub_id) {
621  $class = "ilObj" . $objDefinition->getClassName($type);
622  $class_path = $objDefinition->getLocation($type);
623  $ints = class_implements($class);
624  if (isset($ints["ilAdvancedMetaDataSubItems"])) {
626  $sub_title = $class::getAdvMDSubItemTitle($obj_id, $sub_type, $sub_id);
627  if ($sub_title) {
628  $title .= ' (' . $sub_title . ')';
629  }
630  }
631  }
632 
633  $sel = new ilSelectInputGUI(
634  $type_title . ' ' . $title,
635  "conf[" . $this->getFieldId() . "][" . $old_option_index . "][" . $item_id . "]"
636  );
637  $sel->setRequired(true);
638  $options = array(
639  "" => $lng->txt("please_select"),
640  self::REMOVE_ACTION_ID => $lng->txt("md_adv_confirm_definition_select_option_remove")
641  );
642  foreach ($this->getOptions() as $new_option_index => $new_option) {
643  $options['idx_' . $new_option_index] = $lng->txt("md_adv_confirm_definition_select_option_overwrite") . ': "' . $new_option . '"';
644  }
645  $sel->setOptions($options);
646 
647  // automatic reload does not work
648  if (isset($post_conf[$this->getFieldId()][$old_option_index][$item_id])) {
649  if ($post_conf[$this->getFieldId()][$old_option_index][$item_id]) {
650  $sel->setValue($post_conf[$this->getFieldId()][$old_option_index][$item_id]);
651  } elseif ($post_conf_det[$this->getFieldId()][$old_option_index] == "sgl") {
652  $sel->setAlert($lng->txt("msg_input_is_required"));
653  $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
654  }
655  }
656 
657  $single->addSubItem($sel);
658  }
659  }
660  }
661  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
$type
getItemByPostVar(string $a_post_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setValue(string $a_value)
This class represents a checkbox property in a property form.
global $DIC
Definition: feed.php:28
array $details
Details for error message relating to last request processed.
Definition: System.php:109
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
This class represents a property in a property form.
static _lookupTitle(int $obj_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ prepareElementForEditor()

ilAdvancedMDFieldDefinitionSelect::prepareElementForEditor ( ilADTFormBridge  $a_bridge)

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

852  : void
853  {
854  assert($a_bridge instanceof ilADTEnumFormBridge);
855 
856  $a_bridge->setAutoSort(false);
857  }

◆ save()

ilAdvancedMDFieldDefinitionSelect::save ( bool  $a_keep_pos = false)

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

References saveOptionTranslations().

669  : void
670  {
671  parent::save($a_keep_pos);
672  $this->saveOptionTranslations();
673  }
+ Here is the call graph for this function:

◆ saveOptionTranslations()

ilAdvancedMDFieldDefinitionSelect::saveOptionTranslations ( )
protected

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

References $query, ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getFieldId(), getOptions(), getOptionTranslations(), ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Referenced by save(), and updateOptionTranslations().

688  : void
689  {
690  $options = $this->getOptionTranslations();
691  /*
692  * e.g. on import from <7 no translations are set, so one has to save
693  * the default options for the default language (32410).
694  */
695  if (empty($options)) {
696  $record = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id);
697  $options = [$record->getDefaultLanguage() => $this->getOptions()];
698  }
699  foreach ($options as $lang_key => $options_in_lang) {
700  foreach ($options_in_lang as $idx => $option) {
701  $query = 'insert into adv_mdf_enum (field_id, lang_code, idx, value )' .
702  'values ( ' .
703  $this->db->quote($this->getFieldId(), ilDBConstants::T_INTEGER) . ', ' .
704  $this->db->quote($lang_key, ilDBConstants::T_TEXT) . ', ' .
705  $this->db->quote($idx, ilDBConstants::T_INTEGER) . ', ' .
706  $this->db->quote($option, ilDBConstants::T_TEXT) .
707  ')';
708  $this->db->manipulate($query);
709  }
710  }
711  }
static _getInstanceByRecordId(int $a_record_id)
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOptions()

ilAdvancedMDFieldDefinitionSelect::setOptions ( array  $a_values = null)

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

Referenced by import(), importFieldDefinition(), and importNewSelectOptions().

66  : void
67  {
68  if ($a_values !== null) {
69  foreach ($a_values as $idx => $value) {
70  $a_values[$idx] = trim($value);
71  if (!$a_values[$idx]) {
72  unset($a_values[$idx]);
73  }
74  }
75  $a_values = array_unique($a_values);
76  }
77  $this->options = $a_values;
78  }
+ Here is the caller graph for this function:

◆ setOptionTranslations()

ilAdvancedMDFieldDefinitionSelect::setOptionTranslations ( array  $translations)

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

Referenced by import(), and importTranslatedFormPostValues().

98  : void
99  {
100  $this->option_translations = $translations;
101  }
+ Here is the caller graph for this function:

◆ setOptionTranslationsForLanguage()

ilAdvancedMDFieldDefinitionSelect::setOptionTranslationsForLanguage ( array  $translations,
string  $language 
)

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

References ilAdvancedMDFieldDefinition\$language.

Referenced by importNewSelectOptions().

103  : void
104  {
105  $this->option_translations[$language] = $translations;
106  }
+ 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 841 of file class.ilAdvancedMDFieldDefinitionSelect.php.

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

841  : string
842  {
843  if (
844  !in_array($value, array_keys($this->options)) &&
845  in_array($value, $this->options)
846  ) {
847  $value = (string) array_search($value, $this->options);
848  }
849  return $value;
850  }
+ Here is the caller graph for this function:

◆ update()

ilAdvancedMDFieldDefinitionSelect::update ( )

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

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

713  : void
714  {
715  if (is_array($this->confirmed_objects) && count($this->confirmed_objects) > 0) {
716  // we need the "old" options for the search
717  $def = $this->getADTDefinition();
718  $def = clone($def);
719  $def->setOptions($this->old_options);
720  $search = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($def, false, true);
722 
723  $page_list_mappings = [];
724 
725  foreach ($this->confirmed_objects as $old_option => $item_ids) {
726  // get complete old values
727  $old_values = array();
728  foreach ($this->findBySingleValue($search, $old_option) as $item) {
729  $old_values[$item[0] . "_" . $item[1] . "_" . $item[2]] = $item[3];
730  }
731 
732  foreach ($item_ids as $item => $new_option) {
733  $parts = explode("_", $item);
734  $obj_id = $parts[0];
735  $sub_type = $parts[1];
736  $sub_id = $parts[2];
737 
738  // update existing value (with changed option)
739  if (isset($old_values[$item])) {
740  $old_value = $old_values[$item];
741  // find changed option in old value
742  //$old_value = explode(ilADTMultiEnumDBBridge::SEPARATOR, $old_values[$item]);
743  // remove separators
744  //array_shift($old_value);
745  //array_pop($old_value);
746 
747  //$old_idx = array_keys($old_value, $old_option);
748  $old_idx = $old_value;
749  if (isset($old_idx)) {
750  $primary = array(
751  "obj_id" => array("integer", $obj_id),
752  "sub_type" => array("text", $sub_type),
753  "sub_id" => array("integer", $sub_id),
754  "field_id" => array("integer", $this->getFieldId())
755  );
756 
757  $index_old = array_merge(
758  $primary,
759  [
760  'value_index' => [ilDBConstants::T_INTEGER, $old_idx]
761  ]
762  );
763  $index_new = array_merge(
764  $primary,
765  [
766  'value_index' => [ilDBConstants::T_INTEGER, $new_option]
767  ]
768  );
769  ilADTActiveRecordByType::deleteByPrimary('adv_md_values', $index_old, 'MultiEnum');
770 
771  if (is_numeric($new_option)) {
772  ilADTActiveRecordByType::deleteByPrimary('adv_md_values', $index_new, 'MultiEnum');
773  ilADTActiveRecordByType::create('adv_md_values', $index_new, 'MultiEnum');
774  } else {
775  }
776  }
777  }
778 
779  if ($sub_type == "wpg") {
780  // #15763 - adapt advmd page lists
781  $page_list_mappings[(string) $old_option] = (string) $new_option;
782  }
783  }
784  }
785 
786  if (!empty($page_list_mappings)) {
788  $this->getFieldId(),
789  $page_list_mappings
790  );
791  }
792 
793  $this->confirmed_objects = array();
794  }
795 
796  parent::update();
797  $this->updateOptionTranslations();
798  }
getADTDefinition()
Get ADT definition instance.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
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:

◆ updateOptionTranslations()

ilAdvancedMDFieldDefinitionSelect::updateOptionTranslations ( )
protected

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

References deleteOptionTranslations(), and saveOptionTranslations().

Referenced by update().

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

◆ $confirm_objects_values

array ilAdvancedMDFieldDefinitionSelect::$confirm_objects_values = []
protected

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

◆ $confirmed_objects

array ilAdvancedMDFieldDefinitionSelect::$confirmed_objects = null
protected

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

◆ $old_options

array ilAdvancedMDFieldDefinitionSelect::$old_options = null
protected

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

◆ $option_translations

array ilAdvancedMDFieldDefinitionSelect::$option_translations = []
protected

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

Referenced by getOptionTranslations().

◆ $options

array ilAdvancedMDFieldDefinitionSelect::$options = null
protected

◆ REMOVE_ACTION_ID

const ilAdvancedMDFieldDefinitionSelect::REMOVE_ACTION_ID = "-iladvmdrm-"

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


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