ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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)
 
 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
 
ilAccess $access
 
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 81 of file class.ilAdvancedMDSettingsGUI.php.

82 {
83 global $DIC;
84
85 $this->ctrl = $DIC->ctrl();
86 $this->lng = $DIC->language();
87 $this->lng->loadLanguageModule('meta');
88 $this->tpl = $DIC->ui()->mainTemplate();
89 $this->tabs_gui = $DIC->tabs();
90
91 $this->refinery = $DIC->refinery();
92 $this->toolbar = $DIC->toolbar();
93 $this->ui_factory = $DIC->ui()->factory();
94 $this->ui_renderer = $DIC->ui()->renderer();
95 $this->request = $DIC->http()->request();
96 $this->http = $DIC->http();
97 $this->db = $DIC->database();
98 $this->user = $DIC->user();
99 $this->access = $DIC->access();
100
102 $this->logger = $DIC->logger()->amet();
103
104 $this->context = $a_context;
106 $this->context,
107 $a_ref_id,
108 $a_obj_type,
109 $a_sub_type
110 );
111
113 $this->permissions = ilAdvancedMDPermissionHelper::getInstance($DIC->user()->getId(), $this->ref_id);
114 }
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\access(), 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 797 of file class.ilAdvancedMDSettingsGUI.php.

797 : void
798 {
799 $field_ids = $this->getFieldIdsFromPost();
800 if (!count($field_ids)) {
801 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
802 $this->editFields();
803 return;
804 }
805
806 $this->initRecordObject();
807 $this->setRecordSubTabs(2);
808
809 $c_gui = new ilConfirmationGUI();
810
811 // set confirm/cancel commands
812 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFields"));
813 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_fields_sure"));
814 $c_gui->setCancel($this->lng->txt("cancel"), "editFields");
815 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFields");
816
817 // add items to delete
818 foreach ($field_ids as $field_id) {
820 $c_gui->addItem("field_id[]", (string) $field_id, $field->getTitle() ?: 'No Title');
821 }
822 $this->tpl->setContent($c_gui->getHTML());
823 }
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 532 of file class.ilAdvancedMDSettingsGUI.php.

532 : void
533 {
534 $file_ids = $this->getFileIdsFromPost();
535 if (count($file_ids) !== 1) {
536 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
537 $this->showFiles();
538 return;
539 }
540
541 $c_gui = new ilConfirmationGUI();
542 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
543 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_files_sure"));
544 $c_gui->setCancel($this->lng->txt("cancel"), "showFiles");
545 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
546
548 $this->user->getId(),
549 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
550 );
551 $file_data = $files->readFilesInfo();
552
553 // add items to delete
554 foreach ($file_ids as $file_id) {
555 $info = $file_data[$file_id];
556 $c_gui->addItem(
557 "file_id[]",
558 (string) $file_id,
559 is_array($info['name'] ?? false) ? implode(',', $info['name']) : 'No Records'
560 );
561 }
562 $this->tpl->setContent($c_gui->getHTML());
563 }
$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 602 of file class.ilAdvancedMDSettingsGUI.php.

602 : void
603 {
604 $this->initRecordObject();
605 $this->setRecordSubTabs();
606
607 $record_ids = $this->getRecordIdsFromPost();
608 if (!count($record_ids)) {
609 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
610 $this->showRecords();
611 return;
612 }
613
614 $c_gui = new ilConfirmationGUI();
615
616 // set confirm/cancel commands
617 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteRecords"));
618 $c_gui->setHeaderText($this->lng->txt("md_adv_delete_record_sure"));
619 $c_gui->setCancel($this->lng->txt("cancel"), "showRecords");
620 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteRecords");
621
622 // add items to delete
623 foreach ($record_ids as $record_id) {
625 $c_gui->addItem("record_id[]", (string) $record_id, $record->getTitle() ?: 'No Title');
626 }
627 $this->tpl->setContent($c_gui->getHTML());
628 }
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 1313 of file class.ilAdvancedMDSettingsGUI.php.

1313 : void
1314 {
1315 $record_id = $this->getRecordIdFromQuery();
1316 $field_type = $this->getFieldTypeFromPost();
1317 if (!$field_type) {
1318 $field_type = $this->getFieldTypeFromQuery();
1319 }
1320
1321 $this->initRecordObject();
1322 $this->ctrl->setParameter($this, 'ftype', $field_type);
1323 $this->setRecordSubTabs(2);
1324 if (!$record_id || !$field_type) {
1325 $this->editFields();
1326 return;
1327 }
1328
1329 if (!$a_form) {
1330 $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $field_type);
1331 $field_definition->setRecordId($record_id);
1332 $a_form = $this->initFieldForm($field_definition);
1333 }
1334 $this->tpl->setContent($a_form->getHTML());
1335 }
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 1056 of file class.ilAdvancedMDSettingsGUI.php.

1056 : void
1057 {
1058 $this->initRecordObject();
1059 $this->setRecordSubTabs();
1060 if (!$form instanceof ilPropertyFormGUI) {
1061 $this->initForm('create');
1062 }
1063 $this->tpl->setContent($this->form->getHTML());
1064 }
This class represents a property form user interface.
form(?array $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 825 of file class.ilAdvancedMDSettingsGUI.php.

825 : void
826 {
827 $this->ctrl->saveParameter($this, 'record_id');
828
829 $field_ids = $this->getFieldIdsFromPost();
830 if (!count($field_ids)) {
831 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
832 $this->editFields();
833 return;
834 }
835
836 // all fields have to be deletable
837 $fail = array();
838 foreach ($field_ids as $field_id) {
839 if (!$this->getPermissions()->hasPermission(
841 (int) $field_id,
843 )) {
845 $fail[] = $field->getTitle();
846 }
847 }
848 if ($fail) {
849 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
850 $this->ctrl->redirect($this, "editFields");
851 }
852
853 foreach ($field_ids as $field_id) {
855 $field->delete();
856 }
857 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_fields'), true);
858 $this->ctrl->redirect($this, "editFields");
859 }

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 570 of file class.ilAdvancedMDSettingsGUI.php.

570 : void
571 {
572 $file_ids = $this->getFileIdsFromPost();
573 if (count($file_ids) === 0) {
574 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
575 $this->showFiles();
576 return;
577 }
578
579 if (!$GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
580 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
581 $GLOBALS['DIC']->ctrl()->redirect($this, 'showFiles');
582 }
583
585 $this->user->getId(),
586 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
587 );
588 foreach ($file_ids as $file_id) {
589 $files->deleteByFileId(
590 $this->user->getId(),
591 $file_id
592 );
593 }
594 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_files'));
595 $this->showFiles();
596 }
$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 634 of file class.ilAdvancedMDSettingsGUI.php.

