ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAdvancedMDSettingsGUI Class Reference
+ Collaboration diagram for ilAdvancedMDSettingsGUI:

Public Member Functions

 __construct (int $a_context, int $a_ref_id, ?string $a_obj_type=null, $a_sub_type=null)
 Constructor @access public. More...
 
 executeCommand ()
 
 showRecords ()
 
 updateSubstitutions ()
 Update substitution @access public. More...
 
 exportRecords ()
 Export records @access public. More...
 
 downloadFile ()
 Download XML file @access public. More...
 
 confirmDeleteFiles ()
 confirm delete files @access public More...
 
 deleteFiles ()
 Delete files @access public. More...
 
 confirmDeleteRecords ()
 Confirm delete @access public. More...
 
 deleteRecords ()
 Permanently delete records @access public. More...
 
 updateRecords ()
 Save records (assigned object typed) @access public. More...
 
 confirmDeleteFields ()
 
 deleteFields ()
 
 editRecord (?ilPropertyFormGUI $form=null)
 
 updateFields ()
 Update fields @access public. More...
 
 updateRecord ()
 Update record @access public. More...
 
 createRecord (?ilPropertyFormGUI $form=null)
 Show @access public. More...
 
 importRecord ()
 
 saveRecord ()
 Save record @access public. More...
 
 editField (?ilPropertyFormGUI $a_form=null)
 Edit field @access public. More...
 
 updateField ()
 Update field @access public. More...
 
 createField (?ilPropertyFormGUI $a_form=null)
 Show field type selection @access public. More...
 
 saveField ()
 
 editComplexOption (?ilPropertyFormGUI $a_form=null)
 
 updateComplexOption ()
 

Data Fields

const CONTEXT_ADMINISTRATION = 1
 
const CONTEXT_OBJECT = 2
 

Protected Member Functions

 getRecordIdFromQuery ()
 
 getRecordIdsFromPost ()
 
 getFieldIdFromQuery ()
 
 getFieldIdsFromPost ()
 
 getFileIdsFromPost ()
 
 getFieldTypeFromQuery ()
 
 getFieldTypeFromPost ()
 
 getOidFromQuery ()
 
 getPositionsFromPost ()
 
 getPermissions ()
 
 initContextParameters (int $context, int $ref_id, ?string $obj_type, $sub_type)
 
 showPresentation ()
 
 showFiles ()
 Show export files. More...
 
 editFields ()
 
 importRecords ()
 
 setRecordSubTabs (int $level=1, bool $show_settings=false)
 Set subtabs for record editing/creation. More...
 
 initImportForm ()
 
 initFieldForm (ilAdvancedMDFieldDefinition $a_definition)
 
 initForm ($a_mode)
 
 getSubstitutionFieldPermissions (string $a_obj_type, int $a_field_id)
 
 initFormSubstitutions ()
 init form table 'substitutions' @access protected More...
 
 loadRecordFormData (ilPropertyFormGUI $form)
 
 initRecordObject ()
 
 setSubTabs (int $context)
 Set sub tabs @access protected. More...
 
 getParsedRecordObjects ()
 
 initComplexOptionForm (ilAdvancedMDFieldDefinition $a_def)
 
 initLanguage (int $record_id)
 
 showLanguageSwitch (int $record_id, string $target)
 

Protected Attributes

const TAB_RECORD_SETTINGS = 'editRecord'
 
const TAB_TRANSLATION = 'translations'
 
ilPropertyFormGUI $import_form = null
 
ilPropertyFormGUI $form = null
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
RequestInterface $request
 
GlobalHttpState $http
 
RefineryFactory $refinery
 
ilDBInterface $db
 
ilTabsGUI $tabs_gui
 
UIFactory $ui_factory
 
Renderer $ui_renderer
 
ilToolbarGUI $toolbar
 
ilLogger $logger
 
ilObjUser $user
 
ilAdvancedMDPermissionHelper $permissions
 
ilAdvancedMDRecord $record = null
 
int $ref_id
 
int $obj_id
 
string $obj_type = null
 
 $sub_type = null
 

Private Attributes

 $context = null
 
string $active_language = ''
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDSettingsGUI::__construct ( int  $a_context,
int  $a_ref_id,
?string  $a_obj_type = null,
  $a_sub_type = null 
)

Constructor @access public.

@noinspection PhpUndefinedMethodInspection

@noinspection PhpFieldAssignmentTypeMismatchInspection

Definition at line 80 of file class.ilAdvancedMDSettingsGUI.php.

81 {
82 global $DIC;
83
84 $this->ctrl = $DIC->ctrl();
85 $this->lng = $DIC->language();
86 $this->lng->loadLanguageModule('meta');
87 $this->tpl = $DIC->ui()->mainTemplate();
88 $this->tabs_gui = $DIC->tabs();
89
90 $this->refinery = $DIC->refinery();
91 $this->toolbar = $DIC->toolbar();
92 $this->ui_factory = $DIC->ui()->factory();
93 $this->ui_renderer = $DIC->ui()->renderer();
94 $this->request = $DIC->http()->request();
95 $this->http = $DIC->http();
96 $this->db = $DIC->database();
97 $this->user = $DIC->user();
98
100 $this->logger = $DIC->logger()->amet();
101
102 $this->context = $a_context;
104 $this->context,
105 $a_ref_id,
106 $a_obj_type,
107 $a_sub_type
108 );
109
111 $this->permissions = ilAdvancedMDPermissionHelper::getInstance($DIC->user()->getId(), $this->ref_id);
112 }
initContextParameters(int $context, int $ref_id, ?string $obj_type, $sub_type)
static getInstance(int $a_user_id, int $a_ref_id)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ilClaimingPermissionHelper\getInstance(), ILIAS\FileDelivery\http(), initContextParameters(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ILIAS\Repository\refinery(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ confirmDeleteFields()

ilAdvancedMDSettingsGUI::confirmDeleteFields ( )

Definition at line 834 of file class.ilAdvancedMDSettingsGUI.php.

834 : void
835 {
836 $field_ids = $this->getFieldIdsFromPost();
837 if (!count($field_ids)) {
838 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
839 $this->editFields();
840 return;
841 }
842
843 $this->initRecordObject();
844 $this->setRecordSubTabs(2);
845
846 $c_gui = new ilConfirmationGUI();
847
848 // set confirm/cancel commands
849 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFields"));
850 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_fields_sure"));
851 $c_gui->setCancel($this->lng->txt("cancel"), "editFields");
852 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFields");
853
854 // add items to delete
855 foreach ($field_ids as $field_id) {
857 $c_gui->addItem("field_id[]", (string) $field_id, $field->getTitle() ?: 'No Title');
858 }
859 $this->tpl->setContent($c_gui->getHTML());
860 }
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ confirmDeleteFiles()

ilAdvancedMDSettingsGUI::confirmDeleteFiles ( )

confirm delete files @access public

Definition at line 569 of file class.ilAdvancedMDSettingsGUI.php.

569 : void
570 {
571 $file_ids = $this->getFileIdsFromPost();
572 if (count($file_ids) !== 1) {
573 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
574 $this->showFiles();
575 return;
576 }
577
578 $c_gui = new ilConfirmationGUI();
579 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
580 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_files_sure"));
581 $c_gui->setCancel($this->lng->txt("cancel"), "showFiles");
582 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
583
585 $this->user->getId(),
586 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
587 );
588 $file_data = $files->readFilesInfo();
589
590 // add items to delete
591 foreach ($file_ids as $file_id) {
592 $info = $file_data[$file_id];
593 $c_gui->addItem(
594 "file_id[]",
595 (string) $file_id,
596 is_array($info['name'] ?? false) ? implode(',', $info['name']) : 'No Records'
597 );
598 }
599 $this->tpl->setContent($c_gui->getHTML());
600 }
$info
Definition: entry_point.php:21

References $info, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ confirmDeleteRecords()

ilAdvancedMDSettingsGUI::confirmDeleteRecords ( )

Confirm delete @access public.

Definition at line 639 of file class.ilAdvancedMDSettingsGUI.php.

639 : void
640 {
641 $this->initRecordObject();
642 $this->setRecordSubTabs();
643
644 $record_ids = $this->getRecordIdsFromPost();
645 if (!count($record_ids)) {
646 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
647 $this->showRecords();
648 return;
649 }
650
651 $c_gui = new ilConfirmationGUI();
652
653 // set confirm/cancel commands
654 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteRecords"));
655 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_record_sure"));
656 $c_gui->setCancel($this->lng->txt("cancel"), "showRecords");
657 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteRecords");
658
659 // add items to delete
660 foreach ($record_ids as $record_id) {
662 $c_gui->addItem("record_id[]", (string) $record_id, $record->getTitle() ?: 'No Title');
663 }
664 $this->tpl->setContent($c_gui->getHTML());
665 }
static _getInstanceByRecordId(int $a_record_id)

References ilAdvancedMDRecord\_getInstanceByRecordId(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ createField()

ilAdvancedMDSettingsGUI::createField ( ?ilPropertyFormGUI  $a_form = null)

Show field type selection @access public.

Definition at line 1352 of file class.ilAdvancedMDSettingsGUI.php.

1352 : void
1353 {
1354 $record_id = $this->getRecordIdFromQuery();
1355 $field_type = $this->getFieldTypeFromPost();
1356 if (!$field_type) {
1357 $field_type = $this->getFieldTypeFromQuery();
1358 }
1359
1360 $this->initRecordObject();
1361 $this->ctrl->setParameter($this, 'ftype', $field_type);
1362 $this->setRecordSubTabs(2);
1363 if (!$record_id || !$field_type) {
1364 $this->editFields();
1365 return;
1366 }
1367
1368 if (!$a_form) {
1369 $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $field_type);
1370 $field_definition->setRecordId($record_id);
1371 $a_form = $this->initFieldForm($field_definition);
1372 }
1373 $this->tpl->setContent($a_form->getHTML());
1374 }
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)

References ILIAS\Repository\ctrl(), and ilAdvancedMDFieldDefinition\getInstance().

+ Here is the call graph for this function:

◆ createRecord()

ilAdvancedMDSettingsGUI::createRecord ( ?ilPropertyFormGUI  $form = null)

Show @access public.

Parameters

Definition at line 1095 of file class.ilAdvancedMDSettingsGUI.php.

1095 : void
1096 {
1097 $this->initRecordObject();
1098 $this->setRecordSubTabs();
1099 if (!$form instanceof ilPropertyFormGUI) {
1100 $this->initForm('create');
1101 }
1102 $this->tpl->setContent($this->form->getHTML());
1103 }
This class represents a property form user interface.
form( $class_path, string $cmd, string $submit_caption="")

References ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ deleteFields()

ilAdvancedMDSettingsGUI::deleteFields ( )

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

862 : void
863 {
864 $this->ctrl->saveParameter($this, 'record_id');
865
866 $field_ids = $this->getFieldIdsFromPost();
867 if (!count($field_ids)) {
868 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
869 $this->editFields();
870 return;
871 }
872
873 // all fields have to be deletable
874 $fail = array();
875 foreach ($field_ids as $field_id) {
876 if (!$this->getPermissions()->hasPermission(
878 (string) $field_id,
880 )) {
882 $fail[] = $field->getTitle();
883 }
884 }
885 if ($fail) {
886 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
887 $this->ctrl->redirect($this, "editFields");
888 }
889
890 foreach ($field_ids as $field_id) {
892 $field->delete();
893 }
894 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_fields'), true);
895 $this->ctrl->redirect($this, "editFields");
896 }

References ilAdvancedMDPermissionHelper\ACTION_FIELD_DELETE, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteFiles()

ilAdvancedMDSettingsGUI::deleteFiles ( )

Delete files @access public.

Parameters

Definition at line 607 of file class.ilAdvancedMDSettingsGUI.php.

607 : void
608 {
609 $file_ids = $this->getFileIdsFromPost();
610 if (count($file_ids) === 0) {
611 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
612 $this->showFiles();
613 return;
614 }
615
616 if (!$GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
617 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
618 $GLOBALS['DIC']->ctrl()->redirect($this, 'showFiles');
619 }
620
622 $this->user->getId(),
623 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
624 );
625 foreach ($file_ids as $file_id) {
626 $files->deleteByFileId(
627 $this->user->getId(),
628 $file_id
629 );
630 }
631 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_files'));
632 $this->showFiles();
633 }
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS, ILIAS\Repository\access(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ deleteRecords()

ilAdvancedMDSettingsGUI::deleteRecords ( )

Permanently delete records @access public.

Definition at line 671 of file class.ilAdvancedMDSettingsGUI.php.

671 : void
672 {
673 $record_ids = $this->getRecordIdsFromPost();
674 if (!count($record_ids)) {
675 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
676 $this->showRecords();
677 return;
678 }
679
680 // all records have to be deletable
681 $fail = array();
682 foreach ($record_ids as $record_id) {
683 // must not delete global records in local context
684 if ($this->context == self::CONTEXT_OBJECT) {
686 if (!$record->getParentObject()) {
687 $fail[] = $record->getTitle();
688 }
689 }
690
691 if (!$this->getPermissions()->hasPermission(
693 (string) $record_id,
695 )) {
697 $fail[] = $record->getTitle();
698 }
699 }
700 if ($fail) {
701 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
702 $this->ctrl->redirect($this, "showRecords");
703 }
704
705 foreach ($record_ids as $record_id) {
707 $record->delete();
708 }
709 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_records'), true);
710 $this->ctrl->redirect($this, "showRecords");
711 }

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_DELETE, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ downloadFile()

ilAdvancedMDSettingsGUI::downloadFile ( )

Download XML file @access public.

Parameters

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

550 : void
551 {
552 $file_ids = $this->getFileIdsFromPost();
553 if (count($file_ids) !== 1) {
554 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('md_adv_select_one_file'));
555 $this->showFiles();
556 return;
557 }
559 $this->user->getId(),
560 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
561 );
562 $files->download($file_ids[0], 'ilias_meta_data_record.xml');
563 }

References ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ editComplexOption()

ilAdvancedMDSettingsGUI::editComplexOption ( ?ilPropertyFormGUI  $a_form = null)

Definition at line 2259 of file class.ilAdvancedMDSettingsGUI.php.

2259 : void
2260 {
2261 $field_id = $this->getFieldIdFromQuery();
2262 if (!$field_id) {
2263 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_select_one'));
2264 $this->ctrl->redirect($this, 'showRecords');
2265 }
2266
2267 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
2268 if (!$field_definition->hasComplexOptions()) {
2269 $this->ctrl->redirect($this, "editField");
2270 }
2271
2272 if (!$a_form) {
2273 $a_form = $this->initComplexOptionForm($field_definition);
2274 }
2275
2276 $this->tpl->setContent($a_form->getHTML());
2277 }
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)

References ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ editField()

ilAdvancedMDSettingsGUI::editField ( ?ilPropertyFormGUI  $a_form = null)

Edit field @access public.

Definition at line 1273 of file class.ilAdvancedMDSettingsGUI.php.

1273 : void
1274 {
1275 $record_id = $this->getRecordIdFromQuery();
1276 $field_id = $this->getFieldIdFromQuery();
1277 if (!$record_id || !$field_id) {
1278 $this->editFields();
1279 return;
1280 }
1281 $this->ctrl->saveParameter($this, 'field_id');
1282 $this->ctrl->saveParameter($this, 'record_id');
1283 $this->initRecordObject();
1284 $this->setRecordSubTabs(2);
1285
1286 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1287
1288 if (!$a_form instanceof ilPropertyFormGUI) {
1289 $this->initLanguage($this->record->getRecordId());
1290 $this->showLanguageSwitch($this->record->getRecordId(), 'editField');
1291 $a_form = $this->initFieldForm($field_definition);
1292 }
1293 $table = null;
1294 if ($field_definition->hasComplexOptions()) {
1295 $table = $field_definition->getComplexOptionsOverview($this, "editField");
1296 }
1297 $this->tpl->setContent($a_form->getHTML() . $table);
1298 }
showLanguageSwitch(int $record_id, string $target)

References ILIAS\Repository\ctrl(), and ilAdvancedMDFieldDefinition\getInstance().

+ Here is the call graph for this function:

◆ editFields()

ilAdvancedMDSettingsGUI::editFields ( )
protected

Definition at line 916 of file class.ilAdvancedMDSettingsGUI.php.

916 : void
917 {
918 global $DIC;
919
920 $record_id = $this->getRecordIdFromQuery();
921 if (!$record_id) {
922 $this->ctrl->redirect($this, 'showRecords');
923 }
924 $this->ctrl->saveParameter($this, 'record_id');
925 $this->initRecordObject();
926 $this->setRecordSubTabs();
927 $this->initLanguage($record_id);
928 $this->showLanguageSwitch($record_id, 'editFields');
929
930 $perm = $this->getPermissions()->hasPermissions(
932 (string) $this->record->getRecordId(),
933 array(
935 ,
937 )
938 );
939
940 $filter_warn = [];
942 // type selection
943 $field_buttons = [];
944 foreach (ilAdvancedMDFieldDefinition::getValidTypes() as $type) {
945 $field = ilAdvancedMDFieldDefinition::getInstance(null, $type);
946
947 $this->ctrl->setParameter($this, 'ftype', $type);
948 $create_link = $this->ctrl->getLinkTarget($this, 'createField');
949 $this->ctrl->clearParameterByClass(strtolower(self::class), 'ftype');
950
951 $field_buttons[] = $this->ui_factory->button()->shy(
952 $this->lng->txt($field->getTypeTitle()),
953 $create_link
954 );
955
956 if (!$field->isFilterSupported()) {
957 $filter_warn[] = $this->lng->txt($field->getTypeTitle());
958 }
959 }
960
961 if (count($this->toolbar->getItems())) {
962 $this->toolbar->addSeparator();
963 }
964
965 $dropdown = $this->ui_factory->dropdown()
966 ->standard($field_buttons)
967 ->withLabel($this->lng->txt('meta_advmd_add_field'));
968 $this->toolbar->addComponent($dropdown);
969 }
970
971 // #17092
972 if (sizeof($filter_warn)) {
973 $this->tpl->setOnScreenMessage('info', sprintf($this->lng->txt("md_adv_field_filter_warning"), implode(", ", $filter_warn)));
974 }
975
976 // show field table
978 $this->record->getRecordId(),
979 false,
980 $this->active_language
981 );
982
983 $table_gui = new ilAdvancedMDFieldTableGUI(
984 $this,
985 'editFields',
986 $this->getPermissions(),
988 $this->record->getDefaultLanguage()
989 );
990 $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
991 $table_gui->parseDefinitions($fields);
992 if (sizeof($fields)) {
993 $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
994 }
995 $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
996 $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
997 $table_gui->setSelectAllCheckbox("field_id");
998
999 $this->tpl->setContent($table_gui->getHTML());
1000 }
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.

