3require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionField.php");
4require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php");
5require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
6require_once
"class.ilDataCollectionCache.php";
7require_once(
'./Services/Form/classes/class.ilNonEditableValueGUI.php');
62 $this->obj_id = $a_parent_obj->obj_id;
63 $this->parent_obj = $a_parent_obj;
69 if (!isset($field_id)) {
70 $this->field_id =
$_GET[
'field_id'];
73 if (isset($field_id)) {
78 $ilCtrl->redirectByClass(
"ilDataCollectionGUI",
"listFields");
81 $ilCtrl->saveParameter($this,
"table_id");
96 if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
104 $this->
save(
"update");
122 $tpl->setContent($this->form->getHTML());
135 $tpl->setContent($this->form->getHTML());
144 $tpl->setContent(
"Permission denied");
154 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
156 $conf->setFormAction(
$ilCtrl->getFormAction($this));
157 $conf->setHeaderText(
$lng->txt(
'dcl_confirm_delete_field'));
159 $conf->addItem(
'field_id', (
int)$this->field_obj->getId(), $this->field_obj->getTitle());
161 $conf->setConfirm(
$lng->txt(
'delete'),
'delete');
162 $conf->setCancel(
$lng->txt(
'cancel'),
'cancelDelete');
164 $tpl->setContent($conf->getHTML());
174 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
181 public function delete() {
184 $this->table->deleteField($this->field_obj->getId());
185 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
194 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
206 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
209 if ($a_mode ==
"edit") {
210 $this->form->setTitle(
$lng->txt(
'dcl_edit_field'));
212 $this->form->addItem($hidden_prop);
214 $this->form->setFormAction(
$ilCtrl->getFormAction($this),
"update");
216 $this->form->addCommandButton(
'update',
$lng->txt(
'dcl_update_field'));
218 $this->form->setTitle(
$lng->txt(
'dcl_new_field'));
220 $hidden_prop->setValue($this->field_obj->getTableId());
221 $this->form->addItem($hidden_prop);
223 $this->form->setFormAction(
$ilCtrl->getFormAction($this),
"save");
225 $this->form->addCommandButton(
'save',
$lng->txt(
'dcl_create_field'));
227 $this->form->addCommandButton(
'cancel',
$lng->txt(
'cancel'));
230 $text_prop->setRequired(
true);
233 $this->form->addItem($text_prop);
237 $opt =
new ilRadioOption(
$lng->txt(
'dcl_' . $datatype[
'title']), $datatype[
'id']);
246 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
247 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
248 foreach ($tables as
$table) {
249 foreach (
$table->getRecordFields() as $field) {
252 $options[$field->getId()] =
$table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
257 $table_selection->setOptions(
$options);
259 $opt->addSubItem($table_selection);
265 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
266 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
267 foreach ($tables as
$table) {
268 foreach (
$table->getRecordFields() as $field) {
271 $options[$field->getId()] =
$table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
276 $table_selection->setOptions(
$options);
277 $opt->addSubItem($table_selection);
281 foreach (
$table->getFieldsForFormula() as $f) {
282 $placeholder = ($f->isStandardField()) ? $f->getId() : $f->getTitle();
283 $fields[] =
'<a class="dclPropExpressionField" data-placeholder="' . $placeholder .
'">' . $f->getTitle() .
'</a>';
288 $subitem->setInfo(sprintf(
$lng->txt(
'dcl_prop_expression_info'), $operators, $functions, implode(
'<br>', $fields)));
289 $opt->addSubItem($subitem);
290 } elseif ($property[
'datatype_id'] == $datatype[
'id']) {
294 if(
$lng->txt(
'dcl_'.$property[
'title'].
'_info') !=
'-dcl_'.$property[
'title'].
'_info-') {
295 $subitem->setInfo(
$lng->txt(
'dcl_'.$property[
'title'].
'_info'));
297 $opt->addSubItem($subitem);
299 $subitem =
new ilNumberInputGUI(
$lng->txt(
'dcl_' . $property[
'title']),
'prop_' . $property[
'id']);
305 $subitem->setSize(5);
306 if ($property[
'title'] ==
'length') {
307 $subitem->setMaxValue(4000);
308 $subitem->setInfo(
$lng->txt(
'dcl_'.$property[
'title'].
'_info'));
310 $opt->addSubItem($subitem);
314 $opt->addSubItem($subitem);
316 $subitem =
new ilTextInputGUI(
$lng->txt(
'dcl_' . $property[
'title']),
'prop_' . $property[
'id']);
321 if($property[
'title'] ==
'regex') {
322 $subitem->setInfo(
$lng->txt(
'dcl_'.$property[
'title'].
'_info'));
324 $opt->addSubItem($subitem);
329 $edit_datatype->addOption($opt);
331 $edit_datatype->setRequired(
true);
334 if ($a_mode ==
"edit") {
335 $edit_datatype->setDisabled(
true);
337 $this->form->addItem($edit_datatype);
341 $this->form->addItem($text_prop);
345 $this->form->addItem($cb);
349 $this->form->addItem($cb);
359 'table_id' => $this->field_obj->getTableId(),
360 'field_id' => $this->field_obj->getId(),
361 'title' => $this->field_obj->getTitle(),
362 'datatype' => $this->field_obj->getDatatypeId(),
363 'description' => $this->field_obj->getDescription(),
364 'required' => $this->field_obj->getRequired(),
365 'unique' => $this->field_obj->isUnique(),
368 $propertyvalues = $this->field_obj->getPropertyvalues();
373 $values[
'prop_' . $property[
'id']] = $propertyvalues[$property[
'id']];
377 $this->form->setValuesByArray($values);
388 public function save($a_mode =
"create") {
392 if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
398 $this->
initForm($a_mode ==
"update" ?
"edit" :
"create");
400 $title = $this->form->getInput(
"title");
401 if ($a_mode !=
"create" && $title != $this->field_obj->getTitle()) {
405 $this->field_obj->setTitle($title);
406 $this->field_obj->setDescription($this->form->getInput(
"description"));
407 $this->field_obj->setDatatypeId($this->form->getInput(
"datatype"));
408 $this->field_obj->setRequired($this->form->getInput(
"required"));
409 $this->field_obj->setUnique($this->form->getInput(
"unique"));
411 if ($a_mode ==
"update") {
412 $this->field_obj->doUpdate();
414 $this->field_obj->setVisible(
true);
415 $this->field_obj->setOrder($this->table->getNewOrder());
416 $this->field_obj->doCreate();
420 include_once(
"./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php");
423 $fieldprop_obj->setDatatypePropertyId($property[
'id']);
424 $fieldprop_obj->setFieldId($this->field_obj->getId());
425 $fieldprop_obj->setValue($this->form->getInput(
"prop_" . $property[
'id']));
427 if ($a_mode ==
"update") {
428 $fieldprop_obj->doUpdate();
430 $fieldprop_obj->doCreate();
434 $ilCtrl->setParameter($this,
"field_id", $this->field_obj->getId());
436 if ($a_mode ==
"update") {
439 $this->table->addField($this->field_obj);
440 $this->table->buildOrderFields();
443 $ilCtrl->redirectByClass(strtolower(
"ilDataCollectionFieldListGUI"),
"listFields");
445 $this->form->setValuesByPost();
446 $tpl->setContent($this->form->getHTML());
460 $return = $this->form->checkInput();
468 $inputObj->setAlert(
$lng->txt(
"form_msg_value_too_high"));
473 if ($a_mode ==
'create') {
474 if ($title = $this->form->getInput(
'title')) {
476 $inputObj = $this->form->getItemByPostVar(
'title');
477 $inputObj->setAlert(
$lng->txt(
"dcl_field_title_unique"));
496 $tpl->setContent(
"Access Denied");
Confirmation screen class.
static getTableCache($table_id=0)
static getFieldCache($field_id=0)
static getProperties($a_id)
Get all properties of a Datatype.
const INPUTFORMAT_NON_EDITABLE_VALUE
const INPUTFORMAT_REFERENCELIST
const INPUTFORMAT_BOOLEAN
static getAllDatatypes()
Get all possible Datatypes.
const INPUTFORMAT_REFERENCE
Class ilDataCollectionFieldEditGUI.
executeCommand()
execute command
const REFERENCE_SEPARATOR
getValues()
getFieldValues
checkInput($a_mode)
Check input of form.
save($a_mode="create")
save Field
initForm($a_mode="create")
initEditCustomForm
edit()
create field edit form
__construct(ilObjDataCollectionGUI $a_parent_obj, $table_id, $field_id)
Constructor.
cancelDelete()
cancelDelete
confirmDelete()
confirmDelete
create()
create field add form
Class ilDataCollectionFieldProp.
static _getTitleValidChars($a_as_regex=true)
All valid chars for filed titles.
const PROPERTYID_REFERENCE
const PROPERTYID_TEXTAREA
const PROPERTYID_FORMULA_EXPRESSION
const PROPERTYID_N_REFERENCE
static _hasFieldByTitle($title, $obj_id)
Checks if a table has a field with the given title.
This class represents a non editable value in a property form.
Class ilObjDataCollectionGUI.
This class represents an option in a radio group.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!is_array($argv)) $options