ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
55  $text = new ilTextInputGUI($this->getTitle(), $this->getElementId());
56 
57  if($def->getMaxLength())
58  {
59  $max = $def->getMaxLength();
60  $size = $text->getSize();
61 
62  $text->setMaxLength($max);
63 
64  if($size && $max < $size)
65  {
66  $text->setSize($max);
67  }
68  }
69 
70  }
71  else
72  {
73  $text = new ilTextAreaInputGUI($this->getTitle(), $this->getElementId());
74  if($this->multi_rows)
75  {
76  $text->setRows($this->multi_rows);
77  }
78  if($this->multi_cols)
79  {
80  $text->setCols($this->multi_cols);
81  }
82  }
83 
84  $this->addBasicFieldProperties($text, $def);
85 
86  $text->setValue($this->getADT()->getText());
87 
88  $this->addToParentElement($text);
89  }
90 
91  public function importFromPost()
92  {
93  // ilPropertyFormGUI::checkInput() is pre-requisite
94  $this->getADT()->setText($this->getForm()->getInput($this->getElementId()));
95 
96  $field = $this->getForm()->getItemByPostvar($this->getElementId());
97  $field->setValue($this->getADT()->getText());
98  }
99 }
100 
101 ?>
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
$size
Definition: RandomTest.php:79
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.
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.
$text