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 if(isset(
$_POST[
'position'][$obj_type]))
137 asort(
$_POST[
'position'][$obj_type],SORT_NUMERIC);
138 foreach(
$_POST[
'position'][$obj_type] as $field_id => $pos)
140 if(isset(
$_POST[
'show'][$obj_type][$field_id]) and
$_POST[
'show'][$obj_type][$field_id])
142 $newline = $bold =
false;
143 if(isset(
$_POST[
'bold'][$obj_type][$field_id]) and
$_POST[
'bold'][$obj_type][$field_id])
147 if(isset(
$_POST[
'newline'][$obj_type][$field_id]) and
$_POST[
'newline'][$obj_type][$field_id])
151 $sub->appendSubstitution($field_id,$bold,$newline);
182 if(!isset(
$_POST[
'record_id']))
188 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordXMLWriter.php');
190 $xml_writer->write();
192 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
194 $export_files->create($xml_writer->xmlDumpMem());
210 $this->tabs_gui->setSubTabActive(
'md_adv_file_list');
212 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
214 $file_data =
$files->readFilesInfo();
216 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFilesTableGUI.php");
218 $table_gui->setTitle($this->lng->txt(
"md_record_export_table"));
219 $table_gui->parseFiles($file_data);
220 $table_gui->addMultiCommand(
"downloadFile",$this->lng->txt(
'download'));
221 $table_gui->addMultiCommand(
"confirmDeleteFiles", $this->lng->txt(
"delete"));
222 $table_gui->addCommandButton(
'showFiles',$this->lng->txt(
'cancel'));
223 $table_gui->setSelectAllCheckbox(
"file_id");
225 $this->tpl->setContent($table_gui->getHTML());
237 if(!isset(
$_POST[
'file_id']) or count(
$_POST[
'file_id']) != 1)
244 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
246 $abs_path =
$files->getAbsolutePathByFileId((
int)
$_POST[
'file_id'][0]);
259 if(!isset(
$_POST[
'file_id']))
266 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
270 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFiles"));
271 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_files_sure"));
272 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showFiles");
273 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFiles");
275 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
277 $file_data =
$files->readFilesInfo();
281 foreach(
$_POST[
"file_id"] as $file_id)
283 $info = $file_data[$file_id];
284 $c_gui->addItem(
"file_id[]", $file_id, is_array($info[
'name']) ? implode(
',',$info[
'name']) :
'No Records');
286 $this->tpl->setContent($c_gui->getHTML());
298 if(!isset(
$_POST[
'file_id']))
305 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordExportFiles.php');
308 foreach(
$_POST[
'file_id'] as $file_id)
310 $files->deleteByFileId((
int) $file_id);
324 if(!isset(
$_POST[
'record_id']))
331 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
335 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteRecords"));
336 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_record_sure"));
337 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
338 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteRecords");
341 foreach(
$_POST[
"record_id"] as $record_id)
344 $c_gui->addItem(
"record_id[]", $record_id, $record->getTitle() ? $record->getTitle() :
'No Title');
346 $this->tpl->setContent($c_gui->getHTML());
357 if(!isset(
$_POST[
'record_id']))
363 foreach(
$_POST[
'record_id'] as $record_id)
384 $new_types = isset(
$_POST[
'obj_types'][$record_obj->getRecordId()]) ?
385 $_POST[
'obj_types'][$record_obj->getRecordId()] :
387 $record_obj->setAssignedObjectTypes($new_types);
388 $record_obj->setActive(isset(
$_POST[
'active'][$record_obj->getRecordId()]));
389 $record_obj->update();
403 if(!isset(
$_POST[
'field_id']))
409 $this->ctrl->saveParameter($this,
'record_id');
411 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
415 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"deleteFields"));
416 $c_gui->setHeaderText($this->lng->txt(
"md_adv_delete_fields_sure"));
417 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showRecords");
418 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"deleteFields");
421 foreach(
$_POST[
"field_id"] as $field_id)
424 $c_gui->addItem(
"field_id[]", $field_id, $field->getTitle() ? $field->getTitle() :
'No Title');
426 $this->tpl->setContent($c_gui->getHTML());
438 if(!isset(
$_POST[
'field_id']))
444 foreach(
$_POST[
"field_id"] as $field_id)
465 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.edit_record.html',
'Services/AdvancedMetaData');
466 $this->ctrl->saveParameter($this,
'record_id');
469 $this->tpl->setVariable(
'EDIT_RECORD_TABLE',$this->form->getHTML());
472 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
475 include_once(
"./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldTableGUI.php");
477 $table_gui->setTitle($this->lng->txt(
"md_adv_field_table"));
478 $table_gui->parseDefinitions($fields);
479 $table_gui->addCommandButton(
"updateFields", $this->lng->txt(
"save"));
480 $table_gui->addCommandButton(
'createField',$this->lng->txt(
'add'));
481 $table_gui->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
482 $table_gui->addMultiCommand(
"confirmDeleteFields", $this->lng->txt(
"delete"));
483 $table_gui->setSelectAllCheckbox(
"field_id");
485 $this->tpl->setVariable(
'FIELDS_TABLE',$table_gui->getHTML());
496 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
503 if(!isset(
$_POST[
'position']) or !is_array(
$_POST[
'position']))
509 asort(
$_POST[
'position'],SORT_NUMERIC);
512 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
513 foreach(
$_POST[
'position'] as $field_id => $pos)
516 $definition->setPosition($counter++);
517 $definition->enableSearchable(isset(
$_POST[
'searchable'][$field_id]) ?
true :
false);
518 $definition->update();
537 if(!isset(
$_GET[
'record_id']) or !
$_GET[
'record_id'])
546 if(!$this->record->validate())
552 $this->record->update();
568 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.new_record.html',
'Services/AdvancedMetaData');
572 $this->tpl->setVariable(
'NEW_RECORD_TABLE',$this->form->getHTML());
576 $this->tpl->setVariable(
'IMPORT_RECORD_TABLE',$this->import_form->getHTML());
587 if(is_object($this->import_form))
592 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
594 $this->import_form->setMultipart(
true);
595 $this->import_form->setFormAction($this->ctrl->getFormAction($this));
599 $file->setSuffixes(array(
'xml'));
600 $file->setRequired(
true);
601 $this->import_form->addItem(
$file);
603 $this->import_form->setTitle($this->lng->txt(
'md_adv_import_record'));
604 $this->import_form->addCommandButton(
'importRecord',$this->lng->txt(
'import'));
605 $this->import_form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
618 if(!$this->import_form->checkInput())
620 $this->import_form->setValuesByPost();
625 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordImportFiles.php');
627 if(!$create_time = $import_files->moveUploadedFile($_FILES[
'file'][
'tmp_name']))
635 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordParser.php');
640 $parser->startParsing();
644 $parser->startParsing();
648 catch(ilSAXParserException $exc)
655 $import_files->deleteFileByCreationDate($create_time);
674 if(!$this->record->validate())
680 $this->record->save();
693 $this->ctrl->saveParameter($this,
'record_id');
694 $this->ctrl->saveParameter($this,
'field_id');
698 $this->tpl->setContent($this->form->getHTML());
711 $this->ctrl->saveParameter($this,
'record_id');
716 if(!$this->field_definition->validate())
722 $this->field_definition->update();
735 $this->ctrl->saveParameter($this,
'record_id');
737 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
740 $this->tpl->setContent($this->form->getHTML());
756 if(isset($_GET[
'field_id']) and $_GET[
'field_id'])
775 $this->ctrl->saveParameter($this,
'record_id');
779 if(!$this->field_definition->validate())
785 $this->field_definition->add();
798 if(is_object($this->field_form))
803 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
806 $this->form->setFormAction($this->ctrl->getFormAction($this));
810 $title->setValue($this->field_definition->getTitle());
813 $title->setRequired(
true);
814 $this->form->addItem(
$title);
818 $desc->
setValue($this->field_definition->getDescription());
821 $this->form->addItem($desc);
825 $check->
setChecked($this->field_definition->isSearchable());
827 $this->form->addItem($check);
831 $radio->
setValue($this->field_definition->getFieldType() ?
832 $this->field_definition->getFieldType() :
834 $radio->setRequired(
true);
837 $radio->addOption($radio_option);
840 $radio->addOption($radio_option);
843 $radio->addOption($radio_option);
846 $radio->addOption($radio_option);
848 $values = $this->field_definition->getFieldValues();
850 $max_values = max(count($values),
$_SESSION[
'num_values'] ?
$_SESSION[
'num_values'] : 5);
851 $_SESSION[
'num_values'] = $max_values;
852 for($i = 1; $i <= $max_values;$i++)
855 $title->setValue(isset($values[$i - 1]) ? $values[$i - 1] :
'');
858 $radio_option->addSubItem(
$title);
860 $this->form->addItem($radio);
865 $this->form->setTitle($this->lng->txt(
'md_adv_create_field'));
866 $this->form->addCommandButton(
'saveField',$this->lng->txt(
'create'));
867 $this->form->addCommandButton(
'addValue',$this->lng->txt(
'md_adv_add_value'));
868 $this->form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
873 $this->form->setTitle($this->lng->txt(
'md_adv_edit_field'));
874 $this->form->addCommandButton(
'updateField',$this->lng->txt(
'save'));
875 $this->form->addCommandButton(
'addValue',$this->lng->txt(
'md_adv_add_value'));
876 $this->form->addCommandButton(
'editRecord',$this->lng->txt(
'cancel'));
889 if(is_object($this->form))
894 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
897 $this->form->setFormAction($this->ctrl->getFormAction($this));
901 $title->setValue($this->record->getTitle());
904 $title->setRequired(
true);
905 $this->form->addItem(
$title);
909 $desc->
setValue($this->record->getDescription());
912 $this->form->addItem($desc);
916 $check->
setChecked($this->record->isActive());
918 $this->form->addItem($check);
921 $section->setTitle($this->lng->txt(
'md_obj_types'));
927 $check->
setChecked(in_array($type,$this->record->getAssignedObjectTypes()) ?
true :
false);
928 $check->setValue($type);
929 $this->form->addItem($check);
936 $this->form->setTitle($this->lng->txt(
'md_adv_create_record'));
937 $this->form->addCommandButton(
'saveRecord',$this->lng->txt(
'add'));
938 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
943 $this->form->setTitle($this->lng->txt(
'md_adv_edit_record'));
944 $this->form->addCommandButton(
'updateRecord',$this->lng->txt(
'save'));
945 $this->form->addCommandButton(
'showRecords',$this->lng->txt(
'cancel'));
958 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
966 $this->form->setFormAction($this->ctrl->getFormAction($this));
967 #$this->form->setTableWidth('100%');
970 foreach($visible_records as $obj_type => $records)
972 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php');
978 $section->setTitle($this->lng->txt(
'objs_'.$obj_type));
981 $check =
new ilCheckboxInputGUI($this->lng->txt(
'description'),
'enabled_desc_'.$obj_type);
983 $check->setOptionTitle($this->lng->txt(
'md_adv_desc_show'));
984 $check->setChecked($sub->isDescriptionEnabled() ?
true :
false);
985 $this->form->addItem($check);
987 $check =
new ilCheckboxInputGUI($this->lng->txt(
'md_adv_field_names'),
'enabled_field_names_'.$obj_type);
989 $check->setOptionTitle($this->lng->txt(
'md_adv_fields_show'));
990 $check->setChecked($sub->enabledFieldNames() ?
true :
false);
991 $this->form->addItem($check);
993 #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type);
994 #$area->setUseRte(true);
995 #$area->setRteTagSet('standard');
996 #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString()));
999 #$this->form->addItem($area);
1002 $definitions = $sub->sortDefinitions($definitions);
1005 foreach($definitions as $definition_id)
1009 if($def->isDeleted())
1015 $title = $def->getTitle().
' ('.$title.
')';
1018 $check->setValue(1);
1019 $check->setOptionTitle($this->lng->txt(
'md_adv_show'));
1020 $check->setChecked($sub->isSubstituted($definition_id));
1022 $pos =
new ilTextInputGUI($this->lng->txt(
'position'),
'position['.$obj_type.
']['.$definition_id.
']');
1024 $pos->setMaxLength(4);
1025 $pos->setValue(sprintf(
'%.1f',$counter++));
1026 $check->addSubItem($pos);
1028 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'bold'),
'bold['.$obj_type.
']['.$definition_id.
']');
1030 $bold->setChecked($sub->isBold($definition_id));
1031 $check->addSubItem($bold);
1033 $bold =
new ilCheckboxInputGUI($this->lng->txt(
'newline'),
'newline['.$obj_type.
']['.$definition_id.
']');
1035 $bold->setChecked($sub->hasNewline($definition_id));
1036 $check->addSubItem($bold);
1039 $this->form->addItem($check);
1067 $this->form->setTitle($this->lng->txt(
'md_adv_substitution_table'));
1068 $this->form->addCommandButton(
'updateSubstitutions',$this->lng->txt(
'save'));
1082 $this->record->setAssignedObjectTypes(isset(
$_POST[
'obj_types']) ?
$_POST[
'obj_types'] : array());
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;