ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTTextFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_once "Services/ADT/classes/Bridges/class.ilADTFormBridge.php";
4 
6 {
7  protected $multi; // [bool]
8  protected $multi_rows; // [int]
9  protected $multi_cols; // [int]
10 
11  //
12  // properties
13  //
14 
22  public function setMulti($a_value, $a_cols = null, $a_rows = null)
23  {
24  $this->multi = (bool) $a_value;
25  $this->multi_rows = ($a_rows === null) ? null : (int) $a_rows;
26  $this->multi_cols = ($a_cols === null) ? null : (int) $a_cols;
27  }
28 
34  public function isMulti()
35  {
36  return $this->multi;
37  }
38 
39 
40  //
41  // form
42  //
43 
44  protected function isValidADT(ilADT $a_adt)
45  {
46  return ($a_adt instanceof ilADTText);
47  }
48 
49  public function addToForm()
50  {
51  $def = $this->getADT()->getCopyOfDefinition();
52 
53  if (!$this->isMulti()) {
54  $text = new ilTextInputGUI($this->getTitle(), $this->getElementId());
55 
56  if ($def->getMaxLength()) {
57  $max = $def->getMaxLength();
58  $size = $text->getSize();
59 
60  $text->setMaxLength($max);
61 
62  if ($size && $max < $size) {
63  $text->setSize($max);
64  }
65  }
66  } else {
67  $text = new ilTextAreaInputGUI($this->getTitle(), $this->getElementId());
68  if ($this->multi_rows) {
69  $text->setRows($this->multi_rows);
70  }
71  if ($this->multi_cols) {
72  $text->setCols($this->multi_cols);
73  }
74 
75  if ($def->getMaxLength()) {
76  $max = $def->getMaxLength();
77  $text->setMaxNumOfChars($max);
78  }
79  }
80 
82 
83  $text->setValue($this->getADT()->getText());
84 
85  $this->addToParentElement($text);
86  }
87 
88  public function importFromPost()
89  {
90  // ilPropertyFormGUI::checkInput() is pre-requisite
91  $this->getADT()->setText($this->getForm()->getInput($this->getElementId()));
92 
93  $field = $this->getForm()->getItemByPostvar($this->getElementId());
94  $field->setValue($this->getADT()->getText());
95  }
96 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
$size
Definition: RandomTest.php:84
ADT form bridge base class.
ADT base class.
Definition: class.ilADT.php:11
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
setMulti($a_value, $a_cols=null, $a_rows=null)
Set multi-line.
$text
Definition: errorreport.php:18
This class represents a text property in a property form.
getElementId()
Get element id.
This class represents a text area property in a property form.
$def
Definition: croninfo.php:21