634 : void
635 {
636 $record_ids = $this->getRecordIdsFromPost();
637 if (!count($record_ids)) {
638 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
639 $this->showRecords();
640 return;
641 }
642
643 // all records have to be deletable
644 $fail = array();
645 foreach ($record_ids as $record_id) {
646 // must not delete global records in local context
647 if ($this->context == self::CONTEXT_OBJECT) {
649 if (!$record->getParentObject()) {
650 $fail[] = $record->getTitle();
651 }
652 }
653
654 if (!$this->getPermissions()->hasPermission(
656 (int) $record_id,
658 )) {
660 $fail[] = $record->getTitle();
661 }
662 }
663 if ($fail) {
664 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
665 $this->ctrl->redirect($this, "showRecords");
666 }
667
668 foreach ($record_ids as $record_id) {
670 $record->delete();
671 }
672 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_deleted_records'), true);
673 $this->ctrl->redirect($this, "showRecords");
674 }

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 513 of file class.ilAdvancedMDSettingsGUI.php.

513 : void
514 {
515 $file_ids = $this->getFileIdsFromPost();
516 if (count($file_ids) !== 1) {
517 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('md_adv_select_one_file'));
518 $this->showFiles();
519 return;
520 }
522 $this->user->getId(),
523 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
524 );
525 $files->download($file_ids[0], 'ilias_meta_data_record.xml');
526 }

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 1981 of file class.ilAdvancedMDSettingsGUI.php.

1981 : void
1982 {
1983 $field_id = $this->getFieldIdFromQuery();
1984 if (!$field_id) {
1985 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_select_one'));
1986 $this->ctrl->redirect($this, 'showRecords');
1987 }
1988
1989 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1990 if (!$field_definition->hasComplexOptions()) {
1991 $this->ctrl->redirect($this, "editField");
1992 }
1993
1994 if (!$a_form) {
1995 $a_form = $this->initComplexOptionForm($field_definition);
1996 }
1997
1998 $this->tpl->setContent($a_form->getHTML());
1999 }
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 1234 of file class.ilAdvancedMDSettingsGUI.php.

1234 : void
1235 {
1236 $record_id = $this->getRecordIdFromQuery();
1237 $field_id = $this->getFieldIdFromQuery();
1238 if (!$record_id || !$field_id) {
1239 $this->editFields();
1240 return;
1241 }
1242 $this->ctrl->saveParameter($this, 'field_id');
1243 $this->ctrl->saveParameter($this, 'record_id');
1244 $this->initRecordObject();
1245 $this->setRecordSubTabs(2);
1246
1247 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1248
1249 if (!$a_form instanceof ilPropertyFormGUI) {
1250 $this->initLanguage($this->record->getRecordId());
1251 $this->showLanguageSwitch($this->record->getRecordId(), 'editField');
1252 $a_form = $this->initFieldForm($field_definition);
1253 }
1254 $table = null;
1255 if ($field_definition->hasComplexOptions()) {
1256 $table = $field_definition->getComplexOptionsOverview($this, "editField");
1257 }
1258 $this->tpl->setContent($a_form->getHTML() . $table);
1259 }
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 879 of file class.ilAdvancedMDSettingsGUI.php.

879 : void
880 {
881 $record_id = $this->getRecordIdFromQuery();
882 if (!$record_id) {
883 $this->ctrl->redirect($this, 'showRecords');
884 }
885 $this->ctrl->saveParameter($this, 'record_id');
886 $this->initRecordObject();
887 $this->setRecordSubTabs();
888 $this->initLanguage($record_id);
889 $this->showLanguageSwitch($record_id, 'editFields');
890
891 $perm = $this->getPermissions()->hasPermissions(
893 (int) $this->record->getRecordId(),
894 array(
896 ,
898 )
899 );
900
901 $filter_warn = [];
903 // type selection
904 $field_buttons = [];
905 foreach (ilAdvancedMDFieldDefinition::getValidTypes() as $type) {
906 $field = ilAdvancedMDFieldDefinition::getInstance(null, $type);
907
908 $this->ctrl->setParameter($this, 'ftype', $type);
909 $create_link = $this->ctrl->getLinkTarget($this, 'createField');
910 $this->ctrl->clearParameterByClass(strtolower(self::class), 'ftype');
911
912 $field_buttons[] = $this->ui_factory->button()->shy(
913 $this->lng->txt($field->getTypeTitle()),
914 $create_link
915 );
916
917 if (!$field->isFilterSupported()) {
918 $filter_warn[] = $this->lng->txt($field->getTypeTitle());
919 }
920 }
921
922 if (count($this->toolbar->getItems())) {
923 $this->toolbar->addSeparator();
924 }
925
926 $dropdown = $this->ui_factory->dropdown()
927 ->standard($field_buttons)
928 ->withLabel($this->lng->txt('meta_advmd_add_field'));
929 $this->toolbar->addComponent($dropdown);
930 }
931
932 // #17092
933 if (sizeof($filter_warn)) {
934 $this->tpl->setOnScreenMessage('info', sprintf($this->lng->txt("md_adv_field_filter_warning"), implode(", ", $filter_warn)));
935 }
936
937 // show field table
939 $this->record->getRecordId(),
940 false,
941 $this->active_language
942 );
943
944 $table_gui = new ilAdvancedMDFieldTableGUI(
945 $this,
946 'editFields',
947 $this->getPermissions(),
949 $this->record->getDefaultLanguage()
950 );
951 $table_gui->setTitle($this->lng->txt("md_adv_field_table"));
952 $table_gui->parseDefinitions($fields);
953 if (sizeof($fields)) {
954 $table_gui->addCommandButton("updateFields", $this->lng->txt("save"));
955 }
956 $table_gui->addCommandButton("showRecords", $this->lng->txt('cancel'));
957 $table_gui->addMultiCommand("confirmDeleteFields", $this->lng->txt("delete"));
958 $table_gui->setSelectAllCheckbox("field_id");
959
960 $this->tpl->setContent($table_gui->getHTML());
961 }
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.

References 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 861 of file class.ilAdvancedMDSettingsGUI.php.

