19 declare(strict_types=1);
43 $this->main_tpl = $DIC->ui()->mainTemplate();
44 $ilCtrl = $DIC[
'ilCtrl'];
46 $this->obj_id = $a_parent_obj->
getObjId();
47 $this->parent_obj = $a_parent_obj;
48 $this->
help = $DIC->help();
49 $this->
http = $DIC->http();
51 $this->
lng = $DIC->language();
53 $this->table_id = $this->
http->wrapper()->query()->retrieve(
'table_id', $this->
refinery->kindlyTo()->int());
55 $hasFieldId = $this->
http->wrapper()->query()->has(
'field_id');
57 $this->field_id = $this->
http->wrapper()->query()->retrieve(
'field_id', $this->
refinery->kindlyTo()->int());
62 if ($this->field_id) {
67 $has_datatype = $this->
http->wrapper()->post()->has(
'datatype');
70 $datatype_value = $this->
http->wrapper()->post()->retrieve(
78 $datatype = $datatype_value;
82 if (!$this->table_id) {
83 $ilCtrl->redirectByClass(
"ilDclTableListGUI",
"listFields");
85 $this->field_obj->setTableId($this->table_id);
86 $ilCtrl->saveParameter($this,
"table_id");
98 $ilCtrl = $DIC[
'ilCtrl'];
99 $ilCtrl->saveParameter($this,
'field_id');
101 $cmd = $ilCtrl->getCmd();
110 $this->
save(
"update");
123 $this->
help->setSubScreenId(
'create');
126 $this->main_tpl->setContent($this->
form->getHTML());
134 $this->
help->setSubScreenId(
'edit');
137 $this->field_obj->fillPropertiesForm($this->
form);
138 $this->main_tpl->setContent($this->
form->getHTML());
148 $tpl->setContent(
"Permission denied");
157 $ilCtrl = $DIC[
'ilCtrl'];
162 $conf->setFormAction($ilCtrl->getFormAction($this));
163 $conf->setHeaderText($lng->
txt(
'dcl_confirm_delete_field'));
165 $conf->addItem(
'field_id', $this->field_obj->getId(), $this->field_obj->getTitle());
167 $conf->setConfirm($lng->
txt(
'delete'),
'delete');
168 $conf->setCancel($lng->
txt(
'cancel'),
'cancelDelete');
170 $tpl->setContent($conf->getHTML());
179 $ilCtrl = $DIC[
'ilCtrl'];
181 $ilCtrl->redirectByClass(
"ildclfieldlistgui",
"listFields");
187 public function delete():
void 190 $ilCtrl = $DIC[
'ilCtrl'];
192 $this->table->deleteField((
int) $this->field_obj->getId());
193 $ilCtrl->redirectByClass(
"ildclfieldlistgui",
"listFields");
202 $ilCtrl = $DIC[
'ilCtrl'];
203 $ilCtrl->redirectByClass(
"ildclfieldlistgui",
"listFields");
210 public function initForm(
string $a_mode =
"create"): void
213 $ilCtrl = $DIC[
'ilCtrl'];
218 if ($a_mode ==
"edit") {
219 $this->
form->setTitle($lng->
txt(
'dcl_edit_field'));
221 $this->
form->addItem($hidden_prop);
223 $this->
form->setFormAction($ilCtrl->getFormAction($this));
225 $this->
form->addCommandButton(
'update', $lng->
txt(
'dcl_update_field'));
227 $this->
form->setTitle($lng->
txt(
'dcl_new_field'));
229 $hidden_prop->setValue((
string) $this->field_obj->getTableId());
230 $this->
form->addItem($hidden_prop);
232 $this->
form->setFormAction($ilCtrl->getFormAction($this));
234 $this->
form->addCommandButton(
'save', $lng->
txt(
'dcl_create_field'));
236 $this->
form->addCommandButton(
'cancel', $lng->
txt(
'cancel'));
239 $text_prop->setRequired(
true);
240 $text_prop->setInfo(sprintf(
241 $lng->
txt(
'fieldtitle_allow_chars'),
245 $this->
form->addItem($text_prop);
249 $text_prop->
setInfo($lng->
txt(
'dcl_field_description_desc'));
250 $this->
form->addItem($text_prop);
254 if ($a_mode ===
'edit') {
257 $edit_datatype->setDisabled(
true);
261 $model->setDatatypeId($datatype->getId());
267 $edit_datatype->setRequired(
true);
268 $this->
form->addItem($edit_datatype);
276 public function save(
string $a_mode =
"create"): void
279 $ilCtrl = $DIC[
'ilCtrl'];
283 $this->
initForm($a_mode ==
"update" ?
"edit" :
"create");
288 if (($a_mode ==
"update") && !($this->
form->getInput(
'confirmed')) && $this->field_obj->isConfirmationRequired($this->form)) {
289 $ilConfirmationGUI = $this->field_obj->getConfirmationGUI($this->
form);
290 $tpl->setContent($ilConfirmationGUI->getHTML());
295 $title = $this->
form->getInput(
"title");
296 if ($a_mode !=
"create" && $title != $this->field_obj->getTitle()) {
297 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"dcl_field_title_change_warning"),
true);
300 $this->field_obj->setTitle($title);
301 $this->field_obj->setDescription($this->
form->getInput(
"description"));
302 $this->field_obj->setDatatypeId((
int) $this->
form->getInput(
"datatype"));
304 if ($a_mode ==
"update") {
305 $this->field_obj->doUpdate();
307 $this->field_obj->setOrder($this->table->getNewFieldOrder());
308 $this->field_obj->doCreate();
312 $this->field_obj->storePropertiesFromForm($this->
form);
314 $ilCtrl->setParameter($this,
"field_id", $this->field_obj->getId());
316 if ($a_mode ==
"update") {
317 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
"dcl_msg_field_modified"),
true);
319 $this->table->addField($this->field_obj);
320 $this->table->buildOrderFields();
321 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
"msg_field_created"));
323 $ilCtrl->redirectByClass(strtolower(
"ilDclFieldListGUI"),
"listFields");
325 $this->
form->setValuesByPost();
326 $tpl->setContent($this->
form->getHTML());
339 $return = $this->
form->checkInput();
341 if (!$this->field_obj->checkFieldCreationInput($this->form)) {
346 if ($a_mode ==
'create') {
347 if ($title = $this->
form->getInput(
'title')) {
349 $inputObj = $this->
form->getItemByPostVar(
'title');
350 $inputObj->setAlert($lng->
txt(
"dcl_field_title_unique"));
357 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"form_input_not_valid"));
368 if ($field_id = $this->field_obj->getId()) {
387 return $this->parent_obj->getDataCollectionObject();
checkInput(string $a_mode)
Check input of form.
getDataCollectionObject()
confirmDelete()
confirmDelete
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
static getFieldCache(int $field_id=0)
ILIAS HTTP Services $http
ilDclTableListGUI $parent_obj
save(string $a_mode="create")
save Field
edit()
create field edit form
ilDclTableListGUI: ilDclFieldListGUI, ilDclFieldEditGUI, ilDclTableViewGUI, ilDclTableEditGUI ...
create()
create field add form
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static hasAccessToFields(int $ref_id, int $table_id)
__construct(ilDclTableListGUI $a_parent_obj)
Constructor.
executeCommand()
execute command
static http()
Fetches the global http state from ILIAS.
static getFieldModelInstanceByClass(ilDclBaseFieldModel $field, ?int $field_id=null)
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldMod...
static getFieldModelInstance(int $field_id, ?int $datatype=null)
Get FieldModel from field-id and datatype.
static getAllDatatype(bool $force=false)
Get all possible Datatypes.
static getTableCache(?int $table_id=null)
static hasAccessToField(int $ref_id, int $table_id, int $field_id)
ILIAS Refinery Factory $refinery
ilGlobalTemplateInterface $main_tpl
static _hasFieldByTitle(string $title, int $obj_id)
Checks if a table has a field with the given title.
form( $class_path, string $cmd, string $submit_caption="")
cancelDelete()
cancelDelete
ilDclBaseFieldModel $field_obj
This class represents a text area property in a property form.
initForm(string $a_mode="create")
initEditCustomForm
static _getTitleInvalidChars(bool $a_as_regex=true)
All valid chars for filed titles.