ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
BaseForm.php
Go to the documentation of this file.
1 <?php
2 
4 
10 abstract class BaseForm extends \ilPropertyFormGUI
11 {
12 
16  protected $parent_gui;
20  protected $DIC;
24  protected $object;
25 
26 
34  {
35  $this->parent_gui = $parent_gui;
36  $this->object = $object;
37  $this->dic()->ctrl()->saveParameter($parent_gui, 'arid');
38  $this->setFormAction($this->dic()->ctrl()->getFormAction($this->parent_gui));
39  $this->initFormElements();
40  $this->initButtons();
41  $this->setTarget('_top');
42  parent::__construct();
43  }
44 
45 
46  abstract protected function initFormElements();
47 
48 
49  abstract public function fillForm();
50 
51 
52  abstract protected function fillObject();
53 
54 
58  public function saveObject()
59  {
60  if (!$this->fillObject()) {
61  return false;
62  }
63  if ($this->object->getId()) {
64  $this->object->update();
65  } else {
66  $this->object->create();
67  }
68 
69  return $this->object->getId();
70  }
71 
72 
73  protected function initButtons()
74  {
75  if (!$this->object->getId()) {
76  $this->setTitle($this->txt('create'));
79  } else {
80  $this->setTitle($this->txt('update'));
83  }
84  }
85 
86 
92  protected function txt($key)
93  {
94  return $this->parent_gui->txt($key);
95  }
96 
97 
103  protected function infoTxt($key)
104  {
105  return $this->parent_gui->txt($key . '_info');
106  }
107 
108 
112  protected function dic()
113  {
114  return $GLOBALS["DIC"];
115  }
116 }
getFormAction()
Get FormAction.
This class represents a property form user interface.
Class ActiveRecord.
setFormAction($a_formaction)
Set FormAction.
__construct(BaseCommands $parent_gui, \ActiveRecord $object)
BaseForm constructor.
Definition: BaseForm.php:33
setTarget($a_target)
Set Target.
setTitle($a_title)
Set Title.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
$key
Definition: croninfo.php:18
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.