ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADTBasedObjectGUI Class Reference

ADT based-object GUI base class. More...

+ Inheritance diagram for ilADTBasedObjectGUI:
+ Collaboration diagram for ilADTBasedObjectGUI:

Public Member Functions

 __construct (ilObjectGUI $a_parent_gui)
 Constructor Parent GUI is just needed for testing (ilCtrl) More...
 
 editAction (?ilADTGroupFormBridge $a_form=null)
 
 updateAction ()
 Parse incoming values and update if valid @noinspection PhpParamsInspection. More...
 

Protected Member Functions

 initObject ()
 Init ADT-based object. More...
 
 prepareFormElements (ilADTGroupFormBridge $a_adt_form)
 Prepare/customize form elements. More...
 
 initForm ()
 Init ADT-based form. More...
 

Protected Attributes

ilADTBasedObject $object = null
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 

Private Attributes

ilObjectGUI $gui
 

Detailed Description

ADT based-object GUI base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilADTBasedObjectGUI::__construct ( ilObjectGUI  $a_parent_gui)

Constructor Parent GUI is just needed for testing (ilCtrl)

Parameters
ilObjectGUI$a_parent_gui

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

41 {
42 global $DIC;
43 $this->tpl = $DIC->ui()->mainTemplate();
44 $this->lng = $DIC->language();
45 $this->ctrl = $DIC->ctrl();
46
47 $this->gui = $a_parent_gui;
48 $this->object = $this->initObject();
49 }
initObject()
Init ADT-based object.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), initObject(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ editAction()

ilADTBasedObjectGUI::editAction ( ?ilADTGroupFormBridge  $a_form = null)

Definition at line 61 of file class.ilADTBasedObjectGUI.php.

61 : bool
62 {
63 if (!$a_form) {
64 $a_form = $this->initForm();
65 }
66
67 $this->tpl->setContent($a_form->getForm()->getHTML());
68 return true;
69 }
initForm()
Init ADT-based form.

References initForm().

Referenced by updateAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilADTBasedObjectGUI::initForm ( )
protected

Init ADT-based form.

Returns
ilADTFormBridge $a_form

@noinspection PhpParamsInspection

Definition at line 81 of file class.ilADTBasedObjectGUI.php.

82 {
83 $form = new ilPropertyFormGUI();
84 $form->setFormAction($this->ctrl->getFormAction($this->gui, "updateAction"));
85
86 $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($this->object->getProperties());
87
88 // has to be done BEFORE prepareFormElements() ...
89 $adt_form->setForm($form);
90
92 $this->prepareFormElements($adt_form);
93
94 $adt_form->addToForm();
95 $adt_form->addJS($this->tpl);
96
97 // :TODO:
98 $form->addCommandButton("updateAction", $this->lng->txt("save"));
99
100 return $adt_form;
101 }
prepareFormElements(ilADTGroupFormBridge $a_adt_form)
Prepare/customize form elements.
ADT form bridge base class.
This class represents a property form user interface.

References ILIAS\Repository\ctrl(), ilADTFactory\getInstance(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and prepareFormElements().

Referenced by editAction(), and updateAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initObject()

ilADTBasedObjectGUI::initObject ( )
abstractprotected

Init ADT-based object.

Reimplemented in ilADTTestGUI.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ prepareFormElements()

ilADTBasedObjectGUI::prepareFormElements ( ilADTGroupFormBridge  $a_adt_form)
abstractprotected

Prepare/customize form elements.

Parameters
ilADTGroupFormBridge$a_adt_form

Reimplemented in ilADTTestGUI.

Referenced by initForm().

+ Here is the caller graph for this function:

◆ updateAction()

ilADTBasedObjectGUI::updateAction ( )

Parse incoming values and update if valid @noinspection PhpParamsInspection.

Definition at line 107 of file class.ilADTBasedObjectGUI.php.

107 : bool
108 {
109 $adt_form = $this->initForm();
110 $valid = $adt_form->getForm()->checkInput();
111
112 $old_chksum = $this->object->getProperties()->getCheckSum();
113
114 $adt_form->importFromPost();
115 $valid = $adt_form->validate();
116
117 $changed = ($old_chksum != $this->object->getProperties()->getCheckSum());
118
119 // validation errors have top priority
120 if (!$valid) {
121 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_input_not_valid"));
122 return $this->editAction($adt_form);
123 }
124
125 // :TODO: experimental, update only if necessary
126 if ($changed) {
127 if ($this->object->update()) {
128 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
129 } else {
130 // error occured in db-layer (primary/unique)
131 foreach ($this->object->getDBErrors() as $element_id => $codes) {
132 $element = $adt_form->getElement($element_id);
133 if ($element) {
134 $element->setExternalErrors($this->object->translateDBErrorCodes($codes));
135 }
136 }
137
138 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_input_not_valid"));
139 return $this->editAction($adt_form);
140 }
141 }
142
143 $this->ctrl->redirect($this->gui, "edit");
144 return true;
145 }
editAction(?ilADTGroupFormBridge $a_form=null)
$valid

References $valid, ILIAS\Repository\ctrl(), editAction(), initForm(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilADTBasedObjectGUI::$ctrl
protected

Definition at line 33 of file class.ilADTBasedObjectGUI.php.

◆ $gui

ilObjectGUI ilADTBasedObjectGUI::$gui
private

Definition at line 28 of file class.ilADTBasedObjectGUI.php.

◆ $lng

ilLanguage ilADTBasedObjectGUI::$lng
protected

Definition at line 32 of file class.ilADTBasedObjectGUI.php.

◆ $object

ilADTBasedObject ilADTBasedObjectGUI::$object = null
protected

Definition at line 29 of file class.ilADTBasedObjectGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilADTBasedObjectGUI::$tpl
protected

Definition at line 31 of file class.ilADTBasedObjectGUI.php.


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