861 : void
862 {
863 $record_id = $this->getRecordIdFromQuery();
864 if (!$record_id) {
865 $this->ctrl->redirect($this, 'showRecords');
866 }
867 $this->initRecordObject();
868 $this->setRecordSubTabs(1, true);
869 $this->tabs_gui->activateTab(self::TAB_RECORD_SETTINGS);
870
871 if (!$form instanceof ilPropertyFormGUI) {
872 $this->initLanguage($record_id);
873 $this->showLanguageSwitch($record_id, 'editRecord');
874 $this->initForm('edit');
875 }
876 $this->tpl->setContent($this->form->getHTML());
877 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilAdvancedMDSettingsGUI::executeCommand ( )

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

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

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 442 of file class.ilAdvancedMDSettingsGUI.php.

442 : void
443 {
444 $record_ids = $this->getRecordIdsFromPost();
445 if (!count($record_ids)) {
446 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
447 $this->showRecords();
448 return;
449 }
450
451 // all records have to be exportable
452 $fail = array();
453 foreach ($record_ids as $record_id) {
454 if (!$this->getPermissions()->hasPermission(
456 (int) $record_id,
458 )) {
460 $fail[] = $record->getTitle();
461 }
462 }
463 if ($fail) {
464 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_perm_copy') . " " . implode(", ", $fail), true);
465 $this->ctrl->redirect($this, "showRecords");
466 }
467
468 $xml_writer = new ilAdvancedMDRecordXMLWriter((array) $record_ids);
469 $xml_writer->write();
470
471 $export_files = new ilAdvancedMDRecordExportFiles(
472 $this->user->getId(),
473 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
474 );
475 $export_files->create($xml_writer->xmlDumpMem(false));
476
477 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_records_exported'));
478 $this->showFiles();
479 }

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 142 of file class.ilAdvancedMDSettingsGUI.php.

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

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

+ Here is the call graph for this function:

◆ getFieldIdsFromPost()

ilAdvancedMDSettingsGUI::getFieldIdsFromPost ( )
protected

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

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

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getFieldTypeFromPost()

ilAdvancedMDSettingsGUI::getFieldTypeFromPost ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ getFieldTypeFromQuery()

ilAdvancedMDSettingsGUI::getFieldTypeFromQuery ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ getFileIdsFromPost()

ilAdvancedMDSettingsGUI::getFileIdsFromPost ( )
protected

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

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

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getOidFromQuery()

ilAdvancedMDSettingsGUI::getOidFromQuery ( )
protected

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

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

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 1851 of file class.ilAdvancedMDSettingsGUI.php.

1851 : array
1852 {
1853 $res = [];
1854
1855 $sub_type = (!is_array($this->sub_type))
1856 ? [$this->sub_type]
1857 : $this->sub_type;
1858
1859 if ($this->context === self::CONTEXT_OBJECT) {
1860 // get all records selected for subtype
1861 foreach ($sub_type as $st) {
1862 $selected[$st] = ilAdvancedMDRecord::getObjRecSelection($this->obj_id, $st);
1863 }
1864 }
1865
1867 $orderings = new ilAdvancedMDRecordObjectOrderings();
1868 $records = $orderings->sortRecords($records, $this->obj_id);
1869
1870 $position = 0;
1871
1872 // get all records usuable in current context
1873 foreach ($records as $record) {
1874 $parent_id = $record->getParentObject();
1875
1876 if ($this->context == self::CONTEXT_ADMINISTRATION) {
1877 if ($parent_id) {
1878 continue;
1879 }
1880 } else {
1881 // does not match current object
1882 if ($parent_id && $parent_id != $this->obj_id) {
1883 continue;
1884 }
1885
1886 // inactive records only in administration
1887 if (!$parent_id && !$record->isActive()) {
1888 continue;
1889 }
1890 // scope needs to match in object context
1891 if (
1893 $this->ref_id,
1895 )
1896 ) {
1897 continue;
1898 }
1899 }
1900
1901 $tmp_arr = [];
1902 $tmp_arr['readonly'] = null;
1903 $tmp_arr['local'] = null;
1904 $tmp_arr['optional'] = null;
1905 $tmp_arr['id'] = $record->getRecordId();
1906 $tmp_arr['active'] = $record->isActive();
1907 $tmp_arr['title'] = $record->getTitle();
1908 $tmp_arr['description'] = $record->getDescription();
1909 $tmp_arr['fields'] = [];
1910 /*
1911 * This is a workaround to fix sorting by scope, see #21963
1912 */
1913 $tmp_arr['first_scope'] = ilObject::_lookupTitle(
1915 );
1916 $tmp_arr['obj_types'] = $record->getAssignedObjectTypes();
1917 foreach ($record->getAssignedObjectTypes() as $idx => $item) {
1918 $tmp_arr['obj_types'][$idx]['context'] = null;
1919 }
1920 $position += 10;
1921 $tmp_arr['position'] = $position;
1922
1923 $tmp_arr['perm'] = $this->permissions->hasPermissions(
1926 array(
1928 ,
1930 ,
1932 ,
1935 )
1936 )
1937 );
1938
1939 if ($this->obj_type) {
1940 $tmp_arr["readonly"] = !(bool) $parent_id;
1941 $tmp_arr["local"] = $parent_id;
1942
1943 // local records are never optional (or unassigned)
1944 $assigned = (bool) $parent_id;
1945 $optional = false;
1946 foreach ($tmp_arr['obj_types'] as $idx => $item) {
1947 if ($item["obj_type"] == $this->obj_type &&
1948 in_array($item["sub_type"], $sub_type)) {
1949 $assigned = true;
1950 $optional = $item["optional"];
1951 $tmp_arr['obj_types'][$idx]['context'] = true;
1952 } else {
1953 unset($tmp_arr['obj_types'][$idx]);
1954 }
1955 }
1956 $tmp_arr['optional'] = $optional;
1957 if ($optional) {
1958 // in object context "active" means selected record
1959 // $tmp_arr['active'] = (is_array($selected[$item["sub_type"]]) && in_array($record->getRecordId(), $selected[$item["sub_type"]]));
1960 $tmp_arr['local_selected'] = [];
1961 foreach ($selected as $key => $records) {
1962 if (in_array($record->getRecordId(), $records)) {
1963 $tmp_arr['local_selected'][$this->obj_type][] = $key;
1964 }
1965 }
1966 }
1967 }
1968
1969 if ($assigned ?? true) {
1970 $res[] = $tmp_arr;
1971 }
1972 }
1973 return $res;
1974 }
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 238 of file class.ilAdvancedMDSettingsGUI.php.

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

References $permissions.

◆ getPositionsFromPost()

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

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

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

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

+ Here is the call graph for this function:

◆ getRecordIdFromQuery()

ilAdvancedMDSettingsGUI::getRecordIdFromQuery ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ getRecordIdsFromPost()

ilAdvancedMDSettingsGUI::getRecordIdsFromPost ( )
protected

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

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

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ importRecord()

ilAdvancedMDSettingsGUI::importRecord ( )

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

1145 : void
1146 {
1147 $this->initImportForm();
1148 if (!$this->import_form->checkInput()) {
1149 $this->import_form->setValuesByPost();
1150 $this->importRecords();
1151 return;
1152 }
1153
1154 $import_files = new ilAdvancedMDRecordImportFiles();
1155 if (!$create_time = $import_files->moveUploadedFile($_FILES['file']['tmp_name'])) {
1156 $this->createRecord();
1157 return;
1158 }
1159
1160 try {
1161 $parser = new ilAdvancedMDRecordParser($import_files->getImportFileByCreationDate($create_time));
1162
1163 // local import?
1164 if ($this->context === self::CONTEXT_OBJECT) {
1165 $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
1166 }
1167
1168 // Validate
1170 $parser->startParsing();
1171
1172 // Insert
1173 $parser->setMode(ilAdvancedMDRecordParser::MODE_INSERT);
1174 $parser->startParsing();
1175 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_added_new_record'), true);
1176 $this->ctrl->redirect($this, "showRecords");
1177 } catch (ilSaxParserException $exc) {
1178 $this->tpl->setOnScreenMessage('failure', $exc->getMessage(), true);
1179 $this->ctrl->redirect($this, "importRecords");
1180 }
1181
1182 // Finally delete import file
1183 $import_files->deleteFileByCreationDate($create_time);
1184 }
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 1066 of file class.ilAdvancedMDSettingsGUI.php.

1066 : void
1067 {
1068 $this->initRecordObject();
1069 $this->setRecordSubTabs();
1070
1071 // Import Table
1072 $this->initImportForm();
1073 $this->tpl->setContent($this->import_form->getHTML());
1074 }

◆ initComplexOptionForm()

