ILIAS  release_4-3 Revision
 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

Protected Member Functions

 checkInput ($a_mode)
 Check input of form.

Private Member Functions

 accessDenied ()

Private Attributes

 $obj_id
 $table_id
 $parent_obj
 $table

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 35 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 443 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 171 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl.

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

cancelDelete

Definition at line 150 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 411 of file class.ilDataCollectionFieldEditGUI.php.

References $lng, $title, 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')) {
$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 130 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 95 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 160 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 106 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 68 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 295 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::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 182 of file class.ilDataCollectionFieldEditGUI.php.

References $ilCtrl, $lng, $table, ilDataCollectionField\_getTitleValidChars(), ilSubEnabledFormPropertyGUI\addSubItem(), ilDataCollectionDatatype\getAllDatatypes(), ilDataCollectionDatatype\getProperties(), ilDataCollectionDatatype\INPUTFORMAT_BOOLEAN, ilDataCollectionDatatype\INPUTFORMAT_REFERENCE, ilDataCollectionField\PROPERTYID_REFERENCE, and ilFormPropertyGUI\setRequired().

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');
{
$opt = new ilRadioOption($lng->txt('dcl_'.$datatype['title']), $datatype['id']);
foreach(ilDataCollectionDatatype::getProperties($datatype['id']) as $property)
{
//Type Reference: List Tabels
{
// 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()."->".$field->getTitle();
}
}
}
$table_selection = new ilSelectInputGUI(
'',
'prop_'.$property['id']
);
$table_selection->setOptions($options);
//$table_selection->setValue($this->table_id);
$opt->addSubItem($table_selection);
}
//All other Types: List properties saved in propertie definition table
elseif($property['datatype_id'] == $datatype['id'])
{
if($property['inputformat'] == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN)
{
$subitem = new ilCheckboxInputGUI($lng->txt('dcl_'.$property['title']), 'prop_'.$property['id']);
$opt->addSubItem($subitem);
}
else
{
$subitem = new ilTextInputGUI($lng->txt('dcl_'.$property['title']), 'prop_'.$property['id']);
$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 119 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 331 of file class.ilDataCollectionFieldEditGUI.php.

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

Referenced by executeCommand().

{
global $ilCtrl, $lng;
//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
{
global $tpl;
$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::$obj_id
private

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

ilDataCollectionFieldEditGUI::$parent_obj
private

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

ilDataCollectionFieldEditGUI::$table
private

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

Referenced by initForm().

ilDataCollectionFieldEditGUI::$table_id
private

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

Referenced by __construct().


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