References $DIC, ilAdvancedMDPermissionHelper\ACTION_RECORD_CREATE_FIELD, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ilAdvancedMDFieldDefinition\getValidTypes(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ editRecord()

ilAdvancedMDSettingsGUI::editRecord ( ?ilPropertyFormGUI  $form = null)

Definition at line 898 of file class.ilAdvancedMDSettingsGUI.php.

898 : void
899 {
900 $record_id = $this->getRecordIdFromQuery();
901 if (!$record_id) {
902 $this->ctrl->redirect($this, 'showRecords');
903 }
904 $this->initRecordObject();
905 $this->setRecordSubTabs(1, true);
906 $this->tabs_gui->activateTab(self::TAB_RECORD_SETTINGS);
907
908 if (!$form instanceof ilPropertyFormGUI) {
909 $this->initLanguage($record_id);
910 $this->showLanguageSwitch($record_id, 'editRecord');
911 $this->initForm('edit');
912 }
913 $this->tpl->setContent($this->form->getHTML());
914 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ executeCommand()

ilAdvancedMDSettingsGUI::executeCommand ( )

Definition at line 263 of file class.ilAdvancedMDSettingsGUI.php.

263 : void
264 {
265 $next_class = $this->ctrl->getNextClass($this);
266 $cmd = $this->ctrl->getCmd();
267 switch ($next_class) {
268 case strtolower(ilAdvancedMDRecordTranslationGUI::class):
269 $record = $this->initRecordObject();
270 $this->setRecordSubTabs(1, true);
271 $int_gui = new \ilAdvancedMDRecordTranslationGUI($record);
272 $this->ctrl->forwardCommand($int_gui);
273 break;
274
275 case "ilpropertyformgui":
276 $this->initRecordObject();
277 $this->initForm(
278 $this->record->getRecordId() > 0 ? 'edit' : 'create'
279 );
280 $GLOBALS['DIC']->ctrl()->forwardCommand($this->form);
281 break;
282
283 default:
284 if (!$cmd) {
285 $cmd = 'showRecords';
286 }
287 $this->$cmd();
288 }
289 }

References $GLOBALS, ILIAS\Repository\ctrl(), and ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ exportRecords()

ilAdvancedMDSettingsGUI::exportRecords ( )

Export records @access public.

Definition at line 479 of file class.ilAdvancedMDSettingsGUI.php.

479 : void
480 {
481 $record_ids = $this->getRecordIdsFromPost();
482 if (!count($record_ids)) {
483 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
484 $this->showRecords();
485 return;
486 }
487
488 // all records have to be exportable
489 $fail = array();
490 foreach ($record_ids as $record_id) {
491 if (!$this->getPermissions()->hasPermission(
493 (string) $record_id,
495 )) {
497 $fail[] = $record->getTitle();
498 }
499 }
500 if ($fail) {
501 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_copy') . " " . implode(", ", $fail), true);
502 $this->ctrl->redirect($this, "showRecords");
503 }
504
505 $xml_writer = new ilAdvancedMDRecordXMLWriter((array) $record_ids);
506 $xml_writer->write();
507
508 $export_files = new ilAdvancedMDRecordExportFiles(
509 $this->user->getId(),
510 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
511 );
512 $export_files->create($xml_writer->xmlDumpMem(false));
513
514 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_records_exported'));
515 $this->showFiles();
516 }

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EXPORT, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getFieldIdFromQuery()

ilAdvancedMDSettingsGUI::getFieldIdFromQuery ( )
protected

Definition at line 140 of file class.ilAdvancedMDSettingsGUI.php.

140 : ?int
141 {
142 if ($this->http->wrapper()->query()->has('field_id')) {
143 return $this->http->wrapper()->query()->retrieve(
144 'field_id',
145 $this->refinery->kindlyTo()->int()
146 );
147 }
148 return null;
149 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getFieldIdsFromPost()

ilAdvancedMDSettingsGUI::getFieldIdsFromPost ( )
protected

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

151 : SplFixedArray
152 {
153 if ($this->http->wrapper()->post()->has('field_id')) {
154 return SplFixedArray::fromArray(
155 $this->http->wrapper()->post()->retrieve(
156 'field_id',
157 $this->refinery->kindlyTo()->listOf(
158 $this->refinery->kindlyTo()->int()
159 )
160 )
161 );
162 }
163 return new SplFixedArray(0);
164 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getFieldTypeFromPost()

ilAdvancedMDSettingsGUI::getFieldTypeFromPost ( )
protected

Definition at line 192 of file class.ilAdvancedMDSettingsGUI.php.

192 : ?int
193 {
194 if ($this->http->wrapper()->post()->has('ftype')) {
195 return $this->http->wrapper()->post()->retrieve(
196 'ftype',
197 $this->refinery->kindlyTo()->int()
198 );
199 }
200 return null;
201 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getFieldTypeFromQuery()

ilAdvancedMDSettingsGUI::getFieldTypeFromQuery ( )
protected

Definition at line 181 of file class.ilAdvancedMDSettingsGUI.php.

181 : ?int
182 {
183 if ($this->http->wrapper()->query()->has('ftype')) {
184 return $this->http->wrapper()->query()->retrieve(
185 'ftype',
186 $this->refinery->kindlyTo()->int()
187 );
188 }
189 return null;
190 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getFileIdsFromPost()

ilAdvancedMDSettingsGUI::getFileIdsFromPost ( )
protected

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

166 : SplFixedArray
167 {
168 if ($this->http->wrapper()->post()->has('file_id')) {
169 return SplFixedArray::fromArray(
170 $this->http->wrapper()->post()->retrieve(
171 'file_id',
172 $this->refinery->kindlyTo()->dictOf(
173 $this->refinery->kindlyTo()->string()
174 )
175 )
176 );
177 }
178 return new SplFixedArray(0);
179 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getOidFromQuery()

ilAdvancedMDSettingsGUI::getOidFromQuery ( )
protected

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

203 : ?string
204 {
205 if ($this->http->wrapper()->query()->has('oid')) {
206 return $this->http->wrapper()->query()->retrieve(
207 'oid',
208 $this->refinery->kindlyTo()->string()
209 );
210 }
211 return null;
212 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getParsedRecordObjects()

ilAdvancedMDSettingsGUI::getParsedRecordObjects ( )
protected
Todo:
get rid of this (used in ilAdvancedMDRecordTableGUI) and the parsing there. Also get rid of the usage in ilAvancedMDSettingsGUI::updateRecords

Definition at line 2129 of file class.ilAdvancedMDSettingsGUI.php.

2129 : array
2130 {
2131 $res = [];
2132
2133 $sub_type = (!is_array($this->sub_type))
2134 ? [$this->sub_type]
2135 : $this->sub_type;
2136
2137 if ($this->context === self::CONTEXT_OBJECT) {
2138 // get all records selected for subtype
2139 foreach ($sub_type as $st) {
2140 $selected[$st] = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $st);
2141 }
2142 }
2143
2145 $orderings = new ilAdvancedMDRecordObjectOrderings();
2146 $records = $orderings->sortRecords($records, $this->obj_id);
2147
2148 $position = 0;
2149
2150 // get all records usuable in current context
2151 foreach ($records as $record) {
2152 $parent_id = $record->getParentObject();
2153
2154 if ($this->context == self::CONTEXT_ADMINISTRATION) {
2155 if ($parent_id) {
2156 continue;
2157 }
2158 } else {
2159 // does not match current object
2160 if ($parent_id && $parent_id != $this->obj_id) {
2161 continue;
2162 }
2163
2164 // inactive records only in administration
2165 if (!$parent_id && !$record->isActive()) {
2166 continue;
2167 }
2168 // scope needs to match in object context
2169 if (
2171 $this->ref_id,
2173 )
2174 ) {
2175 continue;
2176 }
2177 }
2178
2179 $tmp_arr = [];
2180 $tmp_arr['readonly'] = null;
2181 $tmp_arr['local'] = null;
2182 $tmp_arr['optional'] = null;
2183 $tmp_arr['id'] = $record->getRecordId();
2184 $tmp_arr['active'] = $record->isActive();
2185 $tmp_arr['title'] = $record->getTitle();
2186 $tmp_arr['description'] = $record->getDescription();
2187 $tmp_arr['fields'] = [];
2188 /*
2189 * This is a workaround to fix sorting by scope, see #21963
2190 */
2191 $tmp_arr['first_scope'] = ilObject::_lookupTitle(
2193 );
2194 $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
2195 foreach ($record->getAssignedObjectTypes() as $idx => $item) {
2196 $tmp_arr['obj_types'][$idx]['context'] = null;
2197 }
2198 $position += 10;
2199 $tmp_arr['position'] = $position;
2200
2201 $tmp_arr['perm'] = $this->permissions->hasPermissions(
2203 (string) $record->getRecordId(),
2204 array(
2206 ,
2208 ,
2210 ,
2213 )
2214 )
2215 );
2216
2217 if ($this->obj_type) {
2218 $tmp_arr["readonly"] = !(bool) $parent_id;
2219 $tmp_arr["local"] = $parent_id;
2220
2221 // local records are never optional (or unassigned)
2222 $assigned = (bool) $parent_id;
2223 $optional = false;
2224 foreach ($tmp_arr['obj_types'] as $idx => $item) {
2225 if ($item["obj_type"] == $this->obj_type &&
2226 in_array($item["sub_type"], $sub_type)) {
2227 $assigned = true;
2228 $optional = $item["optional"];
2229 $tmp_arr['obj_types'][$idx]['context'] = true;
2230 } else {
2231 unset($tmp_arr['obj_types'][$idx]);
2232 }
2233 }
2234 $tmp_arr['optional'] = $optional;
2235 if ($optional) {
2236 // in object context "active" means selected record
2237 // $tmp_arr['active'] = (is_array($selected[$item["sub_type"]]) && in_array($record->getRecordId(), $selected[$item["sub_type"]]));
2238 $tmp_arr['local_selected'] = [];
2239 foreach ($selected as $key => $records) {
2240 if (in_array($record->getRecordId(), $records)) {
2241 $tmp_arr['local_selected'][$this->obj_type][] = $key;
2242 }
2243 }
2244 }
2245 }
2246
2247 if ($assigned ?? true) {
2248 $res[] = $tmp_arr;
2249 }
2250 }
2251 return $res;
2252 }
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
static _getRecords()
Get records @access public.
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
$res
Definition: ltiservices.php:69

References $res, ilAdvancedMDRecord\_getRecords(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_FIELDS, ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilAdvancedMDRecord\getObjRecSelection(), ilAdvancedMDRecord\isFilteredByScope(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

+ Here is the call graph for this function:

◆ getPermissions()

ilAdvancedMDSettingsGUI::getPermissions ( )
protected
Returns
ilAdvancedMDPermissionHelper

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

237 {
238 return $this->permissions;
239 }
Advanced metadata permission helper.
ilAdvancedMDPermissionHelper $permissions

References $permissions.

◆ getPositionsFromPost()

ilAdvancedMDSettingsGUI::getPositionsFromPost ( )
protected
Returns
array<string, float>

Definition at line 217 of file class.ilAdvancedMDSettingsGUI.php.

217 : array
218 {
219 if ($this->http->wrapper()->post()->has('position')) {
220 return $this->http->wrapper()->post()->retrieve(
221 'position',
222 $this->refinery->kindlyTo()->dictOf(
223 $this->refinery->byTrying([
224 $this->refinery->kindlyTo()->float(),
225 $this->refinery->always(0)
226 ])
227 )
228 );
229 }
230 return [];
231 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getRecordIdFromQuery()

ilAdvancedMDSettingsGUI::getRecordIdFromQuery ( )
protected

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

114 : ?int
115 {
116 if ($this->http->wrapper()->query()->has('record_id')) {
117 return $this->http->wrapper()->query()->retrieve(
118 'record_id',
119 $this->refinery->kindlyTo()->int()
120 );
121 }
122 return null;
123 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getRecordIdsFromPost()

ilAdvancedMDSettingsGUI::getRecordIdsFromPost ( )
protected

Definition at line 125 of file class.ilAdvancedMDSettingsGUI.php.

125 : SplFixedArray
126 {
127 if ($this->http->wrapper()->post()->has('record_id')) {
128 return SplFixedArray::fromArray(
129 $this->http->wrapper()->post()->retrieve(
130 'record_id',
131 $this->refinery->kindlyTo()->listOf(
132 $this->refinery->kindlyTo()->int()
133 )
134 )
135 );
136 }
137 return new SplFixedArray(0);
138 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getSubstitutionFieldPermissions()

ilAdvancedMDSettingsGUI::getSubstitutionFieldPermissions ( string  $a_obj_type,
int  $a_field_id 
)
protected

Definition at line 1636 of file class.ilAdvancedMDSettingsGUI.php.

1636 : array
1637 {
1638 if ($a_obj_type == "crs") {
1639 $perm = $this->getPermissions()->hasPermissions(
1641 (string) $a_field_id,
1642 array(
1644 ,
1647 )
1648 ,
1651 )
1652 )
1653 );
1654 return array(
1656 ,
1658 ,
1660 );
1661 } elseif ($a_obj_type == "cat") {
1662 $perm = $this->getPermissions()->hasPermissions(
1664 (string) $a_field_id,
1665 array(
1667 ,
1670 )
1671 ,
1674 )
1675 )
1676 );
1677 return array(
1679 ,
1681 ,
1683 );
1684 } elseif ($a_obj_type == "sess") {
1685 $perm = $this->getPermissions()->hasPermissions(
1687 (string) $a_field_id,
1688 array(
1690 ,
1693 )
1694 ,
1697 )
1698 )
1699 );
1700 return array(
1702 ,
1704 ,
1706 );
1707 } elseif ($a_obj_type == "grp") {
1708 $perm = $this->getPermissions()->hasPermissions(
1710 (string) $a_field_id,
1711 array(
1713 ,
1716 )
1717 ,
1720 )
1721 )
1722 );
1723 return array(
1725 ,
1727 ,
1729 );
1730 } elseif ($a_obj_type == "iass") {
1731 $perm = $this->getPermissions()->hasPermissions(
1733 (string) $a_field_id,
1734 array(
1736 ,
1739 )
1740 ,
1743 )
1744 )
1745 );
1746 return array(
1748 ,
1750 ,
1752 );
1753 } elseif ($a_obj_type == "exc") {
1754 $perm = $this->getPermissions()->hasPermissions(
1756 (string) $a_field_id,
1757 array(
1759 ,
1762 )
1763 ,
1766 )
1767 )
1768 );
1769 return array(
1771 ,
1773 ,
1775 );
1776 } elseif ($a_obj_type == "file") {
1777 $perm = $this->getPermissions()->hasPermissions(
1779 (string) $a_field_id,
1780 array(
1782 ,
1785 )
1786 ,
1789 )
1790 )
1791 );
1792 return array(
1794 ,
1796 ,
1798 );
1799 } elseif ($a_obj_type == "prg") {
1800 $perm = $this->getPermissions()->hasPermissions(
1802 (string) $a_field_id,
1803 [
1805 [
1808 ],
1809 [
1812 ]
1813 ]
1814 );
1815 return array(
1817 ,
1819 ,
1821 );
1822 } elseif ($a_obj_type == "orgu") {
1823 $perm = $this->getPermissions()->hasPermissions(
1825 (string) $a_field_id,
1826 [
1828 ,
1829 [
1832 ]
1833 ,
1834 [
1837 ]
1838 ]
1839 );
1840 return [
1842 ,
1844 ,
1846 ];
1847 }
1848 return [];
1849 }

References ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_COURSE_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_EXERCISE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_EXERCISE_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FILE_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FILE_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_GROUP_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_GROUP_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_IASS_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_IASS_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_ORG_UNIT_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_ORG_UNIT_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_PRG_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_PRG_SHOW_FIELD, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SESSION_SHOW_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_CATEGORY, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_COURSE, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_EXERCISE, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_FILE, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_GROUP, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_IASS, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_ORG_UNIT, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_PRG, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION_SESSION, ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_BOLD, and ilAdvancedMDPermissionHelper\SUBACTION_SUBSTITUTION_NEWLINE.

◆ importRecord()

ilAdvancedMDSettingsGUI::importRecord ( )

Definition at line 1184 of file class.ilAdvancedMDSettingsGUI.php.

1184 : void
1185 {
1186 $this->initImportForm();
1187 if (!$this->import_form->checkInput()) {
1188 $this->import_form->setValuesByPost();
1189 $this->importRecords();
1190 return;
1191 }
1192
1193 $import_files = new ilAdvancedMDRecordImportFiles();
1194 if (!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name'])) {
1195 $this->createRecord();
1196 return;
1197 }
1198
1199 try {
1200 $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
1201
1202 // local import?
1203 if ($this->context === self::CONTEXT_OBJECT) {
1204 $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
1205 }
1206
1207 // Validate
1209 $parser->startParsing();
1210
1211 // Insert
1212 $parser->setMode(ilAdvancedMDRecordParser::MODE_INSERT);
1213 $parser->startParsing();
1214 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_added_new_record'), true);
1215 $this->ctrl->redirect($this, "showRecords");
1216 } catch (ilSaxParserException $exc) {
1217 $this->tpl->setOnScreenMessage('failure', $exc->getMessage(), true);
1218 $this->ctrl->redirect($this, "importRecords");
1219 }
1220
1221 // Finally delete import file
1222 $import_files->deleteFileByCreationDate($create_time);
1223 }
SAX based XML parser for record import files.
createRecord(?ilPropertyFormGUI $form=null)
Show @access public.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilAdvancedMDRecordParser\MODE_INSERT, and ilAdvancedMDRecordParser\MODE_INSERT_VALIDATION.

+ Here is the call graph for this function:

◆ importRecords()

ilAdvancedMDSettingsGUI::importRecords ( )
protected

Definition at line 1105 of file class.ilAdvancedMDSettingsGUI.php.

1105 : void
1106 {
1107 $this->initRecordObject();
1108 $this->setRecordSubTabs();
1109
1110 // Import Table
1111 $this->initImportForm();
1112 $this->tpl->setContent($this->import_form->getHTML());
1113 }

◆ initComplexOptionForm()

ilAdvancedMDSettingsGUI::initComplexOptionForm ( ilAdvancedMDFieldDefinition  $a_def)
protected

Definition at line 2279 of file class.ilAdvancedMDSettingsGUI.php.

2280 {
2281 $this->ctrl->saveParameter($this, "record_id");
2282 $this->ctrl->saveParameter($this, "field_id");
2283 $this->ctrl->saveParameter($this, "oid");
2284
2285 $form = new ilPropertyFormGUI();
2286 $form->setTitle($this->lng->txt("md_adv_edit_complex_option"));
2287 $form->setFormAction($this->ctrl->getFormAction($this, "updateComplexOption"));
2288
2289 $oid = $this->getOidFromQuery();
2290 $a_def->initOptionForm($form, $oid);
2291
2292 $form->addCommandButton("updateComplexOption", $this->lng->txt("save"));
2293 $form->addCommandButton("editField", $this->lng->txt("cancel"));
2294
2295 return $form;
2296 }
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initContextParameters()

ilAdvancedMDSettingsGUI::initContextParameters ( int  $context,
int  $ref_id,
?string  $obj_type,
  $sub_type 
)
protected
Parameters
string | string[] | null$sub_type

Definition at line 244 of file class.ilAdvancedMDSettingsGUI.php.

249 : void {
250 if ($context === self::CONTEXT_ADMINISTRATION) {
251 $this->ref_id = $ref_id;
252 $this->obj_id = null;
253 $this->obj_type = null;
254 $this->sub_type = null;
255 } else {
256 $this->ref_id = $ref_id;
257 $this->obj_id = ilObject::_lookupObjId($ref_id);
258 $this->obj_type = $obj_type;
259 $this->sub_type = $sub_type;
260 }
261 }

References $ref_id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initFieldForm()

ilAdvancedMDSettingsGUI::initFieldForm ( ilAdvancedMDFieldDefinition  $a_definition)
protected

Definition at line 1413 of file class.ilAdvancedMDSettingsGUI.php.

1414 {
1415 $is_creation_mode = $a_definition->getFieldId() ? false : true;
1416
1417 $form = new ilPropertyFormGUI();
1418 $form->setFormAction($this->ctrl->getFormAction($this));
1419
1420 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1421 if ($is_creation_mode) {
1422 $form->setDescription($a_definition->getDescription());
1423 } else {
1424 $form->setDescription($translations->getFormTranslationInfo(
1425 $a_definition->getFieldId(),
1426 $this->active_language
1427 ));
1428 }
1429 $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1430 $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1431 $form->addItem($type);
1432 $a_definition->addToFieldDefinitionForm($form, $this->getPermissions(), $this->active_language);
1433
1434 if ($is_creation_mode) {
1435 $form->setTitle($this->lng->txt('md_adv_create_field'));
1436 $form->addCommandButton('saveField', $this->lng->txt('create'));
1437 } else {
1438 $form->setTitle($this->lng->txt('md_adv_edit_field'));
1439 $form->addCommandButton('updateField', $this->lng->txt('save'));
1440 }
1441
1442 $form->addCommandButton('editFields', $this->lng->txt('cancel'));
1443
1444 return $form;
1445 }
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
Add input elements to definition form.
This class represents a non editable value in a property form.

References ilAdvancedMDFieldDefinition\addToFieldDefinitionForm(), ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getDescription(), ilAdvancedMDFieldDefinition\getFieldId(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getTypeTitle(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initForm()

ilAdvancedMDSettingsGUI::initForm (   $a_mode)
protected

Definition at line 1447 of file class.ilAdvancedMDSettingsGUI.php.

1448 {
1449 if ($this->form instanceof ilPropertyFormGUI) {
1450 return $this->form;
1451 }
1452 $perm = $this->getPermissions()->hasPermissions(
1454 (string) $this->record->getRecordId(),
1455 array(
1458 )
1459 ,
1462 )
1463 ,
1466 )
1467 ,
1469 )
1470 );
1471
1472 $this->form = new ilPropertyFormGUI();
1473
1474 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1475 $this->form->setDescription($translations->getFormTranslationInfo($this->active_language));
1476 $this->form->setFormAction($this->ctrl->getFormAction($this));
1477
1478 // title
1479 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
1480 $title->setValue($this->record->getTitle());
1481 $title->setSize(20);
1482 $title->setMaxLength(70);
1483 $title->setRequired(true);
1484
1486 $title->setDisabled(true);
1487 }
1488 $this->form->addItem($title);
1489 $translations->modifyTranslationInfoForTitle($this->form, $title, $this->active_language);
1490
1491 // desc
1492 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
1493 $desc->setValue($this->record->getDescription());
1494 $desc->setRows(3);
1495
1497 $desc->setDisabled(true);
1498 }
1499 $this->form->addItem($desc);
1500 $translations->modifyTranslationInfoForDescription($this->form, $desc, $this->active_language);
1501
1502 // active
1503 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'), 'active');
1504 $check->setChecked($this->record->isActive());
1505 $check->setValue("1");
1506 $this->form->addItem($check);
1507
1509 $check->setDisabled(true);
1510 }
1511
1512 if (!$this->obj_type) {
1513 // scope
1514 $scope = new ilCheckboxInputGUI($this->lng->txt('md_adv_scope'), 'scope');
1515 $scope->setInfo($this->lng->txt('md_adv_scope_info'));
1516 $scope->setChecked($this->record->enabledScope());
1517 $scope->setValue("1");
1518 $this->form->addItem($scope);
1519 $subitems = new ilRepositorySelector2InputGUI(
1520 $this->lng->txt('md_adv_scope_objects'),
1521 "scope_containers",
1522 true,
1523 $this->form
1524 );
1525 $subitems->setValue($this->record->getScopeRefIds());
1526 $exp = $subitems->getExplorerGUI();
1527
1528 $definition = $GLOBALS['DIC']['objDefinition'];
1529 $white_list = [];
1530 foreach ($definition->getAllRepositoryTypes() as $type) {
1531 if ($definition->isContainer($type)) {
1532 $white_list[] = $type;
1533 }
1534 }
1535
1536 $exp->setTypeWhiteList($white_list);
1537 $exp->setSkipRootNode(false);
1538 $exp->setRootId(ROOT_FOLDER_ID);
1539 $scope->addSubItem($subitems);
1540 }
1541
1542 if (!$this->obj_type) {
1543 $section = new ilFormSectionHeaderGUI();
1544 $section->setTitle($this->lng->txt('md_obj_types'));
1545 $this->form->addItem($section);
1546
1547 // see ilAdvancedMDRecordTableGUI::fillRow()
1548 $options = array(
1549 0 => $this->lng->txt("meta_obj_type_inactive"),
1550 1 => $this->lng->txt("meta_obj_type_mandatory"),
1551 2 => $this->lng->txt("meta_obj_type_optional")
1552 );
1553
1554 foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type) {
1555 $t = $type["obj_type"] . ":" . $type["sub_type"];
1556 $this->lng->loadLanguageModule($type["obj_type"]);
1557
1558 /*
1559 * BT 35914: workaround for hiding portfolio pages in portfolios,
1560 * since they only get data from portfolio templates
1561 */
1562 $hidden = false;
1563 if ($type["obj_type"] == "prtf" && $type["sub_type"] == "pfpg") {
1564 $hidden = true;
1565 }
1566 // EmployeeTalks get their md from templates
1567 if ($type["obj_type"] == "tals" && $type["sub_type"] == "etal") {
1568 $hidden = true;
1569 }
1570
1571
1572 $type_options = $options;
1573 switch ($type["obj_type"]) {
1574 case "orgu":
1575 // currently only optional records for org unit (types)
1576 unset($type_options[1]);
1577 break;
1578 case "talt":
1579 // currently only optional records for talk templates (types)
1580 unset($type_options[1]);
1581 break;
1582 case "rcrs":
1583 // optional makes no sense for ecs-courses
1584 unset($type_options[2]);
1585 break;
1586 }
1587
1588 $value = 0;
1589 if ($a_mode == "edit") {
1590 foreach ($this->record->getAssignedObjectTypes() as $item) {
1591 if ($item["obj_type"] == $type["obj_type"] &&
1592 $item["sub_type"] == $type["sub_type"]) {
1593 $value = $item["optional"]
1594 ? 2
1595 : 1;
1596 }
1597 }
1598 }
1599
1600 $sel_name = 'obj_types__' . $t;
1601
1602 if ($hidden) {
1603 $hidden = new ilHiddenInputGUI($sel_name);
1604 $hidden->setValue((string) $value);
1605 $this->form->addItem($hidden);
1606 continue;
1607 }
1608
1609 $check = new ilSelectInputGUI($type['text'], $sel_name);
1610 //$check = new ilSelectInputGUI($type["text"], 'obj_types[' . $t . ']');
1611 $check->setOptions($type_options);
1612 $check->setValue($value);
1613 $this->form->addItem($check);
1614
1616 $check->setDisabled(true);
1617 }
1618 }
1619 }
1620
1621 switch ($a_mode) {
1622 case 'create':
1623 $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1624 $this->form->addCommandButton('saveRecord', $this->lng->txt('add'));
1625 $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1626 break;
1627
1628 case 'edit':
1629 $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1630 $this->form->addCommandButton('updateRecord', $this->lng->txt('save'));
1631 $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1632 }
1633 return $this->form;
1634 }
$check
Definition: buildRTE.php:81
static _getAssignableObjectTypes(bool $a_include_text=false)
Get assignable object type @access public.
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
const ROOT_FOLDER_ID
Definition: constants.php:32
$scope
Definition: ltiregstart.php:51

References $check, $GLOBALS, $scope, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ILIAS\Repository\lng(), ROOT_FOLDER_ID, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

+ Here is the call graph for this function:

◆ initFormSubstitutions()

ilAdvancedMDSettingsGUI::initFormSubstitutions ( )
protected

init form table 'substitutions' @access protected

Definition at line 1855 of file class.ilAdvancedMDSettingsGUI.php.

1856 {
1857 global $DIC;
1858
1859 $ilAccess = $DIC['ilAccess'];
1860
1861 if (!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType()) {
1862 return null;
1863 }
1864
1865 $this->form = new ilPropertyFormGUI();
1866 $this->form->setFormAction($this->ctrl->getFormAction($this));
1867 #$this->form->setTableWidth('100%');
1868
1869 // substitution
1870 foreach ($visible_records as $obj_type => $records) {
1871 $perm = null;
1872
1873 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
1874 $perm = $this->getPermissions()->hasPermissions(
1876 (string) $obj_type,
1877 array(
1879 ,
1881 ,
1883 )
1884 );
1885 }
1886
1888
1889 // Show section
1890 $section = new ilFormSectionHeaderGUI();
1891 $section->setTitle($this->lng->txt('objs_' . $obj_type));
1892 $this->form->addItem($section);
1893
1894 $check = new ilCheckboxInputGUI($this->lng->txt('description'), 'enabled_desc_' . $obj_type);
1895 $check->setValue("1");
1896 $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1897 $check->setChecked($sub->isDescriptionEnabled());
1898 $this->form->addItem($check);
1899
1901 $check->setDisabled(true);
1902 }
1903
1904 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'), 'enabled_field_names_' . $obj_type);
1905 $check->setValue("1");
1906 $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1907 $check->setChecked($sub->enabledFieldNames());
1908 $this->form->addItem($check);
1909
1911 $check->setDisabled(true);
1912 }
1913
1914 $perm_pos = null;
1915 if ($perm) {
1917 }
1918
1920 $definitions = $sub->sortDefinitions($definitions);
1921
1922 $counter = 1;
1923 foreach ($definitions as $def) {
1924 $definition_id = $def->getFieldId();
1925
1926 $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id);
1927
1928 $title = ilAdvancedMDRecord::_lookupTitle((int) $def->getRecordId());
1929 $title = $def->getTitle() . ' (' . $title . ')';
1930
1931 $check = new ilCheckboxInputGUI($title, 'show_' . $obj_type . '_' . $definition_id);
1932 $check->setValue("1");
1933 $check->setOptionTitle($this->lng->txt('md_adv_show'));
1934 $check->setChecked($sub->isSubstituted($definition_id));
1935
1936 if ($perm && !$perm["show"]) {
1937 $check->setDisabled(true);
1938 }
1939
1940 $pos = new ilNumberInputGUI(
1941 $this->lng->txt('position'),
1942 'position_' . $obj_type . '_' . $definition_id
1943 );
1944 $pos->setSize(3);
1945 $pos->setMaxLength(4);
1946 $pos->allowDecimals(true);
1947 $pos->setValue(sprintf('%.1f', $counter++));
1948 $check->addSubItem($pos);
1949
1950 if ($perm && !$perm_pos) {
1951 $pos->setDisabled(true);
1952 }
1953
1954 $bold = new ilCheckboxInputGUI(
1955 $this->lng->txt('bold'),
1956 'bold_' . $obj_type . '_' . $definition_id
1957 );
1958 $bold->setValue("1");
1959 $bold->setChecked($sub->isBold($definition_id));
1960 $check->addSubItem($bold);
1961
1962 if ($perm && !$perm["bold"]) {
1963 $bold->setDisabled(true);
1964 }
1965
1966 $bold = new ilCheckboxInputGUI(
1967 $this->lng->txt('newline'),
1968 'newline_' . $obj_type . '_' . $definition_id
1969 );
1970 $bold->setValue("1");
1971 $bold->setChecked($sub->hasNewline($definition_id));
1972 $check->addSubItem($bold);
1973
1974 if ($perm && !$perm["newline"]) {
1975 $bold->setDisabled(true);
1976 }
1977
1978 $this->form->addItem($check);
1979 }
1980 }
1981 $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1982
1983 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1984 $this->form->addCommandButton('updateSubstitutions', $this->lng->txt('save'));
1985 }
1986 return $this->form;
1987 }
static getInstancesByObjType($a_obj_type, $a_active_only=true)
static _lookupTitle(int $a_record_id)
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types!
getSubstitutionFieldPermissions(string $a_obj_type, int $a_field_id)
static _getInstanceByObjectType(string $a_type)
This class represents a number property in a property form.
$counter

