ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 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.

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

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  }
global $DIC
Definition: shib_login.php:22
initObject()
Init ADT-based object.
+ 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.

References initForm(), and prepareFormElements().

Referenced by updateAction().

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.
+ 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

PhpParamsInspection

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

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

Referenced by editAction(), and updateAction().

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  }
ADT form bridge base class.
prepareFormElements(ilADTGroupFormBridge $a_adt_form)
Prepare/customize form elements.
+ 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 PhpParamsInspection.

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

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

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  }
$valid
editAction(?ilADTGroupFormBridge $a_form=null)
initForm()
Init ADT-based form.
+ 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: