ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
BaseForm.php
Go to the documentation of this file.
1<?php
2
4
10abstract 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');
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}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Class ActiveRecord.
An exception for terminatinating execution or to throw for unit testing.
__construct(BaseCommands $parent_gui, \ActiveRecord $object)
BaseForm constructor.
Definition: BaseForm.php:33
setTarget($a_target)
Set Target.
setFormAction($a_formaction)
Set FormAction.
getFormAction()
Get FormAction.
This class represents a property form user interface.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setTitle($a_title)
Set Title.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc