94 public function __construct($a_ref_id = null, $a_obj_type = null, $a_sub_type = null)
100 $ilCtrl = $DIC[
'ilCtrl'];
101 $ilTabs = $DIC->tabs();
103 $this->ctrl = $ilCtrl;
105 $this->lng->loadLanguageModule(
'meta');
107 $this->tabs_gui = $ilTabs;
109 $this->toolbar = $DIC->toolbar();
110 $this->ui_factory = $DIC->ui()->factory();
111 $this->ui_renderer = $DIC->ui()->renderer();
112 $this->request = $DIC->http()->request();
114 $this->logger =
$GLOBALS[
'DIC']->logger()->amet();
116 $this->ref_id = $a_ref_id;
121 if (!$this->ref_id) {
122 $this->context = self::CONTEXT_ADMINISTRATION;
124 $this->context = self::CONTEXT_OBJECT;
128 $this->obj_type = $a_obj_type;
129 $this->sub_type = $a_sub_type
159 $next_class = $this->ctrl->getNextClass($this);
160 $cmd = $this->ctrl->getCmd();
161 switch ($next_class) {
163 case strtolower(ilAdvancedMDRecordTranslationGUI::class):
166 $int_gui = new \ilAdvancedMDRecordTranslationGUI(
$record);
167 $this->ctrl->forwardCommand($int_gui);
170 case "ilpropertyformgui":
173 $this->record->getRecordId() > 0 ?
'edit' :
'create' 175 $GLOBALS[
'DIC']->ctrl()->forwardCommand($this->form);
180 $cmd =
'showRecords';
197 $ilToolbar = $DIC[
'ilToolbar'];
198 $ilAccess = $DIC[
'ilAccess'];
212 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
214 $button->setCaption(
"add");
215 $button->setUrl($this->ctrl->getLinkTarget($this,
"createRecord"));
216 $ilToolbar->addButtonInstance($button);
219 $ilToolbar->addSeparator();
224 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
226 $button->setCaption(
"import");
227 $button->setUrl($this->ctrl->getLinkTarget($this,
"importRecords"));
228 $ilToolbar->addButtonInstance($button);
231 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
233 $table_gui->setTitle($this->lng->txt(
"md_record_list_table"));
238 $table_gui->addMultiCommand(
"exportRecords", $this->lng->txt(
'export'));
239 $table_gui->setSelectAllCheckbox(
"record_id");
241 if ($ilAccess->checkAccess(
'write',
'', $_REQUEST[
"ref_id"])) {
242 $table_gui->addMultiCommand(
"confirmDeleteRecords", $this->lng->txt(
"delete"));
243 $table_gui->addCommandButton(
"updateRecords", $this->lng->txt(
"save"));
246 $DIC->ui()->mainTemplate()->setContent($table_gui->getHTML());
257 if (is_object($this->form)) {
258 $this->tabs_gui->setSubTabActive(
'md_adv_presentation');
259 return $this->tpl->setContent($this->form->getHTML());
275 $ilAccess = $DIC[
'ilAccess'];
277 if (!$ilAccess->checkAccess(
'write',
'', $_REQUEST[
"ref_id"])) {
278 $this->ctrl->redirect($this,
"showPresentation");
284 if (in_array($obj_type, $this->permissions->getAllowedObjectTypes())) {
296 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
300 $sub->enableDescription(
$_POST[
'enabled_desc_' . $obj_type]);
304 $sub->enableFieldNames((
int)
$_POST[
'enabled_field_names_' . $obj_type]);
308 $definitions = $sub->sortDefinitions($definitions);
313 foreach ($definitions as $def) {
314 $field_id = $def->getFieldId();
315 $old_sub[$field_id] = array(
316 "active" => $sub->isSubstituted($field_id),
318 "bold" => $sub->isBold($field_id),
319 "newline" => $sub->hasNewline($field_id)
323 $sub->resetSubstitutions(array());
326 foreach ($definitions as $def) {
327 $field_id = $def->getFieldId();
328 $old = $old_sub[$field_id];
331 if ($perm_def[
"show"]) {
334 $active = $old[
"active"];
338 $new_sub[$field_id] = $old;
341 $new_sub[$field_id][
"pos"] = (int)
$_POST[
'position'][$obj_type][$field_id];
343 if ($perm_def[
"bold"]) {
344 $new_sub[$field_id][
"bold"] = (isset(
$_POST[
'bold'][$obj_type][$field_id]) &&
$_POST[
'bold'][
$obj_type][$field_id]);
346 if ($perm_def[
"newline"]) {
347 $new_sub[$field_id][
"newline"] = (isset(
$_POST[
'newline'][$obj_type][$field_id]) &&
$_POST[
'newline'][
$obj_type][$field_id]);
352 if (
sizeof($new_sub)) {
354 foreach ($new_sub as $field_id => $field) {
355 $sub->appendSubstitution($field_id, $field[
"bold"], $field[
"newline"]);
363 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
364 $this->ctrl->redirect($this,
"showPresentation");
374 if (!isset(
$_POST[
'record_id'])) {
382 foreach (
$_POST[
'record_id'] as $record_id) {
393 ilUtil::sendFailure($this->lng->txt(
'msg_no_perm_copy') .
" " . implode(
", ", $fail),
true);
394 $this->ctrl->redirect($this,
"showRecords");
397 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
399 $xml_writer->write();
401 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
403 $export_files->create($xml_writer->xmlDumpMem());
405 ilUtil::sendSuccess($this->lng->txt(
'md_adv_records_exported'));
415 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
417 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
419 $file_data = $files->readFilesInfo();
421 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
423 $table_gui->setTitle($this->lng->txt(
"md_record_export_table"));
424 $table_gui->parseFiles($file_data);
425 $table_gui->addMultiCommand(
"downloadFile", $this->lng->txt(
'download'));
427 if (
$GLOBALS[
'DIC']->access()->checkAccess(
'write',
'', $this->ref_id)) {
428 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->lng->txt(
"delete"));
430 $table_gui->setSelectAllCheckbox(
"file_id");
432 $this->tpl->setContent($table_gui->getHTML());
444 if (!isset(
$_POST[
'file_id']) or count(
$_POST[
'file_id']) != 1) {
450 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
452 $abs_path = $files->getAbsolutePathByFileId((
int)
$_POST[
'file_id'][0]);
465 if (!isset(
$_POST[
'file_id'])) {
471 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
475 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFiles"));
476 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_files_sure"));
477 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showFiles");
478 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFiles");
480 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
482 $file_data = $files->readFilesInfo();
486 foreach (
$_POST[
"file_id"] as $file_id) {
487 $info = $file_data[$file_id];
488 $c_gui->addItem(
"file_id[]", $file_id, is_array($info[
'name']) ? implode(
',', $info[
'name']) :
'No Records');
490 $this->tpl->setContent($c_gui->getHTML());
502 if (!isset(
$_POST[
'file_id'])) {
508 if (!
$GLOBALS[
'DIC']->access()->checkAccess(
'write',
'', $this->ref_id)) {
510 $GLOBALS[
'DIC']->ctrl()->redirect($this,
'showFiles');
513 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
516 foreach (
$_POST[
'file_id'] as $file_id) {
517 $files->deleteByFileId((
int) $file_id);
519 ilUtil::sendSuccess($this->lng->txt(
'md_adv_deleted_files'));
534 if (!isset(
$_POST[
'record_id'])) {
540 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
544 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRecords"));
545 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_record_sure"));
546 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
547 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRecords");
550 foreach (
$_POST[
"record_id"] as $record_id) {
552 $c_gui->addItem(
"record_id[]", $record_id,
$record->getTitle() ?
$record->getTitle() :
'No Title');
554 $this->tpl->setContent($c_gui->getHTML());
565 if (!isset(
$_POST[
'record_id'])) {
573 foreach (
$_POST[
'record_id'] as $record_id) {
575 if ($this->context == self::CONTEXT_OBJECT) {
577 if (!
$record->getParentObject()) {
592 ilUtil::sendFailure($this->lng->txt(
'msg_no_perm_delete') .
" " . implode(
", ", $fail),
true);
593 $this->ctrl->redirect($this,
"showRecords");
596 foreach (
$_POST[
'record_id'] as $record_id) {
600 ilUtil::sendSuccess($this->lng->txt(
'md_adv_deleted_records'),
true);
601 $this->ctrl->redirect($this,
"showRecords");
614 $positions =
$_POST[
'pos'];
615 asort($positions, SORT_NUMERIC);
617 $sorted_positions = [];
619 foreach ($positions as $record_id => $pos) {
620 $sorted_positions[$record_id] =
$i++;
622 $selected_global = array();
634 if ($this->context == self::CONTEXT_ADMINISTRATION) {
638 $obj_types = array();
639 if (is_array(
$_POST[
'obj_types'][$record_obj->getRecordId()])) {
640 foreach (
$_POST[
'obj_types'][$record_obj->getRecordId()] as
$type => $status) {
642 $type = explode(
":", $type);
643 $obj_types[] = array(
646 "optional" => ((
int) $status == 2)
651 $record_obj->setAssignedObjectTypes($obj_types);
655 $record_obj->setActive(isset(
$_POST[
'active'][$record_obj->getRecordId()]));
658 $record_obj->setGlobalPosition((
int) $sorted_positions[$record_obj->getRecordId()]);
659 $record_obj->update();
662 if ($item[
'readonly'] &&
664 $_POST[
'active'][$item[
'id']]) {
665 $selected_global[] = $item[
'id'];
666 } elseif ($item[
'local']) {
668 $record_obj->setActive(isset(
$_POST[
'active'][$item[
'id']]));
669 $record_obj->update();
674 if ($this->context == self::CONTEXT_OBJECT) {
677 $local_position = new \ilAdvancedMDRecordObjectOrdering($item[
'id'], $this->obj_id, $DIC->database());
678 $local_position->setPosition((
int) $sorted_positions[$item[
'id']]);
679 $local_position->save();
683 if ($this->obj_type) {
687 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
688 $this->ctrl->redirect($this,
"showRecords");
699 if (!isset(
$_POST[
'field_id'])) {
708 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
712 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFields"));
713 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_fields_sure"));
714 $c_gui->setCancel($this->lng->txt(
"cancel"),
"editFields");
715 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFields");
718 foreach (
$_POST[
"field_id"] as $field_id) {
720 $c_gui->addItem(
"field_id[]", $field_id, $field->getTitle() ? $field->getTitle() :
'No Title');
722 $this->tpl->setContent($c_gui->getHTML());
734 $this->ctrl->saveParameter($this,
'record_id');
736 if (!isset(
$_POST[
'field_id'])) {
744 foreach (
$_POST[
'field_id'] as $field_id) {
751 $fail[] = $field->getTitle();
755 ilUtil::sendFailure($this->lng->txt(
'msg_no_perm_delete') .
" " . implode(
", ", $fail),
true);
756 $this->ctrl->redirect($this,
"editFields");
759 foreach (
$_POST[
"field_id"] as $field_id) {
763 ilUtil::sendSuccess($this->lng->txt(
'md_adv_deleted_fields'),
true);
764 $this->ctrl->redirect($this,
"editFields");
776 $record_id = $this->request->getQueryParams()[
'record_id'] ?? 0;
778 $this->ctrl->redirect($this,
'showRecords');
782 $this->tabs_gui->activateTab(self::TAB_RECORD_SETTINGS);
789 $this->tpl->setContent($this->form->getHTML());
796 $record_id = $this->request->getQueryParams()[
'record_id'] ?? 0;
798 $this->ctrl->saveParameter($this,
'record_id');
807 $this->record->getRecordId(),
814 $filter_warn = array();
817 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
822 $options[
$type] = $this->lng->txt($field->getTypeTitle());
824 if (!$field->isFilterSupported()) {
825 $filter_warn[] = $this->lng->txt($field->getTypeTitle());
828 $types->setOptions($options);
830 if (count($this->toolbar->getItems())) {
831 $this->toolbar->addSeparator();
833 $this->toolbar->addInputItem($types);
835 $this->toolbar->setFormAction($this->ctrl->getFormAction($this,
"createField"));
837 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
839 $button->setCaption(
"add");
840 $button->setCommand(
"createField");
841 $this->toolbar->addButtonInstance($button);
845 if (
sizeof($filter_warn)) {
846 ilUtil::sendInfo(sprintf($this->lng->txt(
"md_adv_field_filter_warning"), implode(
", ", $filter_warn)));
850 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
853 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
859 $this->active_language
861 $table_gui->setTitle($this->lng->txt(
"md_adv_field_table"));
862 $table_gui->parseDefinitions($fields);
863 if (
sizeof($fields)) {
864 $table_gui->addCommandButton(
"updateFields", $this->lng->txt(
"save"));
866 $table_gui->addCommandButton(
"showRecords", $this->lng->txt(
'cancel'));
867 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->lng->txt(
"delete"));
868 $table_gui->setSelectAllCheckbox(
"field_id");
870 $this->tpl->setContent($table_gui->getHTML());
881 $this->ctrl->saveParameter($this,
'record_id');
883 if (!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id']) {
889 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
897 if (!isset(
$_POST[
'position']) or !is_array(
$_POST[
'position'])) {
902 asort(
$_POST[
'position'], SORT_NUMERIC);
903 $positions = array_flip(array_keys(
$_POST[
'position']));
904 foreach ($fields as $field) {
905 $field->setPosition($positions[$field->getFieldId()]);
910 foreach ($fields as $field) {
913 $field->getFieldId(),
917 $field->setSearchable(isset(
$_POST[
'searchable'][$field->getFieldId()]) ?
true :
false);
922 if ($this->request->getQueryParams()[
'mdlang']) {
923 $this->ctrl->setParameter($this,
'mdlang', $this->request->getQueryParams()[
'mdlang']);
925 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
926 $this->ctrl->redirect($this,
"editFields");
938 $record_id = $this->request->getQueryParams()[
'record_id'] ?? 0;
940 $this->ctrl->redirect($this,
'showRecords');
947 if (!$this->form->checkInput()) {
949 $this->form->setValuesByPost();
955 $this->record->update();
958 $translations->updateTranslations(
959 $this->active_language,
960 $this->form->getInput(
'title'),
961 $this->form->getInput(
'desc')
964 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
965 $this->ctrl->redirect($this,
'editRecord');
984 $this->tpl->setContent($this->form->getHTML());
991 $this->setRecordSubtabs();
995 $this->tpl->setContent($this->import_form->getHTML());
1003 $this->tabs_gui->clearTargets();
1004 $this->tabs_gui->clearSubTabs();
1007 $this->tabs_gui->setBackTarget(
1008 $this->lng->txt(
'md_adv_record_list'),
1009 $this->ctrl->getLinkTarget($this,
'showRecords')
1012 if ($show_settings) {
1013 $this->tabs_gui->addTab(
1014 self::TAB_RECORD_SETTINGS,
1015 $this->lng->txt(
'settings'),
1016 $this->ctrl->getLinkTarget($this, self::TAB_RECORD_SETTINGS)
1018 $this->ctrl->setParameterByClass(
1019 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1021 $this->record->getRecordId()
1023 $this->lng->loadLanguageModule(
'obj');
1024 $this->tabs_gui->addTab(
1025 self::TAB_TRANSLATION,
1026 $this->lng->txt(
'obj_multilinguality'),
1027 $this->ctrl->getLinkTargetByClass(
1028 strtolower(\ilAdvancedMDRecordTranslationGUI::class),
1035 $this->tabs_gui->setBack2Target(
1036 $this->lng->txt(
'md_adv_record_list'),
1037 $this->ctrl->getLinkTarget($this,
'showRecords')
1039 $this->tabs_gui->setBackTarget(
1040 $this->lng->txt(
'md_adv_field_list'),
1041 $this->ctrl->getLinkTarget($this,
'editFields')
1053 if (is_object($this->import_form)) {
1057 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1059 $this->import_form->setMultipart(
true);
1060 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
1065 $file->setRequired(
true);
1066 $this->import_form->addItem($file);
1068 $this->import_form->setTitle($this->lng->txt(
'md_adv_import_record'));
1069 $this->import_form->addCommandButton(
'importRecord', $this->lng->txt(
'import'));
1070 $this->import_form->addCommandButton(
'showRecords', $this->lng->txt(
'cancel'));
1083 if (!$this->import_form->checkInput()) {
1084 $this->import_form->setValuesByPost();
1089 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
1091 if (!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name'])) {
1097 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
1101 if ($this->context == self::CONTEXT_OBJECT) {
1102 $parser->
setContext($this->obj_id, $this->obj_type, $this->sub_type);
1107 $parser->startParsing();
1111 $parser->startParsing();
1112 ilUtil::sendSuccess($this->lng->txt(
'md_adv_added_new_record'),
true);
1113 $this->ctrl->redirect($this,
"showRecords");
1114 }
catch (ilSAXParserException $exc) {
1116 $this->ctrl->redirect($this,
"importRecords");
1120 $import_files->deleteFileByCreationDate($create_time);
1136 if (!$this->form->checkInput()) {
1143 if ($this->obj_type) {
1144 $this->record->setAssignedObjectTypes(array(
1146 "obj_type" => $this->obj_type,
1147 "sub_type" => $this->sub_type,
1152 $record->setDefaultLanguage($this->lng->getDefaultLanguage());
1156 $translations->addTranslationEntry(
$record->getDefaultLanguage(),
true);
1157 $translations->updateTranslations(
1158 $record->getDefaultLanguage(),
1159 $this->form->getInput(
'title'),
1160 $this->form->getInput(
'desc')
1162 ilUtil::sendSuccess($this->lng->txt(
'md_adv_added_new_record'),
true);
1163 $this->ctrl->redirect($this,
'showRecords');
1174 $record_id = (int) ($this->request->getQueryParams()[
'record_id'] ?? 0);
1175 $field_id = (int) ($this->request->getQueryParams()[
'field_id'] ?? 0);
1176 if (!$record_id || !$field_id) {
1179 $this->ctrl->saveParameter($this,
'field_id');
1180 $this->ctrl->saveParameter($this,
'record_id');
1192 if ($field_definition->hasComplexOptions()) {
1193 $table = $field_definition->getComplexOptionsOverview($this,
"editField");
1195 $this->tpl->setContent($a_form->getHTML() . $table);
1206 $record_id = $this->request->getQueryParams()[
'record_id'] ?? 0;
1207 $field_id = $this->request->getQueryParams()[
'field_id'] ?? 0;
1208 $this->ctrl->saveParameter($this,
'record_id');
1209 $this->ctrl->saveParameter($this,
'field_id');
1211 if (!$record_id || !$field_id) {
1222 if ($form->checkInput()) {
1223 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions(), $this->active_language);
1224 if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1225 $field_definition->update();
1227 $translations->updateFromForm($field_id, $this->active_language, $form);
1229 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
1230 $this->ctrl->redirect($this,
'editField');
1236 $form->setValuesByPost();
1241 $field_definition->prepareDefinitionFormConfirmation($form);
1256 $this->ctrl->saveParameter($this,
'ftype');
1259 if (!$_REQUEST[
"record_id"] || !$_REQUEST[
"ftype"]) {
1265 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1267 $field_definition->setRecordId($_REQUEST[
"record_id"]);
1270 $this->tpl->setContent($a_form->getHTML());
1280 $record_id = $this->request->getQueryParams()[
'record_id'];
1281 $ftype = $this->request->getQueryParams()[
'ftype'];
1283 if (!$record_id || !$ftype) {
1289 $this->ctrl->saveParameter($this,
'ftype');
1291 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1293 $field_definition->setRecordId($record_id);
1296 if ($form->checkInput()) {
1297 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions(), $this->active_language);
1298 $field_definition->save();
1301 $translations->read();
1304 ilUtil::sendSuccess($this->lng->txt(
'save_settings'),
true);
1305 $this->ctrl->redirect($this,
"editFields");
1308 $form->setValuesByPost();
1319 $is_creation_mode = $a_definition->
getFieldId() ? false :
true;
1322 $form->setFormAction($this->ctrl->getFormAction($this));
1325 if ($is_creation_mode) {
1328 $form->setDescription($translations->getFormTranslationInfo(
1335 $form->addItem(
$type);
1338 if ($is_creation_mode) {
1339 $form->setTitle($this->lng->txt(
'md_adv_create_field'));
1340 $form->addCommandButton(
'saveField', $this->lng->txt(
'create'));
1342 $form->setTitle($this->lng->txt(
'md_adv_edit_field'));
1343 $form->addCommandButton(
'updateField', $this->lng->txt(
'save'));
1346 $form->addCommandButton(
'editFields', $this->lng->txt(
'cancel'));
1358 if (is_object($this->form)) {
1364 $this->record->getRecordId(),
1376 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1381 $this->form->setDescription($translations->getFormTranslationInfo($this->active_language));
1382 $this->form->setFormAction($this->ctrl->getFormAction($this));
1387 $title->setValue($this->record->getTitle());
1388 $title->setSize(20);
1389 $title->setMaxLength(70);
1390 $title->setRequired(
true);
1393 $title->setDisabled(
true);
1395 $this->form->addItem($title);
1396 $translations->modifyTranslationInfoForTitle($this->form, $title, $this->active_language);
1401 $desc->
setValue($this->record->getDescription());
1405 $desc->setDisabled(
true);
1407 $this->form->addItem($desc);
1408 $translations->modifyTranslationInfoForDescription($this->form, $desc, $this->active_language);
1412 $check->
setChecked($this->record->isActive());
1413 $check->setValue(1);
1414 $this->form->addItem($check);
1417 $check->setDisabled(
true);
1420 if (!$this->obj_type) {
1423 $scope->
setInfo($this->lng->txt(
'md_adv_scope_info'));
1424 $scope->setChecked($this->record->enabledScope());
1425 $scope->setValue(1);
1426 $this->form->addItem($scope);
1429 $this->lng->txt(
'md_adv_scope_objects'),
1433 $subitems->
setValue($this->record->getScopeRefIds());
1434 $exp = $subitems->getExplorerGUI();
1436 $definition =
$GLOBALS[
'DIC'][
'objDefinition'];
1438 foreach ($definition->getAllRepositoryTypes() as
$type) {
1439 if ($definition->isContainer(
$type)) {
1440 $white_list[] =
$type;
1445 $exp->setTypeWhiteList($white_list);
1446 $exp->setSkipRootNode(
false);
1448 $scope->addSubItem($subitems);
1451 if (!$this->obj_type) {
1453 $section->setTitle($this->lng->txt(
'md_obj_types'));
1458 0 => $this->lng->txt(
"meta_obj_type_inactive"),
1459 1 => $this->lng->txt(
"meta_obj_type_mandatory"),
1460 2 => $this->lng->txt(
"meta_obj_type_optional")
1465 $t =
$type[
"obj_type"] .
":" .
$type[
"sub_type"];
1466 $this->lng->loadLanguageModule(
$type[
"obj_type"]);
1468 $type_options = $options;
1469 switch (
$type[
"obj_type"]) {
1472 unset($type_options[1]);
1476 unset($type_options[1]);
1480 unset($type_options[2]);
1485 if ($a_mode ==
"edit") {
1486 foreach ($this->record->getAssignedObjectTypes() as $item) {
1487 if ($item[
"obj_type"] ==
$type[
"obj_type"] &&
1488 $item[
"sub_type"] ==
$type[
"sub_type"]) {
1489 $value = $item[
"optional"]
1496 $sel_name =
'obj_types__' . $t;
1499 $check->setOptions($type_options);
1500 $check->setValue($value);
1501 $this->form->addItem($check);
1504 $check->setDisabled(
true);
1511 $this->form->setTitle($this->lng->txt(
'md_adv_create_record'));
1512 $this->form->addCommandButton(
'saveRecord', $this->lng->txt(
'add'));
1513 $this->form->addCommandButton(
'showRecords', $this->lng->txt(
'cancel'));
1518 $this->form->setTitle($this->lng->txt(
'md_adv_edit_record'));
1519 $this->form->addCommandButton(
'updateRecord', $this->lng->txt(
'save'));
1520 $this->form->addCommandButton(
'showRecords', $this->lng->txt(
'cancel'));
1528 if ($a_obj_type ==
"crs") {
1545 } elseif ($a_obj_type ==
"cat") {
1562 } elseif ($a_obj_type ==
"sess") {
1579 } elseif ($a_obj_type ==
"grp") {
1596 } elseif ($a_obj_type ==
"iass") {
1613 } elseif ($a_obj_type ==
"exc") {
1642 $ilAccess = $DIC[
'ilAccess'];
1644 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1651 $this->form->setFormAction($this->ctrl->getFormAction($this));
1652 #$this->form->setTableWidth('100%'); 1655 foreach ($visible_records as
$obj_type => $records) {
1658 if (in_array(
$obj_type, $this->permissions->getAllowedObjectTypes())) {
1679 $check->setOptionTitle($this->lng->txt(
'md_adv_desc_show'));
1680 $check->setChecked($sub->isDescriptionEnabled() ? true :
false);
1681 $this->form->addItem($check);
1684 $check->setDisabled(
true);
1689 $check->setOptionTitle($this->lng->txt(
'md_adv_fields_show'));
1690 $check->setChecked($sub->enabledFieldNames() ? true :
false);
1691 $this->form->addItem($check);
1694 $check->setDisabled(
true);
1697 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type); 1698 #$area->setUseRte(true); 1699 #$area->setRteTagSet('standard'); 1700 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString())); 1702 #$area->setCols(80); 1703 #$this->form->addItem($area); 1710 $definitions = $sub->sortDefinitions($definitions);
1713 foreach ($definitions as $def) {
1714 $definition_id = $def->getFieldId();
1719 $title = $def->getTitle() .
' (' . $title .
')';
1722 $check->setValue(1);
1723 $check->setOptionTitle($this->lng->txt(
'md_adv_show'));
1724 $check->setChecked($sub->isSubstituted($definition_id));
1726 if ($perm && !$perm[
"show"]) {
1727 $check->setDisabled(
true);
1732 $pos->setMaxLength(4);
1733 $pos->allowDecimals(
true);
1734 $pos->setValue(sprintf(
'%.1f', $counter++));
1735 $check->addSubItem($pos);
1737 if ($perm && !$perm_pos) {
1738 $pos->setDisabled(
true);
1743 $bold->setChecked($sub->isBold($definition_id));
1744 $check->addSubItem($bold);
1746 if ($perm && !$perm[
"bold"]) {
1747 $bold->setDisabled(
true);
1752 $bold->setChecked($sub->hasNewline($definition_id));
1753 $check->addSubItem($bold);
1755 if ($perm && !$perm[
"newline"]) {
1756 $bold->setDisabled(
true);
1760 $this->form->addItem($check);
1788 $this->form->setTitle($this->lng->txt(
'md_adv_substitution_table'));
1790 if ($ilAccess->checkAccess(
'write',
'', $_REQUEST[
"ref_id"])) {
1791 $this->form->addCommandButton(
'updateSubstitutions', $this->lng->txt(
'save'));
1806 $this->record->getRecordId(),
1823 $translations->getDefaultTranslation() == null ||
1831 $translations->getDefaultTranslation() == null ||
1837 if (!$this->obj_type) {
1841 $t = $type[
"obj_type"] .
":" . $type[
"sub_type"];
1842 $value = $this->form->getInput(
'obj_types__' . $t);
1847 'obj_type' => $type[
'obj_type'],
1848 'sub_type' => $type[
'sub_type'],
1849 'optional' => ($value > 1)
1852 $this->record->setAssignedObjectTypes($obj_types);
1857 foreach ((array)
$_POST[
'scope_containers_sel'] as
$ref_id) {
1859 $scope->setRefId($ref_id);
1862 $this->record->setScopes(
$_POST[
'scope'] ? $scopes : []);
1863 $this->record->enableScope(
$_POST[
'scope'] ?
true :
false);
1876 $record_id = $this->request->getQueryParams()[
'record_id'] ?? 0;
1878 $this->ctrl->saveParameter($this,
'record_id');
1883 $this->record->setParentObject($this->obj_id);
1896 if ($context == self::CONTEXT_OBJECT) {
1900 $this->tabs_gui->clearSubTabs();
1902 $this->tabs_gui->addSubTabTarget(
1903 "md_adv_record_list",
1904 $this->ctrl->getLinkTarget($this,
"showRecords"),
1913 $this->tabs_gui->addSubTabTarget(
1914 "md_adv_presentation",
1915 $this->ctrl->getLinkTarget($this,
"showPresentation")
1919 $this->tabs_gui->addSubTabTarget(
1921 $this->ctrl->getLinkTarget($this,
"showFiles"),
1935 if ($this->context == self::CONTEXT_OBJECT) {
1941 $records = $orderings->sortRecords($records, $this->obj_id);
1944 foreach ($records as
$record) {
1945 $parent_id = $record->getParentObject();
1947 if ($this->context == self::CONTEXT_ADMINISTRATION) {
1953 if ($parent_id && $parent_id != $this->obj_id) {
1958 if (!$parent_id && !$record->isActive()) {
1965 $record->getScopes()
1973 $tmp_arr[
'id'] = $record->getRecordId();
1974 $tmp_arr[
'active'] = $record->isActive();
1975 $tmp_arr[
'title'] = $record->getTitle();
1976 $tmp_arr[
'description'] = $record->getDescription();
1977 $tmp_arr[
'fields'] = array();
1978 $tmp_arr[
'obj_types'] = $record->getAssignedObjectTypes();
1980 $tmp_arr[
'position'] = $position;
1982 $tmp_arr[
'perm'] = $this->permissions->hasPermissions(
1984 $record->getRecordId(),
1994 if ($this->obj_type) {
1995 $tmp_arr[
"readonly"] = !(bool) $parent_id;
1996 $tmp_arr[
"local"] = $parent_id;
1999 $assigned = $optional =
false;
2000 foreach ($tmp_arr[
'obj_types'] as $idx => $item) {
2001 if ($item[
"obj_type"] == $this->obj_type &&
2002 $item[
"sub_type"] == $this->sub_type) {
2004 $optional = $item[
"optional"];
2005 $tmp_arr[
'obj_types'][$idx][
'context'] =
true;
2012 $tmp_arr[
'optional'] = $optional;
2015 $tmp_arr[
'active'] = in_array($record->getRecordId(), $selected);
2033 if (!$field_definition->hasComplexOptions()) {
2034 $this->ctrl->redirect($this,
"editField");
2041 $this->tpl->setContent($a_form->getHTML());
2046 $this->ctrl->saveParameter($this,
"record_id");
2047 $this->ctrl->saveParameter($this,
"field_id");
2048 $this->ctrl->saveParameter($this,
"oid");
2050 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
2052 $form->setTitle($this->lng->txt(
"md_adv_edit_complex_option"));
2053 $form->setFormAction($this->ctrl->getFormAction($this,
"updateComplexOption"));
2055 $a_def->initOptionForm($form, $_REQUEST[
"oid"]);
2057 $form->addCommandButton(
"updateComplexOption", $this->lng->txt(
"save"));
2058 $form->addCommandButton(
"editField", $this->lng->txt(
"cancel"));
2066 if ($field_definition->hasComplexOptions()) {
2068 if ($form->checkInput() &&
2069 $field_definition->updateComplexOption($form, $_REQUEST[
"oid"])) {
2070 $field_definition->update();
2071 ilUtil::sendSuccess($this->lng->txt(
"settings_saved"),
true);
2075 $this->ctrl->redirect($this,
"editField");
2086 foreach ($translations->getTranslations() as $translation) {
2087 if ($translation->getLangKey() == $translations->getDefaultLanguage()) {
2088 $default = $translation->getLangKey();
2091 $active = $this->request->getQueryParams()[
'mdlang'] ?? $default;
2092 $this->active_language = $active;
2102 if (count($translations->getTranslations()) <= 1) {
2106 foreach ($translations->getTranslations() as $translation) {
2107 $this->ctrl->setParameter($this,
'mdlang', $translation->getLangKey());
2108 $actions[$translation->getLangKey()] = $this->ctrl->getLinkTarget(
2113 $this->ctrl->setParameter($this,
'mdlang', $this->active_language);
2114 $view_control = $this->ui_factory->viewControl()->mode(
2116 $this->lng->txt(
'meta_aria_language_selection')
2117 )->withActive($this->active_language);
2118 $this->toolbar->addComponent($view_control);
getDescription()
Get description.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
const ACTION_RECORD_FIELD_POSITIONS
deleteFields()
delete fields
Scope restrictions for advanced md records.
const CONTEXT_SUBSTITUTION_COURSE
downloadFile()
Download XML file.
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
const ACTION_RECORD_EDIT_PROPERTY
const CONTEXT_SUBSTITUTION
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)
setSubTabs(int $context)
Set sub tabs.
const SUBACTION_SUBSTITUTION_NEWLINE
updateRecord()
Update record.
static _getRecords()
Get records.
const ACTION_RECORD_EXPORT
const CONTEXT_SUBSTITUTION_EXERCISE
deleteRecords()
Permanently delete records.
const SUBACTION_SUBSTITUTION_BOLD
updateRecords()
Save records (assigned object typed)
const ACTION_FIELD_DELETE
const CONTEXT_SUBSTITUTION_CATEGORY
AMD field abstract base class.
const ACTION_RECORD_CREATE_FIELD
getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
initRecordObject()
Init record object.
editRecord(ilPropertyFormGUI $form=null)
Edit one record.
createRecord(ilPropertyFormGUI $form=null)
Show.
setValue($a_value)
Set Value.
const SUBACTION_RECORD_TITLE
const ACTION_FIELD_EDIT_PROPERTY
getParsedRecordObjects()
Get and cache record objects.
importRecord()
import xml file
const TAB_RECORD_SETTINGS
updateFields()
Update fields.
const CONTEXT_SUBSTITUTION_SESSION
setRecordSubTabs(int $level=1, bool $show_settings=false)
Set subtabs for record editing/creation.
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
updateField()
Update field.
const ACTION_MD_CREATE_RECORD
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
const ACTION_SUBSTITUTION_IASS_EDIT_FIELD_PROPERTY
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
const SUBACTION_FIELD_SEARCHABLE
const ACTION_SUBSTITUTION_SHOW_DESCRIPTION
editComplexOption(ilPropertyFormGUI $a_form=null)
const ACTION_MD_IMPORT_RECORDS
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
confirmDeleteFiles()
confirm delete files
const ACTION_SUBSTITUTION_IASS_SHOW_FIELD
confirmDeleteRecords()
Confirm delete.
initLanguage(int $record_id)
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
Advanced metadata permission helper.
showFiles()
Show export files.
foreach($_POST as $key=> $value) $res
const SUBACTION_RECORD_OBJECT_TYPES
showLanguageSwitch(int $record_id, string $target)
executeCommand()
Execute command.
const ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD
static getInstancesByObjType($a_obj_type, $a_active_only=true)
static _lookupObjId($a_id)
const ACTION_RECORD_TOGGLE_ACTIVATION
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
initImportForm()
show import form
const ACTION_SUBSTITUTION_SESSION_SHOW_FIELD
const ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! public.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _lookupTitle($a_record_id)
Lookup title.
createField(ilPropertyFormGUI $a_form=null)
Show field type selection.
static getValidTypes()
Get all valid types.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstanceByRecordId(int $record_id)
const ACTION_SUBSTITUTION_EXERCISE_EDIT_FIELD_PROPERTY
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
editField(ilPropertyFormGUI $a_form=null)
Edit field.
const ACTION_RECORD_EDIT_FIELDS
const ACTION_RECORD_DELETE
const ACTION_SUBSTITUTION_SHOW_FIELDNAMES
setContext($a_obj_id, $a_obj_type, $a_sub_type=null)
const ACTION_SUBSTITUTION_COURSE_SHOW_FIELD
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
updateSubstitutions()
Update substitution.
const ACTION_SUBSTITUTION_FIELD_POSITIONS
This class represents a non editable value in a property form.
initForm($a_mode)
Init Form.
This class represents a text area property in a property form.
static getInstance($a_field_id, $a_type=null, string $language='')
Get definition instance by type.
const SUBACTION_RECORD_DESCRIPTION
exportRecords()
Export records.
const ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY
const ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY
initFormSubstitutions()
init form table 'substitutions'
static _getActivatedObjTypes()
get activated obj types
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
deleteFiles()
Delete files.
showRecords()
show record list
getTypeTitle()
Get type title (lang id)
const CONTEXT_SUBSTITUTION_GROUP
SAX based XML parser for record import files.
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
Add input elements to definition form.
const ACTION_SUBSTITUTION_EXERCISE_SHOW_FIELD
static getInstancesByRecordId($a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
getFieldId()
Get field_id.
const CONTEXT_SUBSTITUTION_IASS
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
confirmDeleteFields()
show delete fields confirmation screen
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
const MODE_INSERT_VALIDATION
const ACTION_SUBSTITUTION_GROUP_SHOW_FIELD
__construct($a_ref_id=null, $a_obj_type=null, $a_sub_type=null)
Constructor.
Confirmation screen class.
const ACTION_SUBSTITUTION_GROUP_EDIT_FIELD_PROPERTY
const CONTEXT_ADMINISTRATION
static getInstanceByRecordId(int $record_id)