ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDataCollectionFieldEditGUI Class Reference

Class ilDataCollectionFieldEditGUI. More...

+ Collaboration diagram for ilDataCollectionFieldEditGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $a_parent_obj, $table_id, $field_id)
 Constructor.
 executeCommand ()
 execute command
 create ()
 create field add form
 edit ()
 create field edit form
 permissionDenied ()
 confirmDelete ()
 confirmDelete
 cancelDelete ()
 cancelDelete
 delete ()
 cancel ()
 initForm ($a_mode="create")
 initEditCustomForm
 getValues ()
 getFieldValues
 save ($a_mode="create")
 save Field

Data Fields

const REFERENCE_SEPARATOR = " -> "

Protected Member Functions

 checkInput ($a_mode)
 Check input of form.

Protected Attributes

 $obj_id
 $table_id
 $parent_obj
 $table
 $form

Private Member Functions

 accessDenied ()

Detailed Description

Constructor & Destructor Documentation

ilDataCollectionFieldEditGUI::__construct ( ilObjDataCollectionGUI  $a_parent_obj,
  $table_id,
  $field_id 
)

Constructor.

Parameters
object$a_parent_obj
int$table_idWe need a table_id if no field_id is set (creation mode). We ignore the table_id by edit mode
int$field_idThe field_id of a existing fiel (edit mode)

Definition at line 59 of file class.ilDataCollectionFieldEditGUI.php.

References $_GET, $ilCtrl, $table_id, ilDataCollectionCache\getFieldCache(), and ilDataCollectionCache\getTableCache().

{
global $ilCtrl;
$this->obj_id = $a_parent_obj->obj_id;
$this->parent_obj = $a_parent_obj;
$this->table_id = $table_id;
if (!$table_id) {
$table_id = $_GET["table_id"];
}
if (!isset($field_id)) {
$this->field_id = $_GET['field_id'];
}
if (isset($field_id)) {
$this->field_obj = ilDataCollectionCache::getFieldCache($field_id);
} else {
if (!$table_id) {
$ilCtrl->redirectByClass("ilDataCollectionGUI", "listFields");
}
$this->field_obj->setTableId($table_id);
$ilCtrl->saveParameter($this, "table_id");
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilDataCollectionFieldEditGUI::accessDenied ( )
private

Definition at line 491 of file class.ilDataCollectionFieldEditGUI.php.

References $tpl.

Referenced by save().

{
global $tpl;
$tpl->setContent("Access Denied");
}

+ Here is the caller graph for this function:

ilDataCollectionFieldEditGUI::cancel ( )

Definition at line 192 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl.

{
global $ilCtrl;
$ilCtrl->redirectByClass("ildatacollectionfieldlistgui", "listFields");
}
ilDataCollectionFieldEditGUI::cancelDelete ( )

cancelDelete

Definition at line 171 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl.

{
global $ilCtrl;
$ilCtrl->redirectByClass("ildatacollectionfieldlistgui", "listFields");
}
ilDataCollectionFieldEditGUI::checkInput (   $a_mode)
protected

Check input of form.

Parameters
$a_mode'create' | 'update'
Returns
bool

Definition at line 455 of file class.ilDataCollectionFieldEditGUI.php.

References $lng, ilDataCollectionTable\_hasFieldByTitle(), ilDataCollectionDatatype\INPUTFORMAT_TEXT, ilDataCollectionField\PROPERTYID_LENGTH, ilDataCollectionField\PROPERTYID_TEXTAREA, and ilUtil\sendFailure().

Referenced by save().

{
global $lng;
$return = $this->form->checkInput();
// Additional check for text fields: The length property should be max 200 if the textarea option is not set
if ($this->form->getInput('datatype') == ilDataCollectionDatatype::INPUTFORMAT_TEXT
&& (int)$this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_LENGTH) > 200
&& !$this->form->getInput('prop_' . ilDataCollectionField::PROPERTYID_TEXTAREA)
) {
$inputObj = $this->form->getItemByPostVar('prop_' . ilDataCollectionField::PROPERTYID_LENGTH);
$inputObj->setAlert($lng->txt("form_msg_value_too_high"));
$return = false;
}
// Don't allow multiple fields with the same title in this table
if ($a_mode == 'create') {
if ($title = $this->form->getInput('title')) {
if (ilDataCollectionTable::_hasFieldByTitle($title, $this->table_id)) {
$inputObj = $this->form->getItemByPostVar('title');
$inputObj->setAlert($lng->txt("dcl_field_title_unique"));
$return = false;
}
}
}
if (!$return) {
ilUtil::sendFailure($lng->txt("form_input_not_valid"));
}
return $return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionFieldEditGUI::confirmDelete ( )

confirmDelete

Definition at line 151 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl, $lng, and $tpl.

{
global $ilCtrl, $lng, $tpl;
include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
$conf = new ilConfirmationGUI();
$conf->setFormAction($ilCtrl->getFormAction($this));
$conf->setHeaderText($lng->txt('dcl_confirm_delete_field'));
$conf->addItem('field_id', (int)$this->field_obj->getId(), $this->field_obj->getTitle());
$conf->setConfirm($lng->txt('delete'), 'delete');
$conf->setCancel($lng->txt('cancel'), 'cancelDelete');
$tpl->setContent($conf->getHTML());
}
ilDataCollectionFieldEditGUI::create ( )

create field add form

Definition at line 118 of file class.ilDataCollectionFieldEditGUI.php.

References $tpl, and initForm().

{
global $tpl;
$this->initForm();
$tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilDataCollectionFieldEditGUI::delete ( )

Definition at line 181 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl.

{
global $ilCtrl;
$this->table->deleteField($this->field_obj->getId());
$ilCtrl->redirectByClass("ildatacollectionfieldlistgui", "listFields");
}
ilDataCollectionFieldEditGUI::edit ( )

create field edit form

Definition at line 129 of file class.ilDataCollectionFieldEditGUI.php.

References $tpl, getValues(), and initForm().

{
global $tpl;
$this->initForm("edit");
$this->getValues();
$tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilDataCollectionFieldEditGUI::executeCommand ( )

execute command

Definition at line 91 of file class.ilDataCollectionFieldEditGUI.php.

References $cmd, $ilCtrl, $ilUser, $tpl, permissionDenied(), and save().

{
global $tpl, $ilCtrl, $ilUser;
$cmd = $ilCtrl->getCmd();
if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
$this->permissionDenied();
return;
}
switch ($cmd) {
case "update":
$this->save("update");
break;
default:
$this->$cmd();
break;
}
return true;
}

+ Here is the call graph for this function:

ilDataCollectionFieldEditGUI::getValues ( )

getFieldValues

Definition at line 353 of file class.ilDataCollectionFieldEditGUI.php.

References ilDataCollectionDatatype\getAllDatatypes(), and ilDataCollectionDatatype\getProperties().

Referenced by edit().

{
//Std-Values
$values = array(
'table_id' => $this->field_obj->getTableId(),
'field_id' => $this->field_obj->getId(),
'title' => $this->field_obj->getTitle(),
'datatype' => $this->field_obj->getDatatypeId(),
'description' => $this->field_obj->getDescription(),
'required' => $this->field_obj->getRequired(),
'unique' => $this->field_obj->isUnique(),
);
$propertyvalues = $this->field_obj->getPropertyvalues();
// Propertie-Values - Subitems
foreach (ilDataCollectionDatatype::getAllDatatypes() as $datatype) {
foreach (ilDataCollectionDatatype::getProperties($datatype['id']) as $property) {
$values['prop_' . $property['id']] = $propertyvalues[$property['id']];
}
}
$this->form->setValuesByArray($values);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionFieldEditGUI::initForm (   $a_mode = "create")

initEditCustomForm

Parameters
string$a_modevalues: create | edit

Definition at line 203 of file class.ilDataCollectionFieldEditGUI.php.

References $_GET, $ilCtrl, $lng, ilDataCollectionDatatype\$mob_suffixes, $options, $table, ilDataCollectionField\_getTitleValidChars(), ilSubEnabledFormPropertyGUI\addSubItem(), ilDataCollectionDatatype\getAllDatatypes(), ilDclExpressionParser\getFunctions(), ilDclExpressionParser\getOperators(), ilDataCollectionDatatype\getProperties(), ilDataCollectionCache\getTableCache(), ilDataCollectionDatatype\INPUTFORMAT_BOOLEAN, ilDataCollectionDatatype\INPUTFORMAT_NON_EDITABLE_VALUE, ilDataCollectionDatatype\INPUTFORMAT_NUMBER, ilDataCollectionDatatype\INPUTFORMAT_REFERENCE, ilDataCollectionDatatype\INPUTFORMAT_REFERENCELIST, ilDataCollectionField\PROPERTYID_FORMULA_EXPRESSION, ilDataCollectionField\PROPERTYID_N_REFERENCE, ilDataCollectionField\PROPERTYID_REFERENCE, ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setSize(), and ilNonEditableValueGUI\setValue().

Referenced by create(), edit(), and save().

{
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
) {
$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);
} //ReferenceList
) {
// 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);
$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']));
$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);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionFieldEditGUI::permissionDenied ( )

Definition at line 142 of file class.ilDataCollectionFieldEditGUI.php.

References $tpl.

Referenced by executeCommand().

{
global $tpl;
$tpl->setContent("Permission denied");
}

+ Here is the caller graph for this function:

ilDataCollectionFieldEditGUI::save (   $a_mode = "create")

save Field

Parameters
string$a_modevalues: create | update

Definition at line 385 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl, $lng, $tpl, accessDenied(), checkInput(), ilDataCollectionDatatype\getProperties(), initForm(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

Referenced by executeCommand().

{
global $ilCtrl, $lng, $tpl;
//check access
if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
$this->accessDenied();
return;
}
$this->initForm($a_mode == "update" ? "edit" : "create");
if ($this->checkInput($a_mode)) {
$title = $this->form->getInput("title");
if ($a_mode != "create" && $title != $this->field_obj->getTitle()) {
ilUtil::sendInfo($lng->txt("dcl_field_title_change_warning"), true);
}
$this->field_obj->setTitle($title);
$this->field_obj->setDescription($this->form->getInput("description"));
$this->field_obj->setDatatypeId($this->form->getInput("datatype"));
$this->field_obj->setRequired($this->form->getInput("required"));
$this->field_obj->setUnique($this->form->getInput("unique"));
if ($a_mode == "update") {
$this->field_obj->doUpdate();
} else {
$this->field_obj->setVisible(true);
$this->field_obj->setOrder($this->table->getNewOrder());
$this->field_obj->doCreate();
}
// Get possible properties and save them
include_once("./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php");
foreach (ilDataCollectionDatatype::getProperties($this->field_obj->getDatatypeId()) as $property) {
$fieldprop_obj = new ilDataCollectionFieldProp();
$fieldprop_obj->setDatatypePropertyId($property['id']);
$fieldprop_obj->setFieldId($this->field_obj->getId());
$fieldprop_obj->setValue($this->form->getInput("prop_" . $property['id']));
if ($a_mode == "update") {
$fieldprop_obj->doUpdate();
} else {
$fieldprop_obj->doCreate();
}
}
$ilCtrl->setParameter($this, "field_id", $this->field_obj->getId());
if ($a_mode == "update") {
ilUtil::sendSuccess($lng->txt("dcl_msg_field_modified"), true);
} else {
$this->table->addField($this->field_obj);
$this->table->buildOrderFields();
ilUtil::sendSuccess($lng->txt("msg_field_created"), false);
}
$ilCtrl->redirectByClass(strtolower("ilDataCollectionFieldListGUI"), "listFields");
} else {
$this->form->setValuesByPost();
$tpl->setContent($this->form->getHTML());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilDataCollectionFieldEditGUI::$form
protected

Definition at line 50 of file class.ilDataCollectionFieldEditGUI.php.

ilDataCollectionFieldEditGUI::$obj_id
protected

Definition at line 30 of file class.ilDataCollectionFieldEditGUI.php.

ilDataCollectionFieldEditGUI::$parent_obj
protected

Definition at line 40 of file class.ilDataCollectionFieldEditGUI.php.

ilDataCollectionFieldEditGUI::$table
protected

Definition at line 45 of file class.ilDataCollectionFieldEditGUI.php.

Referenced by initForm().

ilDataCollectionFieldEditGUI::$table_id
protected

Definition at line 35 of file class.ilDataCollectionFieldEditGUI.php.

Referenced by __construct().

const ilDataCollectionFieldEditGUI::REFERENCE_SEPARATOR = " -> "

Definition at line 25 of file class.ilDataCollectionFieldEditGUI.php.


The documentation for this class was generated from the following file: