4include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
5include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
6include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDPermissionHelper.php');
7include_once
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordScope.php';
49 public function __construct($a_ref_id =
null, $a_obj_type =
null, $a_sub_type =
null)
56 $ilTabs =
$DIC[
'ilTabs'];
60 $this->lng->loadLanguageModule(
'meta');
62 $this->tabs_gui = $ilTabs;
64 $this->logger =
$GLOBALS[
'DIC']->logger()->amet();
66 $this->ref_id = $a_ref_id;
78 $this->obj_type = $a_obj_type;
79 $this->sub_type = $a_sub_type
106 $next_class = $this->ctrl->getNextClass($this);
107 $cmd = $this->ctrl->getCmd();
109 if (!$this->obj_id) {
113 switch ($next_class) {
114 case "ilpropertyformgui":
117 $this->record->getRecordId() > 0 ?
'edit' :
'create'
119 $GLOBALS[
'DIC']->ctrl()->forwardCommand($this->form);
124 $cmd =
'showRecords';
141 $ilToolbar =
$DIC[
'ilToolbar'];
142 $ilAccess =
$DIC[
'ilAccess'];
154 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
156 $button->setCaption(
"add");
157 $button->setUrl($this->ctrl->getLinkTarget($this,
"createRecord"));
158 $ilToolbar->addButtonInstance($button);
161 $ilToolbar->addSeparator();
166 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
168 $button->setCaption(
"import");
169 $button->setUrl($this->ctrl->getLinkTarget($this,
"importRecords"));
170 $ilToolbar->addButtonInstance($button);
173 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
175 $table_gui->setTitle($this->lng->txt(
"md_record_list_table"));
180 $table_gui->addMultiCommand(
"exportRecords", $this->lng->txt(
'export'));
181 $table_gui->setSelectAllCheckbox(
"record_id");
183 if ($ilAccess->checkAccess(
'write',
'', $_REQUEST[
"ref_id"])) {
184 $table_gui->addMultiCommand(
"confirmDeleteRecords", $this->lng->txt(
"delete"));
185 $table_gui->addCommandButton(
"updateRecords", $this->lng->txt(
"save"));
188 $DIC->ui()->mainTemplate()->setContent($table_gui->getHTML());
195 if (is_object($this->form)) {
196 $this->tabs_gui->setSubTabActive(
'md_adv_presentation');
197 return $this->tpl->setContent($this->form->getHTML());
213 $ilAccess =
$DIC[
'ilAccess'];
215 if (!$ilAccess->checkAccess(
'write',
'', $_REQUEST[
"ref_id"])) {
216 $this->ctrl->redirect($this,
"showPresentation");
222 if (in_array(
$obj_type, $this->permissions->getAllowedObjectTypes())) {
234 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
242 $sub->enableFieldNames((
int)
$_POST[
'enabled_field_names_' .
$obj_type]);
246 $definitions = $sub->sortDefinitions($definitions);
251 foreach ($definitions as $def) {
252 $field_id = $def->getFieldId();
253 $old_sub[$field_id] = array(
254 "active" => $sub->isSubstituted($field_id),
256 "bold" => $sub->isBold($field_id),
257 "newline" => $sub->hasNewline($field_id)
261 $sub->resetSubstitutions(array());
264 foreach ($definitions as $def) {
265 $field_id = $def->getFieldId();
266 $old = $old_sub[$field_id];
269 if ($perm_def[
"show"]) {
272 $active = $old[
"active"];
276 $new_sub[$field_id] = $old;
279 $new_sub[$field_id][
"pos"] = (int)
$_POST[
'position'][
$obj_type][$field_id];
281 if ($perm_def[
"bold"]) {
284 if ($perm_def[
"newline"]) {
290 if (
sizeof($new_sub)) {
292 foreach ($new_sub as $field_id => $field) {
293 $sub->appendSubstitution($field_id, $field[
"bold"], $field[
"newline"]);
301 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
302 $this->ctrl->redirect($this,
"showPresentation");
312 if (!isset(
$_POST[
'record_id'])) {
320 foreach (
$_POST[
'record_id'] as $record_id) {
327 $fail[] = $record->getTitle();
331 ilUtil::sendFailure($this->lng->txt(
'msg_no_perm_copy') .
" " . implode(
", ", $fail),
true);
332 $this->ctrl->redirect($this,
"showRecords");
335 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
337 $xml_writer->write();
339 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
341 $export_files->create($xml_writer->xmlDumpMem());
343 ilUtil::sendSuccess($this->lng->txt(
'md_adv_records_exported'));
356 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
358 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
360 $file_data = $files->readFilesInfo();
362 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
364 $table_gui->setTitle($this->lng->txt(
"md_record_export_table"));
365 $table_gui->parseFiles($file_data);
366 $table_gui->addMultiCommand(
"downloadFile", $this->lng->txt(
'download'));
368 if (
$GLOBALS[
'DIC']->access()->checkAccess(
'write',
'', $this->ref_id)) {
369 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->lng->txt(
"delete"));
371 $table_gui->addCommandButton(
'showFiles', $this->lng->txt(
'cancel'));
372 $table_gui->setSelectAllCheckbox(
"file_id");
374 $this->tpl->setContent($table_gui->getHTML());
386 if (!isset(
$_POST[
'file_id']) or count(
$_POST[
'file_id']) != 1) {
392 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
394 $abs_path = $files->getAbsolutePathByFileId((
int)
$_POST[
'file_id'][0]);
407 if (!isset(
$_POST[
'file_id'])) {
413 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
417 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFiles"));
418 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_files_sure"));
419 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showFiles");
420 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFiles");
422 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
424 $file_data = $files->readFilesInfo();
428 foreach (
$_POST[
"file_id"] as $file_id) {
429 $info = $file_data[$file_id];
430 $c_gui->addItem(
"file_id[]", $file_id, is_array($info[
'name']) ? implode(
',', $info[
'name']) :
'No Records');
432 $this->tpl->setContent($c_gui->getHTML());
444 if (!isset(
$_POST[
'file_id'])) {
450 if (!
$GLOBALS[
'DIC']->access()->checkAccess(
'write',
'', $this->ref_id)) {
452 $GLOBALS[
'DIC']->ctrl()->redirect($this,
'showFiles');
455 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
458 foreach (
$_POST[
'file_id'] as $file_id) {
459 $files->deleteByFileId((
int) $file_id);
461 ilUtil::sendSuccess($this->lng->txt(
'md_adv_deleted_files'));
473 if (!isset(
$_POST[
'record_id'])) {
479 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
483 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRecords"));
484 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_record_sure"));
485 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
486 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRecords");
489 foreach (
$_POST[
"record_id"] as $record_id) {
491 $c_gui->addItem(
"record_id[]", $record_id, $record->getTitle() ? $record->getTitle() :
'No Title');
493 $this->tpl->setContent($c_gui->getHTML());
504 if (!isset(
$_POST[
'record_id'])) {
512 foreach (
$_POST[
'record_id'] as $record_id) {
516 if (!$record->getParentObject()) {
517 $fail[] = $record->getTitle();
527 $fail[] = $record->getTitle();
531 ilUtil::sendFailure($this->lng->txt(
'msg_no_perm_delete') .
" " . implode(
", ", $fail),
true);
532 $this->ctrl->redirect($this,
"showRecords");
535 foreach (
$_POST[
'record_id'] as $record_id) {
539 ilUtil::sendSuccess($this->lng->txt(
'md_adv_deleted_records'),
true);
540 $this->ctrl->redirect($this,
"showRecords");
553 $positions =
$_POST[
'pos'];
554 asort($positions, SORT_NUMERIC);
556 $sorted_positions = [];
558 foreach ($positions as $record_id => $pos) {
559 $sorted_positions[$record_id] =
$i++;
562 $this->logger->dump($sorted_positions);
564 $selected_global = array();
576 if ($this->mode == self::MODE_ADMINISTRATION) {
580 $obj_types = array();
581 if (is_array(
$_POST[
'obj_types'][$record_obj->getRecordId()])) {
582 foreach (
$_POST[
'obj_types'][$record_obj->getRecordId()] as
$type => $status) {
585 $obj_types[] = array(
588 "optional" => ((
int) $status == 2)
593 $record_obj->setAssignedObjectTypes($obj_types);
597 $record_obj->setActive(isset(
$_POST[
'active'][$record_obj->getRecordId()]));
600 $record_obj->setGlobalPosition((
int) $sorted_positions[$record_obj->getRecordId()]);
601 $record_obj->update();
604 if ($item[
'readonly'] &&
606 $_POST[
'active'][$item[
'id']]) {
607 $selected_global[] = $item[
'id'];
608 } elseif ($item[
'local']) {
610 $record_obj->setActive(isset(
$_POST[
'active'][$item[
'id']]));
611 $record_obj->update();
616 if ($this->mode == self::MODE_OBJECT) {
619 $local_position = new \ilAdvancedMDRecordObjectOrdering($item[
'id'], $this->obj_id,
$DIC->database());
620 $local_position->setPosition((
int) $sorted_positions[$item[
'id']]);
621 $local_position->save();
625 if ($this->obj_type) {
629 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
630 $this->ctrl->redirect($this,
"showRecords");
641 if (!isset(
$_POST[
'field_id'])) {
647 $this->ctrl->saveParameter($this,
'record_id');
649 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
653 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFields"));
654 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_fields_sure"));
655 $c_gui->setCancel($this->lng->txt(
"cancel"),
"editFields");
656 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFields");
659 foreach (
$_POST[
"field_id"] as $field_id) {
661 $c_gui->addItem(
"field_id[]", $field_id, $field->getTitle() ? $field->getTitle() :
'No Title');
663 $this->tpl->setContent($c_gui->getHTML());
675 $this->ctrl->saveParameter($this,
'record_id');
677 if (!isset(
$_POST[
'field_id'])) {
685 foreach (
$_POST[
'field_id'] as $field_id) {
692 $fail[] = $field->getTitle();
696 ilUtil::sendFailure($this->lng->txt(
'msg_no_perm_delete') .
" " . implode(
", ", $fail),
true);
697 $this->ctrl->redirect($this,
"editFields");
700 foreach (
$_POST[
"field_id"] as $field_id) {
704 ilUtil::sendSuccess($this->lng->txt(
'md_adv_deleted_fields'),
true);
705 $this->ctrl->redirect($this,
"editFields");
717 $this->ctrl->saveParameter($this,
'record_id');
720 $this->tpl->setContent($this->form->getHTML());
727 $ilToolbar =
$DIC[
'ilToolbar'];
729 $this->ctrl->saveParameter($this,
'record_id');
734 $this->record->getRecordId(),
741 $filter_warn = array();
744 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
749 $options[
$type] = $this->lng->txt($field->getTypeTitle());
751 if (!$field->isFilterSupported()) {
752 $filter_warn[] = $this->lng->txt($field->getTypeTitle());
755 $types->setOptions($options);
756 $ilToolbar->addInputItem($types);
758 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
"createField"));
760 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
762 $button->setCaption(
"add");
763 $button->setCommand(
"createField");
764 $ilToolbar->addButtonInstance($button);
768 if (
sizeof($filter_warn)) {
769 ilUtil::sendInfo(sprintf($this->lng->txt(
"md_adv_field_filter_warning"), implode(
", ", $filter_warn)));
773 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
776 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
778 $table_gui->setTitle($this->lng->txt(
"md_adv_field_table"));
779 $table_gui->parseDefinitions($fields);
780 if (
sizeof($fields)) {
781 $table_gui->addCommandButton(
"updateFields", $this->lng->txt(
"save"));
783 $table_gui->addCommandButton(
"showRecords", $this->lng->txt(
'cancel'));
784 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->lng->txt(
"delete"));
785 $table_gui->setSelectAllCheckbox(
"field_id");
787 $this->tpl->setContent($table_gui->getHTML());
798 $this->ctrl->saveParameter($this,
'record_id');
800 if (!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id']) {
806 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
814 if (!isset(
$_POST[
'position']) or !is_array(
$_POST[
'position'])) {
819 asort(
$_POST[
'position'], SORT_NUMERIC);
820 $positions = array_flip(array_keys(
$_POST[
'position']));
821 foreach ($fields as $field) {
822 $field->setPosition($positions[$field->getFieldId()]);
827 foreach ($fields as $field) {
830 $field->getFieldId(),
834 $field->setSearchable(isset(
$_POST[
'searchable'][$field->getFieldId()]) ?
true :
false);
840 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
841 $this->ctrl->redirect($this,
"editFields");
853 if (!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id']) {
861 $this->logger->dump(
$_POST);
863 if (!$this->record->validate()) {
868 $this->record->update();
869 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'));
886 $this->tpl->setContent($this->form->getHTML());
894 $this->tpl->setContent($this->import_form->getHTML());
904 if (is_object($this->import_form)) {
908 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
910 $this->import_form->setMultipart(
true);
911 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
915 $file->setSuffixes(array(
'xml'));
916 $file->setRequired(
true);
917 $this->import_form->addItem($file);
919 $this->import_form->setTitle($this->lng->txt(
'md_adv_import_record'));
920 $this->import_form->addCommandButton(
'importRecord', $this->lng->txt(
'import'));
921 $this->import_form->addCommandButton(
'showRecords', $this->lng->txt(
'cancel'));
934 if (!$this->import_form->checkInput()) {
935 $this->import_form->setValuesByPost();
940 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
942 if (!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name'])) {
948 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
953 $parser->setContext($this->obj_id, $this->obj_type, $this->sub_type);
963 ilUtil::sendSuccess($this->lng->txt(
'md_adv_added_new_record'),
true);
964 $this->ctrl->redirect($this,
"showRecords");
965 }
catch (ilSAXParserException $exc) {
967 $this->ctrl->redirect($this,
"importRecords");
971 $import_files->deleteFileByCreationDate($create_time);
988 if ($this->obj_type) {
989 $this->record->setAssignedObjectTypes(array(
991 "obj_type" => $this->obj_type,
992 "sub_type" => $this->sub_type,
997 if (!$this->record->validate()) {
1002 $this->record->save();
1004 ilUtil::sendSuccess($this->lng->txt(
'md_adv_added_new_record'));
1016 if (!$_REQUEST[
"record_id"] || !$_REQUEST[
"field_id"]) {
1020 $this->ctrl->saveParameter($this,
'record_id');
1021 $this->ctrl->saveParameter($this,
'field_id');
1030 if ($field_definition->hasComplexOptions()) {
1031 $table = $field_definition->getComplexOptionsOverview($this,
"editField");
1034 $this->tpl->setContent($a_form->getHTML() . $table);
1045 if (!$_REQUEST[
"record_id"] || !$_REQUEST[
"field_id"]) {
1049 $this->ctrl->saveParameter($this,
'record_id');
1050 $this->ctrl->saveParameter($this,
'field_id');
1055 if ($form->checkInput()) {
1056 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions());
1057 if (!$field_definition->importDefinitionFormPostValuesNeedsConfirmation()) {
1058 $field_definition->update();
1060 ilUtil::sendSuccess($this->lng->txt(
'settings_saved'),
true);
1061 $this->ctrl->redirect($this,
"editFields");
1067 $form->setValuesByPost();
1072 $field_definition->prepareDefinitionFormConfirmation($form);
1086 if (!$_REQUEST[
"record_id"] || !$_REQUEST[
"ftype"]) {
1090 $this->ctrl->saveParameter($this,
'record_id');
1091 $this->ctrl->saveParameter($this,
'ftype');
1094 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1096 $field_definition->setRecordId($_REQUEST[
"record_id"]);
1099 $this->tpl->setContent($a_form->getHTML());
1109 if (!$_REQUEST[
"record_id"] || !$_REQUEST[
"ftype"]) {
1113 $this->ctrl->saveParameter($this,
'record_id');
1114 $this->ctrl->saveParameter($this,
'ftype');
1116 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1118 $field_definition->setRecordId($_REQUEST[
"record_id"]);
1121 if ($form->checkInput()) {
1122 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions());
1123 $field_definition->save();
1125 ilUtil::sendSuccess($this->lng->txt(
'save_settings'),
true);
1126 $this->ctrl->redirect($this,
"editFields");
1129 $form->setValuesByPost();
1140 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1143 $form->setFormAction($this->ctrl->getFormAction($this));
1147 $form->addItem(
$type);
1152 $form->setTitle($this->lng->txt(
'md_adv_create_field'));
1153 $form->addCommandButton(
'saveField', $this->lng->txt(
'create'));
1155 $form->setTitle($this->lng->txt(
'md_adv_edit_field'));
1156 $form->addCommandButton(
'updateField', $this->lng->txt(
'save'));
1159 $form->addCommandButton(
'editFields', $this->lng->txt(
'cancel'));
1171 if (is_object($this->form)) {
1177 $this->record->getRecordId(),
1189 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1192 $this->form->setFormAction($this->ctrl->getFormAction($this));
1197 $title->setValue($this->record->getTitle());
1198 $title->setSize(20);
1199 $title->setMaxLength(70);
1200 $title->setRequired(
true);
1201 $this->form->addItem($title);
1204 $title->setDisabled(
true);
1209 $desc->setValue($this->record->getDescription());
1212 $this->form->addItem($desc);
1215 $desc->setDisabled(
true);
1220 $check->setChecked($this->record->isActive());
1221 $check->setValue(1);
1222 $this->form->addItem($check);
1225 $check->setDisabled(
true);
1228 if (!$this->obj_type) {
1231 $scope->setChecked($this->record->enabledScope());
1232 $scope->setValue(1);
1233 $this->form->addItem($scope);
1236 $subitems->setValue($this->record->getScopeRefIds());
1237 $exp = $subitems->getExplorerGUI();
1239 $definition =
$GLOBALS[
'DIC'][
'objDefinition'];
1241 foreach ($definition->getAllRepositoryTypes() as
$type) {
1242 if ($definition->isContainer(
$type)) {
1243 $white_list[] =
$type;
1248 $exp->setTypeWhiteList($white_list);
1249 $exp->setSkipRootNode(
false);
1250 $exp->setRootId(ROOT_FOLDER_ID);
1251 $scope->addSubItem($subitems);
1254 if (!$this->obj_type) {
1256 $section->setTitle($this->lng->txt(
'md_obj_types'));
1261 0 => $this->lng->txt(
"meta_obj_type_inactive"),
1262 1 => $this->lng->txt(
"meta_obj_type_mandatory"),
1263 2 => $this->lng->txt(
"meta_obj_type_optional")
1268 $t =
$type[
"obj_type"] .
":" .
$type[
"sub_type"];
1269 $this->lng->loadLanguageModule(
$type[
"obj_type"]);
1271 $type_options = $options;
1272 switch (
$type[
"obj_type"]) {
1275 unset($type_options[1]);
1279 unset($type_options[1]);
1283 unset($type_options[2]);
1288 if ($a_mode ==
"edit") {
1289 foreach ($this->record->getAssignedObjectTypes() as $item) {
1290 if ($item[
"obj_type"] ==
$type[
"obj_type"] &&
1291 $item[
"sub_type"] ==
$type[
"sub_type"]) {
1292 $value = $item[
"optional"]
1300 $check->setOptions($type_options);
1301 $check->setValue($value);
1302 $this->form->addItem($check);
1305 $check->setDisabled(
true);
1312 $this->form->setTitle($this->lng->txt(
'md_adv_create_record'));
1313 $this->form->addCommandButton(
'saveRecord', $this->lng->txt(
'add'));
1314 $this->form->addCommandButton(
'showRecords', $this->lng->txt(
'cancel'));
1319 $this->form->setTitle($this->lng->txt(
'md_adv_edit_record'));
1320 $this->form->addCommandButton(
'updateRecord', $this->lng->txt(
'save'));
1321 $this->form->addCommandButton(
'showRecords', $this->lng->txt(
'cancel'));
1329 if ($a_obj_type ==
"crs") {
1346 } elseif ($a_obj_type ==
"cat") {
1363 } elseif ($a_obj_type ==
"sess") {
1380 } elseif ($a_obj_type ==
"grp") {
1397 } elseif ($a_obj_type ==
"iass") {
1414 } elseif ($a_obj_type ==
"exc") {
1443 $ilAccess =
$DIC[
'ilAccess'];
1445 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1452 $this->form->setFormAction($this->ctrl->getFormAction($this));
1453 #$this->form->setTableWidth('100%');
1456 foreach ($visible_records as
$obj_type => $records) {
1459 if (in_array(
$obj_type, $this->permissions->getAllowedObjectTypes())) {
1479 $check->setValue(1);
1480 $check->setOptionTitle($this->lng->txt(
'md_adv_desc_show'));
1481 $check->setChecked($sub->isDescriptionEnabled() ?
true :
false);
1482 $this->form->addItem($check);
1485 $check->setDisabled(
true);
1489 $check->setValue(1);
1490 $check->setOptionTitle($this->lng->txt(
'md_adv_fields_show'));
1491 $check->setChecked($sub->enabledFieldNames() ?
true :
false);
1492 $this->form->addItem($check);
1495 $check->setDisabled(
true);
1498 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
1499 #$area->setUseRte(true);
1500 #$area->setRteTagSet('standard');
1501 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
1503 #$area->setCols(80);
1504 #$this->form->addItem($area);
1511 $definitions = $sub->sortDefinitions($definitions);
1514 foreach ($definitions as $def) {
1515 $definition_id = $def->getFieldId();
1520 $title = $def->getTitle() .
' (' . $title .
')';
1523 $check->setValue(1);
1524 $check->setOptionTitle($this->lng->txt(
'md_adv_show'));
1525 $check->setChecked($sub->isSubstituted($definition_id));
1527 if ($perm && !$perm[
"show"]) {
1528 $check->setDisabled(
true);
1533 $pos->setMaxLength(4);
1534 $pos->allowDecimals(
true);
1535 $pos->setValue(sprintf(
'%.1f', $counter++));
1536 $check->addSubItem($pos);
1538 if ($perm && !$perm_pos) {
1539 $pos->setDisabled(
true);
1544 $bold->setChecked($sub->isBold($definition_id));
1545 $check->addSubItem($bold);
1547 if ($perm && !$perm[
"bold"]) {
1548 $bold->setDisabled(
true);
1553 $bold->setChecked($sub->hasNewline($definition_id));
1554 $check->addSubItem($bold);
1556 if ($perm && !$perm[
"newline"]) {
1557 $bold->setDisabled(
true);
1561 $this->form->addItem($check);
1589 $this->form->setTitle($this->lng->txt(
'md_adv_substitution_table'));
1591 if ($ilAccess->checkAccess(
'write',
'', $_REQUEST[
"ref_id"])) {
1592 $this->form->addCommandButton(
'updateSubstitutions', $this->lng->txt(
'save'));
1607 $this->record->getRecordId(),
1629 if (!$this->obj_type) {
1631 $obj_types = array();
1632 if (is_array(
$_POST[
'obj_types'])) {
1633 foreach (
$_POST[
'obj_types'] as $t => $value) {
1635 $t = explode(
":", $t);
1636 $obj_types[] = array(
1639 "optional" => ($value > 1)
1644 $this->record->setAssignedObjectTypes($obj_types);
1649 foreach ((array)
$_POST[
'scope_containers_sel'] as
$ref_id) {
1654 $this->record->setScopes(
$_POST[
'scope'] ? $scopes : []);
1655 $this->record->enableScope(
$_POST[
'scope'] ?
true :
false);
1665 if (!is_object($this->record)) {
1666 $record_id = isset(
$_GET[
'record_id'])
1667 ?
$_GET[
'record_id']
1674 $this->record->setParentObject($this->obj_id);
1678 return $this->record;
1688 $this->tabs_gui->clearSubTabs();
1690 $this->tabs_gui->addSubTabTarget(
1691 "md_adv_record_list",
1692 $this->ctrl->getLinkTarget($this,
"showRecords"),
1701 $this->tabs_gui->addSubTabTarget(
1702 "md_adv_presentation",
1703 $this->ctrl->getLinkTarget($this,
"showPresentation")
1707 $this->tabs_gui->addSubTabTarget(
1709 $this->ctrl->getLinkTarget($this,
"showFiles"),
1723 if ($this->mode == self::MODE_OBJECT) {
1729 $records = $orderings->sortRecords($records, $this->obj_id);
1732 foreach ($records as $record) {
1733 $parent_id = $record->getParentObject();
1735 if ($this->mode == self::MODE_ADMINISTRATION) {
1741 if ($parent_id && $parent_id != $this->obj_id) {
1746 if (!$parent_id && !$record->isActive()) {
1753 $record->getScopes()
1761 $tmp_arr[
'id'] = $record->getRecordId();
1762 $tmp_arr[
'active'] = $record->isActive();
1763 $tmp_arr[
'title'] = $record->getTitle();
1764 $tmp_arr[
'description'] = $record->getDescription();
1765 $tmp_arr[
'fields'] = array();
1766 $tmp_arr[
'obj_types'] = $record->getAssignedObjectTypes();
1768 $tmp_arr[
'position'] = $position;
1770 $tmp_arr[
'perm'] = $this->permissions->hasPermissions(
1772 $record->getRecordId(),
1782 if ($this->obj_type) {
1783 $tmp_arr[
"readonly"] = !(bool) $parent_id;
1784 $tmp_arr[
"local"] = $parent_id;
1787 $assigned = $optional =
false;
1788 foreach ($tmp_arr[
'obj_types'] as $idx => $item) {
1789 if ($item[
"obj_type"] == $this->obj_type &&
1790 $item[
"sub_type"] == $this->sub_type) {
1792 $optional = $item[
"optional"];
1793 $tmp_arr[
'obj_types'][$idx][
'context'] =
true;
1800 $tmp_arr[
'optional'] = $optional;
1803 $tmp_arr[
'active'] = in_array($record->getRecordId(), $selected);
1821 if (!$field_definition->hasComplexOptions()) {
1822 $this->ctrl->redirect($this,
"editField");
1829 $this->tpl->setContent($a_form->getHTML());
1834 $this->ctrl->saveParameter($this,
"record_id");
1835 $this->ctrl->saveParameter($this,
"field_id");
1836 $this->ctrl->saveParameter($this,
"oid");
1838 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1840 $form->setTitle($this->lng->txt(
"md_adv_edit_complex_option"));
1841 $form->setFormAction($this->ctrl->getFormAction($this,
"updateComplexOption"));
1843 $a_def->initOptionForm($form, $_REQUEST[
"oid"]);
1845 $form->addCommandButton(
"updateComplexOption", $this->lng->txt(
"save"));
1846 $form->addCommandButton(
"editField", $this->lng->txt(
"cancel"));
1854 if ($field_definition->hasComplexOptions()) {
1856 if ($form->checkInput() &&
1857 $field_definition->updateComplexOption($form, $_REQUEST[
"oid"])) {
1858 $field_definition->update();
1859 ilUtil::sendSuccess($this->lng->txt(
"settings_saved"),
true);
1863 $this->ctrl->redirect($this,
"editField");
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
AMD field abstract base class.
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
static getInstancesByObjType($a_obj_type, $a_active_only=true)
getFieldId()
Get field_id.
static getValidTypes()
Get all valid types.
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
Add input elements to definition form.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
getTypeTitle()
Get type title (lang id)
const ACTION_SUBSTITUTION_COURSE_SHOW_FIELD
const SUBACTION_FIELD_SEARCHABLE
const CONTEXT_SUBSTITUTION_SESSION
const ACTION_RECORD_EXPORT
const ACTION_SUBSTITUTION_SHOW_FIELDNAMES
const SUBACTION_RECORD_DESCRIPTION
const ACTION_SUBSTITUTION_FIELD_POSITIONS
const ACTION_SUBSTITUTION_GROUP_SHOW_FIELD
const ACTION_SUBSTITUTION_CATEGORY_EDIT_FIELD_PROPERTY
const ACTION_RECORD_CREATE_FIELD
const ACTION_SUBSTITUTION_GROUP_EDIT_FIELD_PROPERTY
const CONTEXT_SUBSTITUTION_COURSE
const CONTEXT_SUBSTITUTION_CATEGORY
const ACTION_SUBSTITUTION_EXERCISE_EDIT_FIELD_PROPERTY
const ACTION_RECORD_EDIT_FIELDS
const ACTION_RECORD_FIELD_POSITIONS
const SUBACTION_RECORD_TITLE
const ACTION_SUBSTITUTION_SHOW_DESCRIPTION
const SUBACTION_SUBSTITUTION_BOLD
const ACTION_FIELD_EDIT_PROPERTY
const ACTION_SUBSTITUTION_COURSE_EDIT_FIELD_PROPERTY
const CONTEXT_SUBSTITUTION_IASS
const ACTION_RECORD_TOGGLE_ACTIVATION
const SUBACTION_SUBSTITUTION_NEWLINE
const ACTION_SUBSTITUTION_CATEGORY_SHOW_FIELD
const ACTION_SUBSTITUTION_IASS_SHOW_FIELD
const ACTION_MD_CREATE_RECORD
const ACTION_SUBSTITUTION_EXERCISE_SHOW_FIELD
const CONTEXT_SUBSTITUTION
const ACTION_RECORD_EDIT_PROPERTY
const ACTION_SUBSTITUTION_SESSION_SHOW_FIELD
const ACTION_MD_IMPORT_RECORDS
const SUBACTION_RECORD_OBJECT_TYPES
const ACTION_SUBSTITUTION_SESSION_EDIT_FIELD_PROPERTY
const CONTEXT_SUBSTITUTION_EXERCISE
const ACTION_SUBSTITUTION_IASS_EDIT_FIELD_PROPERTY
const ACTION_RECORD_DELETE
const CONTEXT_SUBSTITUTION_GROUP
const ACTION_FIELD_DELETE
SAX based XML parser for record import files.
const MODE_INSERT_VALIDATION
Scope restrictions for advanced md records.
static _lookupTitle($a_record_id)
Lookup title.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! @access public.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
static _getActivatedObjTypes()
get activated obj types
static _getRecords()
Get records.
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
updateSubstitutions()
Update substitution.
showFiles()
show export files
setSubTabs()
Set sub tabs.
updateRecord()
Update record.
showRecords()
show record list
updateRecords()
Save records (assigned object typed)
initForm($a_mode)
Init Form.
editField(ilPropertyFormGUI $a_form=null)
Edit field.
importRecord()
import xml file
executeCommand()
Execute command.
initRecordObject()
Init record object.
const MODE_ADMINISTRATION
confirmDeleteFiles()
confirm delete files
initFieldForm(ilAdvancedMDFieldDefinition $a_definition)
init field form
initFormSubstitutions()
init form table 'substitutions'
editComplexOption(ilPropertyFormGUI $a_form=null)
initImportForm()
show import form
initComplexOptionForm(ilAdvancedMDFieldDefinition $a_def)
__construct($a_ref_id=null, $a_obj_type=null, $a_sub_type=null)
Constructor.
deleteRecords()
Permanently delete records.
loadRecordFormData()
load record form data
exportRecords()
Export records.
editRecord()
Edit one record.
updateFields()
Update fields.
deleteFields()
delete fields
confirmDeleteRecords()
Confirm delete.
downloadFile()
Download XML file.
getParsedRecordObjects()
Get and cache record objects.
getSubstitutionFieldPermissions($a_obj_type, $a_field_id)
updateField()
Update field.
createField(ilPropertyFormGUI $a_form=null)
Show field type selection.
confirmDeleteFields()
show delete fields confirmation screen
deleteFiles()
Delete files.
static _getInstanceByObjectType($a_type)
Singleton: use this method to get an instance.
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
Confirmation screen class.
This class represents a non editable value in a property form.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
foreach($_POST as $key=> $value) $res