ilAdvancedMDSettingsGUI::initComplexOptionForm ( ilAdvancedMDFieldDefinition  $a_def)
protected

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

2002 {
2003 $this->ctrl->saveParameter($this, "record_id");
2004 $this->ctrl->saveParameter($this, "field_id");
2005 $this->ctrl->saveParameter($this, "oid");
2006
2007 $form = new ilPropertyFormGUI();
2008 $form->setTitle($this->lng->txt("md_adv_edit_complex_option"));
2009 $form->setFormAction($this->ctrl->getFormAction($this, "updateComplexOption"));
2010
2011 $oid = $this->getOidFromQuery();
2012 $a_def->initOptionForm($form, $oid);
2013
2014 $form->addCommandButton("updateComplexOption", $this->lng->txt("save"));
2015 $form->addCommandButton("editField", $this->lng->txt("cancel"));
2016
2017 return $form;
2018 }
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 246 of file class.ilAdvancedMDSettingsGUI.php.

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

References $ref_id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ initFieldForm()

ilAdvancedMDSettingsGUI::initFieldForm ( ilAdvancedMDFieldDefinition  $a_definition)
protected

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

1375 {
1376 $is_creation_mode = $a_definition->getFieldId() ? false : true;
1377
1378 $form = new ilPropertyFormGUI();
1379 $form->setFormAction($this->ctrl->getFormAction($this));
1380
1381 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1382 if ($is_creation_mode) {
1383 $form->setDescription($a_definition->getDescription());
1384 } else {
1385 $form->setDescription($translations->getFormTranslationInfo(
1386 $a_definition->getFieldId(),
1387 $this->active_language
1388 ));
1389 }
1390 $type = new ilNonEditableValueGUI($this->lng->txt("type"));
1391 $type->setValue($this->lng->txt($a_definition->getTypeTitle()));
1392 $form->addItem($type);
1393 $a_definition->addToFieldDefinitionForm($form, $this->getPermissions(), $this->active_language);
1394
1395 if ($is_creation_mode) {
1396 $form->setTitle($this->lng->txt('md_adv_create_field'));
1397 $form->addCommandButton('saveField', $this->lng->txt('create'));
1398 } else {
1399 $form->setTitle($this->lng->txt('md_adv_edit_field'));
1400 $form->addCommandButton('updateField', $this->lng->txt('save'));
1401 }
1402
1403 $form->addCommandButton('editFields', $this->lng->txt('cancel'));
1404
1405 return $form;
1406 }
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 1408 of file class.ilAdvancedMDSettingsGUI.php.

1409 {
1410 if ($this->form instanceof ilPropertyFormGUI) {
1411 return $this->form;
1412 }
1413 $perm = $this->getPermissions()->hasPermissions(
1415 $this->record->getRecordId(),
1416 array(
1419 )
1420 ,
1423 )
1424 ,
1427 )
1428 ,
1430 )
1431 );
1432
1433 $this->form = new ilPropertyFormGUI();
1434
1435 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1436 $this->form->setDescription($translations->getFormTranslationInfo($this->active_language));
1437 $this->form->setFormAction($this->ctrl->getFormAction($this));
1438
1439 // title
1440 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
1441 $title->setValue($this->record->getTitle());
1442 $title->setSize(20);
1443 $title->setMaxLength(70);
1444 $title->setRequired(true);
1445
1447 $title->setDisabled(true);
1448 }
1449 $this->form->addItem($title);
1450 $translations->modifyTranslationInfoForTitle($this->form, $title, $this->active_language);
1451
1452 // desc
1453 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
1454 $desc->setValue($this->record->getDescription());
1455 $desc->setRows(3);
1456
1458 $desc->setDisabled(true);
1459 }
1460 $this->form->addItem($desc);
1461 $translations->modifyTranslationInfoForDescription($this->form, $desc, $this->active_language);
1462
1463 // active
1464 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_active'), 'active');
1465 $check->setChecked($this->record->isActive());
1466 $check->setValue("1");
1467 $this->form->addItem($check);
1468
1470 $check->setDisabled(true);
1471 }
1472
1473 if (!$this->obj_type) {
1474 // scope
1475 $scope = new ilCheckboxInputGUI($this->lng->txt('md_adv_scope'), 'scope');
1476 $scope->setInfo($this->lng->txt('md_adv_scope_info'));
1477 $scope->setChecked($this->record->enabledScope());
1478 $scope->setValue("1");
1479 $this->form->addItem($scope);
1480 $subitems = new ilRepositorySelector2InputGUI(
1481 $this->lng->txt('md_adv_scope_objects'),
1482 "scope_containers",
1483 true,
1484 $this->form
1485 );
1486 $subitems->setValue($this->record->getScopeRefIds());
1487 $exp = $subitems->getExplorerGUI();
1488
1489 $definition = $GLOBALS['DIC']['objDefinition'];
1490 $white_list = [];
1491 foreach ($definition->getAllRepositoryTypes() as $type) {
1492 if ($definition->isContainer($type)) {
1493 $white_list[] = $type;
1494 }
1495 }
1496
1497 $exp->setTypeWhiteList($white_list);
1498 $exp->setSkipRootNode(false);
1499 $exp->setRootId(ROOT_FOLDER_ID);
1500 $scope->addSubItem($subitems);
1501 }
1502
1503 if (!$this->obj_type) {
1504 $section = new ilFormSectionHeaderGUI();
1505 $section->setTitle($this->lng->txt('md_obj_types'));
1506 $this->form->addItem($section);
1507
1508 // see ilAdvancedMDRecordTableGUI::fillRow()
1509 $options = array(
1510 0 => $this->lng->txt("meta_obj_type_inactive"),
1511 1 => $this->lng->txt("meta_obj_type_mandatory"),
1512 2 => $this->lng->txt("meta_obj_type_optional")
1513 );
1514
1515 foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type) {
1516 $t = $type["obj_type"] . ":" . $type["sub_type"];
1517 $this->lng->loadLanguageModule($type["obj_type"]);
1518
1519 /*
1520 * BT 35914: workaround for hiding portfolio pages in portfolios,
1521 * since they only get data from portfolio templates
1522 */
1523 $hidden = false;
1524 if ($type["obj_type"] == "prtf" && $type["sub_type"] == "pfpg") {
1525 $hidden = true;
1526 }
1527 // EmployeeTalks get their md from templates
1528 if ($type["obj_type"] == "tals" && $type["sub_type"] == "etal") {
1529 $hidden = true;
1530 }
1531
1532
1533 $type_options = $options;
1534 switch ($type["obj_type"]) {
1535 case "orgu":
1536 // currently only optional records for org unit (types)
1537 unset($type_options[1]);
1538 break;
1539 case "talt":
1540 // currently only optional records for talk templates (types)
1541 unset($type_options[1]);
1542 break;
1543 case "rcrs":
1544 // optional makes no sense for ecs-courses
1545 unset($type_options[2]);
1546 break;
1547 }
1548
1549 $value = 0;
1550 if ($a_mode == "edit") {
1551 foreach ($this->record->getAssignedObjectTypes() as $item) {
1552 if ($item["obj_type"] == $type["obj_type"] &&
1553 $item["sub_type"] == $type["sub_type"]) {
1554 $value = $item["optional"]
1555 ? 2
1556 : 1;
1557 }
1558 }
1559 }
1560
1561 $sel_name = 'obj_types__' . $t;
1562
1563 if ($hidden) {
1564 $hidden = new ilHiddenInputGUI($sel_name);
1565 $hidden->setValue((string) $value);
1566 $this->form->addItem($hidden);
1567 continue;
1568 }
1569
1570 $check = new ilSelectInputGUI($type['text'], $sel_name);
1571 //$check = new ilSelectInputGUI($type["text"], 'obj_types[' . $t . ']');
1572 $check->setOptions($type_options);
1573 $check->setValue($value);
1574 $this->form->addItem($check);
1575
1577 $check->setDisabled(true);
1578 }
1579 }
1580 }
1581
1582 switch ($a_mode) {
1583 case 'create':
1584 $this->form->setTitle($this->lng->txt('md_adv_create_record'));
1585 $this->form->addCommandButton('saveRecord', $this->lng->txt('add'));
1586 $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1587 break;
1588
1589 case 'edit':
1590 $this->form->setTitle($this->lng->txt('md_adv_edit_record'));
1591 $this->form->addCommandButton('updateRecord', $this->lng->txt('save'));
1592 $this->form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1593 }
1594 return $this->form;
1595 }
$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, ILIAS\UI\Implementation\Component\Input\Field\$options, $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 1601 of file class.ilAdvancedMDSettingsGUI.php.

