/** * @param ilObjDataCollectionGUI $a_dcl_object */ public function __construct(ilObjDataCollectionGUI $a_dcl_object) { global $tpl, $ilCtrl; $this->dcl_gui_object = $a_dcl_object; $this->record_id = (int) $_REQUEST['record_id']; $this->record_obj = ilDataCollectionCache::getRecordCache($this->record_id); if (!$this->record_obj->hasPermissionToView((int) $_GET['ref_id'])) { ilUtil::sendFailure('dcl_msg_no_perm_view', true); $ilCtrl->redirectByClass('ildatacollectionrecordlistgui', 'listRecords'); } // content style (using system defaults) include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $tpl->setCurrentBlock("SyntaxStyle"); $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath()); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("ContentStyle"); $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0)); $tpl->parseCurrentBlock(); $this->table = $this->record_obj->getTable(); // Comments include_once "./Services/Notes/classes/class.ilNoteGUI.php"; $repId = $this->dcl_gui_object->getDataCollectionObject()->getId(); $objId = (int) $this->record_id; $this->notesGUI = new ilNoteGUI($repId, $objId); $this->notesGUI->enablePublicNotes(true); $this->notesGUI->enablePublicNotesDeletion(true); $ilCtrl->setParameterByClass("ilnotegui", "record_id", $this->record_id); $ilCtrl->setParameterByClass("ilnotegui", "rep_id", $repId); if (isset($_GET['disable_paging']) && $_GET['disable_paging']) { $this->is_enabled_paging = false; } // Find current, prev and next records for navigation if ($this->is_enabled_paging) { $this->determineNextPrevRecords(); } }
/** * initEditCustomForm * * @param string $a_mode values: create | edit */ public function initForm($a_mode = "create") { global $ilCtrl, $lng; include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $this->form = new ilPropertyFormGUI(); if ($a_mode == "edit") { $this->form->setTitle($lng->txt('dcl_edit_field')); $hidden_prop = new ilHiddenInputGUI("field_id"); $this->form->addItem($hidden_prop); $this->form->setFormAction($ilCtrl->getFormAction($this), "update"); $this->form->addCommandButton('update', $lng->txt('dcl_update_field')); } else { $this->form->setTitle($lng->txt('dcl_new_field')); $hidden_prop = new ilHiddenInputGUI("table_id"); $hidden_prop->setValue($this->field_obj->getTableId()); $this->form->addItem($hidden_prop); $this->form->setFormAction($ilCtrl->getFormAction($this), "save"); $this->form->addCommandButton('save', $lng->txt('dcl_create_field')); } $this->form->addCommandButton('cancel', $lng->txt('cancel')); $text_prop = new ilTextInputGUI($lng->txt("title"), "title"); $text_prop->setRequired(true); $text_prop->setInfo(sprintf($lng->txt('fieldtitle_allow_chars'), ilDataCollectionField::_getTitleValidChars(false))); $text_prop->setValidationRegexp(ilDataCollectionField::_getTitleValidChars(true)); $this->form->addItem($text_prop); $edit_datatype = new ilRadioGroupInputGUI($lng->txt('dcl_datatype'), 'datatype'); foreach (ilDataCollectionDatatype::getAllDatatypes() as $datatype) { $opt = new ilRadioOption($lng->txt('dcl_' . $datatype['title']), $datatype['id']); foreach (ilDataCollectionDatatype::getProperties($datatype['id']) as $property) { //Type Reference: List Tabels if ($datatype['id'] == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE and $property['id'] == ilDataCollectionField::PROPERTYID_REFERENCE) { $options = array(); // Get Tables require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php"; $tables = $this->parent_obj->getDataCollectionObject()->getTables(); foreach ($tables as $table) { foreach ($table->getRecordFields() as $field) { //referencing references may lead to endless loops. if ($field->getDatatypeId() != ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) { $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle(); } } } $table_selection = new ilSelectInputGUI('', 'prop_' . $property['id']); $table_selection->setOptions($options); //$table_selection->setValue($this->table_id); $opt->addSubItem($table_selection); } elseif ($datatype['id'] == ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST and $property['id'] == ilDataCollectionField::PROPERTYID_N_REFERENCE) { // Get Tables require_once "./Modules/DataCollection/classes/class.ilDataCollectionTable.php"; $tables = $this->parent_obj->getDataCollectionObject()->getTables(); foreach ($tables as $table) { foreach ($table->getRecordFields() as $field) { //referencing references may lead to endless loops. if ($field->getDatatypeId() != ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST) { $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle(); } } } $table_selection = new ilSelectInputGUI('', 'prop_' . $property['id']); $table_selection->setOptions($options); $opt->addSubItem($table_selection); } elseif ($property['id'] == ilDataCollectionField::PROPERTYID_FORMULA_EXPRESSION) { $table = ilDataCollectionCache::getTableCache((int) $_GET['table_id']); $fields = array(); foreach ($table->getFieldsForFormula() as $f) { $placeholder = $f->isStandardField() ? $f->getId() : $f->getTitle(); $fields[] = '<a class="dclPropExpressionField" data-placeholder="' . $placeholder . '">' . $f->getTitle() . '</a>'; } $subitem = new ilTextAreaInputGUI($lng->txt('dcl_prop_expression'), 'prop_' . $property['id']); $operators = implode(', ', array_keys(ilDclExpressionParser::getOperators())); $functions = implode(', ', ilDclExpressionParser::getFunctions()); $subitem->setInfo(sprintf($lng->txt('dcl_prop_expression_info'), $operators, $functions, implode('<br>', $fields))); $opt->addSubItem($subitem); } elseif ($property['datatype_id'] == $datatype['id']) { //All other Types: List properties saved in propertie definition table if ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) { $subitem = new ilCheckboxInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']); $opt->addSubItem($subitem); } elseif ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_NUMBER) { $subitem = new ilNumberInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']); // TODO: Nicer way to add additional info to fields (need changes in language-logic) /*if($lng->txt('dcl_'.$property['title'].'_info') != '-dcl_'.$property['title'].'_info-') { $subitem->setInfo($lng->txt('dcl_'.$property['title'].'_info')); }*/ $subitem->setSize(5); if ($property['title'] == 'length') { $subitem->setMaxValue(4000); $subitem->setInfo($lng->txt('dcl_' . $property['title'] . '_info')); } $opt->addSubItem($subitem); } elseif ($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_NON_EDITABLE_VALUE) { $subitem = new ilNonEditableValueGUI($lng->txt('dcl_' . $property['title'])); $subitem->setValue(implode(', ', ilDataCollectionDatatype::$mob_suffixes)); $opt->addSubItem($subitem); } else { $subitem = new ilTextInputGUI($lng->txt('dcl_' . $property['title']), 'prop_' . $property['id']); // TODO: Nicer way to add additional info to fields (need changes in language-logic) /*if($lng->txt('dcl_'.$property['title'].'_info') != '-dcl_'.$property['title'].'_info-') { $subitem->setInfo($lng->txt('dcl_'.$property['title'].'_info')); }*/ if ($property['title'] == 'regex') { $subitem->setInfo($lng->txt('dcl_' . $property['title'] . '_info')); } $opt->addSubItem($subitem); } } } $edit_datatype->addOption($opt); } $edit_datatype->setRequired(true); //you can't change type but we still need it in POST if ($a_mode == "edit") { $edit_datatype->setDisabled(true); } $this->form->addItem($edit_datatype); // Description $text_prop = new ilTextAreaInputGUI($lng->txt("dcl_field_description"), "description"); $this->form->addItem($text_prop); // Required $cb = new ilCheckboxInputGUI($lng->txt("dcl_field_required"), "required"); $this->form->addItem($cb); //Unique $cb = new ilCheckboxInputGUI($lng->txt("dcl_unique"), "unique"); $this->form->addItem($cb); }