References $check, $counter, $DIC, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDRecord\_lookupTitle(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDFieldDefinition\getInstancesByObjType(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initImportForm()

ilAdvancedMDSettingsGUI::initImportForm ( )
protected

Definition at line 1163 of file class.ilAdvancedMDSettingsGUI.php.

1163 : void
1164 {
1165 if (is_object($this->import_form)) {
1166 return;
1167 }
1168
1169 $this->import_form = new ilPropertyFormGUI();
1170 $this->import_form->setMultipart(true);
1171 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
1172
1173 // add file property
1174 $file = new ilFileInputGUI($this->lng->txt('file'), 'file');
1175 $file->setSuffixes(array('xml'));
1176 $file->setRequired(true);
1177 $this->import_form->addItem($file);
1178
1179 $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
1180 $this->import_form->addCommandButton('importRecord', $this->lng->txt('import'));
1181 $this->import_form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1182 }
This class represents a file property in a property form.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initLanguage()

ilAdvancedMDSettingsGUI::initLanguage ( int  $record_id)
protected

Definition at line 2316 of file class.ilAdvancedMDSettingsGUI.php.

2316 : void
2317 {
2319 // read active language
2320 $default = '';
2321 foreach ($translations->getTranslations() as $translation) {
2322 if ($translation->getLangKey() == $translations->getDefaultLanguage()) {
2323 $default = $translation->getLangKey();
2324 }
2325 }
2326 $active = $this->request->getQueryParams()['mdlang'] ?? $default;
2327 $this->active_language = $active;
2328 }

References ilAdvancedMDRecordTranslations\getInstanceByRecordId().

+ Here is the call graph for this function:

◆ initRecordObject()

ilAdvancedMDSettingsGUI::initRecordObject ( )
protected
Todo:
get rid of $this->obj_id switch

Definition at line 2075 of file class.ilAdvancedMDSettingsGUI.php.

2076 {
2077 if (!$this->record instanceof ilAdvancedMDRecord) {
2078 $record_id = $this->getRecordIdFromQuery();
2079 $this->record = ilAdvancedMDRecord::_getInstanceByRecordId((int) $record_id);
2080 $this->ctrl->saveParameter($this, 'record_id');
2081
2082 // bind to parent object (aka local adv md)
2083 if (!$record_id && $this->obj_id) {
2084 $this->record->setParentObject($this->obj_id);
2085 }
2086 }
2087 return $this->record;
2088 }

References ilAdvancedMDRecord\_getInstanceByRecordId(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ loadRecordFormData()

ilAdvancedMDSettingsGUI::loadRecordFormData ( ilPropertyFormGUI  $form)
protected

Definition at line 1989 of file class.ilAdvancedMDSettingsGUI.php.

1990 {
1991 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1992
1993 $perm = $this->getPermissions()->hasPermissions(
1995 (string) $this->record->getRecordId(),
1996 array(
1999 )
2000 ,
2003 )
2004 ,
2007 )
2008 ,
2010 )
2011 );
2012
2014 $this->record->setActive((bool) $form->getInput('active'));
2015 }
2017 if (
2018 $translations->getDefaultTranslation() == null ||
2019 $translations->getDefaultTranslation()->getLangKey() == $this->active_language
2020 ) {
2021 $this->record->setTitle((string) $form->getInput('title'));
2022 }
2023 }
2025 if (
2026 $translations->getDefaultTranslation() == null ||
2027 $translations->getDefaultTranslation()->getLangKey() == $this->active_language) {
2028 $this->record->setDescription($form->getInput('desc'));
2029 }
2030 }
2031
2032 if (!$this->obj_type) {
2034 $obj_types = [];
2035 foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type) {
2036 $t = $type["obj_type"] . ":" . $type["sub_type"];
2037 $value = $form->getInput('obj_types__' . $t);
2038 if (!$value) {
2039 continue;
2040 }
2041 $obj_types[] = [
2042 'obj_type' => $type['obj_type'],
2043 'sub_type' => $type['sub_type'],
2044 'optional' => ($value > 1)
2045 ];
2046 }
2047 $this->record->setAssignedObjectTypes($obj_types);
2048 }
2049 }
2050
2051 $scopes = $form->getInput('scope');
2052 $scopes_selection = $form->getInput('scope_containers');
2053 if ($scopes && is_array($scopes_selection)) {
2054 $this->record->enableScope(true);
2055 $this->record->setScopes(
2056 array_map(
2057 function (string $scope_ref_id) {
2059 $scope->setRefId((int) $scope_ref_id);
2060 return $scope;
2061 },
2062 $scopes_selection
2063 )
2064 );
2065 } else {
2066 $this->record->enableScope(false);
2067 $this->record->setScopes([]);
2068 }
2069 return $this->record;
2070 }
Scope restrictions for advanced md records.
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-...
$scopes
Definition: ltitoken.php:96

References $scope, $scopes, ilAdvancedMDRecord\_getAssignableObjectTypes(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ilPropertyFormGUI\getInput(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ilAdvancedMDPermissionHelper\SUBACTION_RECORD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES, and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_TITLE.

+ Here is the call graph for this function:

◆ saveField()

ilAdvancedMDSettingsGUI::saveField ( )

Definition at line 1376 of file class.ilAdvancedMDSettingsGUI.php.

1376 : void
1377 {
1378 $record_id = $this->getRecordIdFromQuery();
1379 $ftype = $this->getFieldTypeFromQuery();
1380
1381 if (!$record_id || !$ftype) {
1382 $this->editFields();
1383 return;
1384 }
1385
1386 $this->initRecordObject();
1387 $this->initLanguage($record_id);
1388 $this->ctrl->saveParameter($this, 'ftype');
1389
1390 $field_definition = ilAdvancedMDFieldDefinition::getInstance(
1391 null,
1392 $ftype
1393 );
1394 $field_definition->setRecordId($record_id);
1395 $form = $this->initFieldForm($field_definition);
1396
1397 if ($form->checkInput()) {
1398 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1399 $field_definition->save();
1400
1401 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($record_id);
1402 $translations->read();
1403 $translations->updateFromForm($field_definition->getFieldId(), $this->active_language, $form);
1404
1405 $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_settings'), true);
1406 $this->ctrl->redirect($this, "editFields");
1407 }
1408
1410 $this->createField($form);
1411 }
createField(?ilPropertyFormGUI $a_form=null)
Show field type selection @access public.

References ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveRecord()

ilAdvancedMDSettingsGUI::saveRecord ( )

Save record @access public.

Parameters

Definition at line 1230 of file class.ilAdvancedMDSettingsGUI.php.

1230 : void
1231 {
1232 $this->initRecordObject();
1233 $form = $this->initForm('create');
1234 if (!$this->form->checkInput()) {
1235 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
1236 $this->createRecord($this->form);
1237 return;
1238 }
1239
1241 if ($this->obj_type) {
1242 $sub_types = (!is_array($this->sub_type))
1243 ? [$this->sub_type]
1244 : $this->sub_type;
1245 $assigned_object_types = array_map(function ($sub_type) {
1246 return [
1247 "obj_type" => $this->obj_type,
1248 "sub_type" => $sub_type,
1249 "optional" => false
1250 ];
1251 }, $sub_types);
1252 $this->record->setAssignedObjectTypes($assigned_object_types);
1253 }
1254
1255 $record->setDefaultLanguage($this->lng->getDefaultLanguage());
1256 $record->save();
1257
1259 $translations->addTranslationEntry($record->getDefaultLanguage(), true);
1260 $translations->updateTranslations(
1262 $this->form->getInput('title'),
1263 $this->form->getInput('desc')
1264 );
1265 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_added_new_record'), true);
1266 $this->ctrl->redirect($this, 'showRecords');
1267 }
setDefaultLanguage(string $language_code)
loadRecordFormData(ilPropertyFormGUI $form)

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setRecordSubTabs()

ilAdvancedMDSettingsGUI::setRecordSubTabs ( int  $level = 1,
bool  $show_settings = false 
)
protected

Set subtabs for record editing/creation.

Definition at line 1118 of file class.ilAdvancedMDSettingsGUI.php.

1118 : void
1119 {
1120 $this->tabs_gui->clearTargets();
1121 $this->tabs_gui->clearSubTabs();
1122
1123 if ($level == 1) {
1124 $this->tabs_gui->setBackTarget(
1125 $this->lng->txt('md_adv_record_list'),
1126 $this->ctrl->getLinkTarget($this, 'showRecords')
1127 );
1128
1129 if ($show_settings) {
1130 $this->tabs_gui->addTab(
1131 self::TAB_RECORD_SETTINGS,
1132 $this->lng->txt('settings'),
1133 $this->ctrl->getLinkTarget($this, self::TAB_RECORD_SETTINGS)
1134 );
1135 $this->ctrl->setParameterByClass(
1136 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1137 'record_id',
1138 $this->record->getRecordId()
1139 );
1140 $this->lng->loadLanguageModule('obj');
1141 $this->tabs_gui->addTab(
1142 self::TAB_TRANSLATION,
1143 $this->lng->txt('obj_multilinguality'),
1144 $this->ctrl->getLinkTargetByClass(
1145 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1146 ''
1147 )
1148 );
1149 }
1150 }
1151 if ($level == 2) {
1152 $this->tabs_gui->setBack2Target(
1153 $this->lng->txt('md_adv_record_list'),
1154 $this->ctrl->getLinkTarget($this, 'showRecords')
1155 );
1156 $this->tabs_gui->setBackTarget(
1157 $this->lng->txt('md_adv_field_list'),
1158 $this->ctrl->getLinkTarget($this, 'editFields')
1159 );
1160 }
1161 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setSubTabs()

ilAdvancedMDSettingsGUI::setSubTabs ( int  $context)
protected

Set sub tabs @access protected.

Definition at line 2094 of file class.ilAdvancedMDSettingsGUI.php.

2094 : void
2095 {
2096 if ($context == self::CONTEXT_OBJECT) {
2097 return;
2098 }
2099
2100 $this->tabs_gui->clearSubTabs();
2101
2102 $this->tabs_gui->addSubTabTarget(
2103 "md_adv_record_list",
2104 $this->ctrl->getLinkTarget($this, "showRecords"),
2105 '',
2106 '',
2107 '',
2108 true
2109 );
2110
2112 $this->tabs_gui->addSubTabTarget(
2113 "md_adv_presentation",
2114 $this->ctrl->getLinkTarget($this, "showPresentation")
2115 );
2116 }
2117
2118 $this->tabs_gui->addSubTabTarget(
2119 "md_adv_file_list",
2120 $this->ctrl->getLinkTarget($this, "showFiles"),
2121 "showFiles"
2122 );
2123 }

References $context, ilAdvancedMDRecord\_getAllRecordsByObjectType(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ showFiles()

ilAdvancedMDSettingsGUI::showFiles ( )
protected

Show export files.

Definition at line 521 of file class.ilAdvancedMDSettingsGUI.php.

521 : void
522 {
523 $this->setSubTabs($this->context);
524 $this->tabs_gui->setSubTabActive('md_adv_file_list');
525
527 $this->user->getId(),
528 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
529 );
530 $file_data = $files->readFilesInfo();
531
532 $table_gui = new ilAdvancedMDRecordExportFilesTableGUI($this, "showFiles");
533 $table_gui->setTitle($this->lng->txt("md_record_export_table"));
534 $table_gui->parseFiles($file_data);
535 $table_gui->addMultiCommand("downloadFile", $this->lng->txt('download'));
536
537 if ($GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
538 $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
539 }
540 $table_gui->setSelectAllCheckbox("file_id");
541
542 $this->tpl->setContent($table_gui->getHTML());
543 }
setSubTabs(int $context)
Set sub tabs @access protected.

References $GLOBALS, ILIAS\Repository\access(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showLanguageSwitch()

ilAdvancedMDSettingsGUI::showLanguageSwitch ( int  $record_id,
string  $target 
)
protected

Definition at line 2330 of file class.ilAdvancedMDSettingsGUI.php.

2330 : void
2331 {
2333
2334 if (count($translations->getTranslations()) <= 1) {
2335 return;
2336 }
2337 $actions = [];
2338 foreach ($translations->getTranslations() as $translation) {
2339 $this->ctrl->setParameter($this, 'mdlang', $translation->getLangKey());
2340 $actions[$translation->getLangKey()] = $this->ctrl->getLinkTarget(
2341 $this,
2342 $target
2343 );
2344 }
2345 $this->ctrl->setParameter($this, 'mdlang', $this->active_language);
2346 $view_control = $this->ui_factory->viewControl()->mode(
2347 $actions,
2348 $this->lng->txt('meta_aria_language_selection')
2349 )->withActive($this->active_language);
2350 $this->toolbar->addComponent($view_control);
2351 }

References ILIAS\Repository\ctrl(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ showPresentation()

ilAdvancedMDSettingsGUI::showPresentation ( )
protected

Definition at line 354 of file class.ilAdvancedMDSettingsGUI.php.

354 : void
355 {
356 $this->setSubTabs($this->context);
357 $form = $this->initFormSubstitutions();
358 if ($form instanceof ilPropertyFormGUI) {
359 $this->tabs_gui->setSubTabActive('md_adv_presentation');
360 $this->tpl->setContent($this->form->getHTML());
361 return;
362 }
363 $this->showRecords();
364 }
initFormSubstitutions()
init form table 'substitutions' @access protected

References ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ showRecords()

ilAdvancedMDSettingsGUI::showRecords ( )

Definition at line 291 of file class.ilAdvancedMDSettingsGUI.php.

291 : void
292 {
293 global $DIC;
294
295 $ilToolbar = $DIC['ilToolbar'];
296 $ilAccess = $DIC['ilAccess'];
297
298 $this->setSubTabs($this->context);
299
300 $perm = $this->getPermissions()->hasPermissions(
302 (string) $this->ref_id,
303 array(
306 )
307 );
308
310 $button = $this->ui_factory->button()->standard(
311 $this->lng->txt('add'),
312 $this->ctrl->getLinkTargetByClass(strtolower(self::class), "createRecord")
313 );
314 $ilToolbar->addComponent($button);
315
317 $ilToolbar->addSeparator();
318 }
319 }
320
322 $button = $this->ui_factory->button()->standard(
323 $this->lng->txt('import'),
324 $this->ctrl->getLinkTargetByClass(strtolower(self::class), "importRecords")
325 );
326 $ilToolbar->addComponent($button);
327 }
328
329 $obj_type_context = ($this->obj_id > 0)
330 ? ilObject::_lookupType($this->obj_id)
331 : "";
332 $table_gui = new ilAdvancedMDRecordTableGUI(
333 $this,
334 "showRecords",
335 $this->getPermissions(),
336 $obj_type_context
337 );
338 $table_gui->setTitle($this->lng->txt("md_record_list_table"));
339 $table_gui->setData($this->getParsedRecordObjects());
340
341 // permissions?
342 //$table_gui->addCommandButton('createRecord',$this->lng->txt('add'));
343 $table_gui->addMultiCommand("exportRecords", $this->lng->txt('export'));
344 $table_gui->setSelectAllCheckbox("record_id");
345
346 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
347 $table_gui->addMultiCommand("confirmDeleteRecords", $this->lng->txt("delete"));
348 $table_gui->addCommandButton("updateRecords", $this->lng->txt("save"));
349 }
350
351 $DIC->ui()->mainTemplate()->setContent($table_gui->getHTML());
352 }
static _lookupType(int $id, bool $reference=false)