1602 {
1603 if (!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType()) {
1604 return null;
1605 }
1606
1607 $this->form = new ilPropertyFormGUI();
1608 $this->form->setFormAction($this->ctrl->getFormAction($this));
1609 #$this->form->setTableWidth('100%');
1610
1611 // substitution
1612 foreach ($visible_records as $obj_type => $records) {
1613 $read_only = !$this->access->checkAccess('write', '', $this->ref_id);
1614 ;
1615
1617
1618 // Show section
1619 $section = new ilFormSectionHeaderGUI();
1620 $section->setTitle($this->lng->txt('objs_' . $obj_type));
1621 $this->form->addItem($section);
1622
1623 $check = new ilCheckboxInputGUI($this->lng->txt('description'), 'enabled_desc_' . $obj_type);
1624 $check->setValue("1");
1625 $check->setOptionTitle($this->lng->txt('md_adv_desc_show'));
1626 $check->setChecked($sub->isDescriptionEnabled());
1627 $this->form->addItem($check);
1628
1629 if ($read_only) {
1630 $check->setDisabled(true);
1631 }
1632
1633 $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'), 'enabled_field_names_' . $obj_type);
1634 $check->setValue("1");
1635 $check->setOptionTitle($this->lng->txt('md_adv_fields_show'));
1636 $check->setChecked($sub->enabledFieldNames());
1637 $this->form->addItem($check);
1638
1639 if ($read_only) {
1640 $check->setDisabled(true);
1641 }
1642
1644 $definitions = $sub->sortDefinitions($definitions);
1645
1646 $counter = 1;
1647 foreach ($definitions as $def) {
1648 $definition_id = $def->getFieldId();
1649
1650 $title = ilAdvancedMDRecord::_lookupTitle((int) $def->getRecordId());
1651 $title = $def->getTitle() . ' (' . $title . ')';
1652
1653 $check = new ilCheckboxInputGUI($title, 'show_' . $obj_type . '_' . $definition_id);
1654 $check->setValue("1");
1655 $check->setOptionTitle($this->lng->txt('md_adv_show'));
1656 $check->setChecked($sub->isSubstituted($definition_id));
1657
1658 if ($read_only) {
1659 $check->setDisabled(true);
1660 }
1661
1662 $pos = new ilNumberInputGUI(
1663 $this->lng->txt('position'),
1664 'position_' . $obj_type . '_' . $definition_id
1665 );
1666 $pos->setSize(3);
1667 $pos->setMaxLength(4);
1668 $pos->allowDecimals(true);
1669 $pos->setValue(sprintf('%.1f', $counter++));
1670 $check->addSubItem($pos);
1671
1672 if ($read_only) {
1673 $pos->setDisabled(true);
1674 }
1675
1676 $bold = new ilCheckboxInputGUI(
1677 $this->lng->txt('bold'),
1678 'bold_' . $obj_type . '_' . $definition_id
1679 );
1680 $bold->setValue("1");
1681 $bold->setChecked($sub->isBold($definition_id));
1682 $check->addSubItem($bold);
1683
1684 if ($read_only) {
1685 $bold->setDisabled(true);
1686 }
1687
1688 $bold = new ilCheckboxInputGUI(
1689 $this->lng->txt('newline'),
1690 'newline_' . $obj_type . '_' . $definition_id
1691 );
1692 $bold->setValue("1");
1693 $bold->setChecked($sub->hasNewline($definition_id));
1694 $check->addSubItem($bold);
1695
1696 if ($read_only) {
1697 $bold->setDisabled(true);
1698 }
1699
1700 $this->form->addItem($check);
1701 }
1702 }
1703 $this->form->setTitle($this->lng->txt('md_adv_substitution_table'));
1704
1705 if ($this->access->checkAccess('write', '', $this->ref_id)) {
1706 $this->form->addCommandButton('updateSubstitutions', $this->lng->txt('save'));
1707 }
1708 return $this->form;
1709 }
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!
static _getInstanceByObjectType(string $a_type)
This class represents a number property in a property form.
$counter

References $check, $counter, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ilAdvancedMDRecord\_lookupTitle(), ILIAS\Repository\access(), 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 1124 of file class.ilAdvancedMDSettingsGUI.php.

1124 : void
1125 {
1126 if (is_object($this->import_form)) {
1127 return;
1128 }
1129
1130 $this->import_form = new ilPropertyFormGUI();
1131 $this->import_form->setMultipart(true);
1132 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
1133
1134 // add file property
1135 $file = new ilFileInputGUI($this->lng->txt('file'), 'file');
1136 $file->setSuffixes(array('xml'));
1137 $file->setRequired(true);
1138 $this->import_form->addItem($file);
1139
1140 $this->import_form->setTitle($this->lng->txt('md_adv_import_record'));
1141 $this->import_form->addCommandButton('importRecord', $this->lng->txt('import'));
1142 $this->import_form->addCommandButton('showRecords', $this->lng->txt('cancel'));
1143 }
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 2038 of file class.ilAdvancedMDSettingsGUI.php.

2038 : void
2039 {
2041 // read active language
2042 $default = '';
2043 foreach ($translations->getTranslations() as $translation) {
2044 if ($translation->getLangKey() == $translations->getDefaultLanguage()) {
2045 $default = $translation->getLangKey();
2046 }
2047 }
2048 $active = $this->request->getQueryParams()['mdlang'] ?? $default;
2049 $this->active_language = $active;
2050 }

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 1797 of file class.ilAdvancedMDSettingsGUI.php.

1798 {
1799 if (!$this->record instanceof ilAdvancedMDRecord) {
1800 $record_id = $this->getRecordIdFromQuery();
1801 $this->record = ilAdvancedMDRecord::_getInstanceByRecordId((int) $record_id);
1802 $this->ctrl->saveParameter($this, 'record_id');
1803
1804 // bind to parent object (aka local adv md)
1805 if (!$record_id && $this->obj_id) {
1806 $this->record->setParentObject($this->obj_id);
1807 }
1808 }
1809 return $this->record;
1810 }

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

+ Here is the call graph for this function:

◆ loadRecordFormData()

ilAdvancedMDSettingsGUI::loadRecordFormData ( ilPropertyFormGUI  $form)
protected

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

1712 {
1713 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1714
1715 $perm = $this->getPermissions()->hasPermissions(
1717 $this->record->getRecordId(),
1718 array(
1721 )
1722 ,
1725 )
1726 ,
1729 )
1730 ,
1732 )
1733 );
1734
1736 $this->record->setActive((bool) $form->getInput('active'));
1737 }
1739 if (
1740 $translations->getDefaultTranslation() == null ||
1741 $translations->getDefaultTranslation()->getLangKey() == $this->active_language
1742 ) {
1743 $this->record->setTitle((string) $form->getInput('title'));
1744 }
1745 }
1747 if (
1748 $translations->getDefaultTranslation() == null ||
1749 $translations->getDefaultTranslation()->getLangKey() == $this->active_language) {
1750 $this->record->setDescription($form->getInput('desc'));
1751 }
1752 }
1753
1754 if (!$this->obj_type) {
1756 $obj_types = [];
1757 foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $type) {
1758 $t = $type["obj_type"] . ":" . $type["sub_type"];
1759 $value = $form->getInput('obj_types__' . $t);
1760 if (!$value) {
1761 continue;
1762 }
1763 $obj_types[] = [
1764 'obj_type' => $type['obj_type'],
1765 'sub_type' => $type['sub_type'],
1766 'optional' => ($value > 1)
1767 ];
1768 }
1769 $this->record->setAssignedObjectTypes($obj_types);
1770 }
1771 }
1772
1773 $scopes = $form->getInput('scope');
1774 $scopes_selection = $form->getInput('scope_containers');
1775 if ($scopes && is_array($scopes_selection)) {
1776 $this->record->enableScope(true);
1777 $this->record->setScopes(
1778 array_map(
1779 function (string $scope_ref_id) {
1781 $scope->setRefId((int) $scope_ref_id);
1782 return $scope;
1783 },
1784 $scopes_selection
1785 )
1786 );
1787 } else {
1788 $this->record->enableScope(false);
1789 $this->record->setScopes([]);
1790 }
1791 return $this->record;
1792 }
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 1337 of file class.ilAdvancedMDSettingsGUI.php.

1337 : void
1338 {
1339 $record_id = $this->getRecordIdFromQuery();
1340 $ftype = $this->getFieldTypeFromQuery();
1341
1342 if (!$record_id || !$ftype) {
1343 $this->editFields();
1344 return;
1345 }
1346
1347 $this->initRecordObject();
1348 $this->initLanguage($record_id);
1349 $this->ctrl->saveParameter($this, 'ftype');
1350
1351 $field_definition = ilAdvancedMDFieldDefinition::getInstance(
1352 null,
1353 $ftype
1354 );
1355 $field_definition->setRecordId($record_id);
1356 $form = $this->initFieldForm($field_definition);
1357
1358 if ($form->checkInput()) {
1359 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1360 $field_definition->save();
1361
1362 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($record_id);
1363 $translations->read();
1364 $translations->updateFromForm($field_definition->getFieldId(), $this->active_language, $form);
1365
1366 $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_settings'), true);
1367 $this->ctrl->redirect($this, "editFields");
1368 }
1369
1371 $this->createField($form);
1372 }
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 1191 of file class.ilAdvancedMDSettingsGUI.php.

1191 : void
1192 {
1193 $this->initRecordObject();
1194 $form = $this->initForm('create');
1195 if (!$this->form->checkInput()) {
1196 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
1197 $this->createRecord($this->form);
1198 return;
1199 }
1200
1202 if ($this->obj_type) {
1203 $sub_types = (!is_array($this->sub_type))
1204 ? [$this->sub_type]
1205 : $this->sub_type;
1206 $assigned_object_types = array_map(function ($sub_type) {
1207 return [
1208 "obj_type" => $this->obj_type,
1209 "sub_type" => $sub_type,
1210 "optional" => false
1211 ];
1212 }, $sub_types);
1213 $this->record->setAssignedObjectTypes($assigned_object_types);
1214 }
1215
1216 $record->setDefaultLanguage($this->lng->getDefaultLanguage());
1217 $record->save();
1218
1220 $translations->addTranslationEntry($record->getDefaultLanguage(), true);
1221 $translations->updateTranslations(
1223 $this->form->getInput('title'),
1224 $this->form->getInput('desc')
1225 );
1226 $this->tpl->setOnScreenMessage('success', $this->lng->txt('md_adv_added_new_record'), true);
1227 $this->ctrl->redirect($this, 'showRecords');
1228 }
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 1079 of file class.ilAdvancedMDSettingsGUI.php.

1079 : void
1080 {
1081 $this->tabs_gui->clearTargets();
1082 $this->tabs_gui->clearSubTabs();
1083
1084 if ($level == 1) {
1085 $this->tabs_gui->setBackTarget(
1086 $this->lng->txt('md_adv_record_list'),
1087 $this->ctrl->getLinkTarget($this, 'showRecords')
1088 );
1089
1090 if ($show_settings) {
1091 $this->tabs_gui->addTab(
1092 self::TAB_RECORD_SETTINGS,
1093 $this->lng->txt('settings'),
1094 $this->ctrl->getLinkTarget($this, self::TAB_RECORD_SETTINGS)
1095 );
1096 $this->ctrl->setParameterByClass(
1097 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1098 'record_id',
1099 $this->record->getRecordId()
1100 );
1101 $this->lng->loadLanguageModule('obj');
1102 $this->tabs_gui->addTab(
1103 self::TAB_TRANSLATION,
1104 $this->lng->txt('obj_multilinguality'),
1105 $this->ctrl->getLinkTargetByClass(
1106 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1107 ''
1108 )
1109 );
1110 }
1111 }
1112 if ($level == 2) {
1113 $this->tabs_gui->setBack2Target(
1114 $this->lng->txt('md_adv_record_list'),
1115 $this->ctrl->getLinkTarget($this, 'showRecords')
1116 );
1117 $this->tabs_gui->setBackTarget(
1118 $this->lng->txt('md_adv_field_list'),
1119 $this->ctrl->getLinkTarget($this, 'editFields')
1120 );
1121 }
1122 }

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 1816 of file class.ilAdvancedMDSettingsGUI.php.

1816 : void
1817 {
1818 if ($context == self::CONTEXT_OBJECT) {
1819 return;
1820 }
1821
1822 $this->tabs_gui->clearSubTabs();
1823
1824 $this->tabs_gui->addSubTabTarget(
1825 "md_adv_record_list",
1826 $this->ctrl->getLinkTarget($this, "showRecords"),
1827 '',
1828 '',
1829 '',
1830 true
1831 );
1832
1834 $this->tabs_gui->addSubTabTarget(
1835 "md_adv_presentation",
1836 $this->ctrl->getLinkTarget($this, "showPresentation")
1837 );
1838 }
1839
1840 $this->tabs_gui->addSubTabTarget(
1841 "md_adv_file_list",
1842 $this->ctrl->getLinkTarget($this, "showFiles"),
1843 "showFiles"
1844 );
1845 }

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 484 of file class.ilAdvancedMDSettingsGUI.php.

