ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilFormGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
15 class ilFormGUI
16 {
17  protected $formaction;
18  protected $multipart = false;
19  protected $keepopen = false;
20  protected $opentag = true;
21  protected $id;
22  protected $name;
23  protected $prevent_double_submission = false;
24 
30  public function setFormAction($a_formaction)
31  {
32  $this->formaction = $a_formaction;
33  }
34 
40  public function getFormAction()
41  {
42  return $this->formaction;
43  }
44 
50  public function setTarget($a_target)
51  {
52  $this->target = $a_target;
53  }
54 
60  public function getTarget()
61  {
62  return $this->target;
63  }
64 
70  public function setMultipart($a_multipart)
71  {
72  $this->multipart = $a_multipart;
73  }
74 
80  public function getMultipart()
81  {
82  return $this->multipart;
83  }
84 
90  public function setId($a_id)
91  {
92  $this->id = $a_id;
93  }
94 
100  public function getId()
101  {
102  return $this->id;
103  }
104 
110  public function setName($a_name)
111  {
112  $this->name = $a_name;
113  }
114 
120  public function getName()
121  {
122  return $this->name;
123  }
124 
130  public function setKeepOpen($a_keepopen)
131  {
132  $this->keepopen = $a_keepopen;
133  }
134 
140  public function getKeepOpen()
141  {
142  return $this->keepopen;
143  }
144 
150  public function setOpenTag($a_open)
151  {
152  $this->opentag = $a_open;
153  }
154 
160  public function getOpenTag()
161  {
162  return $this->opentag;
163  }
164 
170  public function setCloseTag($a_val)
171  {
172  $this->setKeepOpen(!$a_val);
173  }
174 
180  public function getCloseTag()
181  {
182  return !$this->getKeepOpen();
183  }
184 
190  public function setPreventDoubleSubmission($a_val)
191  {
192  $this->prevent_double_submission = $a_val;
193  }
194 
200  public function getPreventDoubleSubmission()
201  {
203  }
204 
208  public function getHTML()
209  {
210  $tpl = new ilTemplate("tpl.form.html", true, true, "Services/Form");
211 
212  // this line also sets multipart, so it must be before the multipart check
213  $content = $this->getContent();
214  if ($this->getOpenTag()) {
215  $opentpl = new ilTemplate('tpl.form_open.html', true, true, "Services/Form");
216  if ($this->getTarget() != "") {
217  $opentpl->setCurrentBlock("form_target");
218  $opentpl->setVariable("FORM_TARGET", $this->getTarget());
219  $opentpl->parseCurrentBlock();
220  }
221  if ($this->getName() != "") {
222  $opentpl->setCurrentBlock("form_name");
223  $opentpl->setVariable("FORM_NAME", $this->getName());
224  $opentpl->parseCurrentBlock();
225  }
226  if ($this->getPreventDoubleSubmission()) {
227  $opentpl->setVariable("FORM_CLASS", "preventDoubleSubmission");
228  }
229 
230  if ($this->getMultipart()) {
231  $opentpl->touchBlock("multipart");
232  /*if (function_exists("apc_fetch"))
233  //
234  // Progress bar would need additional browser window (popup)
235  // to not be stopped, when form is submitted (we can't work
236  // with an iframe or httprequest solution here)
237  //
238  {
239  $tpl->touchBlock("onsubmit");
240 
241  //onsubmit="postForm('{ON_ACT}','form_{F_ID}',1); return false;"
242  $tpl->setCurrentBlock("onsubmit");
243  $tpl->setVariable("ON_ACT", $this->getFormAction());
244  $tpl->setVariable("F_ID", $this->getId());
245  $tpl->setVariable("F_ID", $this->getId());
246  $tpl->parseCurrentBlock();
247 
248  $tpl->setCurrentBlock("hidden_progress");
249  $tpl->setVariable("APC_PROGRESS_ID", uniqid());
250  $tpl->setVariable("APC_FORM_ID", $this->getId());
251  $tpl->parseCurrentBlock();
252  }*/
253  }
254  $opentpl->setVariable("FORM_ACTION", $this->getFormAction());
255  if ($this->getId() != "") {
256  $opentpl->setVariable("FORM_ID", $this->getId());
257  }
258  $opentpl->parseCurrentBlock();
259  $tpl->setVariable('FORM_OPEN_TAG', $opentpl->get());
260  }
261  $tpl->setVariable("FORM_CONTENT", $content);
262  if (!$this->getKeepOpen()) {
263  $tpl->setVariable("FORM_CLOSE_TAG", "</form>");
264  }
265  return $tpl->get();
266  }
267 
271  public function getContent()
272  {
273  return "";
274  }
275 }
setPreventDoubleSubmission($a_val)
Set prevent double submission.
getFormAction()
Get FormAction.
getKeepOpen()
Get Keep Form Tag Open.
setId($a_id)
Set Id.
getCloseTag()
Get close tag.
setOpenTag($a_open)
Enable/Disable Open Form Tag.
$tpl
Definition: ilias.php:10
getHTML()
Get HTML.
setName($a_name)
Set Name.
setKeepOpen($a_keepopen)
Set Keep Form Tag Open.
This class represents a form user interface.
setFormAction($a_formaction)
Set FormAction.
setMultipart($a_multipart)
Set Enctype Multipart/Formdata true/false.
setTarget($a_target)
Set Target.
getContent()
Get Content.
getPreventDoubleSubmission()
Get prevent double submission.
special template class to simplify handling of ITX/PEAR
getId()
Get Id.
getOpenTag()
Get Open Form Tag Enabled.
getTarget()
Get Target.
$target
Definition: test.php:19
setCloseTag($a_val)
Set close tag.
getName()
Get Name.
getMultipart()
Get Enctype Multipart/Formdata true/false.