ILIAS  release_7 Revision v7.30-3-g800a261c036
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. More...
 
 editAction (ilADTGroupFormBridge $a_form=null)
 Edit object ADT properties. More...
 
 updateAction ()
 Parse incoming values and update if valid. 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

 $object
 

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 11 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
Returns
self

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

24 {
25 $this->gui = $a_parent_gui;
26 $this->object = $this->initObject();
27 }
initObject()
Init ADT-based object.

References initObject().

+ Here is the call graph for this function:

Member Function Documentation

◆ editAction()

ilADTBasedObjectGUI::editAction ( ilADTGroupFormBridge  $a_form = null)

Edit object ADT properties.

Parameters
ilADTGroupFormBridge$a_form

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

45 {
46 global $DIC;
47
48 $tpl = $DIC['tpl'];
49
50 if (!$a_form) {
51 $a_form = $this->initForm();
52 }
53
54 $tpl->setContent($a_form->getForm()->getHTML());
55 }
initForm()
Init ADT-based form.
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $DIC, $tpl, and 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
ilADTGroupFormBridge $a_form

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

70 {
71 global $DIC;
72
73 $tpl = $DIC['tpl'];
74 $lng = $DIC['lng'];
75 $ilCtrl = $DIC['ilCtrl'];
76
77 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
78 $form = new ilPropertyFormGUI();
79 $form->setFormAction($ilCtrl->getFormAction($this->gui, "updateAction"));
80
81 $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($this->object->getProperties());
82
83 // has to be done BEFORE prepareFormElements() ...
84 $adt_form->setForm($form);
85
86 $this->prepareFormElements($adt_form);
87
88 $adt_form->addToForm();
89 $adt_form->addJS($tpl);
90
91 // :TODO:
92 $form->addCommandButton("updateAction", $lng->txt("save"));
93
94 return $adt_form;
95 }
prepareFormElements(ilADTGroupFormBridge $a_adt_form)
Prepare/customize form elements.
static getInstance()
Get singleton.
This class represents a property form user interface.
$lng

References $DIC, $lng, $tpl, ilADTFactory\getInstance(), 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.

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

101 {
102 global $DIC;
103
104 $lng = $DIC['lng'];
105 $ilCtrl = $DIC['ilCtrl'];
106
107 $adt_form = $this->initForm();
108 $valid = $adt_form->getForm()->checkInput(); // :TODO: return value is obsolete
109
110 $old_chksum = $this->object->getProperties()->getCheckSum();
111
112 $adt_form->importFromPost();
113 $valid = $adt_form->validate();
114
115 $changed = ($old_chksum != $this->object->getProperties()->getCheckSum());
116
117 // validation errors have top priority
118 if (!$valid) {
119 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
120 return $this->editAction($adt_form);
121 }
122
123 // :TODO: experimental, update only if necessary
124 if ($changed) {
125 if ($this->object->update()) {
126 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
127 } else {
128 // error occured in db-layer (primary/unique)
129 foreach ($this->object->getDBErrors() as $element_id => $codes) {
130 $element = $adt_form->getElement($element_id);
131 if ($element) {
132 $element->setExternalErrors($this->object->translateDBErrorCodes($codes));
133 }
134 }
135
136 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
137 return $this->editAction($adt_form);
138 }
139 }
140
141 $ilCtrl->redirect($this->gui, "edit");
142 }
editAction(ilADTGroupFormBridge $a_form=null)
Edit object ADT properties.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$valid

References $changed, $DIC, $lng, $valid, editAction(), initForm(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

Field Documentation

◆ $object

ilADTBasedObjectGUI::$object
protected

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


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