484 : void
485 {
486 $this->setSubTabs($this->context);
487 $this->tabs_gui->setSubTabActive('md_adv_file_list');
488
490 $this->user->getId(),
491 $this->context === self::CONTEXT_ADMINISTRATION ? null : new ObjectId($this->obj_id)
492 );
493 $file_data = $files->readFilesInfo();
494
495 $table_gui = new ilAdvancedMDRecordExportFilesTableGUI($this, "showFiles");
496 $table_gui->setTitle($this->lng->txt("md_record_export_table"));
497 $table_gui->parseFiles($file_data);
498 $table_gui->addMultiCommand("downloadFile", $this->lng->txt('download'));
499
500 if ($GLOBALS['DIC']->access()->checkAccess('write', '', $this->ref_id)) {
501 $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
502 }
503 $table_gui->setSelectAllCheckbox("file_id");
504
505 $this->tpl->setContent($table_gui->getHTML());
506 }
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 2052 of file class.ilAdvancedMDSettingsGUI.php.

2052 : void
2053 {
2055
2056 if (count($translations->getTranslations()) <= 1) {
2057 return;
2058 }
2059 $actions = [];
2060 foreach ($translations->getTranslations() as $translation) {
2061 $this->ctrl->setParameter($this, 'mdlang', $translation->getLangKey());
2062 $actions[$translation->getLangKey()] = $this->ctrl->getLinkTarget(
2063 $this,
2064 $target
2065 );
2066 }
2067 $this->ctrl->setParameter($this, 'mdlang', $this->active_language);
2068 $view_control = $this->ui_factory->viewControl()->mode(
2069 $actions,
2070 $this->lng->txt('meta_aria_language_selection')
2071 )->withActive($this->active_language);
2072 $this->toolbar->addComponent($view_control);
2073 }

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 351 of file class.ilAdvancedMDSettingsGUI.php.

351 : void
352 {
353 $this->setSubTabs($this->context);
354 $form = $this->initFormSubstitutions();
355 if ($form instanceof ilPropertyFormGUI) {
356 $this->tabs_gui->setSubTabActive('md_adv_presentation');
357 $this->tpl->setContent($this->form->getHTML());
358 return;
359 }
360 $this->showRecords();
361 }
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 293 of file class.ilAdvancedMDSettingsGUI.php.

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

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

+ Here is the call graph for this function:

◆ updateComplexOption()

ilAdvancedMDSettingsGUI::updateComplexOption ( )

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

2020 : void
2021 {
2022 $field_id = $this->getFieldIdFromQuery();
2023 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
2024 $oid = $this->getOidFromQuery();
2025
2026 if ($field_definition->hasComplexOptions()) {
2027 $form = $this->initComplexOptionForm($field_definition);
2028 if ($form->checkInput() &&
2029 $field_definition->updateComplexOption($form, $oid)) {
2030 $field_definition->update();
2031 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2032 }
2033 }
2034
2035 $this->ctrl->redirect($this, "editField");
2036 }

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 1265 of file class.ilAdvancedMDSettingsGUI.php.

1265 : void
1266 {
1267 $record_id = $this->getRecordIdFromQuery();
1268 $field_id = $this->getFieldIdFromQuery();
1269 $this->ctrl->saveParameter($this, 'record_id');
1270 $this->ctrl->saveParameter($this, 'field_id');
1271
1272 if (!$record_id || !$field_id) {
1273 $this->editFields();
1274 return;
1275 }
1276
1277 $this->initRecordObject();
1278 $this->initLanguage($record_id);
1279 $this->showLanguageSwitch($record_id, 'editField');
1280
1281 $confirm = false;
1282 $field_definition = ilAdvancedMDFieldDefinition::getInstance($field_id);
1283 $form = $this->initFieldForm($field_definition);
1284 if ($form->checkInput()) {
1285 $field_definition->importDefinitionFormPostValues($form, $this->getPermissions(), $this->active_language);
1286 if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1287 $field_definition->update();
1288 $translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($this->record->getRecordId());
1289 $translations->updateFromForm($field_id, $this->active_language, $form);
1290
1291 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1292 $this->ctrl->redirect($this, 'editField');
1293 } else {
1294 $confirm = true;
1295 }
1296 }
1297
1299
1300 // fields needs confirmation of updated settings
1301 if ($confirm) {
1302 $this->tpl->setOnScreenMessage('info', $this->lng->txt("md_adv_confirm_definition"));
1303 $field_definition->prepareDefinitionFormConfirmation($form);
1304 }
1305
1306 $this->editField($form);
1307 }
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 967 of file class.ilAdvancedMDSettingsGUI.php.

967 : void
968 {
969 $this->ctrl->saveParameter($this, 'record_id');
970 $positions = $this->getPositionsFromPost();
971 asort($positions, SORT_NUMERIC);
972 $record_id = $this->getRecordIdFromQuery();
973 if (!$record_id) {
974 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
975 $this->editFields();
976 return;
977 }
978
980
981 if ($this->getPermissions()->hasPermission(
983 $record_id,
985 )) {
986 $positions_flipped = array_flip(array_keys($positions));
987 foreach ($fields as $field) {
988 $field->setPosition((int) $positions_flipped[$field->getFieldId()]);
989 $field->update();
990 }
991 }
992
993 foreach ($fields as $field) {
994 if ($this->getPermissions()->hasPermission(
996 (int) $field->getFieldId(),
999 )) {
1000 $post_searchable = (array) ($this->http->request()->getParsedBody()['searchable'] ?? []);
1001 $field->setSearchable((bool) ($post_searchable[$field->getFieldId()] ?? false));
1002 $field->update();
1003 }
1004 }
1005
1006 $language = $this->request->getQueryParams()['mdlang'] ?? false;
1007 if ($language) {
1008 $this->ctrl->setParameter($this, 'mdlang', $this->request->getQueryParams()['mdlang']);
1009 }
1010 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1011 $this->ctrl->redirect($this, "editFields");
1012 }

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 1019 of file class.ilAdvancedMDSettingsGUI.php.

1019 : void
1020 {
1021 $record_id = $this->getRecordIdFromQuery();
1022 if (!$record_id) {
1023 $this->ctrl->redirect($this, 'showRecords');
1024 }
1025 $this->initRecordObject();
1026 $this->initLanguage($record_id);
1027 $this->showLanguageSwitch($record_id, 'editRecord');
1028
1029 $form = $this->initForm('edit');
1030 if (!$this->form->checkInput()) {
1031 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
1032 $this->form->setValuesByPost();
1033 $this->editRecord($this->form);
1034 return;
1035 }
1036
1037 $this->loadRecordFormData($form);
1038 $this->record->update();
1039
1040 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
1041 $translations->updateTranslations(
1042 $this->active_language,
1043 $this->form->getInput('title'),
1044 $this->form->getInput('desc')
1045 );
1046
1047 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1048 $this->ctrl->redirect($this, 'editRecord');
1049 }
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 681 of file class.ilAdvancedMDSettingsGUI.php.

