ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTTextFormBridge Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilADTTextFormBridge:
+ Collaboration diagram for ilADTTextFormBridge:

Public Member Functions

 __construct (ilADT $a_adt)
 
 setMulti ($a_value, $a_cols=null, $a_rows=null)
 Set multi-line. More...
 
 isMulti ()
 Is multi-line? More...
 
 addToForm ()
 
 importFromPost ()
 
- Public Member Functions inherited from ilADTFormBridge
 __construct (ilADT $a_adt)
 Constructor. More...
 
 getADT ()
 Get ADT. More...
 
 setForm (ilPropertyFormGUI $a_form)
 Set form. More...
 
 getForm ()
 Get form. More...
 
 setElementId ($a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 Get element id. More...
 
 setTitle ($a_value)
 Set title (aka form field caption) More...
 
 getTitle ()
 Get title. More...
 
 setInfo ($a_value)
 Set info (aka form field info text) More...
 
 getInfo ()
 Get info. More...
 
 setParentElement ($a_value)
 Set parent element. More...
 
 getParentElement ()
 Get parent element. More...
 
 setDisabled ($a_value)
 Set disabled. More...
 
 isDisabled ()
 Get disabled. More...
 
 setRequired ($a_value)
 Set required. More...
 
 isRequired ()
 Get required. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addJS (ilGlobalTemplate $a_tpl)
 Add ADT-specific JS-files to template. More...
 
 shouldBeImportedFromPost (ilADTFormBridge $a_parent_adt=null)
 Check if incoming values should be imported at all. More...
 
 importFromPost ()
 Import values from form request POST data. More...
 
 validate ()
 Validate ADT and parse error codes. More...
 
 setExternalErrors ($a_errors)
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 
 addElementToForm (string $title, string $element_id, string $value, bool $is_translation=false, string $language='')
 
- Protected Member Functions inherited from ilADTFormBridge
 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo() More...
 
 findParentElementInForm ()
 Try to find parent element in form (could be option) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 

Protected Attributes

 $multi
 
 $multi_rows
 
 $multi_cols
 
- Protected Attributes inherited from ilADTFormBridge
 $adt
 
 $form
 
 $id
 
 $title
 
 $info
 
 $parent_element
 
 $required
 
 $disabled
 

Private Attributes

 $language = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Definition at line 19 of file class.ilADTTextFormBridge.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTTextFormBridge::__construct ( ilADT  $a_adt)

Definition at line 30 of file class.ilADTTextFormBridge.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and language().

31  {
32  global $DIC;
33 
34  parent::__construct($a_adt);
35  $this->language = $DIC->language();
36  $this->language->loadLanguageModule('meta');
37  }
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
language()
Definition: language.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ addElementToForm()

ilADTTextFormBridge::addElementToForm ( string  $title,
string  $element_id,
string  $value,
bool  $is_translation = false,
string  $language = '' 
)
protected
Parameters
string$title
string$element_id
string$value
bool$is_translation
string$language

Definition at line 85 of file class.ilADTTextFormBridge.php.

References $language, $size, ilADTFormBridge\addBasicFieldProperties(), ilADTFormBridge\addToParentElement(), ilADTFormBridge\getADT(), isMulti(), and language().

Referenced by ilADTLocalizedTextFormBridge\addToForm(), and addToForm().

86  {
87  $def = $this->getADT()->getCopyOfDefinition();
88 
89  if (!$this->isMulti()) {
90  $text = new ilTextInputGUI($title, $element_id);
91 
92  if ($def->getMaxLength()) {
93  $max = $def->getMaxLength();
94  $size = $text->getSize();
95 
96  $text->setMaxLength($max);
97 
98  if ($size && $max < $size) {
99  $text->setSize($max);
100  }
101  }
102  } else {
103  $text = new ilTextAreaInputGUI($title, $element_id);
104  if ($this->multi_rows) {
105  $text->setRows($this->multi_rows);
106  }
107  if ($this->multi_cols) {
108  $text->setCols($this->multi_cols);
109  }
110 
111  if ($def->getMaxLength()) {
112  $max = $def->getMaxLength();
113  $text->setMaxNumOfChars($max);
114  }
115  }
116  $this->addBasicFieldProperties($text, $def);
117 
118  if ($is_translation) {
119  $text->setInfo($this->language->txt('md_adv_int_translation_info') . ' ' . $this->language->txt('meta_l_' . $language));
120  $text->setRequired(false);
121  }
122  $text->setValue($value);
123  $this->addToParentElement($text);
124  }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
$size
Definition: RandomTest.php:84
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
This class represents a text area property in a property form.
language()
Definition: language.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addToForm()

ilADTTextFormBridge::addToForm ( )

Definition at line 126 of file class.ilADTTextFormBridge.php.

References addElementToForm(), ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), and ilADTFormBridge\getTitle().

127  {
128  $this->addElementToForm(
129  (string) $this->getTitle(),
130  (string) $this->getElementId(),
131  (string) $this->getADT()->getText()
132  );
133  }
getElementId()
Get element id.
addElementToForm(string $title, string $element_id, string $value, bool $is_translation=false, string $language='')
+ Here is the call graph for this function:

◆ importFromPost()

ilADTTextFormBridge::importFromPost ( )

Definition at line 135 of file class.ilADTTextFormBridge.php.

References ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), and ilADTFormBridge\getForm().

136  {
137  // ilPropertyFormGUI::checkInput() is pre-requisite
138  $this->getADT()->setText($this->getForm()->getInput($this->getElementId()));
139  $field = $this->getForm()->getItemByPostvar($this->getElementId());
140  $field->setValue($this->getADT()->getText());
141  }
getElementId()
Get element id.
+ Here is the call graph for this function:

◆ isMulti()

ilADTTextFormBridge::isMulti ( )

Is multi-line?

Returns
bool

Definition at line 63 of file class.ilADTTextFormBridge.php.

References $multi.

Referenced by addElementToForm().

64  {
65  return $this->multi;
66  }
+ Here is the caller graph for this function:

◆ isValidADT()

ilADTTextFormBridge::isValidADT ( ilADT  $a_adt)
protected

Definition at line 73 of file class.ilADTTextFormBridge.php.

74  {
75  return ($a_adt instanceof ilADTText);
76  }

◆ setMulti()

ilADTTextFormBridge::setMulti (   $a_value,
  $a_cols = null,
  $a_rows = null 
)

Set multi-line.

Parameters
string$a_value
int$a_cols
int$a_rows

Definition at line 51 of file class.ilADTTextFormBridge.php.

52  {
53  $this->multi = (bool) $a_value;
54  $this->multi_rows = ($a_rows === null) ? null : (int) $a_rows;
55  $this->multi_cols = ($a_cols === null) ? null : (int) $a_cols;
56  }

Field Documentation

◆ $language

ilADTTextFormBridge::$language = null
private

◆ $multi

ilADTTextFormBridge::$multi
protected

Definition at line 21 of file class.ilADTTextFormBridge.php.

Referenced by isMulti().

◆ $multi_cols

ilADTTextFormBridge::$multi_cols
protected

Definition at line 23 of file class.ilADTTextFormBridge.php.

◆ $multi_rows

ilADTTextFormBridge::$multi_rows
protected

Definition at line 22 of file class.ilADTTextFormBridge.php.


The documentation for this class was generated from the following file: