ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFormGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected string $formaction = "";
29 protected bool $multipart = false;
30 protected bool $keepopen = false;
31 protected bool $opentag = true;
32 protected string $id = '';
33 protected string $name = '';
34 protected string $target = '';
35 protected bool $prevent_double_submission = false;
36
37 public function setFormAction(string $a_formaction): void
38 {
39 $this->formaction = $a_formaction;
40 }
41
42 public function getFormAction(): string
43 {
44 return $this->formaction;
45 }
46
47 public function setTarget(string $a_target): void
48 {
49 $this->target = $a_target;
50 }
51
52 public function getTarget(): string
53 {
54 return $this->target;
55 }
56
57 public function setMultipart(bool $a_multipart): void
58 {
59 $this->multipart = $a_multipart;
60 }
61
62 public function getMultipart(): bool
63 {
64 return $this->multipart;
65 }
66
67 public function setId(string $a_id): void
68 {
69 $this->id = $a_id;
70 }
71
72 public function getId(): string
73 {
74 return $this->id;
75 }
76
77 public function setName(string $a_name): void
78 {
79 $this->name = $a_name;
80 }
81
82 public function getName(): string
83 {
84 return $this->name;
85 }
86
87 public function setKeepOpen(bool $a_keepopen): void
88 {
89 $this->keepopen = $a_keepopen;
90 }
91
92 public function getKeepOpen(): bool
93 {
94 return $this->keepopen;
95 }
96
97 public function setOpenTag(bool $a_open): void
98 {
99 $this->opentag = $a_open;
100 }
101
102 public function getOpenTag(): bool
103 {
104 return $this->opentag;
105 }
106
107 public function setCloseTag(bool $a_val): void
108 {
109 $this->setKeepOpen(!$a_val);
110 }
111
112 public function getCloseTag(): bool
113 {
114 return !$this->getKeepOpen();
115 }
116
117 public function setPreventDoubleSubmission(bool $a_val): void
118 {
119 $this->prevent_double_submission = $a_val;
120 }
121
122 public function getPreventDoubleSubmission(): bool
123 {
125 }
126
127 public function getHTML(): string
128 {
129 $tpl = new ilTemplate("tpl.form.html", true, true, "components/ILIAS/Form");
130
131 // this line also sets multipart, so it must be before the multipart check
132 $content = $this->getContent();
133 if ($this->getOpenTag()) {
134 $opentpl = new ilTemplate('tpl.form_open.html', true, true, "components/ILIAS/Form");
135 if ($this->getTarget() != "") {
136 $opentpl->setCurrentBlock("form_target");
137 $opentpl->setVariable("FORM_TARGET", $this->getTarget());
138 $opentpl->parseCurrentBlock();
139 }
140 if ($this->getName() != "") {
141 $opentpl->setCurrentBlock("form_name");
142 $opentpl->setVariable("FORM_NAME", $this->getName());
143 $opentpl->parseCurrentBlock();
144 }
145 if ($this->getPreventDoubleSubmission()) {
146 $opentpl->setVariable("FORM_CLASS", "preventDoubleSubmission");
147 }
148
149 if ($this->getMultipart()) {
150 $opentpl->touchBlock("multipart");
151 /*if (function_exists("apc_fetch"))
152 //
153 // Progress bar would need additional browser window (popup)
154 // to not be stopped, when form is submitted (we can't work
155 // with an iframe or httprequest solution here)
156 //
157 {
158 $tpl->touchBlock("onsubmit");
159
160 //onsubmit="postForm('{ON_ACT}','form_{F_ID}',1); return false;"
161 $tpl->setCurrentBlock("onsubmit");
162 $tpl->setVariable("ON_ACT", $this->getFormAction());
163 $tpl->setVariable("F_ID", $this->getId());
164 $tpl->setVariable("F_ID", $this->getId());
165 $tpl->parseCurrentBlock();
166
167 $tpl->setCurrentBlock("hidden_progress");
168 $tpl->setVariable("APC_PROGRESS_ID", uniqid());
169 $tpl->setVariable("APC_FORM_ID", $this->getId());
170 $tpl->parseCurrentBlock();
171 }*/
172 }
173 $opentpl->setVariable("FORM_ACTION", $this->getFormAction());
174 if ($this->getId() != "") {
175 $opentpl->setVariable("FORM_ID", $this->getId());
176 }
177 $opentpl->parseCurrentBlock();
178 $tpl->setVariable('FORM_OPEN_TAG', $opentpl->get());
179 }
180 $tpl->setVariable("FORM_CONTENT", $content);
181 if (!$this->getKeepOpen()) {
182 $tpl->setVariable("FORM_CLOSE_TAG", "</form>");
183 }
184 return $tpl->get();
185 }
186
187 public function getContent(): string
188 {
189 return "";
190 }
191}
This class represents a form user interface.
string $target
getPreventDoubleSubmission()
setFormAction(string $a_formaction)
bool $prevent_double_submission
setPreventDoubleSubmission(bool $a_val)
setCloseTag(bool $a_val)
setName(string $a_name)
setTarget(string $a_target)
setOpenTag(bool $a_open)
setKeepOpen(bool $a_keepopen)
setMultipart(bool $a_multipart)
string $formaction
setId(string $a_id)
special template class to simplify handling of ITX/PEAR