ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
16 protected $ctrl;
17
21 protected $lng;
22
23 protected $type;
24 protected $title;
25 protected $postvar;
26 protected $info;
27 protected $alert;
28 protected $required = false;
29 protected $parentgui;
30 protected $parentform;
31 protected $hidden_title = "";
32 protected $multi = false;
33 protected $multi_sortable = false;
34 protected $multi_addremove = true;
35 protected $multi_values;
36
43 public function __construct($a_title = "", $a_postvar = "")
44 {
45 global $DIC;
46
47 $this->ctrl = $DIC->ctrl();
48 $this->lng = $DIC->language();
49 $this->setTitle($a_title);
50 $this->setPostVar($a_postvar);
51 $this->setDisabled(false);
52 }
53
57 public function executeCommand()
58 {
60
61 $next_class = $ilCtrl->getNextClass($this);
62 $cmd = $ilCtrl->getCmd();
63
64 return $this->$cmd();
65 }
66
72 protected function setType($a_type)
73 {
74 $this->type = $a_type;
75 }
76
82 public function getType()
83 {
84 return $this->type;
85 }
86
92 public function setTitle($a_title)
93 {
94 $this->title = $a_title;
95 }
96
102 public function getTitle()
103 {
104 return $this->title;
105 }
106
112 public function setPostVar($a_postvar)
113 {
114 $this->postvar = $a_postvar;
115 }
116
122 public function getPostVar()
123 {
124 return $this->postvar;
125 }
126
132 public function getFieldId()
133 {
134 $id = str_replace("[", "__", $this->getPostVar());
135 $id = str_replace("]", "__", $id);
136
137 return $id;
138 }
139
145 public function setInfo($a_info)
146 {
147 $this->info = $a_info;
148 }
149
155 public function getInfo()
156 {
157 return $this->info;
158 }
159
165 public function setAlert($a_alert)
166 {
167 $this->alert = $a_alert;
168 }
169
175 public function getAlert()
176 {
177 return $this->alert;
178 }
179
185 public function setRequired($a_required)
186 {
187 $this->required = $a_required;
188 }
189
195 public function getRequired()
196 {
197 return $this->required;
198 }
199
205 public function setDisabled($a_disabled)
206 {
207 $this->disabled = $a_disabled;
208 }
209
215 public function getDisabled()
216 {
217 return $this->disabled;
218 }
219
225 public function checkInput()
226 {
227 return false; // please overwrite
228 }
229
235 public function setParentForm($a_parentform)
236 {
237 $this->setParent($a_parentform);
238 }
239
245 public function getParentForm()
246 {
247 return $this->getParent();
248 }
249
255 public function setParent($a_val)
256 {
257 $this->parent_gui = $a_val;
258 }
259
265 public function getParent()
266 {
267 return $this->parent_gui;
268 }
269
274 public function getSubForm()
275 {
276 return "";
277 }
278
283 public function hideSubForm()
284 {
285 return false;
286 }
287
293 public function setHiddenTitle($a_val)
294 {
295 $this->hidden_title = $a_val;
296 }
297
303 public function getHiddenTitle()
304 {
305 return $this->hidden_title;
306 }
307
313 public function getItemByPostVar($a_post_var)
314 {
315 if ($this->getPostVar() == $a_post_var) {
316 return $this;
317 }
318
319 return false;
320 }
321
325 public function serializeData()
326 {
327 return serialize($this->getValue());
328 }
329
333 public function unserializeData($a_data)
334 {
335 $data = unserialize($a_data);
336
337 if ($data) {
338 $this->setValue($data);
339 } else {
340 $this->setValue(false);
341 }
342 }
343
347 public function writeToSession()
348 {
349 $parent = $this->getParent();
350 if (!is_object($parent)) {
351 die("You must set parent for " . get_class($this) . " to use serialize feature.");
352 }
353 $_SESSION["form_" . $parent->getId()][$this->getFieldId()] =
354 $this->serializeData();
355 }
356
360 public function clearFromSession()
361 {
362 $parent = $this->getParent();
363 if (!is_object($parent)) {
364 die("You must set parent for " . get_class($this) . " to use serialize feature.");
365 }
366 $_SESSION["form_" . $parent->getId()][$this->getFieldId()] = false;
367 }
368
372 public function readFromSession()
373 {
374 $parent = $this->getParent();
375 if (!is_object($parent)) {
376 die("You must set parent for " . get_class($this) . " to use serialize feature.");
377 }
378 $this->unserializeData($_SESSION["form_" . $parent->getId()][$this->getFieldId()]);
379 }
380
384 public function getHiddenTag($a_post_var, $a_value)
385 {
386 return '<input type="hidden" name="' . $a_post_var . '" value="' . ilUtil::prepareFormOutput($a_value) . '" />';
387 }
388
394 public function setMulti($a_multi, $a_sortable = false, $a_addremove = true)
395 {
396 if (!$this instanceof ilMultiValuesItem) {
397 require_once 'Services/Form/exceptions/class.ilFormException.php';
398 throw new ilFormException(sprintf(
399 "%s not supported for form property type %s",
400 __FUNCTION__,
401 get_class($this)
402 ));
403 }
404
405 $this->multi = (bool) $a_multi;
406 $this->multi_sortable = (bool) $a_sortable;
407 $this->multi_addremove = (bool) $a_addremove;
408 }
409
415 public function getMulti()
416 {
417 return $this->multi;
418 }
419
425 public function setMultiValues(array $a_values)
426 {
427 $this->multi_values = array_unique($a_values);
428 }
429
435 public function getMultiValues()
436 {
437 return $this->multi_values;
438 }
439
446 protected function getMultiIconsHTML()
447 {
449
450 $id = $this->getFieldId();
451
452 $tpl = new ilTemplate("tpl.multi_icons.html", true, true, "Services/Form");
453
454 $html = "";
455 if ($this->multi_addremove) {
456 $tpl->setCurrentBlock("addremove");
457 $tpl->setVariable("ID", $id);
458 $tpl->setVariable("TXT_ADD", $lng->txt("add"));
459 $tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
460 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
461 $tpl->setVariable("SRC_ADD", ilGlyphGUI::get(ilGlyphGUI::ADD));
462 $tpl->setVariable("SRC_REMOVE", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
463 $tpl->parseCurrentBlock();
464 }
465
466 if ($this->multi_sortable) {
467 $tpl->setCurrentBlock("sortable");
468 $tpl->setVariable("ID", $id);
469 $tpl->setVariable("TXT_DOWN", $lng->txt("down"));
470 $tpl->setVariable("TXT_UP", $lng->txt("up"));
471 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
472 $tpl->setVariable("SRC_UP", ilGlyphGUI::get(ilGlyphGUI::UP));
473 $tpl->setVariable("SRC_DOWN", ilGlyphGUI::get(ilGlyphGUI::DOWN));
474 $tpl->parseCurrentBlock();
475 }
476
477 return $tpl->get();
478 }
479
485 public function getContentOutsideFormTag()
486 {
487 }
488
496 public static function removeProhibitedCharacters($a_text)
497 {
498 return str_replace("\x0B", "", $a_text);
499 }
500
507 public function stripSlashesAddSpaceFallback($a_str)
508 {
509 $str = ilUtil::stripSlashes($a_str);
510 if ($str != $a_str) {
511 $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
512 }
513 return $str;
514 }
515}
sprintf('%.4f', $callTime)
$tpl
Definition: ilias.php:10
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
Class ilFormException.
This class represents a property in a property form.
setParentForm($a_parentform)
Set Parent Form.
getMultiIconsHTML()
Get HTML for multiple value icons.
executeCommand()
Execute command.
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.
static removeProhibitedCharacters($a_text)
Remove prohibited characters see #19159.
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?
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
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
Interface for multi values support.
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92