4 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
5 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
6 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDPermissionHelper.php');
36 $this->lng->loadLanguageModule(
'meta');
38 $this->tabs_gui = $ilTabs;
57 $next_class = $this->ctrl->getNextClass($this);
58 $cmd = $this->ctrl->getCmd();
93 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
95 $button->setCaption(
"add");
96 $button->setUrl($this->ctrl->getLinkTarget($this,
"createRecord"));
97 $ilToolbar->addButtonInstance($button);
101 $ilToolbar->addSeparator();
107 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
109 $button->setCaption(
"import");
110 $button->setUrl($this->ctrl->getLinkTarget($this,
"importRecords"));
111 $ilToolbar->addButtonInstance($button);
115 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.show_records.html',
'Services/AdvancedMetaData');
117 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
119 $table_gui->setTitle($this->lng->txt(
"md_record_list_table"));
120 $table_gui->parseRecords($this->record_objs);
123 $table_gui->addCommandButton(
"updateRecords", $this->lng->txt(
"save"));
125 $table_gui->addMultiCommand(
"exportRecords",$this->lng->txt(
'export'));
126 $table_gui->addMultiCommand(
"confirmDeleteRecords", $this->lng->txt(
"delete"));
127 $table_gui->setSelectAllCheckbox(
"record_id");
129 $this->tpl->setVariable(
'RECORD_TABLE',$table_gui->getHTML());
138 if (is_object($this->form))
140 $this->tabs_gui->setSubTabActive(
'md_adv_presentation');
141 return $this->tpl->setContent($this->form->getHTML());
159 if(in_array($obj_type, array(
"crs",
"cat")))
171 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
176 $sub->enableDescription(
$_POST[
'enabled_desc_'.$obj_type]);
181 $sub->enableFieldNames((
int)
$_POST[
'enabled_field_names_'.$obj_type]);
185 $definitions = $sub->sortDefinitions($definitions);
190 foreach($definitions as $def)
192 $field_id = $def->getFieldId();
193 $old_sub[$field_id] = array(
194 "active" => $sub->isSubstituted($field_id),
196 "bold" => $sub->isBold($field_id),
197 "newline" => $sub->hasNewline($field_id)
201 $sub->resetSubstitutions(array());
204 foreach($definitions as $def)
206 $field_id = $def->getFieldId();
207 $old = $old_sub[$field_id];
210 if($perm_def[
"show"])
212 $active = (isset(
$_POST[
'show'][$obj_type][$field_id]) &&
$_POST[
'show'][$obj_type][$field_id]);
216 $active = $old[
"active"];
221 $new_sub[$field_id] = $old;
225 $new_sub[$field_id][
"pos"] = (int)
$_POST[
'position'][$obj_type][$field_id];
227 if($perm_def[
"bold"])
229 $new_sub[$field_id][
"bold"] = (isset(
$_POST[
'bold'][$obj_type][$field_id]) &&
$_POST[
'bold'][$obj_type][$field_id]);
231 if($perm_def[
"newline"])
233 $new_sub[$field_id][
"newline"] = (isset(
$_POST[
'newline'][$obj_type][$field_id]) &&
$_POST[
'newline'][$obj_type][$field_id]);
241 foreach($new_sub as $field_id => $field)
243 $sub->appendSubstitution($field_id, $field[
"bold"], $field[
"newline"]);
252 $this->ctrl->redirect($this,
"showPresentation");
262 if(!isset(
$_POST[
'record_id']))
271 foreach(
$_POST[
'record_id'] as $record_id)
279 $fail[] = $record->getTitle();
285 $this->ctrl->redirect($this,
"showRecords");
288 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
290 $xml_writer->write();
292 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
294 $export_files->create($xml_writer->xmlDumpMem());
309 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
311 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
313 $file_data = $files->readFilesInfo();
315 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
317 $table_gui->setTitle($this->lng->txt(
"md_record_export_table"));
318 $table_gui->parseFiles($file_data);
319 $table_gui->addMultiCommand(
"downloadFile",$this->lng->txt(
'download'));
320 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->lng->txt(
"delete"));
321 $table_gui->addCommandButton(
'showFiles',$this->lng->txt(
'cancel'));
322 $table_gui->setSelectAllCheckbox(
"file_id");
324 $this->tpl->setContent($table_gui->getHTML());
336 if(!isset(
$_POST[
'file_id']) or count(
$_POST[
'file_id']) != 1)
343 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
345 $abs_path = $files->getAbsolutePathByFileId((
int)
$_POST[
'file_id'][0]);
358 if(!isset(
$_POST[
'file_id']))
365 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
369 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFiles"));
370 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_files_sure"));
371 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showFiles");
372 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFiles");
374 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
376 $file_data = $files->readFilesInfo();
380 foreach(
$_POST[
"file_id"] as $file_id)
382 $info = $file_data[$file_id];
383 $c_gui->addItem(
"file_id[]", $file_id, is_array($info[
'name']) ? implode(
',',$info[
'name']) :
'No Records');
385 $this->tpl->setContent($c_gui->getHTML());
397 if(!isset(
$_POST[
'file_id']))
404 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
407 foreach(
$_POST[
'file_id'] as $file_id)
409 $files->deleteByFileId((
int) $file_id);
423 if(!isset(
$_POST[
'record_id']))
430 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
434 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRecords"));
435 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_record_sure"));
436 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
437 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRecords");
440 foreach(
$_POST[
"record_id"] as $record_id)
443 $c_gui->addItem(
"record_id[]", $record_id, $record->getTitle() ? $record->getTitle() :
'No Title');
445 $this->tpl->setContent($c_gui->getHTML());
456 if(!isset(
$_POST[
'record_id']))
465 foreach(
$_POST[
'record_id'] as $record_id)
473 $fail[] = $record->getTitle();
479 $this->ctrl->redirect($this,
"showRecords");
482 foreach(
$_POST[
'record_id'] as $record_id)
488 $this->ctrl->redirect($this,
"showRecords");
504 $record_obj->getRecordId(),
513 $obj_types = array();
514 if (is_array(
$_POST[
'obj_types'][$record_obj->getRecordId()]))
516 foreach (
$_POST[
'obj_types'][$record_obj->getRecordId()] as
$t)
518 $t = explode(
":",
$t);
519 $obj_types[] = array(
525 $record_obj->setAssignedObjectTypes($obj_types);
530 $record_obj->setActive(isset(
$_POST[
'active'][$record_obj->getRecordId()]));
533 $record_obj->update();
536 $this->ctrl->redirect($this,
"showRecords");
547 if(!isset(
$_POST[
'field_id']))
554 $this->ctrl->saveParameter($this,
'record_id');
556 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
560 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFields"));
561 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_fields_sure"));
562 $c_gui->setCancel($this->lng->txt(
"cancel"),
"editFields");
563 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFields");
566 foreach(
$_POST[
"field_id"] as $field_id)
569 $c_gui->addItem(
"field_id[]", $field_id, $field->getTitle() ? $field->getTitle() :
'No Title');
571 $this->tpl->setContent($c_gui->getHTML());
583 $this->ctrl->saveParameter($this,
'record_id');
585 if(!isset(
$_POST[
'field_id']))
594 foreach(
$_POST[
'field_id'] as $field_id)
602 $fail[] = $field->getTitle();
608 $this->ctrl->redirect($this,
"editFields");
611 foreach(
$_POST[
"field_id"] as $field_id)
617 $this->ctrl->redirect($this,
"editFields");
629 $this->ctrl->saveParameter($this,
'record_id');
632 $this->tpl->setContent($this->form->getHTML());
640 $this->ctrl->saveParameter($this,
'record_id');
645 $this->record->getRecordId(),
654 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
660 $options[$type] = $this->lng->txt($field->getTypeTitle());
663 $ilToolbar->addInputItem($types);
665 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
"createField"));
667 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
669 $button->setCaption(
"add");
670 $button->setCommand(
"createField");
671 $ilToolbar->addButtonInstance($button);
675 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
678 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
680 $table_gui->setTitle($this->lng->txt(
"md_adv_field_table"));
681 $table_gui->parseDefinitions($fields);
684 $table_gui->addCommandButton(
"updateFields", $this->lng->txt(
"save"));
686 $table_gui->addCommandButton(
"showRecords", $this->lng->txt(
'cancel'));
687 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->lng->txt(
"delete"));
688 $table_gui->setSelectAllCheckbox(
"field_id");
690 $this->tpl->setContent($table_gui->getHTML());
701 $this->ctrl->saveParameter($this,
'record_id');
703 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
710 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
718 if(!isset(
$_POST[
'position']) or !is_array(
$_POST[
'position']))
724 asort(
$_POST[
'position'],SORT_NUMERIC);
725 $positions = array_flip(array_keys(
$_POST[
'position']));
726 foreach($fields as $field)
728 $field->setPosition($positions[$field->getFieldId()]);
733 foreach($fields as $field)
737 $field->getFieldId(),
741 $field->setSearchable(isset(
$_POST[
'searchable'][$field->getFieldId()]) ?
true :
false);
748 $this->ctrl->redirect($this,
"editFields");
762 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
771 if(!$this->record->validate())
777 $this->record->update();
795 $this->tpl->setContent($this->form->getHTML());
803 $this->tpl->setContent($this->import_form->getHTML());
813 if(is_object($this->import_form))
818 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
820 $this->import_form->setMultipart(
true);
821 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
825 $file->setSuffixes(array(
'xml'));
826 $file->setRequired(
true);
827 $this->import_form->addItem(
$file);
829 $this->import_form->setTitle($this->lng->txt(
'md_adv_import_record'));
830 $this->import_form->addCommandButton(
'importRecord',$this->lng->txt(
'import'));
831 $this->import_form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
844 if(!$this->import_form->checkInput())
846 $this->import_form->setValuesByPost();
851 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
853 if(!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name']))
861 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
866 $parser->startParsing();
870 $parser->startParsing();
872 $this->ctrl->redirect($this,
"showRecords");
874 catch(ilSAXParserException $exc)
877 $this->ctrl->redirect($this,
"importRecords");
881 $import_files->deleteFileByCreationDate($create_time);
900 if(!$this->record->validate())
906 $this->record->save();
924 $this->ctrl->saveParameter($this,
'record_id');
925 $this->ctrl->saveParameter($this,
'field_id');
932 $this->tpl->setContent($a_form->getHTML());
950 $this->ctrl->saveParameter($this,
'record_id');
951 $this->ctrl->saveParameter($this,
'field_id');
956 if($form->checkInput())
958 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions());
959 if(!$field_definition->importDefinitionFormPostValuesNeedsConfirmation())
961 $field_definition->update();
964 $this->ctrl->redirect($this,
"editFields");
972 $form->setValuesByPost();
978 $field_definition->prepareDefinitionFormConfirmation($form);
998 $this->ctrl->saveParameter($this,
'record_id');
999 $this->ctrl->saveParameter($this,
'ftype');
1003 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1005 $field_definition->setRecordId(
$_REQUEST[
"record_id"]);
1008 $this->tpl->setContent($a_form->getHTML());
1025 $this->ctrl->saveParameter($this,
'record_id');
1026 $this->ctrl->saveParameter($this,
'ftype');
1028 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1030 $field_definition->setRecordId(
$_REQUEST[
"record_id"]);
1033 if($form->checkInput())
1035 $field_definition->importDefinitionFormPostValues($form, $this->
getPermissions());
1036 $field_definition->save();
1039 $this->ctrl->redirect($this,
"editFields");
1042 $form->setValuesByPost();
1053 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1056 $form->setFormAction($this->ctrl->getFormAction($this));
1060 $form->addItem($type);
1066 $form->setTitle($this->lng->txt(
'md_adv_create_field'));
1067 $form->addCommandButton(
'saveField',$this->lng->txt(
'create'));
1071 $form->setTitle($this->lng->txt(
'md_adv_edit_field'));
1072 $form->addCommandButton(
'updateField',$this->lng->txt(
'save'));
1075 $form->addCommandButton(
'editFields',$this->lng->txt(
'cancel'));
1087 if(is_object($this->form))
1094 $this->record->getRecordId(),
1105 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1108 $this->form->setFormAction($this->ctrl->getFormAction($this));
1113 $title->
setValue($this->record->getTitle());
1114 $title->setSize(20);
1115 $title->setMaxLength(70);
1116 $title->setRequired(
true);
1117 $this->form->addItem($title);
1121 $title->setDisabled(
true);
1126 $desc->
setValue($this->record->getDescription());
1129 $this->form->addItem($desc);
1133 $desc->setDisabled(
true);
1138 $check->
setChecked($this->record->isActive());
1139 $check->setValue(1);
1140 $this->form->addItem($check);
1144 $check->setDisabled(
true);
1148 $section->setTitle($this->lng->txt(
'md_obj_types'));
1153 $t = $type[
"obj_type"].
":".$type[
"sub_type"];
1154 $this->lng->loadLanguageModule($type[
"obj_type"]);
1156 $check->setChecked($this->record->isAssignedObjectType($type[
"obj_type"], $type[
"sub_type"]));
1157 $check->setValue(
$t);
1158 $this->form->addItem($check);
1162 $check->setDisabled(
true);
1169 $this->form->setTitle($this->lng->txt(
'md_adv_create_record'));
1170 $this->form->addCommandButton(
'saveRecord',$this->lng->txt(
'add'));
1171 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
1176 $this->form->setTitle($this->lng->txt(
'md_adv_edit_record'));
1177 $this->form->addCommandButton(
'updateRecord',$this->lng->txt(
'save'));
1178 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
1186 if($a_obj_type ==
"crs")
1204 else if($a_obj_type ==
"cat")
1231 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1239 $this->form->setFormAction($this->ctrl->getFormAction($this));
1240 #$this->form->setTableWidth('100%');
1243 foreach($visible_records as $obj_type =>
$records)
1247 if(in_array($obj_type, array(
"crs",
"cat")))
1259 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
1264 $section->setTitle($this->lng->txt(
'objs_'.$obj_type));
1267 $check =
new ilCheckboxInputGUI($this->lng->txt(
'description'),
'enabled_desc_'.$obj_type);
1269 $check->setOptionTitle($this->lng->txt(
'md_adv_desc_show'));
1270 $check->setChecked($sub->isDescriptionEnabled() ?
true :
false);
1271 $this->form->addItem($check);
1275 $check->setDisabled(
true);
1278 $check =
new ilCheckboxInputGUI($this->lng->txt(
'md_adv_field_names'),
'enabled_field_names_'.$obj_type);
1280 $check->setOptionTitle($this->lng->txt(
'md_adv_fields_show'));
1281 $check->setChecked($sub->enabledFieldNames() ?
true :
false);
1282 $this->form->addItem($check);
1286 $check->setDisabled(
true);
1289 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
1290 #$area->setUseRte(true);
1291 #$area->setRteTagSet('standard');
1292 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
1294 #$area->setCols(80);
1295 #$this->form->addItem($area);
1303 $definitions = $sub->sortDefinitions($definitions);
1306 foreach($definitions as $def)
1308 $definition_id = $def->getFieldId();
1313 $title = $def->getTitle().
' ('.$title.
')';
1316 $check->setValue(1);
1317 $check->setOptionTitle($this->lng->txt(
'md_adv_show'));
1318 $check->setChecked($sub->isSubstituted($definition_id));
1320 if($perm && !$perm[
"show"])
1322 $check->setDisabled(
true);
1325 $pos =
new ilNumberInputGUI($this->lng->txt(
'position'),
'position['.$obj_type.
']['.$definition_id.
']');
1327 $pos->setMaxLength(4);
1328 $pos->allowDecimals(
true);
1329 $pos->setValue(sprintf(
'%.1f',$counter++));
1330 $check->addSubItem($pos);
1332 if($perm && !$perm_pos)
1334 $pos->setDisabled(
true);
1337 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'bold'),
'bold['.$obj_type.
']['.$definition_id.
']');
1339 $bold->setChecked($sub->isBold($definition_id));
1340 $check->addSubItem($bold);
1342 if($perm && !$perm[
"bold"])
1344 $bold->setDisabled(
true);
1347 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'newline'),
'newline['.$obj_type.
']['.$definition_id.
']');
1349 $bold->setChecked($sub->hasNewline($definition_id));
1350 $check->addSubItem($bold);
1352 if($perm && !$perm[
"newline"])
1354 $bold->setDisabled(
true);
1358 $this->form->addItem($check);
1386 $this->form->setTitle($this->lng->txt(
'md_adv_substitution_table'));
1387 $this->form->addCommandButton(
'updateSubstitutions',$this->lng->txt(
'save'));
1400 $this->record->getRecordId(),
1425 $obj_types = array();
1426 if (is_array(
$_POST[
'obj_types']))
1428 foreach (
$_POST[
'obj_types'] as
$t)
1430 $t = explode(
":", $t);
1431 $obj_types[] = array(
1437 $this->record->setAssignedObjectTypes($obj_types);
1448 if(is_object($this->record))
1450 return $this->record;
1453 $record_id = isset(
$_GET[
'record_id']) ?
1454 $_GET[
'record_id'] :
1466 $this->tabs_gui->clearSubTabs();
1468 $this->tabs_gui->addSubTabTarget(
"md_adv_record_list",
1469 $this->ctrl->getLinkTarget($this,
"showRecords"),
1478 $this->tabs_gui->addSubTabTarget(
"md_adv_presentation",
1479 $this->ctrl->getLinkTarget($this,
"showPresentation"));
1482 $this->tabs_gui->addSubTabTarget(
"md_adv_file_list",
1483 $this->ctrl->getLinkTarget($this,
"showFiles"),
1494 if(!isset($this->record_objs))
1498 return $this->record_objs;