681 : void
682 {
683 // sort positions and renumber
684 $positions = $this->getPositionsFromPost();
685 $records = $this->getParsedRecordObjects();
686
687 $all_positions = $positions;
688 foreach ($records as $record) {
689 if (!array_key_exists($record['id'], $all_positions)) {
690 $all_positions[$record['id']] = $record['position'];
691 }
692 }
693 asort($all_positions, SORT_NUMERIC);
694
695 $sorted_positions = [];
696 $i = 1;
697 foreach ($all_positions as $record_id => $pos) {
698 $sorted_positions[(int) $record_id] = $i++;
699 }
700 $selected_global = [];
701
702 $post_active = (array) ($this->http->request()->getParsedBody()['active'] ?? []);
703 if ($this->obj_id > 0) {
705 }
706 foreach ($records as $item) {
707 // BT 35518: this is kind of a hacky solution to skip items not in the table due to pagination
708 $is_on_page = array_key_exists($item['id'], $positions);
709
710 $perm = $this->getPermissions()->hasPermissions(
712 (int) $item['id'],
713 [
715 [
718 ]
719 ]
720 );
721
722 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
723
724 if (
726 $is_on_page
727 ) {
728 $obj_types = array();
729 $post_object_types = (array) ($this->http->request()->getParsedBody()['obj_types'] ?? []);
730 if (is_array($post_object_types[$record_obj->getRecordId()] ?? false)) {
731 foreach ($post_object_types[$record_obj->getRecordId()] as $type => $status) {
732 if ($status) {
733 $type = explode(":", $type);
734 $obj_types[] = array(
735 "obj_type" => ilUtil::stripSlashes($type[0]),
736 "sub_type" => ilUtil::stripSlashes($type[1]),
737 "optional" => ((int) $status == 2)
738 );
739 }
740 }
741 }
742
743 // global records in global administration and local records in local administration
744 if (!$item['readonly']) {
745 // table adv_md_record_objs
746 $record_obj->setAssignedObjectTypes($obj_types);
747 } else { // global records in local administration
748 foreach ($obj_types as $t) {
749 // table adv_md_obj_rec_select
750 ilAdvancedMDRecord::saveObjRecSelection($this->obj_id, $t["sub_type"], [$record_obj->getRecordId()], false);
751 }
752 }
753 }
754
755 if ($this->context == self::CONTEXT_ADMINISTRATION) {
756 if (
758 $is_on_page
759 ) {
760 $record_obj->setActive(isset($post_active[$record_obj->getRecordId()]));
761 }
762
763 $record_obj->setGlobalPosition((int) $sorted_positions[$record_obj->getRecordId()]);
764 $record_obj->update();
765 } elseif (
767 $is_on_page
768 ) {
769 // global, optional record
770 if ($item['readonly'] &&
771 $item['optional'] &&
772 ($post_active[$item['id']] ?? false)) {
773 $selected_global[] = $item['id'];
774 } elseif ($item['local']) {
775 $record_obj = ilAdvancedMDRecord::_getInstanceByRecordId($item['id']);
776 $record_obj->setActive((bool) ($post_active[$item['id']] ?? false));
777 $record_obj->update();
778 }
779 }
780
781 // save local sorting
782 if ($this->context == self::CONTEXT_OBJECT) {
783 $local_position = new \ilAdvancedMDRecordObjectOrdering(
784 $item['id'],
785 $this->obj_id,
786 $this->db
787 );
788 $local_position->setPosition((int) $sorted_positions[$item['id']]);
789 $local_position->save();
790 }
791 }
792
793 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
794 $this->ctrl->redirect($this, "showRecords");
795 }
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 367 of file class.ilAdvancedMDSettingsGUI.php.

367 : void
368 {
369 if (!$this->access->checkAccess('write', '', $this->ref_id)) {
370 $this->ctrl->redirect($this, "showPresentation");
371 }
372
373 $form = $this->initFormSubstitutions();
374 if (!$form instanceof ilPropertyFormGUI) {
375 $this->ctrl->redirect($this, 'showPresentation');
376 return;
377 }
378 if (!$form->checkInput()) {
379 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), true);
380 $this->ctrl->redirect($this, "showPresentation");
381 }
382
383 if (!$visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType()) {
384 return;
385 }
386
387 foreach ($visible_records as $obj_type => $record) {
389 $sub->enableDescription((bool) $form->getInput('enabled_desc_' . $obj_type));
390 $sub->enableFieldNames((bool) $form->getInput('enabled_field_names_' . $obj_type));
391
393 $definitions = $sub->sortDefinitions($definitions);
394
395 // gather existing data
396 $counter = 1;
397 $old_sub = array();
398 foreach ($definitions as $def) {
399 $field_id = $def->getFieldId();
400 $old_sub[$field_id] = array(
401 "active" => $sub->isSubstituted($field_id),
402 "pos" => $counter++,
403 "bold" => $sub->isBold($field_id),
404 "newline" => $sub->hasNewline($field_id)
405 );
406 }
407
408 $sub->resetSubstitutions();
409
410 $new_sub = [];
411 foreach ($definitions as $def) {
412 $field_id = $def->getFieldId();
413 $old = $old_sub[$field_id];
414
415 $active = (bool) $form->getInput('show_' . $obj_type . '_' . $field_id);
416
417 if ($active) {
418 $new_sub[$field_id] = $old;
419 $new_sub[$field_id]['pos'] = (int) $form->getInput('position_' . $obj_type . '_' . $field_id);
420 $new_sub[$field_id]['bold'] = (bool) $form->getInput('bold_' . $obj_type . '_' . $field_id);
421 $new_sub[$field_id]['newline'] = (bool) $form->getInput('newline_' . $obj_type . '_' . $field_id);
422 }
423 }
424
425 if (sizeof($new_sub)) {
426 $new_sub = ilArrayUtil::sortArray($new_sub, "pos", "asc", true, true);
427 foreach ($new_sub as $field_id => $field) {
428 $sub->appendSubstitution($field_id, (bool) $field["bold"], (bool) $field["newline"]);
429 }
430 }
431 $sub->update();
432 }
433
434 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
435 $this->ctrl->redirect($this, "showPresentation");
436 }
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, ilAdvancedMDRecord\_getAllRecordsByObjectType(), ilAdvancedMDSubstitution\_getInstanceByObjectType(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilAdvancedMDFieldDefinition\getInstancesByObjType(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ilArrayUtil\sortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccess ilAdvancedMDSettingsGUI::$access
protected

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

◆ $active_language

string ilAdvancedMDSettingsGUI::$active_language = ''
private

Definition at line 68 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 70 of file class.ilAdvancedMDSettingsGUI.php.

◆ $obj_type

string ilAdvancedMDSettingsGUI::$obj_type = null
protected

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

◆ $permissions

ilAdvancedMDPermissionHelper ilAdvancedMDSettingsGUI::$permissions
protected

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

Referenced by getPermissions().

◆ $record

◆ $ref_id

int ilAdvancedMDSettingsGUI::$ref_id
protected

Definition at line 69 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 75 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: