34 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
35 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
56 $this->lng->loadLanguageModule(
'meta');
58 $this->tabs_gui = $ilTabs;
70 $next_class = $this->ctrl->getNextClass($this);
71 $cmd = $this->ctrl->getCmd();
95 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.show_records.html',
'Services/AdvancedMetaData');
97 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordTableGUI.php");
99 $table_gui->setTitle($this->lng->txt(
"md_record_list_table"));
100 $table_gui->parseRecords($this->record_objs);
101 $table_gui->addCommandButton(
"updateRecords", $this->lng->txt(
"save"));
102 $table_gui->addCommandButton(
'createRecord',$this->lng->txt(
'add'));
103 $table_gui->addMultiCommand(
"exportRecords",$this->lng->txt(
'export'));
104 $table_gui->addMultiCommand(
"confirmDeleteRecords", $this->lng->txt(
"delete"));
105 $table_gui->setSelectAllCheckbox(
"record_id");
106 $this->tpl->setVariable(
'RECORD_TABLE',$table_gui->getHTML());
112 if (is_object($this->form))
114 $this->tpl->setVariable(
'SUBSTITUTION_TABLE',$this->form->getHTML());
129 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
131 $sub->resetSubstitutions(array());
132 $sub->enableDescription($_POST[
'enabled_desc_'.$obj_type]);
133 $sub->enableFieldNames((
int) $_POST[
'enabled_field_names_'.$obj_type]);
135 asort($_POST[
'position'][$obj_type],SORT_NUMERIC);
136 foreach($_POST[
'position'][$obj_type] as $field_id => $pos)
138 if(isset($_POST[
'show'][$obj_type][$field_id]) and $_POST[
'show'][$obj_type][$field_id])
140 $newline = $bold =
false;
141 if(isset($_POST[
'bold'][$obj_type][$field_id]) and $_POST[
'bold'][$obj_type][$field_id])
145 if(isset($_POST[
'newline'][$obj_type][$field_id]) and $_POST[
'newline'][$obj_type][$field_id])
149 $sub->appendSubstitution($field_id,$bold,$newline);
178 if(!isset($_POST[
'record_id']))
184 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
186 $xml_writer->write();
188 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
190 $export_files->create($xml_writer->xmlDumpMem());
206 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
208 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
210 $file_data =
$files->readFilesInfo();
212 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
214 $table_gui->setTitle($this->lng->txt(
"md_record_export_table"));
215 $table_gui->parseFiles($file_data);
216 $table_gui->addMultiCommand(
"downloadFile",$this->lng->txt(
'download'));
217 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->lng->txt(
"delete"));
218 $table_gui->addCommandButton(
'showFiles',$this->lng->txt(
'cancel'));
219 $table_gui->setSelectAllCheckbox(
"file_id");
221 $this->tpl->setContent($table_gui->getHTML());
233 if(!isset($_POST[
'file_id']) or count($_POST[
'file_id']) != 1)
240 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
242 $abs_path =
$files->getAbsolutePathByFileId((
int) $_POST[
'file_id'][0]);
255 if(!isset($_POST[
'file_id']))
262 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
266 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFiles"));
267 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_files_sure"));
268 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showFiles");
269 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFiles");
271 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
273 $file_data =
$files->readFilesInfo();
277 foreach($_POST[
"file_id"] as $file_id)
279 $info = $file_data[$file_id];
280 $c_gui->addItem(
"file_id[]", $file_id, is_array($info[
'name']) ? implode(
',',$info[
'name']) :
'No Records');
282 $this->tpl->setContent($c_gui->getHTML());
294 if(!isset($_POST[
'file_id']))
301 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
304 foreach($_POST[
'file_id'] as $file_id)
306 $files->deleteByFileId((
int) $file_id);
320 if(!isset($_POST[
'record_id']))
327 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
331 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRecords"));
332 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_record_sure"));
333 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
334 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRecords");
337 foreach($_POST[
"record_id"] as $record_id)
340 $c_gui->addItem(
"record_id[]", $record_id, $record->getTitle() ? $record->getTitle() :
'No Title');
342 $this->tpl->setContent($c_gui->getHTML());
353 if(!isset($_POST[
'record_id']))
359 foreach($_POST[
'record_id'] as $record_id)
380 $new_types = isset($_POST[
'obj_types'][$record_obj->getRecordId()]) ?
381 $_POST[
'obj_types'][$record_obj->getRecordId()] :
383 $record_obj->setAssignedObjectTypes($new_types);
384 $record_obj->setActive(isset($_POST[
'active'][$record_obj->getRecordId()]));
385 $record_obj->update();
399 if(!isset($_POST[
'field_id']))
405 $this->ctrl->saveParameter($this,
'record_id');
407 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
411 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFields"));
412 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_fields_sure"));
413 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
414 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFields");
417 foreach($_POST[
"field_id"] as $field_id)
420 $c_gui->addItem(
"field_id[]", $field_id, $field->getTitle() ? $field->getTitle() :
'No Title');
422 $this->tpl->setContent($c_gui->getHTML());
434 if(!isset($_POST[
'field_id']))
440 foreach($_POST[
"field_id"] as $field_id)
461 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.edit_record.html',
'Services/AdvancedMetaData');
462 $this->ctrl->saveParameter($this,
'record_id');
465 $this->tpl->setVariable(
'EDIT_RECORD_TABLE',$this->form->getHTML());
468 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
471 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
473 $table_gui->setTitle($this->lng->txt(
"md_adv_field_table"));
474 $table_gui->parseDefinitions($fields);
475 $table_gui->addCommandButton(
"updateFields", $this->lng->txt(
"save"));
476 $table_gui->addCommandButton(
'createField',$this->lng->txt(
'add'));
477 $table_gui->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
478 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->lng->txt(
"delete"));
479 $table_gui->setSelectAllCheckbox(
"field_id");
481 $this->tpl->setVariable(
'FIELDS_TABLE',$table_gui->getHTML());
492 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
499 if(!isset($_POST[
'position']) or !is_array($_POST[
'position']))
505 asort($_POST[
'position'],SORT_NUMERIC);
508 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
509 foreach($_POST[
'position'] as $field_id => $pos)
512 $definition->setPosition($counter++);
513 $definition->enableSearchable(isset($_POST[
'searchable'][$field_id]) ?
true :
false);
514 $definition->update();
533 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
542 if(!$this->record->validate())
548 $this->record->update();
564 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.new_record.html',
'Services/AdvancedMetaData');
568 $this->tpl->setVariable(
'NEW_RECORD_TABLE',$this->form->getHTML());
572 $this->tpl->setVariable(
'IMPORT_RECORD_TABLE',$this->import_form->getHTML());
583 if(is_object($this->import_form))
588 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
590 $this->import_form->setMultipart(
true);
591 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
595 $file->setSuffixes(array(
'xml'));
596 $file->setRequired(
true);
597 $this->import_form->addItem(
$file);
599 $this->import_form->setTitle($this->lng->txt(
'md_adv_import_record'));
600 $this->import_form->addCommandButton(
'importRecord',$this->lng->txt(
'import'));
601 $this->import_form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
614 if(!$this->import_form->checkInput())
616 $this->import_form->setValuesByPost();
621 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
623 if(!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name']))
631 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
636 $parser->startParsing();
640 $parser->startParsing();
644 catch(ilSAXParserException $exc)
651 $import_files->deleteFileByCreationDate($create_time);
670 if(!$this->record->validate())
676 $this->record->save();
689 $this->ctrl->saveParameter($this,
'record_id');
690 $this->ctrl->saveParameter($this,
'field_id');
694 $this->tpl->setContent($this->form->getHTML());
707 $this->ctrl->saveParameter($this,
'record_id');
712 if(!$this->field_definition->validate())
718 $this->field_definition->update();
731 $this->ctrl->saveParameter($this,
'record_id');
733 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
736 $this->tpl->setContent($this->form->getHTML());
752 if(isset($_GET[
'field_id']) and $_GET[
'field_id'])
771 $this->ctrl->saveParameter($this,
'record_id');
775 if(!$this->field_definition->validate())
781 $this->field_definition->add();
794 if(is_object($this->field_form))
799 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
802 $this->form->setFormAction($this->ctrl->getFormAction($this));
806 $title->setValue($this->field_definition->getTitle());
809 $title->setRequired(
true);
810 $this->form->addItem(
$title);
814 $desc->
setValue($this->field_definition->getDescription());
817 $this->form->addItem($desc);
821 $check->
setChecked($this->field_definition->isSearchable());
823 $this->form->addItem($check);
827 $radio->
setValue($this->field_definition->getFieldType() ?
828 $this->field_definition->getFieldType() :
830 $radio->setRequired(
true);
833 $radio->addOption($radio_option);
836 $radio->addOption($radio_option);
839 $radio->addOption($radio_option);
842 $radio->addOption($radio_option);
844 $values = $this->field_definition->getFieldValues();
846 $max_values = max(count($values),
$_SESSION[
'num_values'] ?
$_SESSION[
'num_values'] : 5);
847 $_SESSION[
'num_values'] = $max_values;
848 for($i = 1; $i <= $max_values;$i++)
851 $title->setValue(isset($values[$i - 1]) ? $values[$i - 1] :
'');
854 $radio_option->addSubItem(
$title);
856 $this->form->addItem($radio);
861 $this->form->setTitle($this->lng->txt(
'md_adv_create_field'));
862 $this->form->addCommandButton(
'saveField',$this->lng->txt(
'create'));
863 $this->form->addCommandButton(
'addValue',$this->lng->txt(
'md_adv_add_value'));
864 $this->form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
869 $this->form->setTitle($this->lng->txt(
'md_adv_edit_field'));
870 $this->form->addCommandButton(
'updateField',$this->lng->txt(
'save'));
871 $this->form->addCommandButton(
'addValue',$this->lng->txt(
'md_adv_add_value'));
872 $this->form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
885 if(is_object($this->form))
890 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
893 $this->form->setFormAction($this->ctrl->getFormAction($this));
897 $title->setValue($this->record->getTitle());
900 $title->setRequired(
true);
901 $this->form->addItem(
$title);
905 $desc->
setValue($this->record->getDescription());
908 $this->form->addItem($desc);
912 $check->
setChecked($this->record->isActive());
914 $this->form->addItem($check);
917 $section->setTitle($this->lng->txt(
'md_obj_types'));
923 $check->
setChecked(in_array($type,$this->record->getAssignedObjectTypes()) ?
true :
false);
924 $check->setValue($type);
925 $this->form->addItem($check);
932 $this->form->setTitle($this->lng->txt(
'md_adv_create_record'));
933 $this->form->addCommandButton(
'saveRecord',$this->lng->txt(
'add'));
934 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
939 $this->form->setTitle($this->lng->txt(
'md_adv_edit_record'));
940 $this->form->addCommandButton(
'updateRecord',$this->lng->txt(
'save'));
941 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
954 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
962 $this->form->setFormAction($this->ctrl->getFormAction($this));
963 #$this->form->setTableWidth('100%');
966 foreach($visible_records as $obj_type => $records)
968 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
974 $section->setTitle($this->lng->txt(
'objs_'.$obj_type));
977 $check =
new ilCheckboxInputGUI($this->lng->txt(
'description'),
'enabled_desc_'.$obj_type);
979 $check->setOptionTitle($this->lng->txt(
'md_adv_desc_show'));
980 $check->setChecked($sub->isDescriptionEnabled() ?
true :
false);
981 $this->form->addItem($check);
983 $check =
new ilCheckboxInputGUI($this->lng->txt(
'md_adv_field_names'),
'enabled_field_names_'.$obj_type);
985 $check->setOptionTitle($this->lng->txt(
'md_adv_fields_show'));
986 $check->setChecked($sub->enabledFieldNames() ?
true :
false);
987 $this->form->addItem($check);
989 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
990 #$area->setUseRte(true);
991 #$area->setRteTagSet('standard');
992 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
995 #$this->form->addItem($area);
998 $definitions = $sub->sortDefinitions($definitions);
1001 foreach($definitions as $definition_id)
1005 if($def->isDeleted())
1011 $title = $def->getTitle().
' ('.$title.
')';
1014 $check->setValue(1);
1015 $check->setOptionTitle($this->lng->txt(
'md_adv_show'));
1016 $check->setChecked($sub->isSubstituted($definition_id));
1018 $pos =
new ilTextInputGUI($this->lng->txt(
'position'),
'position['.$obj_type.
']['.$definition_id.
']');
1020 $pos->setMaxLength(4);
1021 $pos->setValue(sprintf(
'%.1f',$counter++));
1022 $check->addSubItem($pos);
1024 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'bold'),
'bold['.$obj_type.
']['.$definition_id.
']');
1026 $bold->setChecked($sub->isBold($definition_id));
1027 $check->addSubItem($bold);
1029 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'newline'),
'newline['.$obj_type.
']['.$definition_id.
']');
1031 $bold->setChecked($sub->hasNewline($definition_id));
1032 $check->addSubItem($bold);
1035 $this->form->addItem($check);
1063 $this->form->setTitle($this->lng->txt(
'md_adv_substitution_table'));
1064 $this->form->addCommandButton(
'updateSubstitutions',$this->lng->txt(
'save'));
1078 $this->record->setAssignedObjectTypes(isset($_POST[
'obj_types']) ? $_POST[
'obj_types'] : array());
1088 $this->field_definition->setRecordId((
int)
$_GET[
'record_id']);
1091 $this->field_definition->enableSearchable(isset($_POST[
'searchable']) ?
true :
false);
1093 $this->field_definition->setFieldValues(array());
1095 for($i = 1; $i <=
$_SESSION[
'num_values'];$i++)
1097 if(isset($_POST[
'value_'.$i]))
1099 $this->field_definition->appendFieldValue($_POST[
'value_'.$i]);
1111 if(is_object($this->record))
1113 return $this->record;
1116 $record_id = isset(
$_GET[
'record_id']) ?
1117 $_GET[
'record_id'] :
1129 $this->tabs_gui->clearSubTabs();
1131 $this->tabs_gui->addSubTabTarget(
"md_adv_record_list",
1132 $this->ctrl->getLinkTarget($this,
"showRecords"),
1138 $this->tabs_gui->addSubTabTarget(
"md_adv_file_list",
1139 $this->ctrl->getLinkTarget($this,
"showFiles"),
1154 if(!isset($this->record_objs))
1158 return $this->record_objs;