ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilFormPropertyGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 protected $type;
14 protected $title;
15 protected $postvar;
16 protected $info;
17 protected $alert;
18 protected $required = false;
19 protected $parentgui;
20 protected $parentform;
21 protected $hidden_title = "";
22 protected $multi = false;
23 protected $multi_sortable = false;
24 protected $multi_addremove = true;
25 protected $multi_values;
26
33 function __construct($a_title = "", $a_postvar = "")
34 {
35 $this->setTitle($a_title);
36 $this->setPostVar($a_postvar);
37 $this->setDisabled(false);
38 }
39
43 function &executeCommand()
44 {
45 global $ilCtrl;
46
47 $next_class = $ilCtrl->getNextClass($this);
48 $cmd = $ilCtrl->getCmd();
49
50 return $this->$cmd();
51 }
52
58 protected function setType($a_type)
59 {
60 $this->type = $a_type;
61 }
62
68 function getType()
69 {
70 return $this->type;
71 }
72
78 function setTitle($a_title)
79 {
80 $this->title = $a_title;
81 }
82
88 function getTitle()
89 {
90 return $this->title;
91 }
92
98 function setPostVar($a_postvar)
99 {
100 $this->postvar = $a_postvar;
101 }
102
108 function getPostVar()
109 {
110 return $this->postvar;
111 }
112
118 function getFieldId()
119 {
120 $id = str_replace("[", "__", $this->getPostVar());
121 $id = str_replace("]", "__", $id);
122
123 return $id;
124 }
125
131 function setInfo($a_info)
132 {
133 $this->info = $a_info;
134 }
135
141 function getInfo()
142 {
143 return $this->info;
144 }
145
151 function setAlert($a_alert)
152 {
153 $this->alert = $a_alert;
154 }
155
161 function getAlert()
162 {
163 return $this->alert;
164 }
165
171 function setRequired($a_required)
172 {
173 $this->required = $a_required;
174 }
175
181 function getRequired()
182 {
183 return $this->required;
184 }
185
191 function setDisabled($a_disabled)
192 {
193 $this->disabled = $a_disabled;
194 }
195
201 function getDisabled()
202 {
203 return $this->disabled;
204 }
205
211 function checkInput()
212 {
213 return false; // please overwrite
214 }
215
221 function setParentForm($a_parentform)
222 {
223 $this->setParent($a_parentform);
224 }
225
231 function getParentForm()
232 {
233 return $this->getParent();
234 }
235
241 function setParent($a_val)
242 {
243 $this->parent_gui = $a_val;
244 }
245
251 function getParent()
252 {
253 return $this->parent_gui;
254 }
255
260 public function getSubForm()
261 {
262 return "";
263 }
264
269 public function hideSubForm()
270 {
271 return false;
272 }
273
279 function setHiddenTitle($a_val)
280 {
281 $this->hidden_title = $a_val;
282 }
283
289 function getHiddenTitle()
290 {
291 return $this->hidden_title;
292 }
293
299 function getItemByPostVar($a_post_var)
300 {
301 if ($this->getPostVar() == $a_post_var)
302 {
303 return $this;
304 }
305
306 return false;
307 }
308
312 function serializeData()
313 {
314 return serialize($this->getValue());
315 }
316
320 function unserializeData($a_data)
321 {
322 $data = unserialize($a_data);
323
324 if ($data)
325 {
326 $this->setValue($data);
327 }
328 else
329 {
330 $this->setValue(false);
331 }
332 }
333
337 function writeToSession()
338 {
339 $parent = $this->getParent();
340 if (!is_object($parent))
341 {
342 die("You must set parent for ".get_class($this)." to use serialize feature.");
343 }
344 $_SESSION["form_".$parent->getId()][$this->getFieldId()] =
345 $this->serializeData();
346 }
347
352 {
353 $parent = $this->getParent();
354 if (!is_object($parent))
355 {
356 die("You must set parent for ".get_class($this)." to use serialize feature.");
357 }
358 $_SESSION["form_".$parent->getId()][$this->getFieldId()] = false;
359 }
360
365 {
366 $parent = $this->getParent();
367 if (!is_object($parent))
368 {
369 die("You must set parent for ".get_class($this)." to use serialize feature.");
370 }
371 $this->unserializeData($_SESSION["form_".$parent->getId()][$this->getFieldId()]);
372 }
373
377 function getHiddenTag($a_post_var, $a_value)
378 {
379 return '<input type="hidden" name="'.$a_post_var.'" value="'.ilUtil::prepareFormOutput($a_value).'" />';
380 }
381
387 public function setMulti($a_multi, $a_sortable = false, $a_addremove = true)
388 {
389 if(!$this instanceof ilMultiValuesItem)
390 {
391 require_once 'Services/Form/exceptions/class.ilFormException.php';
392 throw new ilFormException(sprintf(
393 "%s not supported for form property type %s",
394 __FUNCTION__, get_class($this)
395 ));
396 }
397
398 $this->multi = (bool)$a_multi;
399 $this->multi_sortable = (bool)$a_sortable;
400 $this->multi_addremove = (bool)$a_addremove;
401 }
402
408 public function getMulti()
409 {
410 return $this->multi;
411 }
412
418 public function setMultiValues(array $a_values)
419 {
420 $this->multi_values = array_unique($a_values);
421 }
422
428 public function getMultiValues()
429 {
430 return $this->multi_values;
431 }
432
439 protected function getMultiIconsHTML()
440 {
441 global $lng;
442
443 $id = $this->getFieldId();
444
445 $tpl = new ilTemplate("tpl.multi_icons.html", true, true, "Services/Form");
446
447 $html = "";
448 if ($this->multi_addremove)
449 {
450 $tpl->setCurrentBlock("addremove");
451 $tpl->setVariable("ID", $id);
452 $tpl->setVariable("TXT_ADD", $lng->txt("add"));
453 $tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
454 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
455 $tpl->setVariable("SRC_ADD", ilGlyphGUI::get(ilGlyphGUI::ADD));
456 $tpl->setVariable("SRC_REMOVE", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
457 $tpl->parseCurrentBlock();
458 }
459
460 if ($this->multi_sortable)
461 {
462
463 $tpl->setCurrentBlock("sortable");
464 $tpl->setVariable("ID", $id);
465 $tpl->setVariable("TXT_DOWN", $lng->txt("down"));
466 $tpl->setVariable("TXT_UP", $lng->txt("up"));
467 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
468 $tpl->setVariable("SRC_UP", ilGlyphGUI::get(ilGlyphGUI::UP));
469 $tpl->setVariable("SRC_DOWN", ilGlyphGUI::get(ilGlyphGUI::DOWN));
470 $tpl->parseCurrentBlock();
471 }
472
473 return $tpl->get();
474 }
475
481 public function getContentOutsideFormTag()
482 {
483
484 }
485
494 {
495 return str_replace("\x0B", "", $a_text);
496 }
497
505 {
506 $str = ilUtil::stripSlashes($a_str);
507 if ($str != $a_str)
508 {
509 $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
510 }
511 return $str;
512 }
513
514
515}
516
517?>
global $tpl
Definition: ilias.php:8
$_SESSION["AccountId"]
Class ilFormException.
This class represents a property in a property form.
setParentForm($a_parentform)
Set Parent Form.
getMultiIconsHTML()
Get HTML for multiple value icons.
setType($a_type)
Set Type.
getParentForm()
Get Parent Form.
getInfo()
Get Information Text.
getItemByPostVar($a_post_var)
Get item by post var.
clearFromSession()
Clear session value.
readFromSession()
Read from session.
setTitle($a_title)
Set Title.
getPostVar()
Get Post Variable.
setMulti($a_multi, $a_sortable=false, $a_addremove=true)
Set Multi.
setInfo($a_info)
Set Information Text.
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
getContentOutsideFormTag()
Get content that has to reside outside of the parent form tag, e.g.
setParent($a_val)
Set Parent GUI object.
writeToSession()
Write to session.
setAlert($a_alert)
Set Alert Text.
getSubForm()
Get sub form html.
getMultiValues()
Get multi values.
& executeCommand()
Execute command.
setRequired($a_required)
Set Required.
unserializeData($a_data)
unserialize data
__construct($a_title="", $a_postvar="")
Constructor.
setMultiValues(array $a_values)
Set multi values.
getFieldId()
Get Post Variable.
getHiddenTitle()
Get hidden title.
stripSlashesAddSpaceFallback($a_str)
Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727.
getParent()
Get Parent GUI object.
setDisabled($a_disabled)
Set Disabled.
hideSubForm()
Sub form hidden on init?
removeProhibitedCharacters($a_text)
Remove prohibited characters see #19159.
setPostVar($a_postvar)
Set Post Variable.
setHiddenTitle($a_val)
Set hidden title (for screenreaders)
checkInput()
Check input, strip slashes etc.
static get($a_glyph, $a_text="")
Get glyph html.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$html
Definition: example_001.php:87
$data
global $ilCtrl
Definition: ilias.php:18
Interface for multi values support.
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35