References $DIC, ilObject\_lookupType(), ilAdvancedMDPermissionHelper\ACTION_MD_CREATE_RECORD, ilAdvancedMDPermissionHelper\ACTION_MD_IMPORT_RECORDS, ilAdvancedMDPermissionHelper\CONTEXT_MD, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ updateComplexOption()

ilAdvancedMDSettingsGUI::updateComplexOption ( )

Definition at line 2298 of file class.ilAdvancedMDSettingsGUI.php.

2298 : void
2299 {
2300 $field_id = $this->getFieldIdFromQuery();
2301 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
2302 $oid = $this->getOidFromQuery();
2303
2304 if ($field_definition->hasComplexOptions()) {
2305 $form = $this->initComplexOptionForm($field_definition);
2306 if ($form->checkInput() &&
2307 $field_definition->updateComplexOption($form, $oid)) {
2308 $field_definition->update();
2309 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2310 }
2311 }
2312
2313 $this->ctrl->redirect($this, "editField");
2314 }

References ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ updateField()

ilAdvancedMDSettingsGUI::updateField ( )

Update field @access public.

Definition at line 1304 of file class.ilAdvancedMDSettingsGUI.php.

1304 : void
1305 {
1306 $record_id = $this->getRecordIdFromQuery();
1307 $field_id = $this->getFieldIdFromQuery();
1308 $this->ctrl->saveParameter($this, 'record_id');
1309 $this->ctrl->saveParameter($this, 'field_id');
1310
1311 if (!$record_id || !$field_id) {
1312 $this->editFields();
1313 return;
1314 }
1315
1316 $this->initRecordObject();
1317 $this->initLanguage($record_id);
1318 $this->showLanguageSwitch($record_id, 'editField');
1319
1320 $confirm = false;
1321 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1322 $form = $this->initFieldForm($field_definition);
1323 if ($form->checkInput()) {
1324 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1325 if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1326 $field_definition->update();
1327 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1328 $translations->updateFromForm($field_id, $this->active_language, $form);
1329
1330 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1331 $this->ctrl->redirect($this, 'editField');
1332 } else {
1333 $confirm = true;
1334 }
1335 }
1336
1338
1339 // fields needs confirmation of updated settings
1340 if ($confirm) {
1341 $this->tpl->setOnScreenMessage('info', $this->lng->txt("md_adv_confirm_definition"));
1342 $field_definition->prepareDefinitionFormConfirmation($form);
1343 }
1344
1345 $this->editField($form);
1346 }
editField(?ilPropertyFormGUI $a_form=null)
Edit field @access public.

References ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstance(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ updateFields()

ilAdvancedMDSettingsGUI::updateFields ( )

Update fields @access public.

Definition at line 1006 of file class.ilAdvancedMDSettingsGUI.php.

1006 : void
1007 {
1008 $this->ctrl->saveParameter($this, 'record_id');
1009 $positions = $this->getPositionsFromPost();
1010 asort($positions, SORT_NUMERIC);
1011 $record_id = $this->getRecordIdFromQuery();
1012 if (!$record_id) {
1013 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
1014 $this->editFields();
1015 return;
1016 }
1017
1019
1020 if ($this->getPermissions()->hasPermission(
1022 (string) $record_id,
1024 )) {
1025 $positions_flipped = array_flip(array_keys($positions));
1026 foreach ($fields as $field) {
1027 $field->setPosition((int) $positions_flipped[$field->getFieldId()]);
1028 $field->update();
1029 }
1030 }
1031
1032 foreach ($fields as $field) {
1033 if ($this->getPermissions()->hasPermission(
1035 (string) $field->getFieldId(),
1038 )) {
1039 $post_searchable = (array) ($this->http->request()->getParsedBody()['searchable'] ?? []);
1040 $field->setSearchable((bool) ($post_searchable[$field->getFieldId()] ?? false));
1041 $field->update();
1042 }
1043 }
1044
1045 $language = $this->request->getQueryParams()['mdlang'] ?? false;
1046 if ($language) {
1047 $this->ctrl->setParameter($this, 'mdlang', $this->request->getQueryParams()['mdlang']);
1048 }
1049 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1050 $this->ctrl->redirect($this, "editFields");
1051 }

References ilAdvancedMDPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ilAdvancedMDPermissionHelper\SUBACTION_FIELD_SEARCHABLE.

+ Here is the call graph for this function:

◆ updateRecord()

ilAdvancedMDSettingsGUI::updateRecord ( )

Update record @access public.

Parameters

Definition at line 1058 of file class.ilAdvancedMDSettingsGUI.php.

1058 : void
1059 {
1060 $record_id = $this->getRecordIdFromQuery();
1061 if (!$record_id) {
1062 $this->ctrl->redirect($this, 'showRecords');
1063 }
1064 $this->initRecordObject();
1065 $this->initLanguage($record_id);
1066 $this->showLanguageSwitch($record_id, 'editRecord');
1067
1068 $form = $this->initForm('edit');
1069 if (!$this->form->checkInput()) {
1070 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
1071 $this->form->setValuesByPost();
1072 $this->editRecord($this->form);
1073 return;
1074 }
1075
1076 $this->loadRecordFormData($form);
1077 $this->record->update();
1078
1079 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1080 $translations->updateTranslations(
1081 $this->active_language,
1082 $this->form->getInput('title'),
1083 $this->form->getInput('desc')
1084 );
1085
1086 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1087 $this->ctrl->redirect($this, 'editRecord');
1088 }
editRecord(?ilPropertyFormGUI $form=null)

References ILIAS\Repository\ctrl(), ILIAS\Repository\form(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ updateRecords()

ilAdvancedMDSettingsGUI::updateRecords ( )

Save records (assigned object typed) @access public.

Parameters

Definition at line 718 of file class.ilAdvancedMDSettingsGUI.php.

718 : void
719 {
720 // sort positions and renumber
721 $positions = $this->getPositionsFromPost();
722 $records = $this->getParsedRecordObjects();
723
724 $all_positions = $positions;
725 foreach ($records as $record) {
726 if (!array_key_exists($record['id'], $all_positions)) {
727 $all_positions[$record['id']] = $record['position'];
728 }
729 }
730 asort($all_positions, SORT_NUMERIC);
731
732 $sorted_positions = [];
733 $i = 1;
734 foreach ($all_positions as $record_id => $pos) {
735 $sorted_positions[(int) $record_id] = $i++;
736 }
737 $selected_global = [];
738
739 $post_active = (array) ($this->http->request()->getParsedBody()['active'] ?? []);
740 if ($this->obj_id > 0) {
742 }
743 foreach ($records as $item) {
744 // BT 35518: this is kind of a hacky solution to skip items not in the table due to pagination
745 $is_on_page = array_key_exists($item['id'], $positions);
746
747 $perm = $this->getPermissions()->hasPermissions(
749 (string) $item['id'],
750 [
752 [
755 ]
756 ]
757 );
758
759 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
760
761 if (
763 $is_on_page
764 ) {
765 $obj_types = array();
766 $post_object_types = (array) ($this->http->request()->getParsedBody()['obj_types'] ?? []);
767 if (is_array($post_object_types[$record_obj->getRecordId()] ?? false)) {
768 foreach ($post_object_types[$record_obj->getRecordId()] as $type => $status) {
769 if ($status) {
770 $type = explode(":", $type);
771 $obj_types[] = array(
772 "obj_type" => ilUtil::stripSlashes($type[0]),
773 "sub_type" => ilUtil::stripSlashes($type[1]),
774 "optional" => ((int) $status == 2)
775 );
776 }
777 }
778 }
779
780 // global records in global administration and local records in local administration
781 if (!$item['readonly']) {
782 // table adv_md_record_objs
783 $record_obj->setAssignedObjectTypes($obj_types);
784 } else { // global records in local administration
785 foreach ($obj_types as $t) {
786 // table adv_md_obj_rec_select
787 ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $t["sub_type"], [$record_obj->getRecordId()], false);
788 }
789 }
790 }
791
792 if ($this->context == self::CONTEXT_ADMINISTRATION) {
793 if (
795 $is_on_page
796 ) {
797 $record_obj->setActive(isset($post_active[$record_obj->getRecordId()]));
798 }
799
800 $record_obj->setGlobalPosition((int) $sorted_positions[$record_obj->getRecordId()]);
801 $record_obj->update();
802 } elseif (
804 $is_on_page
805 ) {
806 // global, optional record
807 if ($item['readonly'] &&
808 $item['optional'] &&
809 ($post_active[$item['id']] ?? false)) {
810 $selected_global[] = $item['id'];
811 } elseif ($item['local']) {
812 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
813 $record_obj->setActive((bool) ($post_active[$item['id']] ?? false));
814 $record_obj->update();
815 }
816 }
817
818 // save local sorting
819 if ($this->context == self::CONTEXT_OBJECT) {
820 $local_position = new \ilAdvancedMDRecordObjectOrdering(
821 $item['id'],
822 $this->obj_id,
823 $this->db
824 );
825 $local_position->setPosition((int) $sorted_positions[$item['id']]);
826 $local_position->save();
827 }
828 }
829
830 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
831 $this->ctrl->redirect($this, "showRecords");
832 }
static deleteObjRecSelection(int $a_obj_id)
Delete repository object record selection.
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", ?array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_RECORD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\ACTION_RECORD_TOGGLE_ACTIVATION, ilAdvancedMDPermissionHelper\CONTEXT_RECORD, ILIAS\Repository\ctrl(), ilAdvancedMDRecord\deleteObjRecSelection(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilAdvancedMDRecord\saveObjRecSelection(), ilUtil\stripSlashes(), and ilAdvancedMDPermissionHelper\SUBACTION_RECORD_OBJECT_TYPES.

+ Here is the call graph for this function:

◆ updateSubstitutions()

ilAdvancedMDSettingsGUI::updateSubstitutions ( )

Update substitution @access public.

Definition at line 370 of file class.ilAdvancedMDSettingsGUI.php.

370 : void
371 {
372 global $DIC;
373
374 $ilAccess = $DIC['ilAccess'];
375
376 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
377 $this->ctrl->redirect($this, "showPresentation");
378 }
379
380 $form = $this->initFormSubstitutions();
381 if (!$form instanceof ilPropertyFormGUI) {
382 $this->ctrl->redirect($this, 'showPresentation');
383 return;
384 }
385 if (!$form->checkInput()) {
386 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), true);
387 $this->ctrl->redirect($this, "showPresentation");
388 }
389
390 if (!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType()) {
391 return;
392 }
393
394 foreach ($visible_records as $obj_type => $record) {
395 $perm = null;
396
397 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
398 $perm = $this->getPermissions()->hasPermissions(
400 "0",
401 array(
403 ,
405 ,
407 )
408 );
409 }
412 $sub->enableDescription((bool) $form->getInput('enabled_desc_' . $obj_type));
413 }
414
416 $sub->enableFieldNames((bool) $form->getInput('enabled_field_names_' . $obj_type));
417 }
418
420 $definitions = $sub->sortDefinitions($definitions);
421
422 // gather existing data
423 $counter = 1;
424 $old_sub = array();
425 foreach ($definitions as $def) {
426 $field_id = $def->getFieldId();
427 $old_sub[$field_id] = array(
428 "active" => $sub->isSubstituted($field_id),
429 "pos" => $counter++,
430 "bold" => $sub->isBold($field_id),
431 "newline" => $sub->hasNewline($field_id)
432 );
433 }
434
435 $sub->resetSubstitutions();
436
437 $new_sub = [];
438 foreach ($definitions as $def) {
439 $field_id = $def->getFieldId();
440 $old = $old_sub[$field_id];
441
442 $perm_def = $this->getSubstitutionFieldPermissions($obj_type, $field_id);
443 if ($perm_def["show"] ?? false) {
444 $active = (bool) $form->getInput('show_' . $obj_type . '_' . $field_id);
445 } else {
446 $active = $old["active"] ?? false;
447 }
448 if ($active) {
449 $new_sub[$field_id] = $old;
451 $new_sub[$field_id]['pos'] = (int) $form->getInput('position_' . $obj_type . '_' . $field_id);
452 }
453 if ($perm_def["bold"] ?? false) {
454 $new_sub[$field_id]['bold'] = (bool) $form->getInput('bold_' . $obj_type . '_' . $field_id);
455 }
456 if ($perm_def["newline"] ?? false) {
457 $new_sub[$field_id]['newline'] = (bool) $form->getInput('newline_' . $obj_type . '_' . $field_id);
458 }
459 }
460 }
461
462 if (sizeof($new_sub)) {
463 $new_sub = ilArrayUtil::sortArray($new_sub, "pos", "asc", true, true);
464 foreach ($new_sub as $field_id => $field) {
465 $sub->appendSubstitution($field_id, (bool) $field["bold"], (bool) $field["newline"]);
466 }
467 }
468 $sub->update();
469 }
470
471 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
472 $this->ctrl->redirect($this, "showPresentation");
473 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)

References $counter, $DIC, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_FIELD_POSITIONS, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper\ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilAdvancedMDPermissionHelper\CONTEXT_SUBSTITUTION, ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstancesByObjType(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ilArrayUtil\sortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $active_language

string ilAdvancedMDSettingsGUI::$active_language = ''
private

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

◆ $context

ilAdvancedMDSettingsGUI::$context = null
private

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

◆ $ctrl

ilCtrl ilAdvancedMDSettingsGUI::$ctrl
protected

Definition at line 51 of file class.ilAdvancedMDSettingsGUI.php.

◆ $db

ilDBInterface ilAdvancedMDSettingsGUI::$db
protected

Definition at line 55 of file class.ilAdvancedMDSettingsGUI.php.

◆ $form

ilPropertyFormGUI ilAdvancedMDSettingsGUI::$form = null
protected

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

◆ $http

GlobalHttpState ilAdvancedMDSettingsGUI::$http
protected

Definition at line 53 of file class.ilAdvancedMDSettingsGUI.php.

◆ $import_form

ilPropertyFormGUI ilAdvancedMDSettingsGUI::$import_form = null
protected

Definition at line 46 of file class.ilAdvancedMDSettingsGUI.php.

◆ $lng

ilLanguage ilAdvancedMDSettingsGUI::$lng
protected

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

◆ $logger

ilLogger ilAdvancedMDSettingsGUI::$logger
protected

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

◆ $obj_id

int ilAdvancedMDSettingsGUI::$obj_id
protected

Definition at line 69 of file class.ilAdvancedMDSettingsGUI.php.

◆ $obj_type

string ilAdvancedMDSettingsGUI::$obj_type = null
protected

Definition at line 70 of file class.ilAdvancedMDSettingsGUI.php.

◆ $permissions

ilAdvancedMDPermissionHelper ilAdvancedMDSettingsGUI::$permissions
protected

Definition at line 64 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by getPermissions().

◆ $record

◆ $ref_id

int ilAdvancedMDSettingsGUI::$ref_id
protected

Definition at line 68 of file class.ilAdvancedMDSettingsGUI.php.

Referenced by initContextParameters().

◆ $refinery

RefineryFactory ilAdvancedMDSettingsGUI::$refinery
protected

Definition at line 54 of file class.ilAdvancedMDSettingsGUI.php.

◆ $request

RequestInterface ilAdvancedMDSettingsGUI::$request
protected

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

◆ $sub_type

ilAdvancedMDSettingsGUI::$sub_type = null
protected

Definition at line 74 of file class.ilAdvancedMDSettingsGUI.php.

◆ $tabs_gui

ilTabsGUI ilAdvancedMDSettingsGUI::$tabs_gui
protected

Definition at line 57 of file class.ilAdvancedMDSettingsGUI.php.

◆ $toolbar

ilToolbarGUI ilAdvancedMDSettingsGUI::$toolbar
protected

Definition at line 60 of file class.ilAdvancedMDSettingsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilAdvancedMDSettingsGUI::$tpl
protected

Definition at line 50 of file class.ilAdvancedMDSettingsGUI.php.

◆ $ui_factory

UIFactory ilAdvancedMDSettingsGUI::$ui_factory
protected

Definition at line 58 of file class.ilAdvancedMDSettingsGUI.php.

◆ $ui_renderer

Renderer ilAdvancedMDSettingsGUI::$ui_renderer
protected

Definition at line 59 of file class.ilAdvancedMDSettingsGUI.php.

◆ $user

ilObjUser ilAdvancedMDSettingsGUI::$user
protected

Definition at line 62 of file class.ilAdvancedMDSettingsGUI.php.

◆ CONTEXT_ADMINISTRATION

const ilAdvancedMDSettingsGUI::CONTEXT_ADMINISTRATION = 1

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

Referenced by ilObjMDSettingsGUI\executeCommand().

◆ CONTEXT_OBJECT

const ilAdvancedMDSettingsGUI::CONTEXT_OBJECT = 2

◆ TAB_RECORD_SETTINGS

const ilAdvancedMDSettingsGUI::TAB_RECORD_SETTINGS = 'editRecord'
protected

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

◆ TAB_TRANSLATION

const ilAdvancedMDSettingsGUI::TAB_TRANSLATION = 'translations'
protected

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


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