ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References initObject().

24  {
25  $this->gui = $a_parent_gui;
26  $this->object = $this->initObject();
27  }
initObject()
Init ADT-based object.
+ 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.

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

Referenced by updateAction().

45  {
46  global $tpl;
47 
48  if (!$a_form) {
49  $a_form = $this->initForm();
50  }
51 
52  $tpl->setContent($a_form->getForm()->getHTML());
53  }
$tpl
Definition: ilias.php:10
initForm()
Init ADT-based form.
+ 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 67 of file class.ilADTBasedObjectGUI.php.

References $form, $ilCtrl, $lng, $tpl, ilADTFactory\getInstance(), PHPExcel\getProperties(), object, and prepareFormElements().

Referenced by editAction(), and updateAction().

68  {
69  global $tpl, $lng, $ilCtrl;
70 
71  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
72  $form = new ilPropertyFormGUI();
73  $form->setFormAction($ilCtrl->getFormAction($this->gui, "updateAction"));
74 
75  $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($this->object->getProperties());
76 
77  // has to be done BEFORE prepareFormElements() ...
78  $adt_form->setForm($form);
79 
80  $this->prepareFormElements($adt_form);
81 
82  $adt_form->addToForm();
83  $adt_form->addJS($tpl);
84 
85  // :TODO:
86  $form->addCommandButton("updateAction", $lng->txt("save"));
87 
88  return $adt_form;
89  }
This class represents a property form user interface.
$tpl
Definition: ilias.php:10
getProperties()
Get properties.
Definition: PHPExcel.php:425
static getInstance()
Get singleton.
global $ilCtrl
Definition: ilias.php:18
prepareFormElements(ilADTGroupFormBridge $a_adt_form)
Prepare/customize form elements.
if(isset($_POST['submit'])) $form
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initObject()

ilADTBasedObjectGUI::initObject ( )
abstractprotected

Init ADT-based object.

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

Referenced by editAction(), and initForm().

+ Here is the caller graph for this function:

◆ updateAction()

ilADTBasedObjectGUI::updateAction ( )

Parse incoming values and update if valid.

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

References $changed, $ilCtrl, $lng, $valid, editAction(), initForm(), object, ilUtil\sendFailure(), and ilUtil\sendSuccess().

95  {
96  global $lng, $ilCtrl;
97 
98  $adt_form = $this->initForm();
99  $valid = $adt_form->getForm()->checkInput(); // :TODO: return value is obsolete
100 
101  $old_chksum = $this->object->getProperties()->getCheckSum();
102 
103  $adt_form->importFromPost();
104  $valid = $adt_form->validate();
105 
106  $changed = ($old_chksum != $this->object->getProperties()->getCheckSum());
107 
108  // validation errors have top priority
109  if (!$valid) {
110  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
111  return $this->editAction($adt_form);
112  }
113 
114  // :TODO: experimental, update only if necessary
115  if ($changed) {
116  if ($this->object->update()) {
117  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
118  } else {
119  // error occured in db-layer (primary/unique)
120  foreach ($this->object->getDBErrors() as $element_id => $codes) {
121  $element = $adt_form->getElement($element_id);
122  if ($element) {
123  $element->setExternalErrors($this->object->translateDBErrorCodes($codes));
124  }
125  }
126 
127  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
128  return $this->editAction($adt_form);
129  }
130  }
131 
132  $ilCtrl->redirect($this->gui, "edit");
133  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$valid
global $ilCtrl
Definition: ilias.php:18
editAction(ilADTGroupFormBridge $a_form=null)
Edit object ADT properties.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
initForm()
Init ADT-based form.
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
+ 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: