/** * @param $type_id * @param ilDataCollectionField $field * @return ilCheckboxInputGUI|ilDateTimeInputGUI|ilFileInputGUI|ilTextInputGUI|NULL */ static function getInputField(ilDataCollectionField $field) { global $lng; $type_id = $field->getDatatypeId(); $title = $field->getTitle(); switch ($type_id) { case ilDataCollectionDatatype::INPUTFORMAT_TEXT: $input = new ilTextInputGUI($title, 'field_' . $field->getId()); if ($field->getTextArea()) { $input = new ilTextAreaInputGUI($title, 'field_' . $field->getId()); } if ($field->getLength()) { $input->setInfo($lng->txt("dcl_max_text_length") . ": " . $field->getLength()); if (!$field->getTextArea()) { $input->setMaxLength($field->getLength()); } } break; case ilDataCollectionDatatype::INPUTFORMAT_NUMBER: $input = new ilTextInputGUI($title, 'field_' . $field->getId()); break; case ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN: $input = new ilCheckboxInputGUI($title, 'field_' . $field->getId()); break; case ilDataCollectionDatatype::INPUTFORMAT_DATETIME: $input = new ilDateTimeInputGUI($title, 'field_' . $field->getId()); $input->setStartYear(date("Y") - 100); break; case ilDataCollectionDatatype::INPUTFORMAT_FILE: $input = new ilFileInputGUI($title, 'field_' . $field->getId()); break; case ilDataCollectionDatatype::INPUTFORMAT_REFERENCE: if (!$field->isNRef()) { $input = new ilSelectInputGUI($title, 'field_' . $field->getId()); } else { $input = new ilMultiSelectInputGUI($title, 'field_' . $field->getId()); } break; case ilDataCollectionDatatype::INPUTFORMAT_RATING: $input = new ilTextInputGUI($title, 'field_' . $field->getId()); $input->setValue($lng->txt("dcl_editable_in_table_gui")); $input->setDisabled(true); break; case ilDataCollectionDatatype::INPUTFORMAT_ILIAS_REF: $input = new ilDataCollectionTreePickInputGUI($title, 'field_' . $field->getId()); break; case ilDataCollectionDatatype::INPUTFORMAT_MOB: $input = new ilImageFileInputGUI($title, 'field_' . $field->getId()); $input->setAllowDeletion(true); break; } if ($field->getDescription()) { $input->setInfo($field->getDescription() . ($input->getInfo() ? "<br>" . $input->getInfo() : "")); } return $input; }