ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilDclTextFieldRepresentation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public function addFilterInputFieldToTable(ilTable2GUI $table): ?string
24  {
25  $input = $table->addFilterItemByMetaType(
26  "filter_" . $this->getField()->getId(),
28  false,
29  $this->getField()->getId()
30  );
31  $input->setSubmitFormOnEnter(true);
32 
33  $this->setupFilterInputField($input);
34 
35  return $this->getFilterInputFieldValue($input);
36  }
37 
41  public function passThroughFilter(ilDclBaseRecordModel $record, $filter): bool
42  {
43  $pass = parent::passThroughFilter($record, $filter);
44 
45  $value = $record->getRecordFieldValue($this->getField()->getId());
46  if (!$filter || strpos(strtolower($value), strtolower($filter)) !== false) {
47  $pass = true;
48  }
49 
50  return $pass;
51  }
52 
53  public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFormPropertyGUI
54  {
55  $length = (int) $this->getField()->getProperty(ilDclBaseFieldModel::PROP_LENGTH);
56  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_TEXTAREA) && !$this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
57  $input = new ilTextAreaInputGUI();
58  $input->setMaxNumOfChars($length ?: 4000);
59  } else {
60  $input = new ilDclTextInputGUI();
61  if ($length > 0) {
62  $input->setMaxLength($length);
63  }
64  }
65  $input->setTitle($this->getField()->getTitle());
66  $input->setPostVar('field_' . $this->getField()->getId());
67 
68  if ($this->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
69  $input->setInfo($this->lng->txt('dcl_text_email_detail_desc'));
70  $title_field = new ilDclTextInputGUI(
71  $this->lng->txt('dcl_text_email_title'),
72  'field_' . $this->getField()->getId() . '_title'
73  );
74  $title_field->setInfo($this->lng->txt('dcl_text_email_title_info'));
75  $input->addSubItem($title_field);
76  } elseif ($length > 0) {
77  $input->setInfo(sprintf($this->lng->txt("dcl_max_text_length"), $length));
78  }
79 
80  $this->setupInputField($input, $this->getField());
81 
82  return $input;
83  }
84 
85  protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption
86  {
87  $opt = parent::buildFieldCreationInput($dcl, $mode);
88 
89  $prop_length = new ilNumberInputGUI(
90  $this->lng->txt('dcl_length'),
92  );
93  $prop_length->setSize(5);
94  $prop_length->setMaxValue(4000);
95  $prop_length->setInfo($this->lng->txt('dcl_length_info'));
96 
97  $opt->addSubItem($prop_length);
98 
99  $prop_url = new ilDclCheckboxInputGUI(
100  $this->lng->txt('dcl_url'),
102  );
103  $opt->addSubItem($prop_url);
104 
105  $prop_textarea = new ilDclCheckboxInputGUI(
106  $this->lng->txt('dcl_text_area'),
108  );
109  $opt->addSubItem($prop_textarea);
110 
111  $prop_page_details = new ilDclCheckboxInputGUI(
112  $this->lng->txt('dcl_link_detail_page'),
114  );
115  $opt->addSubItem($prop_page_details);
116 
117  $prop_regex = new ilDclTextInputGUI(
118  $this->lng->txt('dcl_regex'),
120  );
121  $prop_regex->setInfo($this->lng->txt('dcl_regex_info'));
122 
123  $opt->addSubItem($prop_regex);
124 
125  return $opt;
126  }
127 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRecordFieldValue(?string $field_id)
Get Field Value.
passThroughFilter(ilDclBaseRecordModel $record, $filter)
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
getPropertyInputFieldId(string $property)
Return post-var for property-fields.
const PROP_LENGTH
General properties.
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
getInputField(ilPropertyFormGUI $form, ?int $record_id=null)
buildFieldCreationInput(ilObjDataCollection $dcl, string $mode='create')
This class represents a text area property in a property form.