15 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
16 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
37 $this->lng->loadLanguageModule(
'meta');
39 $this->tabs_gui = $ilTabs;
51 $next_class = $this->ctrl->getNextClass($this);
52 $cmd = $this->ctrl->getCmd();
77 $ilToolbar->addButton($this->lng->txt(
'add'),
78 $this->ctrl->getLinkTarget($this,
"createRecord"));
81 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.show_records.html',
'Services/AdvancedMetaData');
83 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
85 $table_gui->setTitle($this->lng->txt(
"md_record_list_table"));
86 $table_gui->parseRecords($this->record_objs);
87 $table_gui->addCommandButton(
"updateRecords", $this->lng->txt(
"save"));
89 $table_gui->addMultiCommand(
"exportRecords",$this->lng->txt(
'export'));
90 $table_gui->addMultiCommand(
"confirmDeleteRecords", $this->lng->txt(
"delete"));
91 $table_gui->setSelectAllCheckbox(
"record_id");
92 $this->tpl->setVariable(
'RECORD_TABLE',$table_gui->getHTML());
98 if (is_object($this->form))
100 $this->tpl->setVariable(
'SUBSTITUTION_TABLE',$this->form->getHTML());
115 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
117 $sub->resetSubstitutions(array());
118 $sub->enableDescription(
$_POST[
'enabled_desc_'.$obj_type]);
119 $sub->enableFieldNames((
int)
$_POST[
'enabled_field_names_'.$obj_type]);
121 if(isset(
$_POST[
'position'][$obj_type]))
123 asort(
$_POST[
'position'][$obj_type],SORT_NUMERIC);
124 foreach(
$_POST[
'position'][$obj_type] as $field_id => $pos)
126 if(isset(
$_POST[
'show'][$obj_type][$field_id]) and
$_POST[
'show'][$obj_type][$field_id])
128 $newline = $bold =
false;
129 if(isset(
$_POST[
'bold'][$obj_type][$field_id]) and
$_POST[
'bold'][$obj_type][$field_id])
133 if(isset(
$_POST[
'newline'][$obj_type][$field_id]) and
$_POST[
'newline'][$obj_type][$field_id])
137 $sub->appendSubstitution($field_id,$bold,$newline);
158 if(!isset(
$_POST[
'record_id']))
164 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
166 $xml_writer->write();
168 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
170 $export_files->create($xml_writer->xmlDumpMem());
186 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
188 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
190 $file_data = $files->readFilesInfo();
192 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
194 $table_gui->setTitle($this->lng->txt(
"md_record_export_table"));
195 $table_gui->parseFiles($file_data);
196 $table_gui->addMultiCommand(
"downloadFile",$this->lng->txt(
'download'));
197 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->lng->txt(
"delete"));
198 $table_gui->addCommandButton(
'showFiles',$this->lng->txt(
'cancel'));
199 $table_gui->setSelectAllCheckbox(
"file_id");
201 $this->tpl->setContent($table_gui->getHTML());
213 if(!isset(
$_POST[
'file_id']) or count(
$_POST[
'file_id']) != 1)
220 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
222 $abs_path = $files->getAbsolutePathByFileId((
int)
$_POST[
'file_id'][0]);
235 if(!isset(
$_POST[
'file_id']))
242 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
246 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFiles"));
247 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_files_sure"));
248 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showFiles");
249 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFiles");
251 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
253 $file_data = $files->readFilesInfo();
257 foreach(
$_POST[
"file_id"] as $file_id)
259 $info = $file_data[$file_id];
260 $c_gui->addItem(
"file_id[]", $file_id, is_array($info[
'name']) ? implode(
',',$info[
'name']) :
'No Records');
262 $this->tpl->setContent($c_gui->getHTML());
274 if(!isset(
$_POST[
'file_id']))
281 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
284 foreach(
$_POST[
'file_id'] as $file_id)
286 $files->deleteByFileId((
int) $file_id);
300 if(!isset(
$_POST[
'record_id']))
307 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
311 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRecords"));
312 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_record_sure"));
313 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
314 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRecords");
317 foreach(
$_POST[
"record_id"] as $record_id)
320 $c_gui->addItem(
"record_id[]", $record_id, $record->getTitle() ? $record->getTitle() :
'No Title');
322 $this->tpl->setContent($c_gui->getHTML());
333 if(!isset(
$_POST[
'record_id']))
339 foreach(
$_POST[
'record_id'] as $record_id)
360 $obj_types = array();
361 if (is_array(
$_POST[
'obj_types'][$record_obj->getRecordId()]))
363 foreach (
$_POST[
'obj_types'][$record_obj->getRecordId()] as
$t)
365 $t = explode(
":",
$t);
366 $obj_types[] = array(
373 $record_obj->setAssignedObjectTypes($obj_types);
374 $record_obj->setActive(isset(
$_POST[
'active'][$record_obj->getRecordId()]));
375 $record_obj->update();
389 if(!isset(
$_POST[
'field_id']))
395 $this->ctrl->saveParameter($this,
'record_id');
397 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
401 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFields"));
402 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_fields_sure"));
403 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
404 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFields");
407 foreach(
$_POST[
"field_id"] as $field_id)
410 $c_gui->addItem(
"field_id[]", $field_id, $field->getTitle() ? $field->getTitle() :
'No Title');
412 $this->tpl->setContent($c_gui->getHTML());
424 if(!isset(
$_POST[
'field_id']))
430 foreach(
$_POST[
"field_id"] as $field_id)
451 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.edit_record.html',
'Services/AdvancedMetaData');
452 $this->ctrl->saveParameter($this,
'record_id');
455 $this->tpl->setVariable(
'EDIT_RECORD_TABLE',$this->form->getHTML());
458 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
461 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
463 $table_gui->setTitle($this->lng->txt(
"md_adv_field_table"));
464 $table_gui->parseDefinitions($fields);
465 $table_gui->addCommandButton(
"updateFields", $this->lng->txt(
"save"));
466 $table_gui->addCommandButton(
'createField',$this->lng->txt(
'add'));
467 $table_gui->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
468 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->lng->txt(
"delete"));
469 $table_gui->setSelectAllCheckbox(
"field_id");
471 $this->tpl->setVariable(
'FIELDS_TABLE',$table_gui->getHTML());
482 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
489 if(!isset(
$_POST[
'position']) or !is_array(
$_POST[
'position']))
495 asort(
$_POST[
'position'],SORT_NUMERIC);
498 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
499 foreach(
$_POST[
'position'] as $field_id => $pos)
502 $definition->setPosition($counter++);
503 $definition->enableSearchable(isset(
$_POST[
'searchable'][$field_id]) ?
true :
false);
504 $definition->update();
523 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
532 if(!$this->record->validate())
538 $this->record->update();
554 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.new_record.html',
'Services/AdvancedMetaData');
558 $this->tpl->setVariable(
'NEW_RECORD_TABLE',$this->form->getHTML());
562 $this->tpl->setVariable(
'IMPORT_RECORD_TABLE',$this->import_form->getHTML());
573 if(is_object($this->import_form))
578 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
580 $this->import_form->setMultipart(
true);
581 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
585 $file->setSuffixes(array(
'xml'));
586 $file->setRequired(
true);
587 $this->import_form->addItem(
$file);
589 $this->import_form->setTitle($this->lng->txt(
'md_adv_import_record'));
590 $this->import_form->addCommandButton(
'importRecord',$this->lng->txt(
'import'));
591 $this->import_form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
604 if(!$this->import_form->checkInput())
606 $this->import_form->setValuesByPost();
611 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
613 if(!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name']))
621 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
626 $parser->startParsing();
630 $parser->startParsing();
634 catch(ilSAXParserException $exc)
641 $import_files->deleteFileByCreationDate($create_time);
660 if(!$this->record->validate())
666 $this->record->save();
679 $this->ctrl->saveParameter($this,
'record_id');
680 $this->ctrl->saveParameter($this,
'field_id');
684 $this->tpl->setContent($this->form->getHTML());
697 $this->ctrl->saveParameter($this,
'record_id');
702 if(!$this->field_definition->validate())
708 $this->field_definition->update();
721 $this->ctrl->saveParameter($this,
'record_id');
723 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
726 $this->tpl->setContent($this->form->getHTML());
742 if(isset($_GET[
'field_id']) and $_GET[
'field_id'])
761 $this->ctrl->saveParameter($this,
'record_id');
765 if(!$this->field_definition->validate())
771 $this->field_definition->add();
784 if(is_object($this->field_form))
789 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
792 $this->form->setFormAction($this->ctrl->getFormAction($this));
796 $title->
setValue($this->field_definition->getTitle());
798 $title->setMaxLength(70);
799 $title->setRequired(
true);
800 $this->form->addItem($title);
804 $desc->
setValue($this->field_definition->getDescription());
807 $this->form->addItem($desc);
811 $check->
setChecked($this->field_definition->isSearchable());
813 $this->form->addItem($check);
817 $radio->
setValue($this->field_definition->getFieldType() ?
818 $this->field_definition->getFieldType() :
820 $radio->setRequired(
true);
823 $radio->addOption($radio_option);
826 $radio->addOption($radio_option);
829 $radio->addOption($radio_option);
832 $radio->addOption($radio_option);
834 $values = $this->field_definition->getFieldValues();
836 $max_values = max(count($values),
$_SESSION[
'num_values'] ?
$_SESSION[
'num_values'] : 5);
837 $_SESSION[
'num_values'] = $max_values;
838 for($i = 1; $i <= $max_values;$i++)
840 $title =
new ilTextInputGUI($this->lng->txt(
'udf_value').
' '.$i,
'value_'.$i);
841 $title->
setValue(isset($values[$i - 1]) ? $values[$i - 1] :
'');
843 $title->setMaxLength(70);
844 $radio_option->addSubItem($title);
846 $this->form->addItem($radio);
851 $this->form->setTitle($this->lng->txt(
'md_adv_create_field'));
852 $this->form->addCommandButton(
'saveField',$this->lng->txt(
'create'));
853 $this->form->addCommandButton(
'addValue',$this->lng->txt(
'md_adv_add_value'));
854 $this->form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
859 $this->form->setTitle($this->lng->txt(
'md_adv_edit_field'));
860 $this->form->addCommandButton(
'updateField',$this->lng->txt(
'save'));
861 $this->form->addCommandButton(
'addValue',$this->lng->txt(
'md_adv_add_value'));
862 $this->form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
875 if(is_object($this->form))
880 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
883 $this->form->setFormAction($this->ctrl->getFormAction($this));
887 $title->
setValue($this->record->getTitle());
889 $title->setMaxLength(70);
890 $title->setRequired(
true);
891 $this->form->addItem($title);
895 $desc->
setValue($this->record->getDescription());
898 $this->form->addItem($desc);
902 $check->
setChecked($this->record->isActive());
904 $this->form->addItem($check);
907 $section->setTitle($this->lng->txt(
'md_obj_types'));
912 $t = $type[
"obj_type"].
":".$type[
"sub_type"];
913 $this->lng->loadLanguageModule($type[
"obj_type"]);
915 $check->setChecked($this->record->isAssignedObjectType($type[
"obj_type"], $type[
"sub_type"]));
916 $check->setValue(
$t);
917 $this->form->addItem($check);
924 $this->form->setTitle($this->lng->txt(
'md_adv_create_record'));
925 $this->form->addCommandButton(
'saveRecord',$this->lng->txt(
'add'));
926 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
931 $this->form->setTitle($this->lng->txt(
'md_adv_edit_record'));
932 $this->form->addCommandButton(
'updateRecord',$this->lng->txt(
'save'));
933 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
946 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
954 $this->form->setFormAction($this->ctrl->getFormAction($this));
955 #$this->form->setTableWidth('100%');
958 foreach($visible_records as $obj_type =>
$records)
960 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
966 $section->setTitle($this->lng->txt(
'objs_'.$obj_type));
969 $check =
new ilCheckboxInputGUI($this->lng->txt(
'description'),
'enabled_desc_'.$obj_type);
971 $check->setOptionTitle($this->lng->txt(
'md_adv_desc_show'));
972 $check->setChecked($sub->isDescriptionEnabled() ?
true :
false);
973 $this->form->addItem($check);
975 $check =
new ilCheckboxInputGUI($this->lng->txt(
'md_adv_field_names'),
'enabled_field_names_'.$obj_type);
977 $check->setOptionTitle($this->lng->txt(
'md_adv_fields_show'));
978 $check->setChecked($sub->enabledFieldNames() ?
true :
false);
979 $this->form->addItem($check);
981 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
982 #$area->setUseRte(true);
983 #$area->setRteTagSet('standard');
984 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
987 #$this->form->addItem($area);
990 $definitions = $sub->sortDefinitions($definitions);
993 foreach($definitions as $definition_id)
997 if($def->isDeleted())
1003 $title = $def->getTitle().
' ('.$title.
')';
1006 $check->setValue(1);
1007 $check->setOptionTitle($this->lng->txt(
'md_adv_show'));
1008 $check->setChecked($sub->isSubstituted($definition_id));
1010 $pos =
new ilTextInputGUI($this->lng->txt(
'position'),
'position['.$obj_type.
']['.$definition_id.
']');
1012 $pos->setMaxLength(4);
1013 $pos->setValue(sprintf(
'%.1f',$counter++));
1014 $check->addSubItem($pos);
1016 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'bold'),
'bold['.$obj_type.
']['.$definition_id.
']');
1018 $bold->setChecked($sub->isBold($definition_id));
1019 $check->addSubItem($bold);
1021 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'newline'),
'newline['.$obj_type.
']['.$definition_id.
']');
1023 $bold->setChecked($sub->hasNewline($definition_id));
1024 $check->addSubItem($bold);
1027 $this->form->addItem($check);
1055 $this->form->setTitle($this->lng->txt(
'md_adv_substitution_table'));
1056 $this->form->addCommandButton(
'updateSubstitutions',$this->lng->txt(
'save'));
1070 $obj_types = array();
1071 if (is_array(
$_POST[
'obj_types']))
1073 foreach (
$_POST[
'obj_types'] as
$t)
1075 $t = explode(
":", $t);
1076 $obj_types[] = array(
1082 $this->record->setAssignedObjectTypes($obj_types);
1092 $this->field_definition->setRecordId((
int)
$_GET[
'record_id']);
1095 $this->field_definition->enableSearchable(isset(
$_POST[
'searchable']) ?
true :
false);
1097 $this->field_definition->setFieldValues(array());
1099 for($i = 1; $i <=
$_SESSION[
'num_values'];$i++)
1101 if(isset(
$_POST[
'value_'.$i]))
1103 $this->field_definition->appendFieldValue(
$_POST[
'value_'.$i]);
1115 if(is_object($this->record))
1117 return $this->record;
1120 $record_id = isset(
$_GET[
'record_id']) ?
1121 $_GET[
'record_id'] :
1133 $this->tabs_gui->clearSubTabs();
1135 $this->tabs_gui->addSubTabTarget(
"md_adv_record_list",
1136 $this->ctrl->getLinkTarget($this,
"showRecords"),
1142 $this->tabs_gui->addSubTabTarget(
"md_adv_file_list",
1143 $this->ctrl->getLinkTarget($this,
"showFiles"),
1158 if(!isset($this->record_objs))
1162 return $this->record_objs;