19 declare(strict_types=1);
78 public function __construct(
int $a_context,
int $a_ref_id, ?
string $a_obj_type = null, $a_sub_type = null)
82 $this->
ctrl = $DIC->ctrl();
83 $this->
lng = $DIC->language();
84 $this->
lng->loadLanguageModule(
'meta');
85 $this->tpl = $DIC->ui()->mainTemplate();
86 $this->tabs_gui = $DIC->tabs();
89 $this->
toolbar = $DIC->toolbar();
90 $this->ui_factory = $DIC->ui()->factory();
91 $this->ui_renderer = $DIC->ui()->renderer();
92 $this->request = $DIC->http()->request();
93 $this->
http = $DIC->http();
94 $this->db = $DIC->database();
97 $this->
logger = $DIC->logger()->amet();
99 $this->context = $a_context;
113 if ($this->
http->wrapper()->query()->has(
'record_id')) {
114 return $this->
http->wrapper()->query()->retrieve(
124 if ($this->
http->wrapper()->post()->has(
'record_id')) {
125 return SplFixedArray::fromArray(
126 $this->
http->wrapper()->post()->retrieve(
128 $this->
refinery->kindlyTo()->listOf(
134 return new SplFixedArray(0);
139 if ($this->
http->wrapper()->query()->has(
'field_id')) {
140 return $this->
http->wrapper()->query()->retrieve(
150 if ($this->
http->wrapper()->post()->has(
'field_id')) {
151 return SplFixedArray::fromArray(
152 $this->
http->wrapper()->post()->retrieve(
154 $this->
refinery->kindlyTo()->listOf(
160 return new SplFixedArray(0);
165 if ($this->
http->wrapper()->post()->has(
'file_id')) {
166 return SplFixedArray::fromArray(
167 $this->
http->wrapper()->post()->retrieve(
169 $this->
refinery->kindlyTo()->dictOf(
175 return new SplFixedArray(0);
180 if ($this->
http->wrapper()->query()->has(
'ftype')) {
181 return $this->
http->wrapper()->query()->retrieve(
191 if ($this->
http->wrapper()->post()->has(
'ftype')) {
192 return $this->
http->wrapper()->post()->retrieve(
202 if ($this->
http->wrapper()->query()->has(
'oid')) {
203 return $this->
http->wrapper()->query()->retrieve(
205 $this->
refinery->kindlyTo()->string()
216 if ($this->
http->wrapper()->post()->has(
'position')) {
217 return $this->
http->wrapper()->post()->retrieve(
219 $this->
refinery->kindlyTo()->dictOf(
221 $this->refinery->kindlyTo()->float(),
247 if ($context === self::CONTEXT_ADMINISTRATION) {
249 $this->obj_id = null;
250 $this->obj_type = null;
251 $this->sub_type = null;
262 $next_class = $this->
ctrl->getNextClass($this);
263 $cmd = $this->
ctrl->getCmd();
264 switch ($next_class) {
265 case strtolower(ilAdvancedMDRecordTranslationGUI::class):
268 $int_gui = new \ilAdvancedMDRecordTranslationGUI($record);
269 $this->
ctrl->forwardCommand($int_gui);
272 case "ilpropertyformgui":
275 $this->record->getRecordId() > 0 ?
'edit' :
'create' 282 $cmd =
'showRecords';
292 $ilToolbar = $DIC[
'ilToolbar'];
293 $ilAccess = $DIC[
'ilAccess'];
299 (
string) $this->ref_id,
307 $button = $this->ui_factory->button()->standard(
308 $this->
lng->txt(
'add'),
309 $this->
ctrl->getLinkTargetByClass(strtolower(self::class),
"createRecord")
311 $ilToolbar->addComponent($button);
314 $ilToolbar->addSeparator();
319 $button = $this->ui_factory->button()->standard(
320 $this->
lng->txt(
'import'),
321 $this->
ctrl->getLinkTargetByClass(strtolower(self::class),
"importRecords")
323 $ilToolbar->addComponent($button);
326 $obj_type_context = ($this->obj_id > 0)
335 $table_gui->setTitle($this->
lng->txt(
"md_record_list_table"));
340 $table_gui->addMultiCommand(
"exportRecords", $this->
lng->txt(
'export'));
341 $table_gui->setSelectAllCheckbox(
"record_id");
343 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id)) {
344 $table_gui->addMultiCommand(
"confirmDeleteRecords", $this->
lng->txt(
"delete"));
345 $table_gui->addCommandButton(
"updateRecords", $this->
lng->txt(
"save"));
348 $DIC->ui()->mainTemplate()->setContent($table_gui->getHTML());
356 $this->tabs_gui->setSubTabActive(
'md_adv_presentation');
357 $this->tpl->setContent($this->
form->getHTML());
371 $ilAccess = $DIC[
'ilAccess'];
373 if (!$ilAccess->checkAccess(
'write',
'', $this->ref_id)) {
374 $this->
ctrl->redirect($this,
"showPresentation");
379 $this->
ctrl->redirect($this,
'showPresentation');
383 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'),
true);
384 $this->
ctrl->redirect($this,
"showPresentation");
390 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
405 $sub->enableDescription((
bool) $form->
getInput(
'enabled_desc_' . $obj_type));
409 $sub->enableFieldNames((
bool) $form->
getInput(
'enabled_field_names_' . $obj_type));
413 $definitions = $sub->sortDefinitions($definitions);
418 foreach ($definitions as $def) {
419 $field_id = $def->getFieldId();
420 $old_sub[$field_id] = array(
421 "active" => $sub->isSubstituted($field_id),
423 "bold" => $sub->isBold($field_id),
424 "newline" => $sub->hasNewline($field_id)
428 $sub->resetSubstitutions();
431 foreach ($definitions as $def) {
432 $field_id = $def->getFieldId();
433 $old = $old_sub[$field_id];
436 if ($perm_def[
"show"] ??
false) {
437 $active = (bool) $form->
getInput(
'show_' . $obj_type .
'_' . $field_id);
439 $active = $old[
"active"] ??
false;
442 $new_sub[$field_id] = $old;
444 $new_sub[$field_id][
'pos'] = (
int) $form->
getInput(
'position_' . $obj_type .
'_' . $field_id);
446 if ($perm_def[
"bold"] ??
false) {
447 $new_sub[$field_id][
'bold'] = (bool) $form->
getInput(
'bold_' . $obj_type .
'_' . $field_id);
449 if ($perm_def[
"newline"] ??
false) {
450 $new_sub[$field_id][
'newline'] = (bool) $form->
getInput(
'newline_' . $obj_type .
'_' . $field_id);
455 if (
sizeof($new_sub)) {
457 foreach ($new_sub as $field_id => $field) {
458 $sub->appendSubstitution($field_id, (
bool) $field[
"bold"], (
bool) $field[
"newline"]);
464 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
465 $this->
ctrl->redirect($this,
"showPresentation");
475 if (!count($record_ids)) {
476 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
483 foreach ($record_ids as $record_id) {
494 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_copy') .
" " . implode(
", ", $fail),
true);
495 $this->
ctrl->redirect($this,
"showRecords");
499 $xml_writer->write();
502 $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
504 $export_files->create($xml_writer->xmlDumpMem());
506 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_adv_records_exported'));
516 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
519 $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
521 $file_data = $files->readFilesInfo();
524 $table_gui->setTitle($this->
lng->txt(
"md_record_export_table"));
525 $table_gui->parseFiles($file_data);
526 $table_gui->addMultiCommand(
"downloadFile", $this->
lng->txt(
'download'));
528 if (
$GLOBALS[
'DIC']->
access()->checkAccess(
'write',
'', $this->ref_id)) {
529 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->
lng->txt(
"delete"));
531 $table_gui->setSelectAllCheckbox(
"file_id");
533 $this->tpl->setContent($table_gui->getHTML());
544 if (count($file_ids) !== 1) {
545 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'md_adv_select_one_file'));
550 $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
552 $abs_path = $files->getAbsolutePathByFileId($file_ids[0]);
563 if (count($file_ids) !== 1) {
564 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
570 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
"deleteFiles"));
571 $c_gui->setHeaderText($this->
lng->txt(
"md_adv_delete_files_sure"));
572 $c_gui->setCancel($this->
lng->txt(
"cancel"),
"showFiles");
573 $c_gui->setConfirm($this->
lng->txt(
"confirm"),
"deleteFiles");
576 $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
578 $file_data = $files->readFilesInfo();
581 foreach ($file_ids as $file_id) {
582 $info = $file_data[$file_id];
586 is_array($info[
'name'] ??
false) ? implode(
',', $info[
'name']) :
'No Records' 589 $this->tpl->setContent($c_gui->getHTML());
600 if (count($file_ids) === 0) {
601 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
606 if (!
$GLOBALS[
'DIC']->
access()->checkAccess(
'write',
'', $this->ref_id)) {
607 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
608 $GLOBALS[
'DIC']->ctrl()->redirect($this,
'showFiles');
612 $this->context === self::CONTEXT_ADMINISTRATION ? null : $this->obj_id
614 foreach ($file_ids as $file_id) {
615 $files->deleteByFileId((
int) $file_id);
617 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_adv_deleted_files'));
631 if (!count($record_ids)) {
632 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
640 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
"deleteRecords"));
641 $c_gui->setHeaderText($this->
lng->txt(
"md_adv_delete_record_sure"));
642 $c_gui->setCancel($this->
lng->txt(
"cancel"),
"showRecords");
643 $c_gui->setConfirm($this->
lng->txt(
"confirm"),
"deleteRecords");
646 foreach ($record_ids as $record_id) {
648 $c_gui->addItem(
"record_id[]", (
string) $record_id, $record->
getTitle() ?:
'No Title');
650 $this->tpl->setContent($c_gui->getHTML());
660 if (!count($record_ids)) {
661 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
668 foreach ($record_ids as $record_id) {
670 if ($this->context == self::CONTEXT_OBJECT) {
687 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_delete') .
" " . implode(
", ", $fail),
true);
688 $this->
ctrl->redirect($this,
"showRecords");
691 foreach ($record_ids as $record_id) {
695 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_adv_deleted_records'),
true);
696 $this->
ctrl->redirect($this,
"showRecords");
710 $all_positions = $positions;
711 foreach ($records as $record) {
712 if (!array_key_exists($record[
'id'], $all_positions)) {
713 $all_positions[$record[
'id']] = $record[
'position'];
716 asort($all_positions, SORT_NUMERIC);
718 $sorted_positions = [];
720 foreach ($all_positions as $record_id => $pos) {
721 $sorted_positions[(
int) $record_id] = $i++;
723 $selected_global = [];
725 $post_active = (array) ($this->
http->request()->getParsedBody()[
'active'] ?? []);
726 if ($this->obj_id > 0) {
729 foreach ($records as $item) {
731 $is_on_page = array_key_exists($item[
'id'], $positions);
735 (
string) $item[
'id'],
751 $obj_types = array();
752 $post_object_types = (array) ($this->
http->request()->getParsedBody()[
'obj_types'] ?? []);
753 if (is_array($post_object_types[$record_obj->getRecordId()] ??
false)) {
754 foreach ($post_object_types[$record_obj->getRecordId()] as $type => $status) {
756 $type = explode(
":", $type);
757 $obj_types[] = array(
760 "optional" => ((
int) $status == 2)
767 if (!$item[
'readonly']) {
769 $record_obj->setAssignedObjectTypes($obj_types);
771 foreach ($obj_types as $t) {
778 if ($this->context == self::CONTEXT_ADMINISTRATION) {
783 $record_obj->setActive(isset($post_active[$record_obj->getRecordId()]));
786 $record_obj->setGlobalPosition((
int) $sorted_positions[$record_obj->getRecordId()]);
787 $record_obj->update();
793 if ($item[
'readonly'] &&
795 ($post_active[$item[
'id']] ??
false)) {
796 $selected_global[] = $item[
'id'];
797 } elseif ($item[
'local']) {
799 $record_obj->setActive((
bool) ($post_active[$item[
'id']] ??
false));
800 $record_obj->update();
805 if ($this->context == self::CONTEXT_OBJECT) {
806 $local_position = new \ilAdvancedMDRecordObjectOrdering(
811 $local_position->setPosition((
int) $sorted_positions[$item[
'id']]);
812 $local_position->save();
816 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
817 $this->
ctrl->redirect($this,
"showRecords");
823 if (!count($field_ids)) {
824 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
835 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
"deleteFields"));
836 $c_gui->setHeaderText($this->
lng->txt(
"md_adv_delete_fields_sure"));
837 $c_gui->setCancel($this->
lng->txt(
"cancel"),
"editFields");
838 $c_gui->setConfirm($this->
lng->txt(
"confirm"),
"deleteFields");
841 foreach ($field_ids as $field_id) {
843 $c_gui->addItem(
"field_id[]", (
string) $field_id, $field->getTitle() ?:
'No Title');
845 $this->tpl->setContent($c_gui->getHTML());
850 $this->
ctrl->saveParameter($this,
'record_id');
853 if (!count($field_ids)) {
854 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
861 foreach ($field_ids as $field_id) {
868 $fail[] = $field->getTitle();
872 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_delete') .
" " . implode(
", ", $fail),
true);
873 $this->
ctrl->redirect($this,
"editFields");
876 foreach ($field_ids as $field_id) {
880 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_adv_deleted_fields'),
true);
881 $this->
ctrl->redirect($this,
"editFields");
888 $this->
ctrl->redirect($this,
'showRecords');
892 $this->tabs_gui->activateTab(self::TAB_RECORD_SETTINGS);
899 $this->tpl->setContent($this->
form->getHTML());
908 $this->
ctrl->redirect($this,
'showRecords');
910 $this->
ctrl->saveParameter($this,
'record_id');
918 (
string) $this->record->getRecordId(),
933 $this->
ctrl->setParameter($this,
'ftype', $type);
934 $create_link = $this->
ctrl->getLinkTarget($this,
'createField');
935 $this->
ctrl->clearParameterByClass(strtolower(self::class),
'ftype');
937 $field_buttons[] = $this->ui_factory->button()->shy(
938 $this->
lng->txt($field->getTypeTitle()),
942 if (!$field->isFilterSupported()) {
943 $filter_warn[] = $this->
lng->txt($field->getTypeTitle());
947 if (count($this->
toolbar->getItems())) {
948 $this->
toolbar->addSeparator();
951 $dropdown = $this->ui_factory->dropdown()
952 ->standard($field_buttons)
953 ->withLabel($this->
lng->txt(
'meta_advmd_add_field'));
954 $this->
toolbar->addComponent($dropdown);
958 if (
sizeof($filter_warn)) {
959 $this->tpl->setOnScreenMessage(
'info', sprintf($this->
lng->txt(
"md_adv_field_filter_warning"), implode(
", ", $filter_warn)));
964 $this->record->getRecordId(),
974 $this->record->getDefaultLanguage()
976 $table_gui->
setTitle($this->
lng->txt(
"md_adv_field_table"));
977 $table_gui->parseDefinitions($fields);
978 if (
sizeof($fields)) {
979 $table_gui->addCommandButton(
"updateFields", $this->
lng->txt(
"save"));
981 $table_gui->addCommandButton(
"showRecords", $this->
lng->txt(
'cancel'));
982 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->
lng->txt(
"delete"));
983 $table_gui->setSelectAllCheckbox(
"field_id");
985 $this->tpl->setContent($table_gui->getHTML());
994 $this->
ctrl->saveParameter($this,
'record_id');
996 asort($positions, SORT_NUMERIC);
999 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
1008 (
string) $record_id,
1011 $positions_flipped = array_flip(array_keys($positions));
1012 foreach ($fields as $field) {
1013 $field->setPosition((
int) $positions_flipped[$field->getFieldId()]);
1018 foreach ($fields as $field) {
1021 (
string) $field->getFieldId(),
1025 $post_searchable = (array) ($this->
http->request()->getParsedBody()[
'searchable'] ?? []);
1026 $field->setSearchable((
bool) ($post_searchable[$field->getFieldId()] ??
false));
1031 $language = $this->request->getQueryParams()[
'mdlang'] ??
false;
1033 $this->
ctrl->setParameter($this,
'mdlang', $this->request->getQueryParams()[
'mdlang']);
1035 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
1036 $this->
ctrl->redirect($this,
"editFields");
1048 $this->
ctrl->redirect($this,
'showRecords');
1055 if (!$this->
form->checkInput()) {
1056 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
1057 $this->
form->setValuesByPost();
1063 $this->record->update();
1066 $translations->updateTranslations(
1067 $this->active_language,
1068 $this->
form->getInput(
'title'),
1069 $this->
form->getInput(
'desc')
1072 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
1073 $this->
ctrl->redirect($this,
'editRecord');
1088 $this->tpl->setContent($this->
form->getHTML());
1098 $this->tpl->setContent($this->import_form->getHTML());
1106 $this->tabs_gui->clearTargets();
1107 $this->tabs_gui->clearSubTabs();
1110 $this->tabs_gui->setBackTarget(
1111 $this->
lng->txt(
'md_adv_record_list'),
1112 $this->
ctrl->getLinkTarget($this,
'showRecords')
1115 if ($show_settings) {
1116 $this->tabs_gui->addTab(
1117 self::TAB_RECORD_SETTINGS,
1118 $this->
lng->txt(
'settings'),
1119 $this->
ctrl->getLinkTarget($this, self::TAB_RECORD_SETTINGS)
1121 $this->
ctrl->setParameterByClass(
1122 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1124 $this->record->getRecordId()
1126 $this->
lng->loadLanguageModule(
'obj');
1127 $this->tabs_gui->addTab(
1128 self::TAB_TRANSLATION,
1129 $this->
lng->txt(
'obj_multilinguality'),
1130 $this->
ctrl->getLinkTargetByClass(
1131 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1138 $this->tabs_gui->setBack2Target(
1139 $this->
lng->txt(
'md_adv_record_list'),
1140 $this->
ctrl->getLinkTarget($this,
'showRecords')
1142 $this->tabs_gui->setBackTarget(
1143 $this->
lng->txt(
'md_adv_field_list'),
1144 $this->
ctrl->getLinkTarget($this,
'editFields')
1151 if (is_object($this->import_form)) {
1156 $this->import_form->setMultipart(
true);
1157 $this->import_form->setFormAction($this->
ctrl->getFormAction($this));
1162 $file->setRequired(
true);
1163 $this->import_form->addItem($file);
1165 $this->import_form->setTitle($this->
lng->txt(
'md_adv_import_record'));
1166 $this->import_form->addCommandButton(
'importRecord', $this->
lng->txt(
'import'));
1167 $this->import_form->addCommandButton(
'showRecords', $this->
lng->txt(
'cancel'));
1173 if (!$this->import_form->checkInput()) {
1174 $this->import_form->setValuesByPost();
1180 if (!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name'])) {
1189 if ($this->context === self::CONTEXT_OBJECT) {
1190 $parser->
setContext($this->obj_id, $this->obj_type, $this->sub_type);
1195 $parser->startParsing();
1199 $parser->startParsing();
1200 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_adv_added_new_record'),
true);
1201 $this->
ctrl->redirect($this,
"showRecords");
1203 $this->tpl->setOnScreenMessage(
'failure', $exc->getMessage(),
true);
1204 $this->
ctrl->redirect($this,
"importRecords");
1208 $import_files->deleteFileByCreationDate($create_time);
1220 if (!$this->
form->checkInput()) {
1221 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
1227 if ($this->obj_type) {
1228 $sub_types = (!is_array($this->sub_type))
1231 $assigned_object_types = array_map(
function (
$sub_type) {
1238 $this->record->setAssignedObjectTypes($assigned_object_types);
1246 $translations->updateTranslations(
1248 $this->
form->getInput(
'title'),
1249 $this->
form->getInput(
'desc')
1251 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'md_adv_added_new_record'),
true);
1252 $this->
ctrl->redirect($this,
'showRecords');
1263 if (!$record_id || !$field_id) {
1267 $this->
ctrl->saveParameter($this,
'field_id');
1268 $this->
ctrl->saveParameter($this,
'record_id');
1280 if ($field_definition->hasComplexOptions()) {
1281 $table = $field_definition->getComplexOptionsOverview($this,
"editField");
1283 $this->tpl->setContent($a_form->getHTML() . $table);
1294 $this->
ctrl->saveParameter($this,
'record_id');
1295 $this->
ctrl->saveParameter($this,
'field_id');
1297 if (!$record_id || !$field_id) {
1310 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions(), $this->active_language);
1311 if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1312 $field_definition->update();
1314 $translations->updateFromForm($field_id, $this->active_language, $form);
1316 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
1317 $this->
ctrl->redirect($this,
'editField');
1327 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"md_adv_confirm_definition"));
1328 $field_definition->prepareDefinitionFormConfirmation($form);
1347 $this->
ctrl->setParameter($this,
'ftype', $field_type);
1349 if (!$record_id || !$field_type) {
1356 $field_definition->setRecordId($record_id);
1359 $this->tpl->setContent($a_form->getHTML());
1367 if (!$record_id || !$ftype) {
1374 $this->
ctrl->saveParameter($this,
'ftype');
1380 $field_definition->setRecordId($record_id);
1384 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions(), $this->active_language);
1385 $field_definition->save();
1388 $translations->read();
1391 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_settings'),
true);
1392 $this->
ctrl->redirect($this,
"editFields");
1401 $is_creation_mode = $a_definition->
getFieldId() ? false :
true;
1407 if ($is_creation_mode) {
1420 if ($is_creation_mode) {
1421 $form->
setTitle($this->
lng->txt(
'md_adv_create_field'));
1424 $form->
setTitle($this->
lng->txt(
'md_adv_edit_field'));
1440 (
string) $this->record->getRecordId(),
1458 $this->
form =
new ilPropertyFormGUI();
1461 $this->
form->setDescription($translations->getFormTranslationInfo($this->active_language));
1462 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
1466 $title->setValue($this->record->getTitle());
1467 $title->setSize(20);
1468 $title->setMaxLength(70);
1469 $title->setRequired(
true);
1472 $title->setDisabled(
true);
1474 $this->
form->addItem($title);
1475 $translations->modifyTranslationInfoForTitle($this->
form, $title, $this->active_language);
1479 $desc->
setValue($this->record->getDescription());
1483 $desc->setDisabled(
true);
1485 $this->
form->addItem($desc);
1486 $translations->modifyTranslationInfoForDescription($this->
form, $desc, $this->active_language);
1490 $check->setChecked($this->record->isActive());
1495 $check->setDisabled(
true);
1498 if (!$this->obj_type) {
1501 $scope->setInfo($this->
lng->txt(
'md_adv_scope_info'));
1502 $scope->setChecked($this->record->enabledScope());
1506 $this->
lng->txt(
'md_adv_scope_objects'),
1511 $subitems->
setValue($this->record->getScopeRefIds());
1512 $exp = $subitems->getExplorerGUI();
1514 $definition =
$GLOBALS[
'DIC'][
'objDefinition'];
1516 foreach ($definition->getAllRepositoryTypes() as $type) {
1517 if ($definition->isContainer($type)) {
1518 $white_list[] = $type;
1522 $exp->setTypeWhiteList($white_list);
1523 $exp->setSkipRootNode(
false);
1525 $scope->addSubItem($subitems);
1528 if (!$this->obj_type) {
1530 $section->setTitle($this->
lng->txt(
'md_obj_types'));
1531 $this->
form->addItem($section);
1535 0 => $this->
lng->txt(
"meta_obj_type_inactive"),
1536 1 => $this->
lng->txt(
"meta_obj_type_mandatory"),
1537 2 => $this->
lng->txt(
"meta_obj_type_optional")
1541 $t = $type[
"obj_type"] .
":" . $type[
"sub_type"];
1542 $this->
lng->loadLanguageModule($type[
"obj_type"]);
1549 if ($type[
"obj_type"] ==
"prtf" && $type[
"sub_type"] ==
"pfpg") {
1553 if ($type[
"obj_type"] ==
"tals" && $type[
"sub_type"] ==
"etal") {
1558 $type_options = $options;
1559 switch ($type[
"obj_type"]) {
1562 unset($type_options[1]);
1566 unset($type_options[1]);
1570 unset($type_options[2]);
1575 if ($a_mode ==
"edit") {
1576 foreach ($this->record->getAssignedObjectTypes() as $item) {
1577 if ($item[
"obj_type"] == $type[
"obj_type"] &&
1578 $item[
"sub_type"] == $type[
"sub_type"]) {
1579 $value = $item[
"optional"]
1586 $sel_name =
'obj_types__' . $t;
1590 $hidden->setValue((
string) $value);
1591 $this->
form->addItem($hidden);
1597 $check->setOptions($type_options);
1598 $check->setValue($value);
1602 $check->setDisabled(
true);
1609 $this->
form->setTitle($this->
lng->txt(
'md_adv_create_record'));
1610 $this->
form->addCommandButton(
'saveRecord', $this->
lng->txt(
'add'));
1611 $this->
form->addCommandButton(
'showRecords', $this->
lng->txt(
'cancel'));
1615 $this->
form->setTitle($this->
lng->txt(
'md_adv_edit_record'));
1616 $this->
form->addCommandButton(
'updateRecord', $this->
lng->txt(
'save'));
1617 $this->
form->addCommandButton(
'showRecords', $this->
lng->txt(
'cancel'));
1624 if ($a_obj_type ==
"crs") {
1627 (
string) $a_field_id,
1647 } elseif ($a_obj_type ==
"cat") {
1650 (
string) $a_field_id,
1670 } elseif ($a_obj_type ==
"sess") {
1673 (
string) $a_field_id,
1693 } elseif ($a_obj_type ==
"grp") {
1696 (
string) $a_field_id,
1716 } elseif ($a_obj_type ==
"iass") {
1719 (
string) $a_field_id,
1739 } elseif ($a_obj_type ==
"exc") {
1742 (
string) $a_field_id,
1762 } elseif ($a_obj_type ==
"file") {
1765 (
string) $a_field_id,
1785 } elseif ($a_obj_type ==
"prg") {
1788 (
string) $a_field_id,
1808 } elseif ($a_obj_type ==
"orgu") {
1811 (
string) $a_field_id,
1845 $ilAccess = $DIC[
'ilAccess'];
1852 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
1853 #$this->form->setTableWidth('100%'); 1856 foreach ($visible_records as $obj_type => $records) {
1859 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
1877 $section->setTitle($this->
lng->txt(
'objs_' . $obj_type));
1878 $this->
form->addItem($section);
1882 $check->setOptionTitle($this->
lng->txt(
'md_adv_desc_show'));
1883 $check->setChecked($sub->isDescriptionEnabled());
1887 $check->setDisabled(
true);
1892 $check->setOptionTitle($this->
lng->txt(
'md_adv_fields_show'));
1893 $check->setChecked($sub->enabledFieldNames());
1897 $check->setDisabled(
true);
1906 $definitions = $sub->sortDefinitions($definitions);
1909 foreach ($definitions as $def) {
1910 $definition_id = $def->getFieldId();
1915 $title = $def->getTitle() .
' (' . $title .
')';
1919 $check->setOptionTitle($this->
lng->txt(
'md_adv_show'));
1920 $check->setChecked($sub->isSubstituted($definition_id));
1922 if ($perm && !$perm[
"show"]) {
1923 $check->setDisabled(
true);
1927 $this->
lng->txt(
'position'),
1928 'position_' . $obj_type .
'_' . $definition_id
1931 $pos->setMaxLength(4);
1932 $pos->allowDecimals(
true);
1933 $pos->setValue(sprintf(
'%.1f', $counter++));
1934 $check->addSubItem($pos);
1936 if ($perm && !$perm_pos) {
1937 $pos->setDisabled(
true);
1941 $this->
lng->txt(
'bold'),
1942 'bold_' . $obj_type .
'_' . $definition_id
1944 $bold->setValue(
"1");
1945 $bold->setChecked($sub->isBold($definition_id));
1946 $check->addSubItem($bold);
1948 if ($perm && !$perm[
"bold"]) {
1949 $bold->setDisabled(
true);
1953 $this->
lng->txt(
'newline'),
1954 'newline_' . $obj_type .
'_' . $definition_id
1956 $bold->setValue(
"1");
1957 $bold->setChecked($sub->hasNewline($definition_id));
1958 $check->addSubItem($bold);
1960 if ($perm && !$perm[
"newline"]) {
1961 $bold->setDisabled(
true);
1967 $this->
form->setTitle($this->
lng->txt(
'md_adv_substitution_table'));
1969 if ($ilAccess->checkAccess(
'write',
'', $this->ref_id)) {
1970 $this->
form->addCommandButton(
'updateSubstitutions', $this->
lng->txt(
'save'));
1981 (
string) $this->record->getRecordId(),
2000 $this->record->setActive((
bool) $form->
getInput(
'active'));
2004 $translations->getDefaultTranslation() == null ||
2007 $this->record->setTitle((
string) $form->
getInput(
'title'));
2012 $translations->getDefaultTranslation() == null ||
2014 $this->record->setDescription($form->
getInput(
'desc'));
2018 if (!$this->obj_type) {
2022 $t = $type[
"obj_type"] .
":" . $type[
"sub_type"];
2023 $value = $form->
getInput(
'obj_types__' . $t);
2028 'obj_type' => $type[
'obj_type'],
2029 'sub_type' => $type[
'sub_type'],
2030 'optional' => ($value > 1)
2033 $this->record->setAssignedObjectTypes($obj_types);
2038 $scopes_selection = $form->
getInput(
'scope_containers_sel');
2039 if (
$scopes && is_array($scopes_selection)) {
2040 $this->record->enableScope(
true);
2041 $this->record->setScopes(
2043 function (
string $scope_ref_id) {
2045 $scope->setRefId((
int) $scope_ref_id);
2052 $this->record->enableScope(
false);
2053 $this->record->setScopes([]);
2066 $this->
ctrl->saveParameter($this,
'record_id');
2069 if (!$record_id && $this->obj_id) {
2070 $this->record->setParentObject($this->obj_id);
2082 if ($context == self::CONTEXT_OBJECT) {
2086 $this->tabs_gui->clearSubTabs();
2088 $this->tabs_gui->addSubTabTarget(
2089 "md_adv_record_list",
2090 $this->
ctrl->getLinkTarget($this,
"showRecords"),
2098 $this->tabs_gui->addSubTabTarget(
2099 "md_adv_presentation",
2100 $this->
ctrl->getLinkTarget($this,
"showPresentation")
2104 $this->tabs_gui->addSubTabTarget(
2106 $this->
ctrl->getLinkTarget($this,
"showFiles"),
2119 $sub_type = (!is_array($this->sub_type))
2123 if ($this->context === self::CONTEXT_OBJECT) {
2132 $records = $orderings->sortRecords($records, $this->obj_id);
2137 foreach ($records as $record) {
2138 $parent_id = $record->getParentObject();
2140 if ($this->context == self::CONTEXT_ADMINISTRATION) {
2146 if ($parent_id && $parent_id != $this->obj_id) {
2151 if (!$parent_id && !$record->isActive()) {
2158 $record->getScopes()
2166 $tmp_arr[
'readonly'] = null;
2167 $tmp_arr[
'local'] = null;
2168 $tmp_arr[
'optional'] = null;
2169 $tmp_arr[
'id'] = $record->getRecordId();
2170 $tmp_arr[
'active'] = $record->isActive();
2171 $tmp_arr[
'title'] = $record->getTitle();
2172 $tmp_arr[
'description'] = $record->getDescription();
2173 $tmp_arr[
'fields'] = [];
2180 $tmp_arr[
'obj_types'] = $record->getAssignedObjectTypes();
2181 foreach ($record->getAssignedObjectTypes() as $idx => $item) {
2182 $tmp_arr[
'obj_types'][$idx][
'context'] = null;
2185 $tmp_arr[
'position'] = $position;
2187 $tmp_arr[
'perm'] = $this->permissions->hasPermissions(
2189 (
string) $record->getRecordId(),
2203 if ($this->obj_type) {
2204 $tmp_arr[
"readonly"] = !(bool) $parent_id;
2205 $tmp_arr[
"local"] = $parent_id;
2208 $assigned = (bool) $parent_id;
2210 foreach ($tmp_arr[
'obj_types'] as $idx => $item) {
2211 if ($item[
"obj_type"] == $this->obj_type &&
2212 in_array($item[
"sub_type"],
$sub_type)) {
2214 $optional = $item[
"optional"];
2215 $tmp_arr[
'obj_types'][$idx][
'context'] =
true;
2217 unset($tmp_arr[
'obj_types'][$idx]);
2220 $tmp_arr[
'optional'] = $optional;
2224 $tmp_arr[
'local_selected'] = [];
2225 foreach ($selected as
$key => $records) {
2226 if (in_array($record->getRecordId(), $records)) {
2233 if ($assigned ??
true) {
2249 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_select_one'));
2250 $this->
ctrl->redirect($this,
'showRecords');
2254 if (!$field_definition->hasComplexOptions()) {
2255 $this->
ctrl->redirect($this,
"editField");
2262 $this->tpl->setContent($a_form->getHTML());
2267 $this->
ctrl->saveParameter($this,
"record_id");
2268 $this->
ctrl->saveParameter($this,
"field_id");
2269 $this->
ctrl->saveParameter($this,
"oid");
2272 $form->
setTitle($this->
lng->txt(
"md_adv_edit_complex_option"));
2276 $a_def->initOptionForm($form, $oid);
2290 if ($field_definition->hasComplexOptions()) {
2293 $field_definition->updateComplexOption($form, $oid)) {
2294 $field_definition->update();
2295 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"settings_saved"),
true);
2299 $this->
ctrl->redirect($this,
"editField");
2307 foreach ($translations->getTranslations() as $translation) {
2308 if ($translation->getLangKey() == $translations->getDefaultLanguage()) {
2309 $default = $translation->getLangKey();
2312 $active = $this->request->getQueryParams()[
'mdlang'] ?? $default;
2313 $this->active_language = $active;
2320 if (count($translations->getTranslations()) <= 1) {
2324 foreach ($translations->getTranslations() as $translation) {
2325 $this->
ctrl->setParameter($this,
'mdlang', $translation->getLangKey());
2326 $actions[$translation->getLangKey()] = $this->
ctrl->getLinkTarget(
2331 $this->
ctrl->setParameter($this,
'mdlang', $this->active_language);
2332 $view_control = $this->ui_factory->viewControl()->mode(
2334 $this->
lng->txt(
'meta_aria_language_selection')
2335 )->withActive($this->active_language);
2336 $this->
toolbar->addComponent($view_control);
const ACTION_SUBSTITUTION_ORG_UNIT_EDIT_FIELD_PROPERTY
getDescription()
Get description.
const ACTION_RECORD_FIELD_POSITIONS
Interface GlobalHttpState.
Scope restrictions for advanced md records.
RefineryFactory $refinery
An entity that renders components to a string output.
const CONTEXT_SUBSTITUTION_COURSE
downloadFile()
Download XML file public.
const ACTION_RECORD_EDIT_PROPERTY
const CONTEXT_SUBSTITUTION
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)
setSubTabs(int $context)
Set sub tabs protected.
const CONTEXT_SUBSTITUTION_FILE
const SUBACTION_SUBSTITUTION_NEWLINE
updateRecord()
Update record public.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getRecords()
Get records public.
const ACTION_RECORD_EXPORT
const CONTEXT_SUBSTITUTION_EXERCISE
deleteRecords()
Permanently delete records public.
const SUBACTION_SUBSTITUTION_BOLD
updateRecords()
Save records (assigned object typed) public.
const ACTION_FIELD_DELETE
const CONTEXT_SUBSTITUTION_CATEGORY
AMD field abstract base class.
initContextParameters(int $context, int $ref_id, ?string $obj_type, $sub_type)
const ACTION_RECORD_CREATE_FIELD
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
ilPropertyFormGUI $import_form
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
editRecord(ilPropertyFormGUI $form=null)
createRecord(ilPropertyFormGUI $form=null)
Show public.
loadRecordFormData(ilPropertyFormGUI $form)
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
const CONTEXT_SUBSTITUTION_ORG_UNIT
ilAdvancedMDPermissionHelper $permissions
setContext(int $a_obj_id, string $a_obj_type, ?string $a_sub_type=null)
const SUBACTION_RECORD_TITLE
SaxParserException thrown by ilSaxParser if property throwException is set.
ilAdvancedMDRecord $record
const ACTION_FIELD_EDIT_PROPERTY
const TAB_RECORD_SETTINGS
updateFields()
Update fields public.
const CONTEXT_SUBSTITUTION_SESSION
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static _getAssignableObjectTypes(bool $a_include_text=false)
Get assignable object type public.
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
static getInstance(?int $a_field_id, ?int $a_type=null, string $language='')
updateField()
Update field public.
const ACTION_MD_CREATE_RECORD
const ACTION_SUBSTITUTION_FILE_SHOW_FIELD
const ACTION_SUBSTITUTION_IASS_EDIT_FIELD_PROPERTY
const SUBACTION_FIELD_SEARCHABLE
const ACTION_SUBSTITUTION_SHOW_DESCRIPTION
static _lookupObjId(int $ref_id)
editComplexOption(ilPropertyFormGUI $a_form=null)
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
setValue(string $a_value)
const ACTION_MD_IMPORT_RECORDS
getSubstitutionFieldPermissions(string $a_obj_type, int $a_field_id)
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
static _getInstanceByRecordId(int $a_record_id)
confirmDeleteFiles()
confirm delete files public
const ACTION_SUBSTITUTION_IASS_SHOW_FIELD
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveRecord()
Save record public.
static http()
Fetches the global http state from ILIAS.
confirmDeleteRecords()
Confirm delete public.
initLanguage(int $record_id)
Advanced metadata permission helper.
showFiles()
Show export files.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
const SUBACTION_RECORD_OBJECT_TYPES
showLanguageSwitch(int $record_id, string $target)
const ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD
static getInstancesByObjType($a_obj_type, $a_active_only=true)
const ACTION_RECORD_TOGGLE_ACTIVATION
const ACTION_SUBSTITUTION_FILE_EDIT_FIELD_PROPERTY
ilGlobalTemplateInterface $tpl
const ACTION_SUBSTITUTION_SESSION_SHOW_FIELD
const ACTION_SUBSTITUTION_ORG_UNIT_SHOW_FIELD
const ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY
setDefaultLanguage(string $language_code)
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types!
RequestInterface $request
createField(ilPropertyFormGUI $a_form=null)
Show field type selection public.
static getValidTypes()
Get all valid types.
static getInstanceByRecordId(int $record_id)
const ACTION_SUBSTITUTION_EXERCISE_EDIT_FIELD_PROPERTY
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
const ACTION_SUBSTITUTION_PRG_SHOW_FIELD
editField(ilPropertyFormGUI $a_form=null)
Edit field public.
const ACTION_RECORD_EDIT_FIELDS
const ACTION_RECORD_DELETE
const ACTION_SUBSTITUTION_SHOW_FIELDNAMES
static deleteObjRecSelection(int $a_obj_id)
Delete repository object record selection.
form( $class_path, string $cmd, string $submit_caption="")
const ACTION_SUBSTITUTION_COURSE_SHOW_FIELD
updateSubstitutions()
Update substitution public.
const ACTION_SUBSTITUTION_FIELD_POSITIONS
static _lookupTitle(int $a_record_id)
This class represents a text area property in a property form.
const SUBACTION_RECORD_DESCRIPTION
static getInstance(int $a_user_id, int $a_ref_id)
exportRecords()
Export records public.
const ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY
const ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY
initFormSubstitutions()
init form table 'substitutions' protected
static _getActivatedObjTypes()
get activated obj types
__construct(int $a_context, int $a_ref_id, ?string $a_obj_type=null, $a_sub_type=null)
Constructor public.
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
const ACTION_SUBSTITUTION_PRG_EDIT_FIELD_PROPERTY
deleteFiles()
Delete files public.
const CONTEXT_SUBSTITUTION_GROUP
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
Add input elements to definition form.
const CONTEXT_SUBSTITUTION_PRG
const ACTION_SUBSTITUTION_EXERCISE_SHOW_FIELD
getFieldId()
Get field_id.
const CONTEXT_SUBSTITUTION_IASS
const MODE_INSERT_VALIDATION
const ACTION_SUBSTITUTION_GROUP_SHOW_FIELD
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _getInstanceByObjectType(string $a_type)
const ACTION_SUBSTITUTION_GROUP_EDIT_FIELD_PROPERTY
const CONTEXT_ADMINISTRATION
static getInstanceByRecordId(int $record_id)